interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / libc / src / unix / linux_like / emscripten / mod.rs

1473 lines · 47402 bytes Raw Blame History
1use crate::prelude::*;
2
3pub type wchar_t = i32;
4pub type dev_t = u32;
5pub type socklen_t = u32;
6pub type pthread_t = c_ulong;
7pub type mode_t = u32;
8pub type shmatt_t = c_ulong;
9pub type mqd_t = c_int;
10pub type msgqnum_t = c_ulong;
11pub type msglen_t = c_ulong;
12pub type nfds_t = c_ulong;
13pub type nl_item = c_int;
14pub type idtype_t = c_uint;
15pub type loff_t = i64;
16pub type pthread_key_t = c_uint;
17
18pub type clock_t = c_long;
19pub type time_t = i64;
20pub type suseconds_t = c_long;
21pub type ino_t = u64;
22pub type off_t = i64;
23pub type blkcnt_t = i32;
24
25pub type blksize_t = c_long;
26pub type fsblkcnt_t = u32;
27pub type fsfilcnt_t = u32;
28pub type rlim_t = u64;
29pub type nlink_t = u32;
30
31pub type ino64_t = crate::ino_t;
32pub type off64_t = off_t;
33pub type blkcnt64_t = crate::blkcnt_t;
34pub type rlim64_t = crate::rlim_t;
35
36pub type rlimit64 = crate::rlimit;
37pub type flock64 = crate::flock;
38pub type stat64 = crate::stat;
39pub type statfs64 = crate::statfs;
40pub type statvfs64 = crate::statvfs;
41pub type dirent64 = crate::dirent;
42
43extern_ty! {
44 pub type fpos64_t; // FIXME(emscripten): fill this out with a struct
45}
46
47s! {
48 pub struct glob_t {
49 pub gl_pathc: size_t,
50 pub gl_pathv: *mut *mut c_char,
51 pub gl_offs: size_t,
52 pub gl_flags: c_int,
53
54 __unused1: Padding<*mut c_void>,
55 __unused2: Padding<*mut c_void>,
56 __unused3: Padding<*mut c_void>,
57 __unused4: Padding<*mut c_void>,
58 __unused5: Padding<*mut c_void>,
59 }
60
61 pub struct passwd {
62 pub pw_name: *mut c_char,
63 pub pw_passwd: *mut c_char,
64 pub pw_uid: crate::uid_t,
65 pub pw_gid: crate::gid_t,
66 pub pw_gecos: *mut c_char,
67 pub pw_dir: *mut c_char,
68 pub pw_shell: *mut c_char,
69 }
70
71 pub struct spwd {
72 pub sp_namp: *mut c_char,
73 pub sp_pwdp: *mut c_char,
74 pub sp_lstchg: c_long,
75 pub sp_min: c_long,
76 pub sp_max: c_long,
77 pub sp_warn: c_long,
78 pub sp_inact: c_long,
79 pub sp_expire: c_long,
80 pub sp_flag: c_ulong,
81 }
82
83 pub struct statvfs {
84 pub f_bsize: c_ulong,
85 pub f_frsize: c_ulong,
86 pub f_blocks: crate::fsblkcnt_t,
87 pub f_bfree: crate::fsblkcnt_t,
88 pub f_bavail: crate::fsblkcnt_t,
89 pub f_files: crate::fsfilcnt_t,
90 pub f_ffree: crate::fsfilcnt_t,
91 pub f_favail: crate::fsfilcnt_t,
92 pub f_fsid: c_ulong,
93 __f_unused: Padding<c_int>,
94 pub f_flag: c_ulong,
95 pub f_namemax: c_ulong,
96 __f_spare: [c_int; 6],
97 }
98
99 pub struct signalfd_siginfo {
100 pub ssi_signo: u32,
101 pub ssi_errno: i32,
102 pub ssi_code: i32,
103 pub ssi_pid: u32,
104 pub ssi_uid: u32,
105 pub ssi_fd: i32,
106 pub ssi_tid: u32,
107 pub ssi_band: u32,
108 pub ssi_overrun: u32,
109 pub ssi_trapno: u32,
110 pub ssi_status: i32,
111 pub ssi_int: i32,
112 pub ssi_ptr: u64,
113 pub ssi_utime: u64,
114 pub ssi_stime: u64,
115 pub ssi_addr: u64,
116 pub ssi_addr_lsb: u16,
117 _pad2: Padding<u16>,
118 pub ssi_syscall: i32,
119 pub ssi_call_addr: u64,
120 pub ssi_arch: u32,
121 _pad: Padding<[u8; 28]>,
122 }
123
124 pub struct fsid_t {
125 __val: [c_int; 2],
126 }
127
128 pub struct cpu_set_t {
129 bits: [u32; 32],
130 }
131
132 // System V IPC
133 pub struct msginfo {
134 pub msgpool: c_int,
135 pub msgmap: c_int,
136 pub msgmax: c_int,
137 pub msgmnb: c_int,
138 pub msgmni: c_int,
139 pub msgssz: c_int,
140 pub msgtql: c_int,
141 pub msgseg: c_ushort,
142 }
143
144 pub struct sembuf {
145 pub sem_num: c_ushort,
146 pub sem_op: c_short,
147 pub sem_flg: c_short,
148 }
149
150 // FIXME(1.0): This should not implement `PartialEq`
151 #[allow(unpredictable_function_pointer_comparisons)]
152 pub struct sigaction {
153 pub sa_sigaction: crate::sighandler_t,
154 pub sa_mask: crate::sigset_t,
155 pub sa_flags: c_int,
156 pub sa_restorer: Option<extern "C" fn()>,
157 }
158
159 pub struct ipc_perm {
160 pub __ipc_perm_key: crate::key_t,
161 pub uid: crate::uid_t,
162 pub gid: crate::gid_t,
163 pub cuid: crate::uid_t,
164 pub cgid: crate::gid_t,
165 pub mode: mode_t,
166 pub __seq: c_int,
167 __unused1: Padding<c_long>,
168 __unused2: Padding<c_long>,
169 }
170
171 pub struct termios {
172 pub c_iflag: crate::tcflag_t,
173 pub c_oflag: crate::tcflag_t,
174 pub c_cflag: crate::tcflag_t,
175 pub c_lflag: crate::tcflag_t,
176 pub c_line: crate::cc_t,
177 pub c_cc: [crate::cc_t; crate::NCCS],
178 pub __c_ispeed: crate::speed_t,
179 pub __c_ospeed: crate::speed_t,
180 }
181
182 pub struct flock {
183 pub l_type: c_short,
184 pub l_whence: c_short,
185 pub l_start: off_t,
186 pub l_len: off_t,
187 pub l_pid: crate::pid_t,
188 }
189
190 pub struct pthread_attr_t {
191 // 11 pointer-width words: 44 bytes on wasm32, 88 on wasm64 (MEMORY64).
192 __size: [usize; 11],
193 }
194
195 pub struct sigset_t {
196 __val: [c_ulong; 32],
197 }
198
199 pub struct msghdr {
200 pub msg_name: *mut c_void,
201 pub msg_namelen: crate::socklen_t,
202 pub msg_iov: *mut crate::iovec,
203 pub msg_iovlen: c_int,
204 pub msg_control: *mut c_void,
205 pub msg_controllen: crate::socklen_t,
206 pub msg_flags: c_int,
207 }
208
209 pub struct cmsghdr {
210 pub cmsg_len: crate::socklen_t,
211 pub cmsg_level: c_int,
212 pub cmsg_type: c_int,
213 }
214
215 pub struct in6_pktinfo {
216 pub ipi6_addr: crate::in6_addr,
217 pub ipi6_ifindex: c_uint,
218 }
219
220 pub struct sem_t {
221 __val: [c_int; 4],
222 }
223 pub struct stat {
224 pub st_dev: crate::dev_t,
225 #[cfg(emscripten_old_stat_abi)]
226 __st_dev_padding: Padding<c_int>,
227 #[cfg(emscripten_old_stat_abi)]
228 __st_ino_truncated: c_long,
229 pub st_mode: mode_t,
230 pub st_nlink: crate::nlink_t,
231 pub st_uid: crate::uid_t,
232 pub st_gid: crate::gid_t,
233 pub st_rdev: crate::dev_t,
234 #[cfg(emscripten_old_stat_abi)]
235 __st_rdev_padding: Padding<c_int>,
236 pub st_size: off_t,
237 pub st_blksize: crate::blksize_t,
238 pub st_blocks: crate::blkcnt_t,
239 pub st_atime: crate::time_t,
240 pub st_atime_nsec: c_long,
241 pub st_mtime: crate::time_t,
242 pub st_mtime_nsec: c_long,
243 pub st_ctime: crate::time_t,
244 pub st_ctime_nsec: c_long,
245 pub st_ino: crate::ino_t,
246 }
247
248 pub struct stack_t {
249 pub ss_sp: *mut c_void,
250 pub ss_flags: c_int,
251 pub ss_size: size_t,
252 }
253
254 pub struct shmid_ds {
255 pub shm_perm: crate::ipc_perm,
256 pub shm_segsz: size_t,
257 pub shm_atime: crate::time_t,
258 pub shm_dtime: crate::time_t,
259 pub shm_ctime: crate::time_t,
260 pub shm_cpid: crate::pid_t,
261 pub shm_lpid: crate::pid_t,
262 pub shm_nattch: c_ulong,
263 __pad1: Padding<c_ulong>,
264 __pad2: Padding<c_ulong>,
265 }
266
267 pub struct msqid_ds {
268 pub msg_perm: crate::ipc_perm,
269 pub msg_stime: crate::time_t,
270 pub msg_rtime: crate::time_t,
271 pub msg_ctime: crate::time_t,
272 pub __msg_cbytes: c_ulong,
273 pub msg_qnum: crate::msgqnum_t,
274 pub msg_qbytes: crate::msglen_t,
275 pub msg_lspid: crate::pid_t,
276 pub msg_lrpid: crate::pid_t,
277 __pad1: Padding<c_ulong>,
278 __pad2: Padding<c_ulong>,
279 }
280
281 pub struct statfs {
282 pub f_type: c_ulong,
283 pub f_bsize: c_ulong,
284 pub f_blocks: crate::fsblkcnt_t,
285 pub f_bfree: crate::fsblkcnt_t,
286 pub f_bavail: crate::fsblkcnt_t,
287 pub f_files: crate::fsfilcnt_t,
288 pub f_ffree: crate::fsfilcnt_t,
289 pub f_fsid: crate::fsid_t,
290 pub f_namelen: c_ulong,
291 pub f_frsize: c_ulong,
292 pub f_flags: c_ulong,
293 pub f_spare: [c_ulong; 4],
294 }
295
296 pub struct siginfo_t {
297 pub si_signo: c_int,
298 pub si_errno: c_int,
299 pub si_code: c_int,
300 pub _pad: [c_int; 29],
301 _align: [usize; 0],
302 }
303
304 pub struct arpd_request {
305 pub req: c_ushort,
306 pub ip: u32,
307 pub dev: c_ulong,
308 pub stamp: c_ulong,
309 pub updated: c_ulong,
310 pub ha: [c_uchar; crate::MAX_ADDR_LEN],
311 }
312
313 #[repr(align(4))]
314 pub struct pthread_mutex_t {
315 size: [u8; crate::__SIZEOF_PTHREAD_MUTEX_T],
316 }
317
318 #[repr(align(4))]
319 pub struct pthread_rwlock_t {
320 size: [u8; crate::__SIZEOF_PTHREAD_RWLOCK_T],
321 }
322
323 #[repr(align(4))]
324 pub struct pthread_mutexattr_t {
325 size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T],
326 }
327
328 #[repr(align(4))]
329 pub struct pthread_rwlockattr_t {
330 size: [u8; crate::__SIZEOF_PTHREAD_RWLOCKATTR_T],
331 }
332
333 #[repr(align(4))]
334 pub struct pthread_condattr_t {
335 size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T],
336 }
337
338 pub struct dirent {
339 pub d_ino: crate::ino_t,
340 pub d_off: off_t,
341 pub d_reclen: c_ushort,
342 pub d_type: c_uchar,
343 pub d_name: [c_char; 256],
344 }
345
346 pub struct sysinfo {
347 pub uptime: c_ulong,
348 pub loads: [c_ulong; 3],
349 pub totalram: c_ulong,
350 pub freeram: c_ulong,
351 pub sharedram: c_ulong,
352 pub bufferram: c_ulong,
353 pub totalswap: c_ulong,
354 pub freeswap: c_ulong,
355 pub procs: c_ushort,
356 pub pad: c_ushort,
357 pub totalhigh: c_ulong,
358 pub freehigh: c_ulong,
359 pub mem_unit: c_uint,
360 pub __reserved: [c_char; 256],
361 }
362
363 pub struct mq_attr {
364 pub mq_flags: c_long,
365 pub mq_maxmsg: c_long,
366 pub mq_msgsize: c_long,
367 pub mq_curmsgs: c_long,
368 pad: Padding<[c_long; 4]>,
369 }
370
371 #[cfg_attr(target_pointer_width = "32", repr(align(4)))]
372 #[cfg_attr(target_pointer_width = "64", repr(align(8)))]
373 pub struct pthread_cond_t {
374 size: [u8; crate::__SIZEOF_PTHREAD_COND_T],
375 }
376}
377
378s_no_extra_traits! {
379 #[repr(align(8))]
380 pub struct max_align_t {
381 priv_: [f64; 3],
382 }
383}
384
385pub const MADV_SOFT_OFFLINE: c_int = 101;
386pub const MS_NOUSER: c_ulong = 0x80000000;
387pub const MS_RMT_MASK: c_ulong = 0x02800051;
388
389pub const ABDAY_1: crate::nl_item = 0x20000;
390pub const ABDAY_2: crate::nl_item = 0x20001;
391pub const ABDAY_3: crate::nl_item = 0x20002;
392pub const ABDAY_4: crate::nl_item = 0x20003;
393pub const ABDAY_5: crate::nl_item = 0x20004;
394pub const ABDAY_6: crate::nl_item = 0x20005;
395pub const ABDAY_7: crate::nl_item = 0x20006;
396
397pub const DAY_1: crate::nl_item = 0x20007;
398pub const DAY_2: crate::nl_item = 0x20008;
399pub const DAY_3: crate::nl_item = 0x20009;
400pub const DAY_4: crate::nl_item = 0x2000A;
401pub const DAY_5: crate::nl_item = 0x2000B;
402pub const DAY_6: crate::nl_item = 0x2000C;
403pub const DAY_7: crate::nl_item = 0x2000D;
404
405pub const ABMON_1: crate::nl_item = 0x2000E;
406pub const ABMON_2: crate::nl_item = 0x2000F;
407pub const ABMON_3: crate::nl_item = 0x20010;
408pub const ABMON_4: crate::nl_item = 0x20011;
409pub const ABMON_5: crate::nl_item = 0x20012;
410pub const ABMON_6: crate::nl_item = 0x20013;
411pub const ABMON_7: crate::nl_item = 0x20014;
412pub const ABMON_8: crate::nl_item = 0x20015;
413pub const ABMON_9: crate::nl_item = 0x20016;
414pub const ABMON_10: crate::nl_item = 0x20017;
415pub const ABMON_11: crate::nl_item = 0x20018;
416pub const ABMON_12: crate::nl_item = 0x20019;
417
418pub const MON_1: crate::nl_item = 0x2001A;
419pub const MON_2: crate::nl_item = 0x2001B;
420pub const MON_3: crate::nl_item = 0x2001C;
421pub const MON_4: crate::nl_item = 0x2001D;
422pub const MON_5: crate::nl_item = 0x2001E;
423pub const MON_6: crate::nl_item = 0x2001F;
424pub const MON_7: crate::nl_item = 0x20020;
425pub const MON_8: crate::nl_item = 0x20021;
426pub const MON_9: crate::nl_item = 0x20022;
427pub const MON_10: crate::nl_item = 0x20023;
428pub const MON_11: crate::nl_item = 0x20024;
429pub const MON_12: crate::nl_item = 0x20025;
430
431pub const AM_STR: crate::nl_item = 0x20026;
432pub const PM_STR: crate::nl_item = 0x20027;
433
434pub const D_T_FMT: crate::nl_item = 0x20028;
435pub const D_FMT: crate::nl_item = 0x20029;
436pub const T_FMT: crate::nl_item = 0x2002A;
437pub const T_FMT_AMPM: crate::nl_item = 0x2002B;
438
439pub const ERA: crate::nl_item = 0x2002C;
440pub const ERA_D_FMT: crate::nl_item = 0x2002E;
441pub const ALT_DIGITS: crate::nl_item = 0x2002F;
442pub const ERA_D_T_FMT: crate::nl_item = 0x20030;
443pub const ERA_T_FMT: crate::nl_item = 0x20031;
444
445pub const CODESET: crate::nl_item = 14;
446
447pub const CRNCYSTR: crate::nl_item = 0x4000F;
448
449pub const RUSAGE_THREAD: c_int = 1;
450pub const RUSAGE_CHILDREN: c_int = -1;
451
452pub const RADIXCHAR: crate::nl_item = 0x10000;
453pub const THOUSEP: crate::nl_item = 0x10001;
454
455pub const YESEXPR: crate::nl_item = 0x50000;
456pub const NOEXPR: crate::nl_item = 0x50001;
457pub const YESSTR: crate::nl_item = 0x50002;
458pub const NOSTR: crate::nl_item = 0x50003;
459
460pub const FILENAME_MAX: c_uint = 4096;
461pub const L_tmpnam: c_uint = 20;
462pub const _PC_LINK_MAX: c_int = 0;
463pub const _PC_MAX_CANON: c_int = 1;
464pub const _PC_MAX_INPUT: c_int = 2;
465pub const _PC_NAME_MAX: c_int = 3;
466pub const _PC_PATH_MAX: c_int = 4;
467pub const _PC_PIPE_BUF: c_int = 5;
468pub const _PC_CHOWN_RESTRICTED: c_int = 6;
469pub const _PC_NO_TRUNC: c_int = 7;
470pub const _PC_VDISABLE: c_int = 8;
471pub const _PC_SYNC_IO: c_int = 9;
472pub const _PC_ASYNC_IO: c_int = 10;
473pub const _PC_PRIO_IO: c_int = 11;
474pub const _PC_SOCK_MAXBUF: c_int = 12;
475pub const _PC_FILESIZEBITS: c_int = 13;
476pub const _PC_REC_INCR_XFER_SIZE: c_int = 14;
477pub const _PC_REC_MAX_XFER_SIZE: c_int = 15;
478pub const _PC_REC_MIN_XFER_SIZE: c_int = 16;
479pub const _PC_REC_XFER_ALIGN: c_int = 17;
480pub const _PC_ALLOC_SIZE_MIN: c_int = 18;
481pub const _PC_SYMLINK_MAX: c_int = 19;
482pub const _PC_2_SYMLINKS: c_int = 20;
483
484pub const _SC_ARG_MAX: c_int = 0;
485pub const _SC_CHILD_MAX: c_int = 1;
486pub const _SC_CLK_TCK: c_int = 2;
487pub const _SC_NGROUPS_MAX: c_int = 3;
488pub const _SC_OPEN_MAX: c_int = 4;
489pub const _SC_STREAM_MAX: c_int = 5;
490pub const _SC_TZNAME_MAX: c_int = 6;
491pub const _SC_JOB_CONTROL: c_int = 7;
492pub const _SC_SAVED_IDS: c_int = 8;
493pub const _SC_REALTIME_SIGNALS: c_int = 9;
494pub const _SC_PRIORITY_SCHEDULING: c_int = 10;
495pub const _SC_TIMERS: c_int = 11;
496pub const _SC_ASYNCHRONOUS_IO: c_int = 12;
497pub const _SC_PRIORITIZED_IO: c_int = 13;
498pub const _SC_SYNCHRONIZED_IO: c_int = 14;
499pub const _SC_FSYNC: c_int = 15;
500pub const _SC_MAPPED_FILES: c_int = 16;
501pub const _SC_MEMLOCK: c_int = 17;
502pub const _SC_MEMLOCK_RANGE: c_int = 18;
503pub const _SC_MEMORY_PROTECTION: c_int = 19;
504pub const _SC_MESSAGE_PASSING: c_int = 20;
505pub const _SC_SEMAPHORES: c_int = 21;
506pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22;
507pub const _SC_AIO_LISTIO_MAX: c_int = 23;
508pub const _SC_AIO_MAX: c_int = 24;
509pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25;
510pub const _SC_DELAYTIMER_MAX: c_int = 26;
511pub const _SC_MQ_OPEN_MAX: c_int = 27;
512pub const _SC_MQ_PRIO_MAX: c_int = 28;
513pub const _SC_VERSION: c_int = 29;
514pub const _SC_PAGESIZE: c_int = 30;
515pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE;
516pub const _SC_RTSIG_MAX: c_int = 31;
517pub const _SC_SEM_NSEMS_MAX: c_int = 32;
518pub const _SC_SEM_VALUE_MAX: c_int = 33;
519pub const _SC_SIGQUEUE_MAX: c_int = 34;
520pub const _SC_TIMER_MAX: c_int = 35;
521pub const _SC_BC_BASE_MAX: c_int = 36;
522pub const _SC_BC_DIM_MAX: c_int = 37;
523pub const _SC_BC_SCALE_MAX: c_int = 38;
524pub const _SC_BC_STRING_MAX: c_int = 39;
525pub const _SC_COLL_WEIGHTS_MAX: c_int = 40;
526pub const _SC_EXPR_NEST_MAX: c_int = 42;
527pub const _SC_LINE_MAX: c_int = 43;
528pub const _SC_RE_DUP_MAX: c_int = 44;
529pub const _SC_2_VERSION: c_int = 46;
530pub const _SC_2_C_BIND: c_int = 47;
531pub const _SC_2_C_DEV: c_int = 48;
532pub const _SC_2_FORT_DEV: c_int = 49;
533pub const _SC_2_FORT_RUN: c_int = 50;
534pub const _SC_2_SW_DEV: c_int = 51;
535pub const _SC_2_LOCALEDEF: c_int = 52;
536pub const _SC_UIO_MAXIOV: c_int = 60;
537pub const _SC_IOV_MAX: c_int = 60;
538pub const _SC_THREADS: c_int = 67;
539pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68;
540pub const _SC_GETGR_R_SIZE_MAX: c_int = 69;
541pub const _SC_GETPW_R_SIZE_MAX: c_int = 70;
542pub const _SC_LOGIN_NAME_MAX: c_int = 71;
543pub const _SC_TTY_NAME_MAX: c_int = 72;
544pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73;
545pub const _SC_THREAD_KEYS_MAX: c_int = 74;
546pub const _SC_THREAD_STACK_MIN: c_int = 75;
547pub const _SC_THREAD_THREADS_MAX: c_int = 76;
548pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77;
549pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78;
550pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79;
551pub const _SC_THREAD_PRIO_INHERIT: c_int = 80;
552pub const _SC_THREAD_PRIO_PROTECT: c_int = 81;
553pub const _SC_THREAD_PROCESS_SHARED: c_int = 82;
554pub const _SC_NPROCESSORS_CONF: c_int = 83;
555pub const _SC_NPROCESSORS_ONLN: c_int = 84;
556pub const _SC_PHYS_PAGES: c_int = 85;
557pub const _SC_AVPHYS_PAGES: c_int = 86;
558pub const _SC_ATEXIT_MAX: c_int = 87;
559pub const _SC_PASS_MAX: c_int = 88;
560pub const _SC_XOPEN_VERSION: c_int = 89;
561pub const _SC_XOPEN_XCU_VERSION: c_int = 90;
562pub const _SC_XOPEN_UNIX: c_int = 91;
563pub const _SC_XOPEN_CRYPT: c_int = 92;
564pub const _SC_XOPEN_ENH_I18N: c_int = 93;
565pub const _SC_XOPEN_SHM: c_int = 94;
566pub const _SC_2_CHAR_TERM: c_int = 95;
567pub const _SC_2_UPE: c_int = 97;
568pub const _SC_XOPEN_XPG2: c_int = 98;
569pub const _SC_XOPEN_XPG3: c_int = 99;
570pub const _SC_XOPEN_XPG4: c_int = 100;
571pub const _SC_NZERO: c_int = 109;
572pub const _SC_XBS5_ILP32_OFF32: c_int = 125;
573pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126;
574pub const _SC_XBS5_LP64_OFF64: c_int = 127;
575pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128;
576pub const _SC_XOPEN_LEGACY: c_int = 129;
577pub const _SC_XOPEN_REALTIME: c_int = 130;
578pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131;
579pub const _SC_ADVISORY_INFO: c_int = 132;
580pub const _SC_BARRIERS: c_int = 133;
581pub const _SC_CLOCK_SELECTION: c_int = 137;
582pub const _SC_CPUTIME: c_int = 138;
583pub const _SC_THREAD_CPUTIME: c_int = 139;
584pub const _SC_MONOTONIC_CLOCK: c_int = 149;
585pub const _SC_READER_WRITER_LOCKS: c_int = 153;
586pub const _SC_SPIN_LOCKS: c_int = 154;
587pub const _SC_REGEXP: c_int = 155;
588pub const _SC_SHELL: c_int = 157;
589pub const _SC_SPAWN: c_int = 159;
590pub const _SC_SPORADIC_SERVER: c_int = 160;
591pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161;
592pub const _SC_TIMEOUTS: c_int = 164;
593pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165;
594pub const _SC_2_PBS: c_int = 168;
595pub const _SC_2_PBS_ACCOUNTING: c_int = 169;
596pub const _SC_2_PBS_LOCATE: c_int = 170;
597pub const _SC_2_PBS_MESSAGE: c_int = 171;
598pub const _SC_2_PBS_TRACK: c_int = 172;
599pub const _SC_SYMLOOP_MAX: c_int = 173;
600pub const _SC_STREAMS: c_int = 174;
601pub const _SC_2_PBS_CHECKPOINT: c_int = 175;
602pub const _SC_V6_ILP32_OFF32: c_int = 176;
603pub const _SC_V6_ILP32_OFFBIG: c_int = 177;
604pub const _SC_V6_LP64_OFF64: c_int = 178;
605pub const _SC_V6_LPBIG_OFFBIG: c_int = 179;
606pub const _SC_HOST_NAME_MAX: c_int = 180;
607pub const _SC_TRACE: c_int = 181;
608pub const _SC_TRACE_EVENT_FILTER: c_int = 182;
609pub const _SC_TRACE_INHERIT: c_int = 183;
610pub const _SC_TRACE_LOG: c_int = 184;
611pub const _SC_IPV6: c_int = 235;
612pub const _SC_RAW_SOCKETS: c_int = 236;
613pub const _SC_V7_ILP32_OFF32: c_int = 237;
614pub const _SC_V7_ILP32_OFFBIG: c_int = 238;
615pub const _SC_V7_LP64_OFF64: c_int = 239;
616pub const _SC_V7_LPBIG_OFFBIG: c_int = 240;
617pub const _SC_SS_REPL_MAX: c_int = 241;
618pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242;
619pub const _SC_TRACE_NAME_MAX: c_int = 243;
620pub const _SC_TRACE_SYS_MAX: c_int = 244;
621pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245;
622pub const _SC_XOPEN_STREAMS: c_int = 246;
623pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247;
624pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248;
625
626pub const RLIM_SAVED_MAX: crate::rlim_t = RLIM_INFINITY;
627pub const RLIM_SAVED_CUR: crate::rlim_t = RLIM_INFINITY;
628
629pub const GLOB_ERR: c_int = 1 << 0;
630pub const GLOB_MARK: c_int = 1 << 1;
631pub const GLOB_NOSORT: c_int = 1 << 2;
632pub const GLOB_DOOFFS: c_int = 1 << 3;
633pub const GLOB_NOCHECK: c_int = 1 << 4;
634pub const GLOB_APPEND: c_int = 1 << 5;
635pub const GLOB_NOESCAPE: c_int = 1 << 6;
636
637pub const GLOB_NOSPACE: c_int = 1;
638pub const GLOB_ABORTED: c_int = 2;
639pub const GLOB_NOMATCH: c_int = 3;
640
641pub const POSIX_MADV_NORMAL: c_int = 0;
642pub const POSIX_MADV_RANDOM: c_int = 1;
643pub const POSIX_MADV_SEQUENTIAL: c_int = 2;
644pub const POSIX_MADV_WILLNEED: c_int = 3;
645
646pub const AT_EACCESS: c_int = 0x200;
647
648pub const S_IEXEC: mode_t = 0o0100;
649pub const S_IWRITE: mode_t = 0o0200;
650pub const S_IREAD: mode_t = 0o0400;
651
652pub const F_LOCK: c_int = 1;
653pub const F_TEST: c_int = 3;
654pub const F_TLOCK: c_int = 2;
655pub const F_ULOCK: c_int = 0;
656
657pub const ST_RDONLY: c_ulong = 1;
658pub const ST_NOSUID: c_ulong = 2;
659pub const ST_NODEV: c_ulong = 4;
660pub const ST_NOEXEC: c_ulong = 8;
661pub const ST_SYNCHRONOUS: c_ulong = 16;
662pub const ST_MANDLOCK: c_ulong = 64;
663pub const ST_WRITE: c_ulong = 128;
664pub const ST_APPEND: c_ulong = 256;
665pub const ST_IMMUTABLE: c_ulong = 512;
666pub const ST_NOATIME: c_ulong = 1024;
667pub const ST_NODIRATIME: c_ulong = 2048;
668
669pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void;
670pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut();
671pub const RTLD_NODELETE: c_int = 0x1000;
672pub const RTLD_NOW: c_int = 0x2;
673
674pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
675 size: [0; __SIZEOF_PTHREAD_MUTEX_T],
676};
677pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
678 size: [0; __SIZEOF_PTHREAD_COND_T],
679};
680pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
681 size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
682};
683
684pub const PTHREAD_MUTEX_NORMAL: c_int = 0;
685pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1;
686pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2;
687pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL;
688pub const PTHREAD_PROCESS_PRIVATE: c_int = 0;
689pub const PTHREAD_PROCESS_SHARED: c_int = 1;
690pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
691
692pub const SCHED_OTHER: c_int = 0;
693pub const SCHED_FIFO: c_int = 1;
694pub const SCHED_RR: c_int = 2;
695pub const SCHED_BATCH: c_int = 3;
696pub const SCHED_IDLE: c_int = 5;
697
698pub const AF_IB: c_int = 27;
699pub const AF_MPLS: c_int = 28;
700pub const AF_NFC: c_int = 39;
701pub const AF_VSOCK: c_int = 40;
702pub const PF_IB: c_int = AF_IB;
703pub const PF_MPLS: c_int = AF_MPLS;
704pub const PF_NFC: c_int = AF_NFC;
705pub const PF_VSOCK: c_int = AF_VSOCK;
706
707// System V IPC
708pub const IPC_PRIVATE: crate::key_t = 0;
709
710pub const IPC_CREAT: c_int = 0o1000;
711pub const IPC_EXCL: c_int = 0o2000;
712pub const IPC_NOWAIT: c_int = 0o4000;
713
714pub const IPC_RMID: c_int = 0;
715pub const IPC_SET: c_int = 1;
716pub const IPC_STAT: c_int = 2;
717pub const IPC_INFO: c_int = 3;
718pub const MSG_STAT: c_int = 11;
719pub const MSG_INFO: c_int = 12;
720
721pub const MSG_NOERROR: c_int = 0o10000;
722pub const MSG_EXCEPT: c_int = 0o20000;
723
724pub const SHM_R: c_int = 0o400;
725pub const SHM_W: c_int = 0o200;
726
727pub const SHM_RDONLY: c_int = 0o10000;
728pub const SHM_RND: c_int = 0o20000;
729pub const SHM_REMAP: c_int = 0o40000;
730pub const SHM_EXEC: c_int = 0o100000;
731
732pub const SHM_LOCK: c_int = 11;
733pub const SHM_UNLOCK: c_int = 12;
734
735pub const SHM_HUGETLB: c_int = 0o4000;
736pub const SHM_NORESERVE: c_int = 0o10000;
737
738pub const LOG_NFACILITIES: c_int = 24;
739
740pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut();
741
742pub const AI_PASSIVE: c_int = 0x0001;
743pub const AI_CANONNAME: c_int = 0x0002;
744pub const AI_NUMERICHOST: c_int = 0x0004;
745pub const AI_V4MAPPED: c_int = 0x0008;
746pub const AI_ALL: c_int = 0x0010;
747pub const AI_ADDRCONFIG: c_int = 0x0020;
748
749pub const AI_NUMERICSERV: c_int = 0x0400;
750
751pub const EAI_BADFLAGS: c_int = -1;
752pub const EAI_NONAME: c_int = -2;
753pub const EAI_AGAIN: c_int = -3;
754pub const EAI_FAIL: c_int = -4;
755pub const EAI_FAMILY: c_int = -6;
756pub const EAI_SOCKTYPE: c_int = -7;
757pub const EAI_SERVICE: c_int = -8;
758pub const EAI_MEMORY: c_int = -10;
759pub const EAI_OVERFLOW: c_int = -12;
760
761pub const NI_NUMERICHOST: c_int = 1;
762pub const NI_NUMERICSERV: c_int = 2;
763pub const NI_NOFQDN: c_int = 4;
764pub const NI_NAMEREQD: c_int = 8;
765pub const NI_DGRAM: c_int = 16;
766
767pub const SYNC_FILE_RANGE_WAIT_BEFORE: c_uint = 1;
768pub const SYNC_FILE_RANGE_WRITE: c_uint = 2;
769pub const SYNC_FILE_RANGE_WAIT_AFTER: c_uint = 4;
770
771pub const EAI_SYSTEM: c_int = -11;
772
773pub const MREMAP_MAYMOVE: c_int = 1;
774pub const MREMAP_FIXED: c_int = 2;
775
776pub const ITIMER_REAL: c_int = 0;
777pub const ITIMER_VIRTUAL: c_int = 1;
778pub const ITIMER_PROF: c_int = 2;
779
780pub const _POSIX_VDISABLE: crate::cc_t = 0;
781
782pub const FALLOC_FL_KEEP_SIZE: c_int = 0x01;
783pub const FALLOC_FL_PUNCH_HOLE: c_int = 0x02;
784
785pub const NCCS: usize = 32;
786
787pub const O_TRUNC: c_int = 512;
788pub const O_NOATIME: c_int = 0o1000000;
789pub const O_CLOEXEC: c_int = 0x80000;
790
791// Defined as wasi value.
792pub const EPERM: c_int = 63;
793pub const ENOENT: c_int = 44;
794pub const ESRCH: c_int = 71;
795pub const EINTR: c_int = 27;
796pub const EIO: c_int = 29;
797pub const ENXIO: c_int = 60;
798pub const E2BIG: c_int = 1;
799pub const ENOEXEC: c_int = 45;
800pub const EBADF: c_int = 8;
801pub const ECHILD: c_int = 12;
802pub const EAGAIN: c_int = 6;
803pub const ENOMEM: c_int = 48;
804pub const EACCES: c_int = 2;
805pub const EFAULT: c_int = 21;
806pub const ENOTBLK: c_int = 105;
807pub const EBUSY: c_int = 10;
808pub const EEXIST: c_int = 20;
809pub const EXDEV: c_int = 75;
810pub const ENODEV: c_int = 43;
811pub const ENOTDIR: c_int = 54;
812pub const EISDIR: c_int = 31;
813pub const EINVAL: c_int = 28;
814pub const ENFILE: c_int = 41;
815pub const EMFILE: c_int = 33;
816pub const ENOTTY: c_int = 59;
817pub const ETXTBSY: c_int = 74;
818pub const EFBIG: c_int = 22;
819pub const ENOSPC: c_int = 51;
820pub const ESPIPE: c_int = 70;
821pub const EROFS: c_int = 69;
822pub const EMLINK: c_int = 34;
823pub const EPIPE: c_int = 64;
824pub const EDOM: c_int = 18;
825pub const ERANGE: c_int = 68;
826pub const EWOULDBLOCK: c_int = EAGAIN;
827pub const ENOLINK: c_int = 47;
828pub const EPROTO: c_int = 65;
829pub const EDEADLK: c_int = 16;
830pub const EDEADLOCK: c_int = EDEADLK;
831pub const ENAMETOOLONG: c_int = 37;
832pub const ENOLCK: c_int = 46;
833pub const ENOSYS: c_int = 52;
834pub const ENOTEMPTY: c_int = 55;
835pub const ELOOP: c_int = 32;
836pub const ENOMSG: c_int = 49;
837pub const EIDRM: c_int = 24;
838pub const EMULTIHOP: c_int = 36;
839pub const EBADMSG: c_int = 9;
840pub const EOVERFLOW: c_int = 61;
841pub const EILSEQ: c_int = 25;
842pub const ENOTSOCK: c_int = 57;
843pub const EDESTADDRREQ: c_int = 17;
844pub const EMSGSIZE: c_int = 35;
845pub const EPROTOTYPE: c_int = 67;
846pub const ENOPROTOOPT: c_int = 50;
847pub const EPROTONOSUPPORT: c_int = 66;
848pub const EAFNOSUPPORT: c_int = 5;
849pub const EADDRINUSE: c_int = 3;
850pub const EADDRNOTAVAIL: c_int = 4;
851pub const ENETDOWN: c_int = 38;
852pub const ENETUNREACH: c_int = 40;
853pub const ENETRESET: c_int = 39;
854pub const ECONNABORTED: c_int = 13;
855pub const ECONNRESET: c_int = 15;
856pub const ENOBUFS: c_int = 42;
857pub const EISCONN: c_int = 30;
858pub const ENOTCONN: c_int = 53;
859pub const ETIMEDOUT: c_int = 73;
860pub const ECONNREFUSED: c_int = 14;
861pub const EHOSTUNREACH: c_int = 23;
862pub const EALREADY: c_int = 7;
863pub const EINPROGRESS: c_int = 26;
864pub const ESTALE: c_int = 72;
865pub const EDQUOT: c_int = 19;
866pub const ECANCELED: c_int = 11;
867pub const EOWNERDEAD: c_int = 62;
868pub const ENOTRECOVERABLE: c_int = 56;
869
870pub const ENOSTR: c_int = 100;
871pub const EBFONT: c_int = 101;
872pub const EBADSLT: c_int = 102;
873pub const EBADRQC: c_int = 103;
874pub const ENOANO: c_int = 104;
875pub const ECHRNG: c_int = 106;
876pub const EL3HLT: c_int = 107;
877pub const EL3RST: c_int = 108;
878pub const ELNRNG: c_int = 109;
879pub const EUNATCH: c_int = 110;
880pub const ENOCSI: c_int = 111;
881pub const EL2HLT: c_int = 112;
882pub const EBADE: c_int = 113;
883pub const EBADR: c_int = 114;
884pub const EXFULL: c_int = 115;
885pub const ENODATA: c_int = 116;
886pub const ETIME: c_int = 117;
887pub const ENOSR: c_int = 118;
888pub const ENONET: c_int = 119;
889pub const ENOPKG: c_int = 120;
890pub const EREMOTE: c_int = 121;
891pub const EADV: c_int = 122;
892pub const ESRMNT: c_int = 123;
893pub const ECOMM: c_int = 124;
894pub const EDOTDOT: c_int = 125;
895pub const ENOTUNIQ: c_int = 126;
896pub const EBADFD: c_int = 127;
897pub const EREMCHG: c_int = 128;
898pub const ELIBACC: c_int = 129;
899pub const ELIBBAD: c_int = 130;
900pub const ELIBSCN: c_int = 131;
901pub const ELIBMAX: c_int = 132;
902pub const ELIBEXEC: c_int = 133;
903pub const ERESTART: c_int = 134;
904pub const ESTRPIPE: c_int = 135;
905pub const EUSERS: c_int = 136;
906pub const ESOCKTNOSUPPORT: c_int = 137;
907pub const EOPNOTSUPP: c_int = 138;
908pub const ENOTSUP: c_int = EOPNOTSUPP;
909pub const EPFNOSUPPORT: c_int = 139;
910pub const ESHUTDOWN: c_int = 140;
911pub const ETOOMANYREFS: c_int = 141;
912pub const EHOSTDOWN: c_int = 142;
913pub const EUCLEAN: c_int = 143;
914pub const ENOTNAM: c_int = 144;
915pub const ENAVAIL: c_int = 145;
916pub const EISNAM: c_int = 146;
917pub const EREMOTEIO: c_int = 147;
918pub const ENOMEDIUM: c_int = 148;
919pub const EMEDIUMTYPE: c_int = 149;
920pub const ENOKEY: c_int = 150;
921pub const EKEYEXPIRED: c_int = 151;
922pub const EKEYREVOKED: c_int = 152;
923pub const EKEYREJECTED: c_int = 153;
924pub const ERFKILL: c_int = 154;
925pub const EHWPOISON: c_int = 155;
926pub const EL2NSYNC: c_int = 156;
927
928pub const SA_NODEFER: c_int = 0x40000000;
929pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000);
930pub const SA_RESTART: c_int = 0x10000000;
931pub const SA_NOCLDSTOP: c_int = 0x00000001;
932
933pub const BUFSIZ: c_uint = 1024;
934pub const TMP_MAX: c_uint = 10000;
935pub const FOPEN_MAX: c_uint = 1000;
936pub const O_PATH: c_int = 0o10000000;
937pub const O_EXEC: c_int = 0o10000000;
938pub const O_SEARCH: c_int = 0o10000000;
939pub const O_ACCMODE: c_int = 0o10000003;
940pub const O_NDELAY: c_int = O_NONBLOCK;
941pub const NI_MAXHOST: crate::socklen_t = 255;
942pub const PTHREAD_STACK_MIN: size_t = 2048;
943pub const POSIX_FADV_DONTNEED: c_int = 4;
944pub const POSIX_FADV_NOREUSE: c_int = 5;
945
946pub const POSIX_MADV_DONTNEED: c_int = 4;
947
948pub const RLIM_INFINITY: crate::rlim_t = !0;
949#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
950pub const RLIMIT_NLIMITS: c_int = 16;
951#[allow(deprecated)]
952#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
953pub const RLIM_NLIMITS: c_int = RLIMIT_NLIMITS;
954
955pub const MAP_ANONYMOUS: c_int = MAP_ANON;
956
957#[doc(hidden)]
958#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")]
959pub const SIGUNUSED: c_int = crate::SIGSYS;
960
961pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
962pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
963pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
964
965pub const CPU_SETSIZE: c_int = 1024;
966
967pub const TCSANOW: c_int = 0;
968pub const TCSADRAIN: c_int = 1;
969pub const TCSAFLUSH: c_int = 2;
970
971pub const TIOCINQ: c_int = crate::FIONREAD;
972
973pub const RTLD_GLOBAL: c_int = 0x100;
974pub const RTLD_NOLOAD: c_int = 0x4;
975
976pub const CLOCK_SGI_CYCLE: crate::clockid_t = 10;
977
978pub const MCL_CURRENT: c_int = 0x0001;
979pub const MCL_FUTURE: c_int = 0x0002;
980
981pub const SIGSTKSZ: size_t = 8192;
982pub const MINSIGSTKSZ: size_t = 2048;
983pub const CBAUD: crate::tcflag_t = 0o0010017;
984pub const TAB1: c_int = 0x00000800;
985pub const TAB2: c_int = 0x00001000;
986pub const TAB3: c_int = 0x00001800;
987pub const CR1: c_int = 0x00000200;
988pub const CR2: c_int = 0x00000400;
989pub const CR3: c_int = 0x00000600;
990pub const FF1: c_int = 0x00008000;
991pub const BS1: c_int = 0x00002000;
992pub const VT1: c_int = 0x00004000;
993pub const VWERASE: usize = 14;
994pub const VREPRINT: usize = 12;
995pub const VSUSP: usize = 10;
996pub const VSTART: usize = 8;
997pub const VSTOP: usize = 9;
998pub const VDISCARD: usize = 13;
999pub const VTIME: usize = 5;
1000pub const IXON: crate::tcflag_t = 0x00000400;
1001pub const IXOFF: crate::tcflag_t = 0x00001000;
1002pub const ONLCR: crate::tcflag_t = 0x4;
1003pub const CSIZE: crate::tcflag_t = 0x00000030;
1004pub const CS6: crate::tcflag_t = 0x00000010;
1005pub const CS7: crate::tcflag_t = 0x00000020;
1006pub const CS8: crate::tcflag_t = 0x00000030;
1007pub const CSTOPB: crate::tcflag_t = 0x00000040;
1008pub const CREAD: crate::tcflag_t = 0x00000080;
1009pub const PARENB: crate::tcflag_t = 0x00000100;
1010pub const PARODD: crate::tcflag_t = 0x00000200;
1011pub const HUPCL: crate::tcflag_t = 0x00000400;
1012pub const CLOCAL: crate::tcflag_t = 0x00000800;
1013pub const ECHOKE: crate::tcflag_t = 0x00000800;
1014pub const ECHOE: crate::tcflag_t = 0x00000010;
1015pub const ECHOK: crate::tcflag_t = 0x00000020;
1016pub const ECHONL: crate::tcflag_t = 0x00000040;
1017pub const ECHOPRT: crate::tcflag_t = 0x00000400;
1018pub const ECHOCTL: crate::tcflag_t = 0x00000200;
1019pub const ISIG: crate::tcflag_t = 0x00000001;
1020pub const ICANON: crate::tcflag_t = 0x00000002;
1021pub const PENDIN: crate::tcflag_t = 0x00004000;
1022pub const NOFLSH: crate::tcflag_t = 0x00000080;
1023pub const CBAUDEX: crate::tcflag_t = 0o010000;
1024pub const VSWTC: usize = 7;
1025pub const OLCUC: crate::tcflag_t = 0o000002;
1026pub const NLDLY: crate::tcflag_t = 0o000400;
1027pub const CRDLY: crate::tcflag_t = 0o003000;
1028pub const TABDLY: crate::tcflag_t = 0o014000;
1029pub const BSDLY: crate::tcflag_t = 0o020000;
1030pub const FFDLY: crate::tcflag_t = 0o100000;
1031pub const VTDLY: crate::tcflag_t = 0o040000;
1032pub const XTABS: crate::tcflag_t = 0o014000;
1033
1034pub const B0: crate::speed_t = 0o000000;
1035pub const B50: crate::speed_t = 0o000001;
1036pub const B75: crate::speed_t = 0o000002;
1037pub const B110: crate::speed_t = 0o000003;
1038pub const B134: crate::speed_t = 0o000004;
1039pub const B150: crate::speed_t = 0o000005;
1040pub const B200: crate::speed_t = 0o000006;
1041pub const B300: crate::speed_t = 0o000007;
1042pub const B600: crate::speed_t = 0o000010;
1043pub const B1200: crate::speed_t = 0o000011;
1044pub const B1800: crate::speed_t = 0o000012;
1045pub const B2400: crate::speed_t = 0o000013;
1046pub const B4800: crate::speed_t = 0o000014;
1047pub const B9600: crate::speed_t = 0o000015;
1048pub const B19200: crate::speed_t = 0o000016;
1049pub const B38400: crate::speed_t = 0o000017;
1050pub const B57600: crate::speed_t = 0o010001;
1051pub const B115200: crate::speed_t = 0o010002;
1052pub const B230400: crate::speed_t = 0o010003;
1053pub const B460800: crate::speed_t = 0o010004;
1054pub const B500000: crate::speed_t = 0o010005;
1055pub const B576000: crate::speed_t = 0o010006;
1056pub const B921600: crate::speed_t = 0o010007;
1057pub const B1000000: crate::speed_t = 0o010010;
1058pub const B1152000: crate::speed_t = 0o010011;
1059pub const B1500000: crate::speed_t = 0o010012;
1060pub const B2000000: crate::speed_t = 0o010013;
1061pub const B2500000: crate::speed_t = 0o010014;
1062pub const B3000000: crate::speed_t = 0o010015;
1063pub const B3500000: crate::speed_t = 0o010016;
1064pub const B4000000: crate::speed_t = 0o010017;
1065
1066pub const SO_BINDTODEVICE: c_int = 25;
1067pub const SO_TIMESTAMP: c_int = 63;
1068pub const SO_MARK: c_int = 36;
1069pub const SO_RXQ_OVFL: c_int = 40;
1070pub const SO_PEEK_OFF: c_int = 42;
1071pub const SO_BUSY_POLL: c_int = 46;
1072
1073#[cfg(target_pointer_width = "32")]
1074pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
1075#[cfg(target_pointer_width = "64")]
1076pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
1077#[cfg(target_pointer_width = "32")]
1078pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
1079#[cfg(target_pointer_width = "64")]
1080pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
1081
1082pub const O_DIRECT: c_int = 0x4000;
1083pub const O_DIRECTORY: c_int = 0x10000;
1084pub const O_NOFOLLOW: c_int = 0x20000;
1085pub const O_ASYNC: c_int = 0x2000;
1086
1087pub const FIOCLEX: c_int = 0x5451;
1088pub const FIONBIO: c_int = 0x5421;
1089
1090pub const RLIMIT_RSS: c_int = 5;
1091pub const RLIMIT_NOFILE: c_int = 7;
1092pub const RLIMIT_AS: c_int = 9;
1093pub const RLIMIT_NPROC: c_int = 6;
1094pub const RLIMIT_MEMLOCK: c_int = 8;
1095pub const RLIMIT_CPU: c_int = 0;
1096pub const RLIMIT_FSIZE: c_int = 1;
1097pub const RLIMIT_DATA: c_int = 2;
1098pub const RLIMIT_STACK: c_int = 3;
1099pub const RLIMIT_CORE: c_int = 4;
1100pub const RLIMIT_LOCKS: c_int = 10;
1101pub const RLIMIT_SIGPENDING: c_int = 11;
1102pub const RLIMIT_MSGQUEUE: c_int = 12;
1103pub const RLIMIT_NICE: c_int = 13;
1104pub const RLIMIT_RTPRIO: c_int = 14;
1105
1106pub const O_APPEND: c_int = 1024;
1107pub const O_CREAT: c_int = 64;
1108pub const O_EXCL: c_int = 128;
1109pub const O_NOCTTY: c_int = 256;
1110pub const O_NONBLOCK: c_int = 2048;
1111pub const O_SYNC: c_int = 1052672;
1112pub const O_RSYNC: c_int = 1052672;
1113pub const O_DSYNC: c_int = 4096;
1114
1115pub const SOCK_NONBLOCK: c_int = 2048;
1116
1117pub const MAP_ANON: c_int = 0x0020;
1118pub const MAP_GROWSDOWN: c_int = 0x0100;
1119pub const MAP_DENYWRITE: c_int = 0x0800;
1120pub const MAP_EXECUTABLE: c_int = 0x01000;
1121pub const MAP_LOCKED: c_int = 0x02000;
1122pub const MAP_NORESERVE: c_int = 0x04000;
1123pub const MAP_POPULATE: c_int = 0x08000;
1124pub const MAP_NONBLOCK: c_int = 0x010000;
1125pub const MAP_STACK: c_int = 0x020000;
1126
1127pub const SOCK_STREAM: c_int = 1;
1128pub const SOCK_DGRAM: c_int = 2;
1129pub const SOCK_SEQPACKET: c_int = 5;
1130
1131pub const IPPROTO_MAX: c_int = 263;
1132
1133pub const SOL_SOCKET: c_int = 1;
1134
1135pub const SO_REUSEADDR: c_int = 2;
1136pub const SO_TYPE: c_int = 3;
1137pub const SO_ERROR: c_int = 4;
1138pub const SO_DONTROUTE: c_int = 5;
1139pub const SO_BROADCAST: c_int = 6;
1140pub const SO_SNDBUF: c_int = 7;
1141pub const SO_RCVBUF: c_int = 8;
1142pub const SO_KEEPALIVE: c_int = 9;
1143pub const SO_OOBINLINE: c_int = 10;
1144pub const SO_LINGER: c_int = 13;
1145pub const SO_REUSEPORT: c_int = 15;
1146pub const SO_RCVLOWAT: c_int = 18;
1147pub const SO_SNDLOWAT: c_int = 19;
1148pub const SO_RCVTIMEO: c_int = 66;
1149pub const SO_SNDTIMEO: c_int = 67;
1150pub const SO_ACCEPTCONN: c_int = 30;
1151
1152pub const IPV6_RTHDR_LOOSE: c_int = 0;
1153pub const IPV6_RTHDR_STRICT: c_int = 1;
1154
1155pub const SA_ONSTACK: c_int = 0x08000000;
1156pub const SA_SIGINFO: c_int = 0x00000004;
1157pub const SA_NOCLDWAIT: c_int = 0x00000002;
1158
1159pub const SIGCHLD: c_int = 17;
1160pub const SIGBUS: c_int = 7;
1161pub const SIGTTIN: c_int = 21;
1162pub const SIGTTOU: c_int = 22;
1163pub const SIGXCPU: c_int = 24;
1164pub const SIGXFSZ: c_int = 25;
1165pub const SIGVTALRM: c_int = 26;
1166pub const SIGPROF: c_int = 27;
1167pub const SIGWINCH: c_int = 28;
1168pub const SIGUSR1: c_int = 10;
1169pub const SIGUSR2: c_int = 12;
1170pub const SIGCONT: c_int = 18;
1171pub const SIGSTOP: c_int = 19;
1172pub const SIGTSTP: c_int = 20;
1173pub const SIGURG: c_int = 23;
1174pub const SIGIO: c_int = 29;
1175pub const SIGSYS: c_int = 31;
1176pub const SIGSTKFLT: c_int = 16;
1177pub const SIGPOLL: c_int = 29;
1178pub const SIGPWR: c_int = 30;
1179pub const SIG_SETMASK: c_int = 2;
1180pub const SIG_BLOCK: c_int = 0x000000;
1181pub const SIG_UNBLOCK: c_int = 0x01;
1182
1183pub const EXTPROC: crate::tcflag_t = 0x00010000;
1184
1185pub const MAP_HUGETLB: c_int = 0x040000;
1186
1187pub const F_GETLK: c_int = 12;
1188pub const F_GETOWN: c_int = 9;
1189pub const F_SETLK: c_int = 13;
1190pub const F_SETLKW: c_int = 14;
1191pub const F_SETOWN: c_int = 8;
1192pub const F_OFD_GETLK: c_int = 36;
1193pub const F_OFD_SETLK: c_int = 37;
1194pub const F_OFD_SETLKW: c_int = 38;
1195
1196pub const VEOF: usize = 4;
1197pub const VEOL: usize = 11;
1198pub const VEOL2: usize = 16;
1199pub const VMIN: usize = 6;
1200pub const IEXTEN: crate::tcflag_t = 0x00008000;
1201pub const TOSTOP: crate::tcflag_t = 0x00000100;
1202pub const FLUSHO: crate::tcflag_t = 0x00001000;
1203
1204pub const TCGETS: c_int = 0x5401;
1205pub const TCSETS: c_int = 0x5402;
1206pub const TCSETSW: c_int = 0x5403;
1207pub const TCSETSF: c_int = 0x5404;
1208pub const TCGETA: c_int = 0x5405;
1209pub const TCSETA: c_int = 0x5406;
1210pub const TCSETAW: c_int = 0x5407;
1211pub const TCSETAF: c_int = 0x5408;
1212pub const TCSBRK: c_int = 0x5409;
1213pub const TCXONC: c_int = 0x540A;
1214pub const TCFLSH: c_int = 0x540B;
1215pub const TIOCGSOFTCAR: c_int = 0x5419;
1216pub const TIOCSSOFTCAR: c_int = 0x541A;
1217pub const TIOCLINUX: c_int = 0x541C;
1218pub const TIOCGSERIAL: c_int = 0x541E;
1219pub const TIOCEXCL: c_int = 0x540C;
1220pub const TIOCNXCL: c_int = 0x540D;
1221pub const TIOCSCTTY: c_int = 0x540E;
1222pub const TIOCGPGRP: c_int = 0x540F;
1223pub const TIOCSPGRP: c_int = 0x5410;
1224pub const TIOCOUTQ: c_int = 0x5411;
1225pub const TIOCSTI: c_int = 0x5412;
1226pub const TIOCGWINSZ: c_int = 0x5413;
1227pub const TIOCSWINSZ: c_int = 0x5414;
1228pub const TIOCMGET: c_int = 0x5415;
1229pub const TIOCMBIS: c_int = 0x5416;
1230pub const TIOCMBIC: c_int = 0x5417;
1231pub const TIOCMSET: c_int = 0x5418;
1232pub const FIONREAD: c_int = 0x541B;
1233pub const TIOCCONS: c_int = 0x541D;
1234
1235pub const SYS_gettid: c_long = 224; // Valid for arm (32-bit) and x86 (32-bit)
1236
1237pub const POLLWRNORM: c_short = 0x100;
1238pub const POLLWRBAND: c_short = 0x200;
1239
1240pub const TIOCM_LE: c_int = 0x001;
1241pub const TIOCM_DTR: c_int = 0x002;
1242pub const TIOCM_RTS: c_int = 0x004;
1243pub const TIOCM_ST: c_int = 0x008;
1244pub const TIOCM_SR: c_int = 0x010;
1245pub const TIOCM_CTS: c_int = 0x020;
1246pub const TIOCM_CAR: c_int = 0x040;
1247pub const TIOCM_RNG: c_int = 0x080;
1248pub const TIOCM_DSR: c_int = 0x100;
1249pub const TIOCM_CD: c_int = TIOCM_CAR;
1250pub const TIOCM_RI: c_int = TIOCM_RNG;
1251pub const O_TMPFILE: c_int = 0x410000;
1252
1253pub const MAX_ADDR_LEN: usize = 7;
1254pub const ARPD_UPDATE: c_ushort = 0x01;
1255pub const ARPD_LOOKUP: c_ushort = 0x02;
1256pub const ARPD_FLUSH: c_ushort = 0x03;
1257pub const ATF_MAGIC: c_int = 0x80;
1258
1259pub const PRIO_PROCESS: c_int = 0;
1260pub const PRIO_PGRP: c_int = 1;
1261pub const PRIO_USER: c_int = 2;
1262
1263pub const SOMAXCONN: c_int = 128;
1264
1265f! {
1266 pub unsafe fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr {
1267 if ((*cmsg).cmsg_len as usize) < size_of::<cmsghdr>() {
1268 return ptr::null_mut();
1269 }
1270 let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr;
1271 let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
1272 if (next.offset(1)) as usize >= max {
1273 ptr::null_mut()
1274 } else {
1275 next.cast()
1276 }
1277 }
1278
1279 pub unsafe fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
1280 cpuset.bits.fill(0);
1281 }
1282
1283 pub unsafe fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
1284 let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc
1285 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
1286 cpuset.bits[idx] |= 1 << offset;
1287 ()
1288 }
1289
1290 pub unsafe fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
1291 let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc
1292 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
1293 cpuset.bits[idx] &= !(1 << offset);
1294 ()
1295 }
1296
1297 pub unsafe fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
1298 let size_in_bits = 8 * size_of_val(&cpuset.bits[0]);
1299 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
1300 0 != (cpuset.bits[idx] & (1 << offset))
1301 }
1302
1303 pub unsafe fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
1304 set1.bits == set2.bits
1305 }
1306}
1307
1308safe_f! {
1309 pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t {
1310 let major = major as crate::dev_t;
1311 let minor = minor as crate::dev_t;
1312 let mut dev = 0;
1313 dev |= (major & 0xfffff000) << 31 << 1;
1314 dev |= (major & 0x00000fff) << 8;
1315 dev |= (minor & 0xffffff00) << 12;
1316 dev |= minor & 0x000000ff;
1317 dev
1318 }
1319
1320 pub const safe fn major(dev: crate::dev_t) -> c_uint {
1321 // see
1322 // https://github.com/emscripten-core/emscripten/blob/
1323 // main/system/lib/libc/musl/include/sys/sysmacros.h
1324 let mut major = 0;
1325 major |= (dev >> 31 >> 1) & 0xfffff000;
1326 major |= (dev >> 8) & 0x00000fff;
1327 major as c_uint
1328 }
1329
1330 pub const safe fn minor(dev: crate::dev_t) -> c_uint {
1331 // see
1332 // https://github.com/emscripten-core/emscripten/blob/
1333 // main/system/lib/libc/musl/include/sys/sysmacros.h
1334 let mut minor = 0;
1335 minor |= (dev >> 12) & 0xffffff00;
1336 minor |= dev & 0x000000ff;
1337 minor as c_uint
1338 }
1339}
1340
1341extern "C" {
1342 pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int;
1343 pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int;
1344 pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int;
1345
1346 pub fn abs(i: c_int) -> c_int;
1347 pub fn labs(i: c_long) -> c_long;
1348 pub fn rand() -> c_int;
1349 pub fn srand(seed: c_uint);
1350
1351 pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int;
1352
1353 pub fn setpwent();
1354 pub fn endpwent();
1355 pub fn getpwent() -> *mut passwd;
1356
1357 pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
1358
1359 pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
1360 pub fn __errno_location() -> *mut c_int;
1361
1362 pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;
1363 pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
1364 pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
1365 pub fn dup3(oldfd: c_int, newfd: c_int, flags: c_int) -> c_int;
1366 pub fn nl_langinfo_l(item: crate::nl_item, locale: crate::locale_t) -> *mut c_char;
1367 pub fn accept4(
1368 fd: c_int,
1369 addr: *mut crate::sockaddr,
1370 len: *mut crate::socklen_t,
1371 flg: c_int,
1372 ) -> c_int;
1373 pub fn getnameinfo(
1374 sa: *const crate::sockaddr,
1375 salen: crate::socklen_t,
1376 host: *mut c_char,
1377 hostlen: crate::socklen_t,
1378 serv: *mut c_char,
1379 servlen: crate::socklen_t,
1380 flags: c_int,
1381 ) -> c_int;
1382 pub fn getloadavg(loadavg: *mut c_double, nelem: c_int) -> c_int;
1383
1384 pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
1385
1386 pub fn mremap(
1387 addr: *mut c_void,
1388 len: size_t,
1389 new_len: size_t,
1390 flags: c_int,
1391 ...
1392 ) -> *mut c_void;
1393
1394 pub fn glob(
1395 pattern: *const c_char,
1396 flags: c_int,
1397 errfunc: Option<extern "C" fn(epath: *const c_char, errno: c_int) -> c_int>,
1398 pglob: *mut crate::glob_t,
1399 ) -> c_int;
1400 pub fn globfree(pglob: *mut crate::glob_t);
1401
1402 pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
1403
1404 pub fn shm_unlink(name: *const c_char) -> c_int;
1405
1406 pub fn seekdir(dirp: *mut crate::DIR, loc: c_long);
1407
1408 pub fn telldir(dirp: *mut crate::DIR) -> c_long;
1409 pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
1410
1411 pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int;
1412
1413 pub fn recvfrom(
1414 socket: c_int,
1415 buf: *mut c_void,
1416 len: size_t,
1417 flags: c_int,
1418 addr: *mut crate::sockaddr,
1419 addrlen: *mut crate::socklen_t,
1420 ) -> ssize_t;
1421 pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int;
1422 pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char;
1423
1424 pub fn sendmmsg(
1425 sockfd: c_int,
1426 msgvec: *mut crate::mmsghdr,
1427 vlen: c_uint,
1428 flags: c_uint,
1429 ) -> c_int;
1430 pub fn recvmmsg(
1431 sockfd: c_int,
1432 msgvec: *mut crate::mmsghdr,
1433 vlen: c_uint,
1434 flags: c_uint,
1435 timeout: *mut crate::timespec,
1436 ) -> c_int;
1437 pub fn sync();
1438 pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int;
1439 pub fn getpriority(which: c_int, who: crate::id_t) -> c_int;
1440 pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int;
1441
1442 pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int;
1443
1444 // grp.h
1445 pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group;
1446 pub fn getgrnam(name: *const c_char) -> *mut crate::group;
1447 pub fn getgrnam_r(
1448 name: *const c_char,
1449 grp: *mut crate::group,
1450 buf: *mut c_char,
1451 buflen: size_t,
1452 result: *mut *mut crate::group,
1453 ) -> c_int;
1454 pub fn getgrgid_r(
1455 gid: crate::gid_t,
1456 grp: *mut crate::group,
1457 buf: *mut c_char,
1458 buflen: size_t,
1459 result: *mut *mut crate::group,
1460 ) -> c_int;
1461 pub fn sigwait(set: *const crate::sigset_t, sig: *mut c_int) -> c_int;
1462 pub fn sigwaitinfo(set: *const crate::sigset_t, info: *mut crate::siginfo_t) -> c_int;
1463 pub fn sigtimedwait(
1464 set: *const crate::sigset_t,
1465 info: *mut crate::siginfo_t,
1466 timeout: *const crate::timespec,
1467 ) -> c_int;
1468 pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int;
1469}
1470
1471// Alias <foo> to <foo>64 to mimic glibc's LFS64 support
1472mod lfs64;
1473pub use self::lfs64::*;