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

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