summaryrefslogtreecommitdiff
path: root/third_party/libc/src/unix/notbsd/linux/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libc/src/unix/notbsd/linux/mod.rs')
-rw-r--r--third_party/libc/src/unix/notbsd/linux/mod.rs674
1 files changed, 674 insertions, 0 deletions
diff --git a/third_party/libc/src/unix/notbsd/linux/mod.rs b/third_party/libc/src/unix/notbsd/linux/mod.rs
new file mode 100644
index 0000000..a909082
--- /dev/null
+++ b/third_party/libc/src/unix/notbsd/linux/mod.rs
@@ -0,0 +1,674 @@
1//! Linux-specific definitions for linux-like values
2
3use dox::mem;
4
5pub type useconds_t = u32;
6pub type dev_t = u64;
7pub type socklen_t = u32;
8pub type pthread_t = c_ulong;
9pub type mode_t = u32;
10pub type ino64_t = u64;
11pub type off64_t = i64;
12pub type blkcnt64_t = i64;
13pub type rlim64_t = u64;
14pub type key_t = ::c_int;
15pub type shmatt_t = ::c_ulong;
16pub type mqd_t = ::c_int;
17pub type nfds_t = ::c_ulong;
18pub type nl_item = ::c_int;
19
20pub enum fpos64_t {} // TODO: fill this out with a struct
21
22s! {
23 pub struct dirent {
24 pub d_ino: ::ino_t,
25 pub d_off: ::off_t,
26 pub d_reclen: ::c_ushort,
27 pub d_type: ::c_uchar,
28 pub d_name: [::c_char; 256],
29 }
30
31 pub struct dirent64 {
32 pub d_ino: ::ino64_t,
33 pub d_off: ::off64_t,
34 pub d_reclen: ::c_ushort,
35 pub d_type: ::c_uchar,
36 pub d_name: [::c_char; 256],
37 }
38
39 pub struct rlimit64 {
40 pub rlim_cur: rlim64_t,
41 pub rlim_max: rlim64_t,
42 }
43
44 pub struct glob_t {
45 pub gl_pathc: ::size_t,
46 pub gl_pathv: *mut *mut c_char,
47 pub gl_offs: ::size_t,
48 pub gl_flags: ::c_int,
49
50 __unused1: *mut ::c_void,
51 __unused2: *mut ::c_void,
52 __unused3: *mut ::c_void,
53 __unused4: *mut ::c_void,
54 __unused5: *mut ::c_void,
55 }
56
57 pub struct ifaddrs {
58 pub ifa_next: *mut ifaddrs,
59 pub ifa_name: *mut c_char,
60 pub ifa_flags: ::c_uint,
61 pub ifa_addr: *mut ::sockaddr,
62 pub ifa_netmask: *mut ::sockaddr,
63 pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union
64 pub ifa_data: *mut ::c_void
65 }
66
67 pub struct pthread_mutex_t {
68 #[cfg(any(target_arch = "mips", target_arch = "mipsel",
69 target_arch = "arm"))]
70 __align: [::c_long; 0],
71 #[cfg(not(any(target_arch = "mips", target_arch = "mipsel",
72 target_arch = "arm")))]
73 __align: [::c_longlong; 0],
74 size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
75 }
76
77 pub struct pthread_rwlock_t {
78 #[cfg(any(target_arch = "mips", target_arch = "mipsel",
79 target_arch = "arm"))]
80 __align: [::c_long; 0],
81 #[cfg(not(any(target_arch = "mips", target_arch = "mipsel",
82 target_arch = "arm")))]
83 __align: [::c_longlong; 0],
84 size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
85 }
86
87 pub struct pthread_mutexattr_t {
88 #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64"))]
89 __align: [::c_int; 0],
90 #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64")))]
91 __align: [::c_long; 0],
92 size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
93 }
94
95 pub struct pthread_cond_t {
96 #[cfg(any(target_env = "musl"))]
97 __align: [*const ::c_void; 0],
98 #[cfg(not(any(target_env = "musl")))]
99 __align: [::c_longlong; 0],
100 size: [u8; __SIZEOF_PTHREAD_COND_T],
101 }
102
103 pub struct pthread_condattr_t {
104 __align: [::c_int; 0],
105 size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
106 }
107
108 pub struct passwd {
109 pub pw_name: *mut ::c_char,
110 pub pw_passwd: *mut ::c_char,
111 pub pw_uid: ::uid_t,
112 pub pw_gid: ::gid_t,
113 pub pw_gecos: *mut ::c_char,
114 pub pw_dir: *mut ::c_char,
115 pub pw_shell: *mut ::c_char,
116 }
117
118 pub struct statvfs {
119 pub f_bsize: ::c_ulong,
120 pub f_frsize: ::c_ulong,
121 pub f_blocks: ::fsblkcnt_t,
122 pub f_bfree: ::fsblkcnt_t,
123 pub f_bavail: ::fsblkcnt_t,
124 pub f_files: ::fsfilcnt_t,
125 pub f_ffree: ::fsfilcnt_t,
126 pub f_favail: ::fsfilcnt_t,
127 pub f_fsid: ::c_ulong,
128 #[cfg(target_pointer_width = "32")]
129 pub __f_unused: ::c_int,
130 pub f_flag: ::c_ulong,
131 pub f_namemax: ::c_ulong,
132 __f_spare: [::c_int; 6],
133 }
134
135 pub struct dqblk {
136 pub dqb_bhardlimit: ::uint64_t,
137 pub dqb_bsoftlimit: ::uint64_t,
138 pub dqb_curspace: ::uint64_t,
139 pub dqb_ihardlimit: ::uint64_t,
140 pub dqb_isoftlimit: ::uint64_t,
141 pub dqb_curinodes: ::uint64_t,
142 pub dqb_btime: ::uint64_t,
143 pub dqb_itime: ::uint64_t,
144 pub dqb_valid: ::uint32_t,
145 }
146
147 pub struct signalfd_siginfo {
148 pub ssi_signo: ::uint32_t,
149 pub ssi_errno: ::int32_t,
150 pub ssi_code: ::int32_t,
151 pub ssi_pid: ::uint32_t,
152 pub ssi_uid: ::uint32_t,
153 pub ssi_fd: ::int32_t,
154 pub ssi_tid: ::uint32_t,
155 pub ssi_band: ::uint32_t,
156 pub ssi_overrun: ::uint32_t,
157 pub ssi_trapno: ::uint32_t,
158 pub ssi_status: ::int32_t,
159 pub ssi_int: ::int32_t,
160 pub ssi_ptr: ::uint64_t,
161 pub ssi_utime: ::uint64_t,
162 pub ssi_stime: ::uint64_t,
163 pub ssi_addr: ::uint64_t,
164 _pad: [::uint8_t; 48],
165 }
166
167 pub struct fsid_t {
168 __val: [::c_int; 2],
169 }
170
171 pub struct mq_attr {
172 pub mq_flags: ::c_long,
173 pub mq_maxmsg: ::c_long,
174 pub mq_msgsize: ::c_long,
175 pub mq_curmsgs: ::c_long,
176 pad: [::c_long; 4]
177 }
178
179 pub struct cpu_set_t {
180 #[cfg(target_pointer_width = "32")]
181 bits: [u32; 32],
182 #[cfg(target_pointer_width = "64")]
183 bits: [u64; 16],
184 }
185
186 pub struct if_nameindex {
187 pub if_index: ::c_uint,
188 pub if_name: *mut ::c_char,
189 }
190
191}
192
193pub const ABDAY_1: ::nl_item = 0x20000;
194pub const ABDAY_2: ::nl_item = 0x20001;
195pub const ABDAY_3: ::nl_item = 0x20002;
196pub const ABDAY_4: ::nl_item = 0x20003;
197pub const ABDAY_5: ::nl_item = 0x20004;
198pub const ABDAY_6: ::nl_item = 0x20005;
199pub const ABDAY_7: ::nl_item = 0x20006;
200
201pub const DAY_1: ::nl_item = 0x20007;
202pub const DAY_2: ::nl_item = 0x20008;
203pub const DAY_3: ::nl_item = 0x20009;
204pub const DAY_4: ::nl_item = 0x2000A;
205pub const DAY_5: ::nl_item = 0x2000B;
206pub const DAY_6: ::nl_item = 0x2000C;
207pub const DAY_7: ::nl_item = 0x2000D;
208
209pub const ABMON_1: ::nl_item = 0x2000E;
210pub const ABMON_2: ::nl_item = 0x2000F;
211pub const ABMON_3: ::nl_item = 0x20010;
212pub const ABMON_4: ::nl_item = 0x20011;
213pub const ABMON_5: ::nl_item = 0x20012;
214pub const ABMON_6: ::nl_item = 0x20013;
215pub const ABMON_7: ::nl_item = 0x20014;
216pub const ABMON_8: ::nl_item = 0x20015;
217pub const ABMON_9: ::nl_item = 0x20016;
218pub const ABMON_10: ::nl_item = 0x20017;
219pub const ABMON_11: ::nl_item = 0x20018;
220pub const ABMON_12: ::nl_item = 0x20019;
221
222pub const MON_1: ::nl_item = 0x2001A;
223pub const MON_2: ::nl_item = 0x2001B;
224pub const MON_3: ::nl_item = 0x2001C;
225pub const MON_4: ::nl_item = 0x2001D;
226pub const MON_5: ::nl_item = 0x2001E;
227pub const MON_6: ::nl_item = 0x2001F;
228pub const MON_7: ::nl_item = 0x20020;
229pub const MON_8: ::nl_item = 0x20021;
230pub const MON_9: ::nl_item = 0x20022;
231pub const MON_10: ::nl_item = 0x20023;
232pub const MON_11: ::nl_item = 0x20024;
233pub const MON_12: ::nl_item = 0x20025;
234
235pub const AM_STR: ::nl_item = 0x20026;
236pub const PM_STR: ::nl_item = 0x20027;
237
238pub const D_T_FMT: ::nl_item = 0x20028;
239pub const D_FMT: ::nl_item = 0x20029;
240pub const T_FMT: ::nl_item = 0x2002A;
241pub const T_FMT_AMPM: ::nl_item = 0x2002B;
242
243pub const ERA: ::nl_item = 0x2002C;
244pub const ERA_D_FMT: ::nl_item = 0x2002E;
245pub const ALT_DIGITS: ::nl_item = 0x2002F;
246pub const ERA_D_T_FMT: ::nl_item = 0x20030;
247pub const ERA_T_FMT: ::nl_item = 0x20031;
248
249pub const CODESET: ::nl_item = 14;
250
251pub const CRNCYSTR: ::nl_item = 0x4000F;
252
253pub const RADIXCHAR: ::nl_item = 0x10000;
254pub const THOUSEP: ::nl_item = 0x10001;
255
256pub const YESEXPR: ::nl_item = 0x50000;
257pub const NOEXPR: ::nl_item = 0x50001;
258pub const YESSTR: ::nl_item = 0x50002;
259pub const NOSTR: ::nl_item = 0x50003;
260
261pub const FILENAME_MAX: ::c_uint = 4096;
262pub const L_tmpnam: ::c_uint = 20;
263pub const _PC_LINK_MAX: ::c_int = 0;
264pub const _PC_MAX_CANON: ::c_int = 1;
265pub const _PC_MAX_INPUT: ::c_int = 2;
266pub const _PC_NAME_MAX: ::c_int = 3;
267pub const _PC_PATH_MAX: ::c_int = 4;
268pub const _PC_PIPE_BUF: ::c_int = 5;
269pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
270pub const _PC_NO_TRUNC: ::c_int = 7;
271pub const _PC_VDISABLE: ::c_int = 8;
272
273pub const _SC_ARG_MAX: ::c_int = 0;
274pub const _SC_CHILD_MAX: ::c_int = 1;
275pub const _SC_CLK_TCK: ::c_int = 2;
276pub const _SC_NGROUPS_MAX: ::c_int = 3;
277pub const _SC_OPEN_MAX: ::c_int = 4;
278pub const _SC_STREAM_MAX: ::c_int = 5;
279pub const _SC_TZNAME_MAX: ::c_int = 6;
280pub const _SC_JOB_CONTROL: ::c_int = 7;
281pub const _SC_SAVED_IDS: ::c_int = 8;
282pub const _SC_REALTIME_SIGNALS: ::c_int = 9;
283pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10;
284pub const _SC_TIMERS: ::c_int = 11;
285pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12;
286pub const _SC_PRIORITIZED_IO: ::c_int = 13;
287pub const _SC_SYNCHRONIZED_IO: ::c_int = 14;
288pub const _SC_FSYNC: ::c_int = 15;
289pub const _SC_MAPPED_FILES: ::c_int = 16;
290pub const _SC_MEMLOCK: ::c_int = 17;
291pub const _SC_MEMLOCK_RANGE: ::c_int = 18;
292pub const _SC_MEMORY_PROTECTION: ::c_int = 19;
293pub const _SC_MESSAGE_PASSING: ::c_int = 20;
294pub const _SC_SEMAPHORES: ::c_int = 21;
295pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22;
296pub const _SC_AIO_LISTIO_MAX: ::c_int = 23;
297pub const _SC_AIO_MAX: ::c_int = 24;
298pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25;
299pub const _SC_DELAYTIMER_MAX: ::c_int = 26;
300pub const _SC_MQ_OPEN_MAX: ::c_int = 27;
301pub const _SC_MQ_PRIO_MAX: ::c_int = 28;
302pub const _SC_VERSION: ::c_int = 29;
303pub const _SC_PAGESIZE: ::c_int = 30;
304pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
305pub const _SC_RTSIG_MAX: ::c_int = 31;
306pub const _SC_SEM_NSEMS_MAX: ::c_int = 32;
307pub const _SC_SEM_VALUE_MAX: ::c_int = 33;
308pub const _SC_SIGQUEUE_MAX: ::c_int = 34;
309pub const _SC_TIMER_MAX: ::c_int = 35;
310pub const _SC_BC_BASE_MAX: ::c_int = 36;
311pub const _SC_BC_DIM_MAX: ::c_int = 37;
312pub const _SC_BC_SCALE_MAX: ::c_int = 38;
313pub const _SC_BC_STRING_MAX: ::c_int = 39;
314pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40;
315pub const _SC_EXPR_NEST_MAX: ::c_int = 42;
316pub const _SC_LINE_MAX: ::c_int = 43;
317pub const _SC_RE_DUP_MAX: ::c_int = 44;
318pub const _SC_2_VERSION: ::c_int = 46;
319pub const _SC_2_C_BIND: ::c_int = 47;
320pub const _SC_2_C_DEV: ::c_int = 48;
321pub const _SC_2_FORT_DEV: ::c_int = 49;
322pub const _SC_2_FORT_RUN: ::c_int = 50;
323pub const _SC_2_SW_DEV: ::c_int = 51;
324pub const _SC_2_LOCALEDEF: ::c_int = 52;
325pub const _SC_IOV_MAX: ::c_int = 60;
326pub const _SC_THREADS: ::c_int = 67;
327pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68;
328pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69;
329pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70;
330pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
331pub const _SC_TTY_NAME_MAX: ::c_int = 72;
332pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73;
333pub const _SC_THREAD_KEYS_MAX: ::c_int = 74;
334pub const _SC_THREAD_STACK_MIN: ::c_int = 75;
335pub const _SC_THREAD_THREADS_MAX: ::c_int = 76;
336pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
337pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
338pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79;
339pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80;
340pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81;
341pub const _SC_NPROCESSORS_ONLN: ::c_int = 84;
342pub const _SC_ATEXIT_MAX: ::c_int = 87;
343pub const _SC_XOPEN_VERSION: ::c_int = 89;
344pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90;
345pub const _SC_XOPEN_UNIX: ::c_int = 91;
346pub const _SC_XOPEN_CRYPT: ::c_int = 92;
347pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
348pub const _SC_XOPEN_SHM: ::c_int = 94;
349pub const _SC_2_CHAR_TERM: ::c_int = 95;
350pub const _SC_2_UPE: ::c_int = 97;
351pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
352pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
353pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128;
354pub const _SC_XOPEN_LEGACY: ::c_int = 129;
355pub const _SC_XOPEN_REALTIME: ::c_int = 130;
356pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
357pub const _SC_HOST_NAME_MAX: ::c_int = 180;
358
359pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
360pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
361
362pub const GLOB_ERR: ::c_int = 1 << 0;
363pub const GLOB_MARK: ::c_int = 1 << 1;
364pub const GLOB_NOSORT: ::c_int = 1 << 2;
365pub const GLOB_DOOFFS: ::c_int = 1 << 3;
366pub const GLOB_NOCHECK: ::c_int = 1 << 4;
367pub const GLOB_APPEND: ::c_int = 1 << 5;
368pub const GLOB_NOESCAPE: ::c_int = 1 << 6;
369
370pub const GLOB_NOSPACE: ::c_int = 1;
371pub const GLOB_ABORTED: ::c_int = 2;
372pub const GLOB_NOMATCH: ::c_int = 3;
373
374pub const POSIX_MADV_NORMAL: ::c_int = 0;
375pub const POSIX_MADV_RANDOM: ::c_int = 1;
376pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
377pub const POSIX_MADV_WILLNEED: ::c_int = 3;
378
379pub const S_IEXEC: mode_t = 64;
380pub const S_IWRITE: mode_t = 128;
381pub const S_IREAD: mode_t = 256;
382
383pub const F_LOCK: ::c_int = 1;
384pub const F_TEST: ::c_int = 3;
385pub const F_TLOCK: ::c_int = 2;
386pub const F_ULOCK: ::c_int = 0;
387
388pub const ST_RDONLY: ::c_ulong = 1;
389pub const ST_NOSUID: ::c_ulong = 2;
390pub const ST_NODEV: ::c_ulong = 4;
391pub const ST_NOEXEC: ::c_ulong = 8;
392pub const ST_SYNCHRONOUS: ::c_ulong = 16;
393pub const ST_MANDLOCK: ::c_ulong = 64;
394pub const ST_WRITE: ::c_ulong = 128;
395pub const ST_APPEND: ::c_ulong = 256;
396pub const ST_IMMUTABLE: ::c_ulong = 512;
397pub const ST_NOATIME: ::c_ulong = 1024;
398pub const ST_NODIRATIME: ::c_ulong = 2048;
399
400pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
401pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
402pub const RTLD_NODELETE: ::c_int = 0x1000;
403pub const RTLD_NOW: ::c_int = 0x2;
404
405pub const TCP_MD5SIG: ::c_int = 14;
406
407pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
408 __align: [],
409 size: [0; __SIZEOF_PTHREAD_MUTEX_T],
410};
411pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
412 __align: [],
413 size: [0; __SIZEOF_PTHREAD_COND_T],
414};
415pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
416 __align: [],
417 size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
418};
419pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
420pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
421pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
422pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
423pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
424
425pub const SCHED_OTHER: ::c_int = 0;
426pub const SCHED_FIFO: ::c_int = 1;
427pub const SCHED_RR: ::c_int = 2;
428pub const SCHED_BATCH: ::c_int = 3;
429pub const SCHED_IDLE: ::c_int = 5;
430
431pub const IPC_CREAT: ::c_int = 0o1000;
432pub const IPC_EXCL: ::c_int = 0o2000;
433pub const IPC_NOWAIT: ::c_int = 0o4000;
434
435pub const IPC_RMID: ::c_int = 0;
436pub const IPC_SET: ::c_int = 1;
437pub const IPC_STAT: ::c_int = 2;
438pub const IPC_INFO: ::c_int = 3;
439
440pub const SHM_R: ::c_int = 0o400;
441pub const SHM_W: ::c_int = 0o200;
442
443pub const SHM_RDONLY: ::c_int = 0o10000;
444pub const SHM_RND: ::c_int = 0o20000;
445pub const SHM_REMAP: ::c_int = 0o40000;
446pub const SHM_EXEC: ::c_int = 0o100000;
447
448pub const SHM_LOCK: ::c_int = 11;
449pub const SHM_UNLOCK: ::c_int = 12;
450
451pub const SHM_HUGETLB: ::c_int = 0o4000;
452pub const SHM_NORESERVE: ::c_int = 0o10000;
453
454pub const EPOLLRDHUP: ::c_int = 0x2000;
455pub const EPOLLONESHOT: ::c_int = 0x40000000;
456
457pub const QFMT_VFS_OLD: ::c_int = 1;
458pub const QFMT_VFS_V0: ::c_int = 2;
459
460pub const SFD_CLOEXEC: ::c_int = 0x080000;
461
462pub const EFD_SEMAPHORE: ::c_int = 0x1;
463
464pub const NCCS: usize = 32;
465
466pub const AF_NETLINK: ::c_int = 16;
467
468pub const LOG_NFACILITIES: ::c_int = 24;
469
470pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t;
471
472pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32;
473pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32;
474pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32;
475pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32;
476pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32;
477pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32;
478pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32;
479
480f! {
481 pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
482 for slot in cpuset.bits.iter_mut() {
483 *slot = 0;
484 }
485 }
486
487 pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
488 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
489 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
490 cpuset.bits[idx] |= 1 << offset;
491 ()
492 }
493
494 pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
495 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]);
496 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
497 0 != (cpuset.bits[idx] & (1 << offset))
498 }
499
500 pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
501 set1.bits == set2.bits
502 }
503}
504
505extern {
506 pub fn setpwent();
507 pub fn getpwent() -> *mut passwd;
508 pub fn shm_open(name: *const c_char, oflag: ::c_int,
509 mode: mode_t) -> ::c_int;
510 pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
511 pub fn shmat(shmid: ::c_int,
512 shmaddr: *const ::c_void,
513 shmflg: ::c_int) -> *mut ::c_void;
514 pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
515 pub fn shmctl(shmid: ::c_int,
516 cmd: ::c_int,
517 buf: *mut ::shmid_ds) -> ::c_int;
518 pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
519 -> ::c_int;
520 pub fn __errno_location() -> *mut ::c_int;
521
522 pub fn fopen64(filename: *const c_char,
523 mode: *const c_char) -> *mut ::FILE;
524 pub fn freopen64(filename: *const c_char, mode: *const c_char,
525 file: *mut ::FILE) -> *mut ::FILE;
526 pub fn tmpfile64() -> *mut ::FILE;
527 pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
528 pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
529 pub fn fseeko64(stream: *mut ::FILE,
530 offset: ::off64_t,
531 whence: ::c_int) -> ::c_int;
532 pub fn ftello64(stream: *mut ::FILE) -> ::off64_t;
533 pub fn fallocate(fd: ::c_int, mode: ::c_int,
534 offset: ::off_t, len: ::off_t) -> ::c_int;
535 pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
536 len: ::off_t) -> ::c_int;
537 pub fn readahead(fd: ::c_int, offset: ::off64_t,
538 count: ::size_t) -> ::ssize_t;
539 pub fn getxattr(path: *const c_char, name: *const c_char,
540 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
541 pub fn lgetxattr(path: *const c_char, name: *const c_char,
542 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
543 pub fn fgetxattr(filedes: ::c_int, name: *const c_char,
544 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
545 pub fn setxattr(path: *const c_char, name: *const c_char,
546 value: *const ::c_void, size: ::size_t,
547 flags: ::c_int) -> ::c_int;
548 pub fn lsetxattr(path: *const c_char, name: *const c_char,
549 value: *const ::c_void, size: ::size_t,
550 flags: ::c_int) -> ::c_int;
551 pub fn fsetxattr(filedes: ::c_int, name: *const c_char,
552 value: *const ::c_void, size: ::size_t,
553 flags: ::c_int) -> ::c_int;
554 pub fn listxattr(path: *const c_char, list: *mut c_char,
555 size: ::size_t) -> ::ssize_t;
556 pub fn llistxattr(path: *const c_char, list: *mut c_char,
557 size: ::size_t) -> ::ssize_t;
558 pub fn flistxattr(filedes: ::c_int, list: *mut c_char,
559 size: ::size_t) -> ::ssize_t;
560 pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int;
561 pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
562 pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
563 pub fn signalfd(fd: ::c_int,
564 mask: *const ::sigset_t,
565 flags: ::c_int) -> ::c_int;
566 pub fn pwritev(fd: ::c_int,
567 iov: *const ::iovec,
568 iovcnt: ::c_int,
569 offset: ::off_t) -> ::ssize_t;
570 pub fn preadv(fd: ::c_int,
571 iov: *const ::iovec,
572 iovcnt: ::c_int,
573 offset: ::off_t) -> ::ssize_t;
574 pub fn quotactl(cmd: ::c_int,
575 special: *const ::c_char,
576 id: ::c_int,
577 data: *mut ::c_char) -> ::c_int;
578 pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
579 pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
580 pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
581 pub fn mq_receive(mqd: ::mqd_t,
582 msg_ptr: *mut ::c_char,
583 msg_len: ::size_t,
584 msq_prio: *mut ::c_uint) -> ::ssize_t;
585 pub fn mq_send(mqd: ::mqd_t,
586 msg_ptr: *const ::c_char,
587 msg_len: ::size_t,
588 msq_prio: ::c_uint) -> ::c_int;
589 pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
590 pub fn mq_setattr(mqd: ::mqd_t,
591 newattr: *const ::mq_attr,
592 oldattr: *mut ::mq_attr) -> ::c_int;
593 pub fn sched_getaffinity(pid: ::pid_t,
594 cpusetsize: ::size_t,
595 cpuset: *mut cpu_set_t) -> ::c_int;
596 pub fn sched_setaffinity(pid: ::pid_t,
597 cpusetsize: ::size_t,
598 cpuset: *const cpu_set_t) -> ::c_int;
599 pub fn epoll_pwait(epfd: ::c_int,
600 events: *mut ::epoll_event,
601 maxevents: ::c_int,
602 timeout: ::c_int,
603 sigmask: *const ::sigset_t) -> ::c_int;
604 pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int;
605 pub fn unshare(flags: ::c_int) -> ::c_int;
606 pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
607 pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int;
608 pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
609 pub fn mkostemps(template: *mut ::c_char,
610 suffixlen: ::c_int,
611 flags: ::c_int) -> ::c_int;
612 pub fn sigtimedwait(set: *const sigset_t,
613 info: *mut siginfo_t,
614 timeout: *const ::timespec) -> ::c_int;
615 pub fn sigwaitinfo(set: *const sigset_t,
616 info: *mut siginfo_t) -> ::c_int;
617 pub fn openpty(amaster: *mut ::c_int,
618 aslave: *mut ::c_int,
619 name: *mut ::c_char,
620 termp: *const termios,
621 winp: *const ::winsize) -> ::c_int;
622 pub fn forkpty(amaster: *mut ::c_int,
623 name: *mut ::c_char,
624 termp: *const termios,
625 winp: *const ::winsize) -> ::pid_t;
626 pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
627 pub fn getnameinfo(sa: *const ::sockaddr,
628 salen: ::socklen_t,
629 host: *mut ::c_char,
630 hostlen: ::socklen_t,
631 serv: *mut ::c_char,
632 sevlen: ::socklen_t,
633 flags: ::c_int) -> ::c_int;
634 pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit,
635 old_limit: *mut ::rlimit) -> ::c_int;
636 pub fn prlimit64(pid: ::pid_t,
637 resource: ::c_int,
638 new_limit: *const ::rlimit64,
639 old_limit: *mut ::rlimit64) -> ::c_int;
640 pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
641 pub fn process_vm_readv(pid: ::pid_t,
642 local_iov: *const ::iovec,
643 liovcnt: ::c_ulong,
644 remote_iov: *const ::iovec,
645 riovcnt: ::c_ulong,
646 flags: ::c_ulong) -> isize;
647 pub fn process_vm_writev(pid: ::pid_t,
648 local_iov: *const ::iovec,
649 liovcnt: ::c_ulong,
650 remote_iov: *const ::iovec,
651 riovcnt: ::c_ulong,
652 flags: ::c_ulong) -> isize;
653 pub fn reboot(how_to: ::c_int) -> ::c_int;
654
655 // Not available now on Android
656 pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
657 mode: ::mode_t) -> ::c_int;
658 pub fn if_nameindex() -> *mut if_nameindex;
659 pub fn if_freenameindex(ptr: *mut if_nameindex);
660}
661
662cfg_if! {
663 if #[cfg(any(target_env = "musl",
664 target_os = "emscripten"))] {
665 mod musl;
666 pub use self::musl::*;
667 } else if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] {
668 mod mips;
669 pub use self::mips::*;
670 } else {
671 mod other;
672 pub use self::other::*;
673 }
674}