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

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