Skip to content

Commit 225ef2f

Browse files
committed
Auto merge of #2690 - lancethepants:RLIMIT, r=Amanieu
Set __rlimit_resource_t definition for all uclibc (c_ulong). Bring all linux RLIMIT definitions into arch/generic/mod.rs or respective architectures. Define all RLIMIT constants for all architectures. Move BLKSSZGET/BLKPBSZGET with their other Ioctls Constants. arch/generic/mod.rs No need to check for mips(64), powerpc(64), or sparc(64).
2 parents fc52607 + ad3f860 commit 225ef2f

File tree

37 files changed

+296
-303
lines changed

37 files changed

+296
-303
lines changed

src/unix/linux_like/linux/arch/generic/mod.rs

Lines changed: 136 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -114,103 +114,90 @@ pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING;
114114

115115
// Ioctl Constants
116116

117-
cfg_if! {
118-
if #[cfg(not(any(target_arch = "mips",
119-
target_arch = "mips64",
120-
target_arch = "powerpc",
121-
target_arch = "powerpc64",
122-
target_arch = "sparc",
123-
target_arch = "sparc64")))] {
124-
125-
pub const TCGETS: ::Ioctl = 0x5401;
126-
pub const TCSETS: ::Ioctl = 0x5402;
127-
pub const TCSETSW: ::Ioctl = 0x5403;
128-
pub const TCSETSF: ::Ioctl = 0x5404;
129-
pub const TCGETA: ::Ioctl = 0x5405;
130-
pub const TCSETA: ::Ioctl = 0x5406;
131-
pub const TCSETAW: ::Ioctl = 0x5407;
132-
pub const TCSETAF: ::Ioctl = 0x5408;
133-
pub const TCSBRK: ::Ioctl = 0x5409;
134-
pub const TCXONC: ::Ioctl = 0x540A;
135-
pub const TCFLSH: ::Ioctl = 0x540B;
136-
pub const TIOCEXCL: ::Ioctl = 0x540C;
137-
pub const TIOCNXCL: ::Ioctl = 0x540D;
138-
pub const TIOCSCTTY: ::Ioctl = 0x540E;
139-
pub const TIOCGPGRP: ::Ioctl = 0x540F;
140-
pub const TIOCSPGRP: ::Ioctl = 0x5410;
141-
pub const TIOCOUTQ: ::Ioctl = 0x5411;
142-
pub const TIOCSTI: ::Ioctl = 0x5412;
143-
pub const TIOCGWINSZ: ::Ioctl = 0x5413;
144-
pub const TIOCSWINSZ: ::Ioctl = 0x5414;
145-
pub const TIOCMGET: ::Ioctl = 0x5415;
146-
pub const TIOCMBIS: ::Ioctl = 0x5416;
147-
pub const TIOCMBIC: ::Ioctl = 0x5417;
148-
pub const TIOCMSET: ::Ioctl = 0x5418;
149-
pub const TIOCGSOFTCAR: ::Ioctl = 0x5419;
150-
pub const TIOCSSOFTCAR: ::Ioctl = 0x541A;
151-
pub const FIONREAD: ::Ioctl = 0x541B;
152-
pub const TIOCINQ: ::Ioctl = FIONREAD;
153-
pub const TIOCLINUX: ::Ioctl = 0x541C;
154-
pub const TIOCCONS: ::Ioctl = 0x541D;
155-
pub const TIOCGSERIAL: ::Ioctl = 0x541E;
156-
pub const TIOCSSERIAL: ::Ioctl = 0x541F;
157-
pub const TIOCPKT: ::Ioctl = 0x5420;
158-
pub const FIONBIO: ::Ioctl = 0x5421;
159-
pub const TIOCNOTTY: ::Ioctl = 0x5422;
160-
pub const TIOCSETD: ::Ioctl = 0x5423;
161-
pub const TIOCGETD: ::Ioctl = 0x5424;
162-
pub const TCSBRKP: ::Ioctl = 0x5425;
163-
pub const TIOCSBRK: ::Ioctl = 0x5427;
164-
pub const TIOCCBRK: ::Ioctl = 0x5428;
165-
pub const TIOCGSID: ::Ioctl = 0x5429;
166-
pub const TCGETS2: ::Ioctl = 0x802c542a;
167-
pub const TCSETS2: ::Ioctl = 0x402c542b;
168-
pub const TCSETSW2: ::Ioctl = 0x402c542c;
169-
pub const TCSETSF2: ::Ioctl = 0x402c542d;
170-
pub const TIOCGRS485: ::Ioctl = 0x542E;
171-
pub const TIOCSRS485: ::Ioctl = 0x542F;
172-
pub const TIOCGPTN: ::Ioctl = 0x80045430;
173-
pub const TIOCSPTLCK: ::Ioctl = 0x40045431;
174-
pub const TIOCGDEV: ::Ioctl = 0x80045432;
175-
pub const TCGETX: ::Ioctl = 0x5432;
176-
pub const TCSETX: ::Ioctl = 0x5433;
177-
pub const TCSETXF: ::Ioctl = 0x5434;
178-
pub const TCSETXW: ::Ioctl = 0x5435;
179-
pub const TIOCSIG: ::Ioctl = 0x40045436;
180-
pub const TIOCVHANGUP: ::Ioctl = 0x5437;
181-
pub const TIOCGPKT: ::Ioctl = 0x80045438;
182-
pub const TIOCGPTLCK: ::Ioctl = 0x80045439;
183-
pub const TIOCGEXCL: ::Ioctl = 0x80045440;
184-
pub const TIOCGPTPEER: ::Ioctl = 0x5441;
185-
// pub const TIOCGISO7816: ::Ioctl = 0x80285442;
186-
// pub const TIOCSISO7816: ::Ioctl = 0xc0285443;
187-
pub const FIONCLEX: ::Ioctl = 0x5450;
188-
pub const FIOCLEX: ::Ioctl = 0x5451;
189-
pub const FIOASYNC: ::Ioctl = 0x5452;
190-
pub const TIOCSERCONFIG: ::Ioctl = 0x5453;
191-
pub const TIOCSERGWILD: ::Ioctl = 0x5454;
192-
pub const TIOCSERSWILD: ::Ioctl = 0x5455;
193-
pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456;
194-
pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457;
195-
pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458;
196-
pub const TIOCSERGETLSR: ::Ioctl = 0x5459;
197-
pub const TIOCSERGETMULTI: ::Ioctl = 0x545A;
198-
pub const TIOCSERSETMULTI: ::Ioctl = 0x545B;
199-
pub const TIOCMIWAIT: ::Ioctl = 0x545C;
200-
pub const TIOCGICOUNT: ::Ioctl = 0x545D;
201-
}
202-
}
117+
pub const TCGETS: ::Ioctl = 0x5401;
118+
pub const TCSETS: ::Ioctl = 0x5402;
119+
pub const TCSETSW: ::Ioctl = 0x5403;
120+
pub const TCSETSF: ::Ioctl = 0x5404;
121+
pub const TCGETA: ::Ioctl = 0x5405;
122+
pub const TCSETA: ::Ioctl = 0x5406;
123+
pub const TCSETAW: ::Ioctl = 0x5407;
124+
pub const TCSETAF: ::Ioctl = 0x5408;
125+
pub const TCSBRK: ::Ioctl = 0x5409;
126+
pub const TCXONC: ::Ioctl = 0x540A;
127+
pub const TCFLSH: ::Ioctl = 0x540B;
128+
pub const TIOCEXCL: ::Ioctl = 0x540C;
129+
pub const TIOCNXCL: ::Ioctl = 0x540D;
130+
pub const TIOCSCTTY: ::Ioctl = 0x540E;
131+
pub const TIOCGPGRP: ::Ioctl = 0x540F;
132+
pub const TIOCSPGRP: ::Ioctl = 0x5410;
133+
pub const TIOCOUTQ: ::Ioctl = 0x5411;
134+
pub const TIOCSTI: ::Ioctl = 0x5412;
135+
pub const TIOCGWINSZ: ::Ioctl = 0x5413;
136+
pub const TIOCSWINSZ: ::Ioctl = 0x5414;
137+
pub const TIOCMGET: ::Ioctl = 0x5415;
138+
pub const TIOCMBIS: ::Ioctl = 0x5416;
139+
pub const TIOCMBIC: ::Ioctl = 0x5417;
140+
pub const TIOCMSET: ::Ioctl = 0x5418;
141+
pub const TIOCGSOFTCAR: ::Ioctl = 0x5419;
142+
pub const TIOCSSOFTCAR: ::Ioctl = 0x541A;
143+
pub const FIONREAD: ::Ioctl = 0x541B;
144+
pub const TIOCINQ: ::Ioctl = FIONREAD;
145+
pub const TIOCLINUX: ::Ioctl = 0x541C;
146+
pub const TIOCCONS: ::Ioctl = 0x541D;
147+
pub const TIOCGSERIAL: ::Ioctl = 0x541E;
148+
pub const TIOCSSERIAL: ::Ioctl = 0x541F;
149+
pub const TIOCPKT: ::Ioctl = 0x5420;
150+
pub const FIONBIO: ::Ioctl = 0x5421;
151+
pub const TIOCNOTTY: ::Ioctl = 0x5422;
152+
pub const TIOCSETD: ::Ioctl = 0x5423;
153+
pub const TIOCGETD: ::Ioctl = 0x5424;
154+
pub const TCSBRKP: ::Ioctl = 0x5425;
155+
pub const TIOCSBRK: ::Ioctl = 0x5427;
156+
pub const TIOCCBRK: ::Ioctl = 0x5428;
157+
pub const TIOCGSID: ::Ioctl = 0x5429;
158+
pub const TCGETS2: ::Ioctl = 0x802c542a;
159+
pub const TCSETS2: ::Ioctl = 0x402c542b;
160+
pub const TCSETSW2: ::Ioctl = 0x402c542c;
161+
pub const TCSETSF2: ::Ioctl = 0x402c542d;
162+
pub const TIOCGRS485: ::Ioctl = 0x542E;
163+
pub const TIOCSRS485: ::Ioctl = 0x542F;
164+
pub const TIOCGPTN: ::Ioctl = 0x80045430;
165+
pub const TIOCSPTLCK: ::Ioctl = 0x40045431;
166+
pub const TIOCGDEV: ::Ioctl = 0x80045432;
167+
pub const TCGETX: ::Ioctl = 0x5432;
168+
pub const TCSETX: ::Ioctl = 0x5433;
169+
pub const TCSETXF: ::Ioctl = 0x5434;
170+
pub const TCSETXW: ::Ioctl = 0x5435;
171+
pub const TIOCSIG: ::Ioctl = 0x40045436;
172+
pub const TIOCVHANGUP: ::Ioctl = 0x5437;
173+
pub const TIOCGPKT: ::Ioctl = 0x80045438;
174+
pub const TIOCGPTLCK: ::Ioctl = 0x80045439;
175+
pub const TIOCGEXCL: ::Ioctl = 0x80045440;
176+
pub const TIOCGPTPEER: ::Ioctl = 0x5441;
177+
// pub const TIOCGISO7816: ::Ioctl = 0x80285442;
178+
// pub const TIOCSISO7816: ::Ioctl = 0xc0285443;
179+
pub const FIONCLEX: ::Ioctl = 0x5450;
180+
pub const FIOCLEX: ::Ioctl = 0x5451;
181+
pub const FIOASYNC: ::Ioctl = 0x5452;
182+
pub const TIOCSERCONFIG: ::Ioctl = 0x5453;
183+
pub const TIOCSERGWILD: ::Ioctl = 0x5454;
184+
pub const TIOCSERSWILD: ::Ioctl = 0x5455;
185+
pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456;
186+
pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457;
187+
pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458;
188+
pub const TIOCSERGETLSR: ::Ioctl = 0x5459;
189+
pub const TIOCSERGETMULTI: ::Ioctl = 0x545A;
190+
pub const TIOCSERSETMULTI: ::Ioctl = 0x545B;
191+
pub const TIOCMIWAIT: ::Ioctl = 0x545C;
192+
pub const TIOCGICOUNT: ::Ioctl = 0x545D;
193+
pub const BLKSSZGET: ::Ioctl = 0x1268;
194+
pub const BLKPBSZGET: ::Ioctl = 0x127B;
203195

