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

1use crate::prelude::*;
2use crate::{Ioctl, _IOR, _IOW};
3
4s! {
5    pub struct termios2 {
6        pub c_iflag: crate::tcflag_t,
7        pub c_oflag: crate::tcflag_t,
8        pub c_cflag: crate::tcflag_t,
9        pub c_lflag: crate::tcflag_t,
10        pub c_line: crate::cc_t,
11        pub c_cc: [crate::cc_t; 19],
12        pub c_ispeed: crate::speed_t,
13        pub c_ospeed: crate::speed_t,
14    }
15}
16
17// include/uapi/asm-generic/socket.h
18// arch/alpha/include/uapi/asm/socket.h
19// tools/include/uapi/asm-generic/socket.h
20// arch/mips/include/uapi/asm/socket.h
21pub const SOL_SOCKET: c_int = 1;
22
23// Defined in unix/linux_like/mod.rs
24// pub const SO_DEBUG: c_int = 1;
25pub const SO_REUSEADDR: c_int = 2;
26pub const SO_TYPE: c_int = 3;
27pub const SO_ERROR: c_int = 4;
28pub const SO_DONTROUTE: c_int = 5;
29pub const SO_BROADCAST: c_int = 6;
30pub const SO_SNDBUF: c_int = 7;
31pub const SO_RCVBUF: c_int = 8;
32pub const SO_KEEPALIVE: c_int = 9;
33pub const SO_OOBINLINE: c_int = 10;
34pub const SO_NO_CHECK: c_int = 11;
35pub const SO_PRIORITY: c_int = 12;
36pub const SO_LINGER: c_int = 13;
37pub const SO_BSDCOMPAT: c_int = 14;
38pub const SO_REUSEPORT: c_int = 15;
39pub const SO_PASSCRED: c_int = 16;
40pub const SO_PEERCRED: c_int = 17;
41pub const SO_RCVLOWAT: c_int = 18;
42pub const SO_SNDLOWAT: c_int = 19;
43const SO_RCVTIMEO_OLD: c_int = 20;
44const SO_SNDTIMEO_OLD: c_int = 21;
45pub const SO_SECURITY_AUTHENTICATION: c_int = 22;
46pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23;
47pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24;
48pub const SO_BINDTODEVICE: c_int = 25;
49pub const SO_ATTACH_FILTER: c_int = 26;
50pub const SO_DETACH_FILTER: c_int = 27;
51pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER;
52pub const SO_PEERNAME: c_int = 28;
53const SO_TIMESTAMP_OLD: c_int = 29;
54const SO_TIMESTAMPNS_OLD: c_int = 35;
55const SO_TIMESTAMPING_OLD: c_int = 37;
56
57cfg_if! {
58    if #[cfg(all(
59        linux_time_bits64,
60        any(target_arch = "arm", target_arch = "x86"),
61        not(any(target_env = "musl", target_env = "ohos"))
62    ))] {
63        pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
64        pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
65        pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
66        pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW;
67        pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW;
68    } else if #[cfg(all(
69        linux_time_bits64,
70        any(target_arch = "arm", target_arch = "x86"),
71        any(target_env = "musl", target_env = "ohos")
72    ))] {
73        pub const SO_TIMESTAMP: c_int = 63;
74        pub const SO_TIMESTAMPNS: c_int = 64;
75        pub const SO_TIMESTAMPING: c_int = 65;
76        pub const SO_RCVTIMEO: c_int = 66;
77        pub const SO_SNDTIMEO: c_int = 67;
78    } else {
79        pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
80        pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
81        pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;
82        pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD;
83        pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD;
84    }
85}
86
87pub const SO_ACCEPTCONN: c_int = 30;
88pub const SO_PEERSEC: c_int = 31;
89pub const SO_SNDBUFFORCE: c_int = 32;
90pub const SO_RCVBUFFORCE: c_int = 33;
91pub const SO_PASSSEC: c_int = 34;
92pub const SO_MARK: c_int = 36;
93pub const SO_PROTOCOL: c_int = 38;
94pub const SO_DOMAIN: c_int = 39;
95pub const SO_RXQ_OVFL: c_int = 40;
96pub const SO_WIFI_STATUS: c_int = 41;
97pub const SCM_WIFI_STATUS: c_int = SO_WIFI_STATUS;
98pub const SO_PEEK_OFF: c_int = 42;
99pub const SO_NOFCS: c_int = 43;
100pub const SO_LOCK_FILTER: c_int = 44;
101pub const SO_SELECT_ERR_QUEUE: c_int = 45;
102pub const SO_BUSY_POLL: c_int = 46;
103pub const SO_MAX_PACING_RATE: c_int = 47;
104pub const SO_BPF_EXTENSIONS: c_int = 48;
105pub const SO_INCOMING_CPU: c_int = 49;
106pub const SO_ATTACH_BPF: c_int = 50;
107pub const SO_DETACH_BPF: c_int = SO_DETACH_FILTER;
108pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 51;
109pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 52;
110pub const SO_CNX_ADVICE: c_int = 53;
111pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54;
112pub const SO_MEMINFO: c_int = 55;
113pub const SO_INCOMING_NAPI_ID: c_int = 56;
114pub const SO_COOKIE: c_int = 57;
115pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58;
116pub const SO_PEERGROUPS: c_int = 59;
117pub const SO_ZEROCOPY: c_int = 60;
118pub const SO_TXTIME: c_int = 61;
119pub const SCM_TXTIME: c_int = SO_TXTIME;
120pub const SO_BINDTOIFINDEX: c_int = 62;
121cfg_if! {
122    // Some of these platforms in CI already have these constants.
123    // But they may still not have those _OLD ones.
124    if #[cfg(all(
125        any(
126            target_arch = "x86",
127            target_arch = "x86_64",
128            target_arch = "arm",
129            target_arch = "aarch64",
130            target_arch = "csky",
131            target_arch = "loongarch64"
132        ),
133        // FIXME(musl):
134        // Musl hardcodes the SO_* constants instead
135        // of inheriting them from the kernel headers.
136        // For new constants you might need consider updating
137        // musl in the CI as well.
138        not(any(target_env = "musl", target_env = "ohos"))
139    ))] {
140        pub const SO_TIMESTAMP_NEW: c_int = 63;
141        pub const SO_TIMESTAMPNS_NEW: c_int = 64;
142        pub const SO_TIMESTAMPING_NEW: c_int = 65;
143        pub const SO_RCVTIMEO_NEW: c_int = 66;
144        pub const SO_SNDTIMEO_NEW: c_int = 67;
145        pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
146    }
147}
148pub const SO_PREFER_BUSY_POLL: c_int = 69;
149pub const SO_BUSY_POLL_BUDGET: c_int = 70;
150pub const SO_NETNS_COOKIE: c_int = 71;
151pub const SO_BUF_LOCK: c_int = 72;
152pub const SO_RESERVE_MEM: c_int = 73;
153pub const SO_TXREHASH: c_int = 74;
154pub const SO_RCVMARK: c_int = 75;
155pub const SO_PASSPIDFD: c_int = 76;
156pub const SO_PEERPIDFD: c_int = 77;
157pub const SO_DEVMEM_LINEAR: c_int = 78;
158pub const SO_DEVMEM_DMABUF: c_int = 79;
159pub const SO_DEVMEM_DONTNEED: c_int = 80;
160
161pub const FICLONE: Ioctl = _IOW::<c_int>(0x94, 9) as Ioctl;
162pub const FICLONERANGE: Ioctl = _IOW::<crate::file_clone_range>(0x94, 13) as Ioctl;
163
164// Defined in unix/linux_like/mod.rs
165// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP;
166pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
167pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
168
169pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
170pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
171
172// Ioctl Constants
173
174pub const TCGETS: Ioctl = 0x5401;
175pub const TCSETS: Ioctl = 0x5402;
176pub const TCSETSW: Ioctl = 0x5403;
177pub const TCSETSF: Ioctl = 0x5404;
178pub const TCGETA: Ioctl = 0x5405;
179pub const TCSETA: Ioctl = 0x5406;
180pub const TCSETAW: Ioctl = 0x5407;
181pub const TCSETAF: Ioctl = 0x5408;
182pub const TCSBRK: Ioctl = 0x5409;
183pub const TCXONC: Ioctl = 0x540A;
184pub const TCFLSH: Ioctl = 0x540B;
185pub const TIOCEXCL: Ioctl = 0x540C;
186pub const TIOCNXCL: Ioctl = 0x540D;
187pub const TIOCSCTTY: Ioctl = 0x540E;
188pub const TIOCGPGRP: Ioctl = 0x540F;
189pub const TIOCSPGRP: Ioctl = 0x5410;
190pub const TIOCOUTQ: Ioctl = 0x5411;
191pub const TIOCSTI: Ioctl = 0x5412;
192pub const TIOCGWINSZ: Ioctl = 0x5413;
193pub const TIOCSWINSZ: Ioctl = 0x5414;
194pub const TIOCMGET: Ioctl = 0x5415;
195pub const TIOCMBIS: Ioctl = 0x5416;
196pub const TIOCMBIC: Ioctl = 0x5417;
197pub const TIOCMSET: Ioctl = 0x5418;
198pub const TIOCGSOFTCAR: Ioctl = 0x5419;
199pub const TIOCSSOFTCAR: Ioctl = 0x541A;
200pub const FIONREAD: Ioctl = 0x541B;
201pub const TIOCINQ: Ioctl = FIONREAD;
202pub const TIOCLINUX: Ioctl = 0x541C;
203pub const TIOCCONS: Ioctl = 0x541D;
204pub const TIOCGSERIAL: Ioctl = 0x541E;
205pub const TIOCSSERIAL: Ioctl = 0x541F;
206pub const TIOCPKT: Ioctl = 0x5420;
207pub const FIONBIO: Ioctl = 0x5421;
208pub const TIOCNOTTY: Ioctl = 0x5422;
209pub const TIOCSETD: Ioctl = 0x5423;
210pub const TIOCGETD: Ioctl = 0x5424;
211pub const TCSBRKP: Ioctl = 0x5425;
212pub const TIOCSBRK: Ioctl = 0x5427;
213pub const TIOCCBRK: Ioctl = 0x5428;
214pub const TIOCGSID: Ioctl = 0x5429;
215pub const TCGETS2: Ioctl = 0x802c542a;
216pub const TCSETS2: Ioctl = 0x402c542b;
217pub const TCSETSW2: Ioctl = 0x402c542c;
218pub const TCSETSF2: Ioctl = 0x402c542d;
219pub const TIOCGRS485: Ioctl = 0x542E;
220pub const TIOCSRS485: Ioctl = 0x542F;
221pub const TIOCGPTN: Ioctl = 0x80045430;
222pub const TIOCSPTLCK: Ioctl = 0x40045431;
223pub const TIOCGDEV: Ioctl = 0x80045432;
224pub const TCGETX: Ioctl = 0x5432;
225pub const TCSETX: Ioctl = 0x5433;
226pub const TCSETXF: Ioctl = 0x5434;
227pub const TCSETXW: Ioctl = 0x5435;
228pub const TIOCSIG: Ioctl = 0x40045436;
229pub const TIOCVHANGUP: Ioctl = 0x5437;
230pub const TIOCGPKT: Ioctl = 0x80045438;
231pub const TIOCGPTLCK: Ioctl = 0x80045439;
232pub const TIOCGEXCL: Ioctl = 0x80045440;
233pub const TIOCGPTPEER: Ioctl = 0x5441;
234// pub const TIOCGISO7816: Ioctl = 0x80285442;
235// pub const TIOCSISO7816: Ioctl = 0xc0285443;
236pub const FIONCLEX: Ioctl = 0x5450;
237pub const FIOCLEX: Ioctl = 0x5451;
238pub const FIOASYNC: Ioctl = 0x5452;
239pub const TIOCSERCONFIG: Ioctl = 0x5453;
240pub const TIOCSERGWILD: Ioctl = 0x5454;
241pub const TIOCSERSWILD: Ioctl = 0x5455;
242pub const TIOCGLCKTRMIOS: Ioctl = 0x5456;
243pub const TIOCSLCKTRMIOS: Ioctl = 0x5457;
244pub const TIOCSERGSTRUCT: Ioctl = 0x5458;
245pub const TIOCSERGETLSR: Ioctl = 0x5459;
246pub const TIOCSERGETMULTI: Ioctl = 0x545A;
247pub const TIOCSERSETMULTI: Ioctl = 0x545B;
248pub const TIOCMIWAIT: Ioctl = 0x545C;
249pub const TIOCGICOUNT: Ioctl = 0x545D;
250pub const BLKIOMIN: Ioctl = 0x1278;
251pub const BLKIOOPT: Ioctl = 0x1279;
252pub const BLKSSZGET: Ioctl = 0x1268;
253pub const BLKPBSZGET: Ioctl = 0x127B;
254// linux/if_tun.h
255pub const TUNSETNOCSUM: Ioctl = 0x400454c8;
256pub const TUNSETDEBUG: Ioctl = 0x400454c9;
257pub const TUNSETIFF: Ioctl = 0x400454ca;
258pub const TUNSETPERSIST: Ioctl = 0x400454cb;
259pub const TUNSETOWNER: Ioctl = 0x400454cc;
260pub const TUNSETLINK: Ioctl = 0x400454cd;
261pub const TUNSETGROUP: Ioctl = 0x400454ce;
262pub const TUNGETFEATURES: Ioctl = 0x800454cf;
263pub const TUNSETOFFLOAD: Ioctl = 0x400454d0;
264pub const TUNSETTXFILTER: Ioctl = 0x400454d1;
265pub const TUNGETIFF: Ioctl = 0x800454d2;
266pub const TUNGETSNDBUF: Ioctl = 0x800454d3;
267pub const TUNSETSNDBUF: Ioctl = 0x400454d4;
268pub const TUNGETVNETHDRSZ: Ioctl = 0x800454d7;
269pub const TUNSETVNETHDRSZ: Ioctl = 0x400454d8;
270pub const TUNSETQUEUE: Ioctl = 0x400454d9;
271pub const TUNSETIFINDEX: Ioctl = 0x400454da;
272pub const TUNSETVNETLE: Ioctl = 0x400454dc;
273pub const TUNGETVNETLE: Ioctl = 0x800454dd;
274/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on
275 * little-endian hosts. Not all kernel configurations support them, but all
276 * configurations that support SET also support GET.
277 */
278pub const TUNSETVNETBE: Ioctl = 0x400454de;
279pub const TUNGETVNETBE: Ioctl = 0x800454df;
280pub const TUNSETSTEERINGEBPF: Ioctl = 0x800454e0;
281pub const TUNSETFILTEREBPF: Ioctl = 0x800454e1;
282
283pub const FS_IOC_GETFLAGS: Ioctl = _IOR::<c_long>('f' as u32, 1) as Ioctl;
284pub const FS_IOC_SETFLAGS: Ioctl = _IOW::<c_long>('f' as u32, 2) as Ioctl;
285pub const FS_IOC_GETVERSION: Ioctl = _IOR::<c_long>('v' as u32, 1) as Ioctl;
286pub const FS_IOC_SETVERSION: Ioctl = _IOW::<c_long>('v' as u32, 2) as Ioctl;
287pub const FS_IOC32_GETFLAGS: Ioctl = _IOR::<c_int>('f' as u32, 1) as Ioctl;
288pub const FS_IOC32_SETFLAGS: Ioctl = _IOW::<c_int>('f' as u32, 2) as Ioctl;
289pub const FS_IOC32_GETVERSION: Ioctl = _IOR::<c_int>('v' as u32, 1) as Ioctl;
290pub const FS_IOC32_SETVERSION: Ioctl = _IOW::<c_int>('v' as u32, 2) as Ioctl;
291
292pub const TUNATTACHFILTER: Ioctl = _IOW::<crate::sock_fprog>('T' as u32, 213) as Ioctl;
293pub const TUNDETACHFILTER: Ioctl = _IOW::<crate::sock_fprog>('T' as u32, 214) as Ioctl;
294pub const TUNGETFILTER: Ioctl = _IOR::<crate::sock_fprog>('T' as u32, 219) as Ioctl;
295
296cfg_if! {
297    if #[cfg(any(target_arch = "arm", target_arch = "s390x"))] {
298        pub const FIOQSIZE: Ioctl = 0x545E;
299    } else {
300        pub const FIOQSIZE: Ioctl = 0x5460;
301    }
302}
303
304pub const TIOCM_LE: c_int = 0x001;
305pub const TIOCM_DTR: c_int = 0x002;
306pub const TIOCM_RTS: c_int = 0x004;
307pub const TIOCM_ST: c_int = 0x008;
308pub const TIOCM_SR: c_int = 0x010;
309pub const TIOCM_CTS: c_int = 0x020;
310pub const TIOCM_CAR: c_int = 0x040;
311pub const TIOCM_CD: c_int = TIOCM_CAR;
312pub const TIOCM_RNG: c_int = 0x080;
313pub const TIOCM_RI: c_int = TIOCM_RNG;
314pub const TIOCM_DSR: c_int = 0x100;
315
316pub const BOTHER: crate::speed_t = 0o010000;
317pub const IBSHIFT: crate::tcflag_t = 16;
318
319// RLIMIT Constants
320
321cfg_if! {
322    if #[cfg(any(target_env = "gnu", target_env = "uclibc"))] {
323        pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0;
324        pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1;
325        pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2;
326        pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3;
327        pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4;
328        pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5;
329        pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 6;
330        pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 7;
331        pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8;
332        pub const RLIMIT_AS: crate::__rlimit_resource_t = 9;
333        pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10;
334        pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11;
335        pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12;
336        pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13;
337        pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14;
338        pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15;
339        #[allow(deprecated)]
340        #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
341        pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS;
342    } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
343        pub const RLIMIT_CPU: c_int = 0;
344        pub const RLIMIT_FSIZE: c_int = 1;
345        pub const RLIMIT_DATA: c_int = 2;
346        pub const RLIMIT_STACK: c_int = 3;
347        pub const RLIMIT_CORE: c_int = 4;
348        pub const RLIMIT_RSS: c_int = 5;
349        pub const RLIMIT_NPROC: c_int = 6;
350        pub const RLIMIT_NOFILE: c_int = 7;
351        pub const RLIMIT_MEMLOCK: c_int = 8;
352        pub const RLIMIT_AS: c_int = 9;
353        pub const RLIMIT_LOCKS: c_int = 10;
354        pub const RLIMIT_SIGPENDING: c_int = 11;
355        pub const RLIMIT_MSGQUEUE: c_int = 12;
356        pub const RLIMIT_NICE: c_int = 13;
357        pub const RLIMIT_RTPRIO: c_int = 14;
358        pub const RLIMIT_RTTIME: c_int = 15;
359        #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
360        #[cfg(not(target_arch = "loongarch64"))]
361        pub const RLIM_NLIMITS: c_int = 15;
362        #[cfg(target_arch = "loongarch64")]
363        pub const RLIM_NLIMITS: c_int = 16;
364        #[allow(deprecated)]
365        #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
366        pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS;
367    }
368}
369
370cfg_if! {
371    if #[cfg(target_env = "gnu")] {
372        #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
373        pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16;
374    } else if #[cfg(target_env = "uclibc")] {
375        #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
376        pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 15;
377    }
378}
379
380pub const RLIM_INFINITY: crate::rlim_t = !0;