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_SECURITY_AUTHENTICATION: c_int = 22;
44pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23;
45pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24;
46pub const SO_BINDTODEVICE: c_int = 25;
47pub const SO_ATTACH_FILTER: c_int = 26;
48pub const SO_DETACH_FILTER: c_int = 27;
49pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER;
50pub const SO_PEERNAME: c_int = 28;
51
52cfg_if! {
53    if #[cfg(all(
54        linux_time_bits64,
55        any(target_arch = "arm", target_arch = "x86"),
56        not(any(target_env = "musl", target_env = "ohos"))
57    ))] {
58        pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
59        pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
60        pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
61        pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW;
62        pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW;
63    } else if #[cfg(all(
64        linux_time_bits64,
65        any(target_arch = "arm", target_arch = "x86"),
66        any(target_env = "musl", target_env = "ohos")
67    ))] {
68        pub const SO_TIMESTAMP: c_int = 63;
69        pub const SO_TIMESTAMPNS: c_int = 64;
70        pub const SO_TIMESTAMPING: c_int = 65;
71        pub const SO_RCVTIMEO: c_int = 66;
72        pub const SO_SNDTIMEO: c_int = 67;
73    } else {
74        const SO_TIMESTAMP_OLD: c_int = 29;
75        const SO_TIMESTAMPNS_OLD: c_int = 35;
76        const SO_TIMESTAMPING_OLD: c_int = 37;
77        const SO_RCVTIMEO_OLD: c_int = 20;
78        const SO_SNDTIMEO_OLD: c_int = 21;
79
80        pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
81        pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
82        pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;
83        pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD;
84        pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD;
85    }
86}
87
88pub const SO_ACCEPTCONN: c_int = 30;
89pub const SO_PEERSEC: c_int = 31;
90pub const SO_SNDBUFFORCE: c_int = 32;
91pub const SO_RCVBUFFORCE: c_int = 33;
92pub const SO_PASSSEC: c_int = 34;
93pub const SO_MARK: c_int = 36;
94pub const SO_PROTOCOL: c_int = 38;
95pub const SO_DOMAIN: c_int = 39;
96pub const SO_RXQ_OVFL: c_int = 40;
97pub const SO_WIFI_STATUS: c_int = 41;
98pub const SCM_WIFI_STATUS: c_int = SO_WIFI_STATUS;
99pub const SO_PEEK_OFF: c_int = 42;
100pub const SO_NOFCS: c_int = 43;
101pub const SO_LOCK_FILTER: c_int = 44;
102pub const SO_SELECT_ERR_QUEUE: c_int = 45;
103pub const SO_BUSY_POLL: c_int = 46;
104pub const SO_MAX_PACING_RATE: c_int = 47;
105pub const SO_BPF_EXTENSIONS: c_int = 48;
106pub const SO_INCOMING_CPU: c_int = 49;
107pub const SO_ATTACH_BPF: c_int = 50;
108pub const SO_DETACH_BPF: c_int = SO_DETACH_FILTER;
109pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 51;
110pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 52;
111pub const SO_CNX_ADVICE: c_int = 53;
112pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54;
113pub const SO_MEMINFO: c_int = 55;
114pub const SO_INCOMING_NAPI_ID: c_int = 56;
115pub const SO_COOKIE: c_int = 57;
116pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58;
117pub const SO_PEERGROUPS: c_int = 59;
118pub const SO_ZEROCOPY: c_int = 60;
119pub const SO_TXTIME: c_int = 61;
120pub const SCM_TXTIME: c_int = SO_TXTIME;
121pub const SO_BINDTOIFINDEX: c_int = 62;
122cfg_if! {
123    // Some of these platforms in CI already have these constants.
124    // But they may still not have those _OLD ones.
125    if #[cfg(all(
126        any(
127            target_arch = "x86",
128            target_arch = "x86_64",
129            target_arch = "arm",
130            target_arch = "aarch64",
131            target_arch = "csky",
132            target_arch = "loongarch64"
133        ),
134        // FIXME(musl):
135        // Musl hardcodes the SO_* constants instead
136        // of inheriting them from the kernel headers.
137        // For new constants you might need consider updating
138        // musl in the CI as well.
139        not(any(target_env = "musl", target_env = "ohos"))
140    ))] {
141        pub const SO_TIMESTAMP_NEW: c_int = 63;
142        pub const SO_TIMESTAMPNS_NEW: c_int = 64;
143        pub const SO_TIMESTAMPING_NEW: c_int = 65;
144        pub const SO_RCVTIMEO_NEW: c_int = 66;
145        pub const SO_SNDTIMEO_NEW: c_int = 67;
146        pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
147    }
148}
149pub const SO_PREFER_BUSY_POLL: c_int = 69;
150pub const SO_BUSY_POLL_BUDGET: c_int = 70;
151pub const SO_NETNS_COOKIE: c_int = 71;
152pub const SO_BUF_LOCK: c_int = 72;
153pub const SO_RESERVE_MEM: c_int = 73;
154pub const SO_TXREHASH: c_int = 74;
155pub const SO_RCVMARK: c_int = 75;
156pub const SO_PASSPIDFD: c_int = 76;
157pub const SO_PEERPIDFD: c_int = 77;
158pub const SO_DEVMEM_LINEAR: c_int = 78;
159pub const SO_DEVMEM_DMABUF: c_int = 79;
160pub const SO_DEVMEM_DONTNEED: c_int = 80;
161
162// Defined in unix/linux_like/mod.rs
163// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP;
164pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
165pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;
166
167pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
168pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;
169
170// Ioctl Constants
171
172pub const TCGETS: Ioctl = 0x5401;
173pub const TCSETS: Ioctl = 0x5402;
174pub const TCSETSW: Ioctl = 0x5403;
175pub const TCSETSF: Ioctl = 0x5404;
176pub const TCGETA: Ioctl = 0x5405;
177pub const TCSETA: Ioctl = 0x5406;
178pub const TCSETAW: Ioctl = 0x5407;
179pub const TCSETAF: Ioctl = 0x5408;
180pub const TCSBRK: Ioctl = 0x5409;
181pub const TCXONC: Ioctl = 0x540A;
182pub const TCFLSH: Ioctl = 0x540B;
183pub const TIOCEXCL: Ioctl = 0x540C;
184pub const TIOCNXCL: Ioctl = 0x540D;
185pub const TIOCSCTTY: Ioctl = 0x540E;
186pub const TIOCGPGRP: Ioctl = 0x540F;
187pub const TIOCSPGRP: Ioctl = 0x5410;
188pub const TIOCOUTQ: Ioctl = 0x5411;
189pub const TIOCSTI: Ioctl = 0x5412;
190pub const TIOCGWINSZ: Ioctl = 0x5413;
191pub const TIOCSWINSZ: Ioctl = 0x5414;
192pub const TIOCMGET: Ioctl = 0x5415;
193pub const TIOCMBIS: Ioctl = 0x5416;
194pub const TIOCMBIC: Ioctl = 0x5417;
195pub const TIOCMSET: Ioctl = 0x5418;
196pub const TIOCGSOFTCAR: Ioctl = 0x5419;
197pub const TIOCSSOFTCAR: Ioctl = 0x541A;
198pub const FIONREAD: Ioctl = 0x541B;
199pub const TIOCINQ: Ioctl = FIONREAD;
200pub const TIOCLINUX: Ioctl = 0x541C;
201pub const TIOCCONS: Ioctl = 0x541D;
202pub const TIOCGSERIAL: Ioctl = 0x541E;
203pub const TIOCSSERIAL: Ioctl = 0x541F;
204pub const TIOCPKT: Ioctl = 0x5420;
205pub const FIONBIO: Ioctl = 0x5421;
206pub const TIOCNOTTY: Ioctl = 0x5422;
207pub const TIOCSETD: Ioctl = 0x5423;
208pub const TIOCGETD: Ioctl = 0x5424;
209pub const TCSBRKP: Ioctl = 0x5425;
210pub const TIOCSBRK: Ioctl = 0x5427;
211pub const TIOCCBRK: Ioctl = 0x5428;
212pub const TIOCGSID: Ioctl = 0x5429;
213pub const TCGETS2: Ioctl = 0x802c542a;
214pub const TCSETS2: Ioctl = 0x402c542b;
215pub const TCSETSW2: Ioctl = 0x402c542c;
216pub const TCSETSF2: Ioctl = 0x402c542d;
217pub const TIOCGRS485: Ioctl = 0x542E;
218pub const TIOCSRS485: Ioctl = 0x542F;
219pub const TIOCGPTN: Ioctl = 0x80045430;
220pub const TIOCSPTLCK: Ioctl = 0x40045431;
221pub const TIOCGDEV: Ioctl = 0x80045432;
222pub const TCGETX: Ioctl = 0x5432;
223pub const TCSETX: Ioctl = 0x5433;
224pub const TCSETXF: Ioctl = 0x5434;
225pub const TCSETXW: Ioctl = 0x5435;
226pub const TIOCSIG: Ioctl = 0x40045436;
227pub const TIOCVHANGUP: Ioctl = 0x5437;
228pub const TIOCGPKT: Ioctl = 0x80045438;
229pub const TIOCGPTLCK: Ioctl = 0x80045439;
230pub const TIOCGEXCL: Ioctl = 0x80045440;
231pub const TIOCGPTPEER: Ioctl = 0x5441;
232// pub const TIOCGISO7816: Ioctl = 0x80285442;
233// pub const TIOCSISO7816: Ioctl = 0xc0285443;
234pub const FIONCLEX: Ioctl = 0x5450;
235pub const FIOCLEX: Ioctl = 0x5451;
236pub const FIOASYNC: Ioctl = 0x5452;
237pub const TIOCSERCONFIG: Ioctl = 0x5453;
238pub const TIOCSERGWILD: Ioctl = 0x5454;
239pub const TIOCSERSWILD: Ioctl = 0x5455;
240pub const TIOCGLCKTRMIOS: Ioctl = 0x5456;
241pub const TIOCSLCKTRMIOS: Ioctl = 0x5457;
242pub const TIOCSERGSTRUCT: Ioctl = 0x5458;
243pub const TIOCSERGETLSR: Ioctl = 0x5459;
244pub const TIOCSERGETMULTI: Ioctl = 0x545A;
245pub const TIOCSERSETMULTI: Ioctl = 0x545B;
246pub const TIOCMIWAIT: Ioctl = 0x545C;
247pub const TIOCGICOUNT: Ioctl = 0x545D;
248pub const BLKIOMIN: Ioctl = 0x1278;
249pub const BLKIOOPT: Ioctl = 0x1279;
250pub const BLKSSZGET: Ioctl = 0x1268;
251pub const BLKPBSZGET: Ioctl = 0x127B;
252
253cfg_if! {
254    if #[cfg(any(target_arch = "arm", target_arch = "s390x"))] {
255        pub const FIOQSIZE: Ioctl = 0x545E;
256    } else {
257        pub const FIOQSIZE: Ioctl = 0x5460;
258    }
259}
260
261pub const TIOCM_LE: c_int = 0x001;
262pub const TIOCM_DTR: c_int = 0x002;
263pub const TIOCM_RTS: c_int = 0x004;
264pub const TIOCM_ST: c_int = 0x008;
265pub const TIOCM_SR: c_int = 0x010;
266pub const TIOCM_CTS: c_int = 0x020;
267pub const TIOCM_CAR: c_int = 0x040;
268pub const TIOCM_CD: c_int = TIOCM_CAR;
269pub const TIOCM_RNG: c_int = 0x080;
270pub const TIOCM_RI: c_int = TIOCM_RNG;
271pub const TIOCM_DSR: c_int = 0x100;
272
273pub const BOTHER: crate::speed_t = 0o010000;
274pub const IBSHIFT: crate::tcflag_t = 16;
275
276// RLIMIT Constants
277
278cfg_if! {
279    if #[cfg(any(target_env = "gnu", target_env = "uclibc"))] {
280        pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0;
281        pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1;
282        pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2;
283        pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3;
284        pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4;
285        pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5;
286        pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 6;
287        pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 7;
288        pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8;
289        pub const RLIMIT_AS: crate::__rlimit_resource_t = 9;
290        pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10;
291        pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11;
292        pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12;
293        pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13;
294        pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14;
295        pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15;
296        #[allow(deprecated)]
297        #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
298        pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS;
299    } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
300        pub const RLIMIT_CPU: c_int = 0;
301        pub const RLIMIT_FSIZE: c_int = 1;
302        pub const RLIMIT_DATA: c_int = 2;
303        pub const RLIMIT_STACK: c_int = 3;
304        pub const RLIMIT_CORE: c_int = 4;
305        pub const RLIMIT_RSS: c_int = 5;
306        pub const RLIMIT_NPROC: c_int = 6;
307        pub const RLIMIT_NOFILE: c_int = 7;
308        pub const RLIMIT_MEMLOCK: c_int = 8;
309        pub const RLIMIT_AS: c_int = 9;
310        pub const RLIMIT_LOCKS: c_int = 10;
311        pub const RLIMIT_SIGPENDING: c_int = 11;
312        pub const RLIMIT_MSGQUEUE: c_int = 12;
313        pub const RLIMIT_NICE: c_int = 13;
314        pub const RLIMIT_RTPRIO: c_int = 14;
315        pub const RLIMIT_RTTIME: c_int = 15;
316        #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
317        pub const RLIM_NLIMITS: c_int = 16;
318        #[allow(deprecated)]
319        #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
320        pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS;
321    }
322}
323
324cfg_if! {
325    if #[cfg(target_env = "gnu")] {
326        #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
327        pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16;
328    } else if #[cfg(target_env = "uclibc")] {
329        #[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
330        pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 15;
331    }
332}
333
334pub const RLIM_INFINITY: crate::rlim_t = !0;