204196
cfg_if! {
205197
if #[cfg(any(target_arch = "arm",
206198
target_arch = "s390x"))] {
207199
pub const FIOQSIZE: ::Ioctl = 0x545E;
208-
} else if #[cfg(not(any(target_arch = "mips",
209-
target_arch = "mips64",
210-
target_arch = "powerpc",
211-
target_arch = "powerpc64",
212-
target_arch = "sparc",
213-
target_arch = "sparc64")))] {
200+
} else {
214201
pub const FIOQSIZE: ::Ioctl = 0x5460;
215202
}
216203
}
@@ -230,5 +217,60 @@ pub const TIOCM_DSR: ::c_int = 0x100;
230217
pub const BOTHER: ::speed_t = 0o010000;
231218
pub const IBSHIFT: ::tcflag_t = 16;
232219

233-
pub const BLKSSZGET: ::Ioctl = 0x1268;
234-
pub const BLKPBSZGET: ::Ioctl = 0x127B;
220+
// RLIMIT Constants
221+
222+
cfg_if! {
223+
if #[cfg(any(target_env = "gnu",
224+
target_env = "uclibc"))] {
225+
226+
pub const RLIMIT_CPU: ::__rlimit_resource_t = 0;
227+
pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1;
228+
pub const RLIMIT_DATA: ::__rlimit_resource_t = 2;
229+
pub const RLIMIT_STACK: ::__rlimit_resource_t = 3;
230+
pub const RLIMIT_CORE: ::__rlimit_resource_t = 4;
231+
pub const RLIMIT_RSS: ::__rlimit_resource_t = 5;
232+
pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6;
233+
pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7;
234+
pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8;
235+
pub const RLIMIT_AS: ::__rlimit_resource_t = 9;
236+
pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10;
237+
pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11;
238+
pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12;
239+
pub const RLIMIT_NICE: ::__rlimit_resource_t = 13;
240+
pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14;
241+
pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15;
242+
pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = RLIM_NLIMITS;
243+
244+
} else if #[cfg(target_env = "musl")] {
245+
246+
pub const RLIMIT_CPU: ::c_int = 0;
247+
pub const RLIMIT_FSIZE: ::c_int = 1;
248+
pub const RLIMIT_DATA: ::c_int = 2;
249+
pub const RLIMIT_STACK: ::c_int = 3;
250+
pub const RLIMIT_CORE: ::c_int = 4;
251+
pub const RLIMIT_RSS: ::c_int = 5;
252+
pub const RLIMIT_NPROC: ::c_int = 6;
253+
pub const RLIMIT_NOFILE: ::c_int = 7;
254+
pub const RLIMIT_MEMLOCK: ::c_int = 8;
255+
pub const RLIMIT_AS: ::c_int = 9;
256+
pub const RLIMIT_LOCKS: ::c_int = 10;
257+
pub const RLIMIT_SIGPENDING: ::c_int = 11;
258+
pub const RLIMIT_MSGQUEUE: ::c_int = 12;
259+
pub const RLIMIT_NICE: ::c_int = 13;
260+
pub const RLIMIT_RTPRIO: ::c_int = 14;
261+
pub const RLIMIT_RTTIME: ::c_int = 15;
262+
pub const RLIM_NLIMITS: ::c_int = 15;
263+
pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS;
264+
}
265+
}
266+
267+
cfg_if! {
268+
if #[cfg(target_env = "gnu")] {
269+
pub const RLIM_NLIMITS: ::__rlimit_resource_t = 16;
270+
}
271+
else if #[cfg(target_env = "uclibc")] {
272+
pub const RLIM_NLIMITS: ::__rlimit_resource_t = 15;
273+
}
274+
}
275+
276+
pub const RLIM_INFINITY: ::rlim_t = !0;

