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