src/unix/linux_like/linux/arch/mips/mod.rs

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ pub const TIOCSLTC: ::Ioctl = 0x7475;
185185
pub const TIOCGETP: ::Ioctl = 0x7408;
186186
pub const TIOCSETP: ::Ioctl = 0x7409;
187187
pub const TIOCSETN: ::Ioctl = 0x740a;
188+
pub const BLKSSZGET: ::Ioctl = 0x20001268;
189+
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
188190

189191
cfg_if! {
190192
if #[cfg(target_env = "musl")] {
@@ -208,5 +210,74 @@ pub const TIOCM_DSR: ::c_int = 0x400;
208210
pub const BOTHER: ::speed_t = 0o010000;
209211
pub const IBSHIFT: ::tcflag_t = 16;
210212

211-
pub const BLKSSZGET: ::Ioctl = 0x20001268;
212-
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
213+
// RLIMIT Constants
214+
215+
cfg_if! {
216+
if #[cfg(any(target_env = "gnu",
217+
target_env = "uclibc"))] {
218+
219+
pub const RLIMIT_CPU: ::__rlimit_resource_t = 0;
220+
pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1;
221+
pub const RLIMIT_DATA: ::__rlimit_resource_t = 2;
222+
pub const RLIMIT_STACK: ::__rlimit_resource_t = 3;
223+
pub const RLIMIT_CORE: ::__rlimit_resource_t = 4;
224+
pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 5;
225+
pub const RLIMIT_AS: ::__rlimit_resource_t = 6;
226+
pub const RLIMIT_RSS: ::__rlimit_resource_t = 7;
227+
pub const RLIMIT_NPROC: ::__rlimit_resource_t = 8;
228+
pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 9;
229+
pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10;
230+
pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11;
231+
pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12;
232+
pub const RLIMIT_NICE: ::__rlimit_resource_t = 13;
233+
pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14;
234+
pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15;
235+
pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = RLIM_NLIMITS;
236+
237+
} else if #[cfg(target_env = "musl")] {
238+
239+
pub const RLIMIT_CPU: ::c_int = 0;
240+
pub const RLIMIT_FSIZE: ::c_int = 1;
241+
pub const RLIMIT_DATA: ::c_int = 2;
242+
pub const RLIMIT_STACK: ::c_int = 3;
243+
pub const RLIMIT_CORE: ::c_int = 4;
244+
pub const RLIMIT_NOFILE: ::c_int = 5;
245+
pub const RLIMIT_AS: ::c_int = 6;
246+
pub const RLIMIT_RSS: ::c_int = 7;
247+
pub const RLIMIT_NPROC: ::c_int = 8;
248+
pub const RLIMIT_MEMLOCK: ::c_int = 9;
249+
pub const RLIMIT_LOCKS: ::c_int = 10;
250+
pub const RLIMIT_SIGPENDING: ::c_int = 11;
251+
pub const RLIMIT_MSGQUEUE: ::c_int = 12;
252+
pub const RLIMIT_NICE: ::c_int = 13;
253+
pub const RLIMIT_RTPRIO: ::c_int = 14;
254+
pub const RLIMIT_RTTIME: ::c_int = 15;
255+
pub const RLIM_NLIMITS: ::c_int = 15;
256+
pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS;
257+
pub const RLIM_INFINITY: ::rlim_t = !0;
258+
}
259+
}
260+
261+
cfg_if! {
262+
if #[cfg(target_env = "gnu")] {
263+
pub const RLIM_NLIMITS: ::__rlimit_resource_t = 16;
264+
} else if #[cfg(target_env = "uclibc")] {
265+
pub const RLIM_NLIMITS: ::__rlimit_resource_t = 15;
266+
}
267+
}
268+
269+
cfg_if! {
270+
if #[cfg(target_arch = "mips64",
271+
any(target_env = "gnu",
272+
target_env = "uclibc"))] {
273+
pub const RLIM_INFINITY: ::rlim_t = !0;
274+
}
275+
}
276+
277+
cfg_if! {
278+
if #[cfg(target_arch = "mips",
279+
any(target_env = "gnu",
280+
target_env = "uclibc"))] {
281+
pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
282+
}
283+
}

0 commit comments

Comments
 (0)