blob: f5068580e616e95f510e29fb24c1f59523ad4195 [file] [log] [blame]
Alex Crichton50a42e22015-09-15 14:27:15 -07001//! Linux-specific definitions for linux-like values
2
Marco A L Barbosaa3759d72017-02-27 17:25:55 -03003use dox::{mem, Option};
Peter Jin1a190c72016-02-05 15:06:39 -08004
Alex Crichton918f8e12015-09-15 16:39:51 -07005pub type useconds_t = u32;
Alex Crichton52605872015-09-15 16:49:37 -07006pub type dev_t = u64;
7pub type socklen_t = u32;
8pub type pthread_t = c_ulong;
Alex Crichtonc4a8d602015-09-18 15:00:49 -07009pub type mode_t = u32;
Alex Crichton74825222015-10-29 17:36:55 -070010pub type ino64_t = u64;
11pub type off64_t = i64;
12pub type blkcnt64_t = i64;
13pub type rlim64_t = u64;
Alexander Polakov58501562015-12-14 02:09:45 +030014pub type shmatt_t = ::c_ulong;
Alex Crichton881ef9b2015-12-01 09:04:13 -080015pub type mqd_t = ::c_int;
Alexander Schlarb75905652016-09-17 22:17:17 +020016pub type msgqnum_t = ::c_ulong;
17pub type msglen_t = ::c_ulong;
David Henningsson9d2493e2015-12-25 22:06:44 +010018pub type nfds_t = ::c_ulong;
A.J. Gardner24c84f12016-03-31 20:08:03 -050019pub type nl_item = ::c_int;
Zack Weinberg984fb542017-01-10 11:09:51 -050020pub type idtype_t = ::c_uint;
Alex Crichton74825222015-10-29 17:36:55 -070021
22pub enum fpos64_t {} // TODO: fill this out with a struct
Alex Crichton918f8e12015-09-15 16:39:51 -070023
Alex Crichton50a42e22015-09-15 14:27:15 -070024s! {
Alex Crichtond6e07e22015-10-29 22:59:44 -070025 pub struct dirent {
26 pub d_ino: ::ino_t,
27 pub d_off: ::off_t,
28 pub d_reclen: ::c_ushort,
29 pub d_type: ::c_uchar,
30 pub d_name: [::c_char; 256],
31 }
32
Alex Crichton74825222015-10-29 17:36:55 -070033 pub struct dirent64 {
34 pub d_ino: ::ino64_t,
35 pub d_off: ::off64_t,
36 pub d_reclen: ::c_ushort,
37 pub d_type: ::c_uchar,
38 pub d_name: [::c_char; 256],
39 }
40
41 pub struct rlimit64 {
42 pub rlim_cur: rlim64_t,
43 pub rlim_max: rlim64_t,
44 }
45
Alex Crichton50a42e22015-09-15 14:27:15 -070046 pub struct glob_t {
Alex Crichton17910462015-09-22 19:11:04 -070047 pub gl_pathc: ::size_t,
Alex Crichton50a42e22015-09-15 14:27:15 -070048 pub gl_pathv: *mut *mut c_char,
Alex Crichton17910462015-09-22 19:11:04 -070049 pub gl_offs: ::size_t,
Alex Crichton52605872015-09-15 16:49:37 -070050 pub gl_flags: ::c_int,
Alex Crichton50a42e22015-09-15 14:27:15 -070051
52 __unused1: *mut ::c_void,
53 __unused2: *mut ::c_void,
54 __unused3: *mut ::c_void,
55 __unused4: *mut ::c_void,
56 __unused5: *mut ::c_void,
57 }
58
59 pub struct ifaddrs {
60 pub ifa_next: *mut ifaddrs,
61 pub ifa_name: *mut c_char,
Alex Crichton52605872015-09-15 16:49:37 -070062 pub ifa_flags: ::c_uint,
Alex Crichton50a42e22015-09-15 14:27:15 -070063 pub ifa_addr: *mut ::sockaddr,
64 pub ifa_netmask: *mut ::sockaddr,
65 pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union
66 pub ifa_data: *mut ::c_void
67 }
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070068
69 pub struct pthread_mutex_t {
Wang Xuerui0caba712016-11-07 11:18:05 +080070 #[cfg(any(target_arch = "mips", target_arch = "arm",
71 target_arch = "powerpc"))]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070072 __align: [::c_long; 0],
Wang Xuerui0caba712016-11-07 11:18:05 +080073 #[cfg(not(any(target_arch = "mips", target_arch = "arm",
74 target_arch = "powerpc")))]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070075 __align: [::c_longlong; 0],
76 size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
77 }
78
79 pub struct pthread_rwlock_t {
Wang Xuerui0caba712016-11-07 11:18:05 +080080 #[cfg(any(target_arch = "mips", target_arch = "arm",
81 target_arch = "powerpc"))]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070082 __align: [::c_long; 0],
Wang Xuerui0caba712016-11-07 11:18:05 +080083 #[cfg(not(any(target_arch = "mips", target_arch = "arm",
84 target_arch = "powerpc")))]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070085 __align: [::c_longlong; 0],
86 size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
87 }
88
89 pub struct pthread_mutexattr_t {
Jorge Aparicio196b0e82016-08-26 22:30:42 -050090 #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64",
Jorge Aparicio98589872016-12-30 01:33:51 -050091 target_arch = "mips64", target_arch = "s390x",
92 target_arch = "sparc64"))]
Alex Crichtonb347b442015-09-17 15:48:30 -070093 __align: [::c_int; 0],
Jorge Aparicio196b0e82016-08-26 22:30:42 -050094 #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64",
Jorge Aparicio98589872016-12-30 01:33:51 -050095 target_arch = "mips64", target_arch = "s390x",
96 target_arch = "sparc64")))]
Alex Crichton684cfa42015-09-17 15:18:18 -070097 __align: [::c_long; 0],
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070098 size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
99 }
100
101 pub struct pthread_cond_t {
Jorge Aparicio23a50922016-07-26 16:13:03 -0500102 #[cfg(any(target_env = "musl"))]
Jorge Aparicio751bea32016-01-30 01:28:50 -0500103 __align: [*const ::c_void; 0],
Jorge Aparicio23a50922016-07-26 16:13:03 -0500104 #[cfg(not(any(target_env = "musl")))]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700105 __align: [::c_longlong; 0],
106 size: [u8; __SIZEOF_PTHREAD_COND_T],
107 }
108
Tomasz MiÄ…skocb644852016-07-20 07:31:48 +0200109 pub struct pthread_condattr_t {
110 __align: [::c_int; 0],
111 size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
112 }
113
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700114 pub struct passwd {
115 pub pw_name: *mut ::c_char,
116 pub pw_passwd: *mut ::c_char,
117 pub pw_uid: ::uid_t,
118 pub pw_gid: ::gid_t,
119 pub pw_gecos: *mut ::c_char,
120 pub pw_dir: *mut ::c_char,
121 pub pw_shell: *mut ::c_char,
122 }
Dan Burkert85a76f82015-11-04 20:26:27 -0800123
Philipp Keller26f3eb92016-09-26 22:00:29 +0200124 pub struct spwd {
125 pub sp_namp: *mut ::c_char,
126 pub sp_pwdp: *mut ::c_char,
127 pub sp_lstchg: ::c_long,
128 pub sp_min: ::c_long,
129 pub sp_max: ::c_long,
130 pub sp_warn: ::c_long,
131 pub sp_inact: ::c_long,
132 pub sp_expire: ::c_long,
133 pub sp_flag: ::c_ulong,
134 }
135
Dan Burkert85a76f82015-11-04 20:26:27 -0800136 pub struct statvfs {
137 pub f_bsize: ::c_ulong,
138 pub f_frsize: ::c_ulong,
139 pub f_blocks: ::fsblkcnt_t,
140 pub f_bfree: ::fsblkcnt_t,
141 pub f_bavail: ::fsblkcnt_t,
142 pub f_files: ::fsfilcnt_t,
143 pub f_ffree: ::fsfilcnt_t,
144 pub f_favail: ::fsfilcnt_t,
Jorge Aparicio3df00572016-09-11 23:57:37 -0500145 #[cfg(target_endian = "little")]
Dan Burkert85a76f82015-11-04 20:26:27 -0800146 pub f_fsid: ::c_ulong,
147 #[cfg(target_pointer_width = "32")]
Jorge Aparicio41101f22016-09-12 23:41:17 -0500148 __f_unused: ::c_int,
Jorge Aparicio3df00572016-09-11 23:57:37 -0500149 #[cfg(target_endian = "big")]
150 pub f_fsid: ::c_ulong,
Dan Burkert85a76f82015-11-04 20:26:27 -0800151 pub f_flag: ::c_ulong,
152 pub f_namemax: ::c_ulong,
153 __f_spare: [::c_int; 6],
154 }
Alexander Polakov440bd532015-11-07 15:42:38 +0300155
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800156 pub struct dqblk {
157 pub dqb_bhardlimit: ::uint64_t,
158 pub dqb_bsoftlimit: ::uint64_t,
159 pub dqb_curspace: ::uint64_t,
160 pub dqb_ihardlimit: ::uint64_t,
161 pub dqb_isoftlimit: ::uint64_t,
162 pub dqb_curinodes: ::uint64_t,
163 pub dqb_btime: ::uint64_t,
164 pub dqb_itime: ::uint64_t,
165 pub dqb_valid: ::uint32_t,
166 }
167
168 pub struct signalfd_siginfo {
169 pub ssi_signo: ::uint32_t,
170 pub ssi_errno: ::int32_t,
171 pub ssi_code: ::int32_t,
172 pub ssi_pid: ::uint32_t,
173 pub ssi_uid: ::uint32_t,
174 pub ssi_fd: ::int32_t,
175 pub ssi_tid: ::uint32_t,
176 pub ssi_band: ::uint32_t,
177 pub ssi_overrun: ::uint32_t,
178 pub ssi_trapno: ::uint32_t,
179 pub ssi_status: ::int32_t,
180 pub ssi_int: ::int32_t,
181 pub ssi_ptr: ::uint64_t,
182 pub ssi_utime: ::uint64_t,
183 pub ssi_stime: ::uint64_t,
184 pub ssi_addr: ::uint64_t,
185 _pad: [::uint8_t; 48],
186 }
187
188 pub struct fsid_t {
189 __val: [::c_int; 2],
190 }
191
192 pub struct mq_attr {
193 pub mq_flags: ::c_long,
194 pub mq_maxmsg: ::c_long,
195 pub mq_msgsize: ::c_long,
196 pub mq_curmsgs: ::c_long,
197 pad: [::c_long; 4]
198 }
199
200 pub struct cpu_set_t {
201 #[cfg(target_pointer_width = "32")]
202 bits: [u32; 32],
203 #[cfg(target_pointer_width = "64")]
204 bits: [u64; 16],
205 }
Charles J. Schneider332bd862016-07-12 09:32:42 +0200206
207 pub struct if_nameindex {
208 pub if_index: ::c_uint,
209 pub if_name: *mut ::c_char,
210 }
211
Alexander Schlarb75905652016-09-17 22:17:17 +0200212 // System V IPC
213 pub struct msginfo {
214 pub msgpool: ::c_int,
215 pub msgmap: ::c_int,
216 pub msgmax: ::c_int,
217 pub msgmnb: ::c_int,
218 pub msgmni: ::c_int,
219 pub msgssz: ::c_int,
220 pub msgtql: ::c_int,
221 pub msgseg: ::c_ushort,
222 }
NODA, Kai61c23fb2016-04-10 22:21:55 +0800223
224 pub struct mmsghdr {
225 pub msg_hdr: ::msghdr,
226 pub msg_len: ::c_uint,
227 }
Andrew Salmon548e4cf2017-05-26 04:35:40 -0700228
229 pub struct sembuf {
Andrew Salmonbc482022017-05-26 12:47:53 -0700230 pub sem_num: ::c_ushort,
231 pub sem_op: ::c_short,
Andrew Salmon0f93f372017-05-26 12:54:03 -0700232 pub sem_flg: ::c_short,
Andrew Salmon548e4cf2017-05-26 04:35:40 -0700233 }
234
Andrew Salmon41f9e7c2017-05-26 13:24:11 -0700235 // FIXME
Andrew Salmon548e4cf2017-05-26 04:35:40 -0700236 pub struct semid_ds {
Andrew Salmon41f9e7c2017-05-26 13:24:11 -0700237 // pub sem_perm: ::ipc_perm,
238 // pub sem_otime: ::time_t,
239 // pub sem_ctime: ::time_t,
240 // pub sem_nsems: ::c_ulong,
Andrew Salmon548e4cf2017-05-26 04:35:40 -0700241 }
Alex Crichton50a42e22015-09-15 14:27:15 -0700242}
243
A.J. Gardner24c84f12016-03-31 20:08:03 -0500244pub const ABDAY_1: ::nl_item = 0x20000;
245pub const ABDAY_2: ::nl_item = 0x20001;
246pub const ABDAY_3: ::nl_item = 0x20002;
247pub const ABDAY_4: ::nl_item = 0x20003;
248pub const ABDAY_5: ::nl_item = 0x20004;
249pub const ABDAY_6: ::nl_item = 0x20005;
250pub const ABDAY_7: ::nl_item = 0x20006;
251
252pub const DAY_1: ::nl_item = 0x20007;
253pub const DAY_2: ::nl_item = 0x20008;
254pub const DAY_3: ::nl_item = 0x20009;
255pub const DAY_4: ::nl_item = 0x2000A;
256pub const DAY_5: ::nl_item = 0x2000B;
257pub const DAY_6: ::nl_item = 0x2000C;
258pub const DAY_7: ::nl_item = 0x2000D;
259
260pub const ABMON_1: ::nl_item = 0x2000E;
261pub const ABMON_2: ::nl_item = 0x2000F;
262pub const ABMON_3: ::nl_item = 0x20010;
263pub const ABMON_4: ::nl_item = 0x20011;
264pub const ABMON_5: ::nl_item = 0x20012;
265pub const ABMON_6: ::nl_item = 0x20013;
266pub const ABMON_7: ::nl_item = 0x20014;
267pub const ABMON_8: ::nl_item = 0x20015;
268pub const ABMON_9: ::nl_item = 0x20016;
269pub const ABMON_10: ::nl_item = 0x20017;
270pub const ABMON_11: ::nl_item = 0x20018;
271pub const ABMON_12: ::nl_item = 0x20019;
272
273pub const MON_1: ::nl_item = 0x2001A;
274pub const MON_2: ::nl_item = 0x2001B;
275pub const MON_3: ::nl_item = 0x2001C;
276pub const MON_4: ::nl_item = 0x2001D;
277pub const MON_5: ::nl_item = 0x2001E;
278pub const MON_6: ::nl_item = 0x2001F;
279pub const MON_7: ::nl_item = 0x20020;
280pub const MON_8: ::nl_item = 0x20021;
281pub const MON_9: ::nl_item = 0x20022;
282pub const MON_10: ::nl_item = 0x20023;
283pub const MON_11: ::nl_item = 0x20024;
284pub const MON_12: ::nl_item = 0x20025;
285
286pub const AM_STR: ::nl_item = 0x20026;
287pub const PM_STR: ::nl_item = 0x20027;
288
289pub const D_T_FMT: ::nl_item = 0x20028;
290pub const D_FMT: ::nl_item = 0x20029;
291pub const T_FMT: ::nl_item = 0x2002A;
292pub const T_FMT_AMPM: ::nl_item = 0x2002B;
293
294pub const ERA: ::nl_item = 0x2002C;
295pub const ERA_D_FMT: ::nl_item = 0x2002E;
296pub const ALT_DIGITS: ::nl_item = 0x2002F;
297pub const ERA_D_T_FMT: ::nl_item = 0x20030;
298pub const ERA_T_FMT: ::nl_item = 0x20031;
299
300pub const CODESET: ::nl_item = 14;
301
302pub const CRNCYSTR: ::nl_item = 0x4000F;
303
Ian Denhardt0ecafc32016-10-03 20:08:12 -0400304pub const RUSAGE_THREAD: ::c_int = 1;
305pub const RUSAGE_CHILDREN: ::c_int = -1;
306
A.J. Gardner24c84f12016-03-31 20:08:03 -0500307pub const RADIXCHAR: ::nl_item = 0x10000;
308pub const THOUSEP: ::nl_item = 0x10001;
309
310pub const YESEXPR: ::nl_item = 0x50000;
311pub const NOEXPR: ::nl_item = 0x50001;
312pub const YESSTR: ::nl_item = 0x50002;
313pub const NOSTR: ::nl_item = 0x50003;
314
Alex Crichton52605872015-09-15 16:49:37 -0700315pub const FILENAME_MAX: ::c_uint = 4096;
Alex Crichton52605872015-09-15 16:49:37 -0700316pub const L_tmpnam: ::c_uint = 20;
Philipp Keller2cad6ca2016-07-06 21:15:38 +0200317pub const _PC_LINK_MAX: ::c_int = 0;
318pub const _PC_MAX_CANON: ::c_int = 1;
319pub const _PC_MAX_INPUT: ::c_int = 2;
Alex Crichton52605872015-09-15 16:49:37 -0700320pub const _PC_NAME_MAX: ::c_int = 3;
Philipp Keller2cad6ca2016-07-06 21:15:38 +0200321pub const _PC_PATH_MAX: ::c_int = 4;
322pub const _PC_PIPE_BUF: ::c_int = 5;
323pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
324pub const _PC_NO_TRUNC: ::c_int = 7;
325pub const _PC_VDISABLE: ::c_int = 8;
Alex Crichton50a42e22015-09-15 14:27:15 -0700326
Alex Crichton52605872015-09-15 16:49:37 -0700327pub const _SC_ARG_MAX: ::c_int = 0;
328pub const _SC_CHILD_MAX: ::c_int = 1;
329pub const _SC_CLK_TCK: ::c_int = 2;
330pub const _SC_NGROUPS_MAX: ::c_int = 3;
331pub const _SC_OPEN_MAX: ::c_int = 4;
332pub const _SC_STREAM_MAX: ::c_int = 5;
333pub const _SC_TZNAME_MAX: ::c_int = 6;
334pub const _SC_JOB_CONTROL: ::c_int = 7;
335pub const _SC_SAVED_IDS: ::c_int = 8;
336pub const _SC_REALTIME_SIGNALS: ::c_int = 9;
337pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10;
338pub const _SC_TIMERS: ::c_int = 11;
339pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12;
340pub const _SC_PRIORITIZED_IO: ::c_int = 13;
341pub const _SC_SYNCHRONIZED_IO: ::c_int = 14;
342pub const _SC_FSYNC: ::c_int = 15;
343pub const _SC_MAPPED_FILES: ::c_int = 16;
344pub const _SC_MEMLOCK: ::c_int = 17;
345pub const _SC_MEMLOCK_RANGE: ::c_int = 18;
346pub const _SC_MEMORY_PROTECTION: ::c_int = 19;
347pub const _SC_MESSAGE_PASSING: ::c_int = 20;
348pub const _SC_SEMAPHORES: ::c_int = 21;
349pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22;
350pub const _SC_AIO_LISTIO_MAX: ::c_int = 23;
351pub const _SC_AIO_MAX: ::c_int = 24;
352pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25;
353pub const _SC_DELAYTIMER_MAX: ::c_int = 26;
354pub const _SC_MQ_OPEN_MAX: ::c_int = 27;
355pub const _SC_MQ_PRIO_MAX: ::c_int = 28;
356pub const _SC_VERSION: ::c_int = 29;
357pub const _SC_PAGESIZE: ::c_int = 30;
Brian Campbell11f29f52016-01-31 21:28:16 -0500358pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
Alex Crichton52605872015-09-15 16:49:37 -0700359pub const _SC_RTSIG_MAX: ::c_int = 31;
360pub const _SC_SEM_NSEMS_MAX: ::c_int = 32;
361pub const _SC_SEM_VALUE_MAX: ::c_int = 33;
362pub const _SC_SIGQUEUE_MAX: ::c_int = 34;
363pub const _SC_TIMER_MAX: ::c_int = 35;
364pub const _SC_BC_BASE_MAX: ::c_int = 36;
365pub const _SC_BC_DIM_MAX: ::c_int = 37;
366pub const _SC_BC_SCALE_MAX: ::c_int = 38;
367pub const _SC_BC_STRING_MAX: ::c_int = 39;
368pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40;
369pub const _SC_EXPR_NEST_MAX: ::c_int = 42;
370pub const _SC_LINE_MAX: ::c_int = 43;
371pub const _SC_RE_DUP_MAX: ::c_int = 44;
372pub const _SC_2_VERSION: ::c_int = 46;
373pub const _SC_2_C_BIND: ::c_int = 47;
374pub const _SC_2_C_DEV: ::c_int = 48;
375pub const _SC_2_FORT_DEV: ::c_int = 49;
376pub const _SC_2_FORT_RUN: ::c_int = 50;
377pub const _SC_2_SW_DEV: ::c_int = 51;
378pub const _SC_2_LOCALEDEF: ::c_int = 52;
379pub const _SC_IOV_MAX: ::c_int = 60;
380pub const _SC_THREADS: ::c_int = 67;
381pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68;
382pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69;
383pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70;
384pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
385pub const _SC_TTY_NAME_MAX: ::c_int = 72;
386pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73;
387pub const _SC_THREAD_KEYS_MAX: ::c_int = 74;
388pub const _SC_THREAD_STACK_MIN: ::c_int = 75;
389pub const _SC_THREAD_THREADS_MAX: ::c_int = 76;
390pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
391pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
392pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79;
393pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80;
394pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81;
395pub const _SC_NPROCESSORS_ONLN: ::c_int = 84;
396pub const _SC_ATEXIT_MAX: ::c_int = 87;
397pub const _SC_XOPEN_VERSION: ::c_int = 89;
398pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90;
399pub const _SC_XOPEN_UNIX: ::c_int = 91;
400pub const _SC_XOPEN_CRYPT: ::c_int = 92;
401pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
402pub const _SC_XOPEN_SHM: ::c_int = 94;
403pub const _SC_2_CHAR_TERM: ::c_int = 95;
Alex Crichton52605872015-09-15 16:49:37 -0700404pub const _SC_2_UPE: ::c_int = 97;
405pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
406pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
407pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128;
408pub const _SC_XOPEN_LEGACY: ::c_int = 129;
409pub const _SC_XOPEN_REALTIME: ::c_int = 130;
410pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
Raphael Cohnf3651112016-05-04 10:35:08 +0100411pub const _SC_HOST_NAME_MAX: ::c_int = 180;
Alex Crichton50a42e22015-09-15 14:27:15 -0700412
413pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
414pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
415
Alex Crichton52605872015-09-15 16:49:37 -0700416pub const GLOB_ERR: ::c_int = 1 << 0;
417pub const GLOB_MARK: ::c_int = 1 << 1;
418pub const GLOB_NOSORT: ::c_int = 1 << 2;
419pub const GLOB_DOOFFS: ::c_int = 1 << 3;
420pub const GLOB_NOCHECK: ::c_int = 1 << 4;
421pub const GLOB_APPEND: ::c_int = 1 << 5;
422pub const GLOB_NOESCAPE: ::c_int = 1 << 6;
Alex Crichton50a42e22015-09-15 14:27:15 -0700423
Alex Crichton52605872015-09-15 16:49:37 -0700424pub const GLOB_NOSPACE: ::c_int = 1;
425pub const GLOB_ABORTED: ::c_int = 2;
426pub const GLOB_NOMATCH: ::c_int = 3;
Alex Crichton50a42e22015-09-15 14:27:15 -0700427
Alex Crichton52605872015-09-15 16:49:37 -0700428pub const POSIX_MADV_NORMAL: ::c_int = 0;
429pub const POSIX_MADV_RANDOM: ::c_int = 1;
430pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
431pub const POSIX_MADV_WILLNEED: ::c_int = 3;
Alex Crichton50a42e22015-09-15 14:27:15 -0700432
433pub const S_IEXEC: mode_t = 64;
434pub const S_IWRITE: mode_t = 128;
435pub const S_IREAD: mode_t = 256;
436
Alex Crichton52605872015-09-15 16:49:37 -0700437pub const F_LOCK: ::c_int = 1;
438pub const F_TEST: ::c_int = 3;
439pub const F_TLOCK: ::c_int = 2;
440pub const F_ULOCK: ::c_int = 0;
Alex Crichton50a42e22015-09-15 14:27:15 -0700441
Dan Burkert85a76f82015-11-04 20:26:27 -0800442pub const ST_RDONLY: ::c_ulong = 1;
443pub const ST_NOSUID: ::c_ulong = 2;
444pub const ST_NODEV: ::c_ulong = 4;
445pub const ST_NOEXEC: ::c_ulong = 8;
446pub const ST_SYNCHRONOUS: ::c_ulong = 16;
447pub const ST_MANDLOCK: ::c_ulong = 64;
448pub const ST_WRITE: ::c_ulong = 128;
449pub const ST_APPEND: ::c_ulong = 256;
450pub const ST_IMMUTABLE: ::c_ulong = 512;
451pub const ST_NOATIME: ::c_ulong = 1024;
452pub const ST_NODIRATIME: ::c_ulong = 2048;
453
Dong Zhou188bef62015-11-29 22:24:10 -0500454pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
455pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
Alex Crichton29de5982016-02-04 13:48:13 -0800456pub const RTLD_NODELETE: ::c_int = 0x1000;
457pub const RTLD_NOW: ::c_int = 0x2;
Dong Zhou51ed5742015-11-29 21:42:14 -0500458
Alex Crichton52605872015-09-15 16:49:37 -0700459pub const TCP_MD5SIG: ::c_int = 14;
Alex Crichton50a42e22015-09-15 14:27:15 -0700460
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700461pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
462 __align: [],
463 size: [0; __SIZEOF_PTHREAD_MUTEX_T],
464};
465pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
466 __align: [],
467 size: [0; __SIZEOF_PTHREAD_COND_T],
468};
469pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
470 __align: [],
471 size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
472};
Amanieu d'Antrasb2b9f292016-05-21 06:40:14 +0100473pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700474pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
Amanieu d'Antrasb2b9f292016-05-21 06:40:14 +0100475pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
476pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700477pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700478
Alexander Polakov26974c72015-11-27 03:02:44 +0300479pub const SCHED_OTHER: ::c_int = 0;
480pub const SCHED_FIFO: ::c_int = 1;
481pub const SCHED_RR: ::c_int = 2;
482pub const SCHED_BATCH: ::c_int = 3;
483pub const SCHED_IDLE: ::c_int = 5;
484
Zac Berkowitz1479ea82017-02-28 03:59:17 +0000485pub const AF_IB: ::c_int = 27;
486pub const AF_MPLS: ::c_int = 28;
487pub const AF_NFC: ::c_int = 39;
488pub const AF_VSOCK: ::c_int = 40;
Zac Berkowitz985ea402017-03-01 15:39:24 +0000489#[doc(hidden)]
Zac Berkowitz1479ea82017-02-28 03:59:17 +0000490pub const AF_MAX: ::c_int = 42;
491pub const PF_IB: ::c_int = AF_IB;
492pub const PF_MPLS: ::c_int = AF_MPLS;
493pub const PF_NFC: ::c_int = AF_NFC;
494pub const PF_VSOCK: ::c_int = AF_VSOCK;
Zac Berkowitz985ea402017-03-01 15:39:24 +0000495#[doc(hidden)]
Zac Berkowitz1479ea82017-02-28 03:59:17 +0000496pub const PF_MAX: ::c_int = AF_MAX;
497
Alexander Schlarb75905652016-09-17 22:17:17 +0200498// System V IPC
499pub const IPC_PRIVATE: ::key_t = 0;
500
Alexander Polakov58501562015-12-14 02:09:45 +0300501pub const IPC_CREAT: ::c_int = 0o1000;
502pub const IPC_EXCL: ::c_int = 0o2000;
503pub const IPC_NOWAIT: ::c_int = 0o4000;
504
505pub const IPC_RMID: ::c_int = 0;
506pub const IPC_SET: ::c_int = 1;
507pub const IPC_STAT: ::c_int = 2;
508pub const IPC_INFO: ::c_int = 3;
Alexander Schlarb75905652016-09-17 22:17:17 +0200509pub const MSG_STAT: ::c_int = 11;
510pub const MSG_INFO: ::c_int = 12;
511
512pub const MSG_NOERROR: ::c_int = 0o10000;
513pub const MSG_EXCEPT: ::c_int = 0o20000;
514pub const MSG_COPY: ::c_int = 0o40000;
Alexander Polakov58501562015-12-14 02:09:45 +0300515
516pub const SHM_R: ::c_int = 0o400;
517pub const SHM_W: ::c_int = 0o200;
518
519pub const SHM_RDONLY: ::c_int = 0o10000;
520pub const SHM_RND: ::c_int = 0o20000;
521pub const SHM_REMAP: ::c_int = 0o40000;
522pub const SHM_EXEC: ::c_int = 0o100000;
523
524pub const SHM_LOCK: ::c_int = 11;
525pub const SHM_UNLOCK: ::c_int = 12;
526
527pub const SHM_HUGETLB: ::c_int = 0o4000;
528pub const SHM_NORESERVE: ::c_int = 0o10000;
529
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800530pub const EPOLLRDHUP: ::c_int = 0x2000;
Simon Liud6fbc0d2017-02-17 23:25:19 +0800531pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800532pub const EPOLLONESHOT: ::c_int = 0x40000000;
533
534pub const QFMT_VFS_OLD: ::c_int = 1;
535pub const QFMT_VFS_V0: ::c_int = 2;
536
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800537pub const EFD_SEMAPHORE: ::c_int = 0x1;
538
Raphael Cohn1c6c0ca2016-05-05 17:45:29 +0100539pub const LOG_NFACILITIES: ::c_int = 24;
540
Steven Fackler41699f72016-06-03 21:02:56 -0700541pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t;
542
Philipp Matthias Schaefer5a68b6a2016-07-15 23:19:00 +0200543pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32;
544pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32;
545pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32;
546pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32;
547pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32;
548pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32;
549pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32;
Sergey Bugaev5d65c3f2016-07-12 20:55:08 +0300550
Stefan Luecked37d42a2016-12-20 15:29:17 +0100551pub const AI_PASSIVE: ::c_int = 0x0001;
552pub const AI_CANONNAME: ::c_int = 0x0002;
553pub const AI_NUMERICHOST: ::c_int = 0x0004;
554pub const AI_V4MAPPED: ::c_int = 0x0008;
555pub const AI_ALL: ::c_int = 0x0010;
556pub const AI_ADDRCONFIG: ::c_int = 0x0020;
557
558pub const AI_NUMERICSERV: ::c_int = 0x0400;
559
560pub const EAI_BADFLAGS: ::c_int = -1;
561pub const EAI_NONAME: ::c_int = -2;
562pub const EAI_AGAIN: ::c_int = -3;
563pub const EAI_FAIL: ::c_int = -4;
564pub const EAI_FAMILY: ::c_int = -6;
565pub const EAI_SOCKTYPE: ::c_int = -7;
566pub const EAI_SERVICE: ::c_int = -8;
567pub const EAI_MEMORY: ::c_int = -10;
568pub const EAI_OVERFLOW: ::c_int = -12;
569
570pub const NI_NUMERICHOST: ::c_int = 1;
571pub const NI_NUMERICSERV: ::c_int = 2;
572pub const NI_NOFQDN: ::c_int = 4;
573pub const NI_NAMEREQD: ::c_int = 8;
574pub const NI_DGRAM: ::c_int = 16;
575
Chris Kaminskiae6cbcd2016-09-07 13:15:49 -0400576pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1;
577pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2;
578pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4;
Chris Kaminski37552b72016-09-06 20:20:00 -0400579
Tomasz MiÄ…skof514d462016-09-19 12:29:45 +0200580pub const EAI_SYSTEM: ::c_int = -11;
581
Alan Somers804763c2016-11-13 15:03:14 -0700582pub const AIO_CANCELED: ::c_int = 0;
583pub const AIO_NOTCANCELED: ::c_int = 1;
584pub const AIO_ALLDONE: ::c_int = 2;
585pub const LIO_READ: ::c_int = 0;
586pub const LIO_WRITE: ::c_int = 1;
587pub const LIO_NOP: ::c_int = 2;
588pub const LIO_WAIT: ::c_int = 0;
589pub const LIO_NOWAIT: ::c_int = 1;
590
sankaku545f67d2016-12-27 18:40:18 -0500591pub const MREMAP_MAYMOVE: ::c_int = 1;
592pub const MREMAP_FIXED: ::c_int = 2;
593
zethra18876302016-12-28 16:59:35 -0500594pub const PR_SET_PDEATHSIG: ::c_int = 1;
595pub const PR_GET_PDEATHSIG: ::c_int = 2;
596
597pub const PR_GET_DUMPABLE: ::c_int = 3;
598pub const PR_SET_DUMPABLE: ::c_int = 4;
599
600pub const PR_GET_UNALIGN: ::c_int = 5;
601pub const PR_SET_UNALIGN: ::c_int = 6;
602pub const PR_UNALIGN_NOPRINT: ::c_int = 1;
603pub const PR_UNALIGN_SIGBUS: ::c_int = 2;
604
605pub const PR_GET_KEEPCAPS: ::c_int = 7;
606pub const PR_SET_KEEPCAPS: ::c_int = 8;
607
608pub const PR_GET_FPEMU: ::c_int = 9;
609pub const PR_SET_FPEMU: ::c_int = 10;
610pub const PR_FPEMU_NOPRINT: ::c_int = 1;
611pub const PR_FPEMU_SIGFPE: ::c_int = 2;
612
613pub const PR_GET_FPEXC: ::c_int = 11;
614pub const PR_SET_FPEXC: ::c_int = 12;
615pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80;
616pub const PR_FP_EXC_DIV: ::c_int = 0x010000;
617pub const PR_FP_EXC_OVF: ::c_int = 0x020000;
618pub const PR_FP_EXC_UND: ::c_int = 0x040000;
619pub const PR_FP_EXC_RES: ::c_int = 0x080000;
620pub const PR_FP_EXC_INV: ::c_int = 0x100000;
621pub const PR_FP_EXC_DISABLED: ::c_int = 0;
622pub const PR_FP_EXC_NONRECOV: ::c_int = 1;
623pub const PR_FP_EXC_ASYNC: ::c_int = 2;
624pub const PR_FP_EXC_PRECISE: ::c_int = 3;
625
626pub const PR_GET_TIMING: ::c_int = 13;
627pub const PR_SET_TIMING: ::c_int = 14;
628pub const PR_TIMING_STATISTICAL: ::c_int = 0;
629pub const PR_TIMING_TIMESTAMP: ::c_int = 1;
630
631pub const PR_SET_NAME: ::c_int = 15;
632pub const PR_GET_NAME: ::c_int = 16;
633
634pub const PR_GET_ENDIAN: ::c_int = 19;
635pub const PR_SET_ENDIAN: ::c_int = 20;
636pub const PR_ENDIAN_BIG: ::c_int = 0;
637pub const PR_ENDIAN_LITTLE: ::c_int = 1;
638pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2;
639
640pub const PR_GET_SECCOMP: ::c_int = 21;
641pub const PR_SET_SECCOMP: ::c_int = 22;
642
643pub const PR_CAPBSET_READ: ::c_int = 23;
644pub const PR_CAPBSET_DROP: ::c_int = 24;
645
646pub const PR_GET_TSC: ::c_int = 25;
647pub const PR_SET_TSC: ::c_int = 26;
648pub const PR_TSC_ENABLE: ::c_int = 1;
649pub const PR_TSC_SIGSEGV: ::c_int = 2;
650
651pub const PR_GET_SECUREBITS: ::c_int = 27;
652pub const PR_SET_SECUREBITS: ::c_int = 28;
653
654pub const PR_SET_TIMERSLACK: ::c_int = 29;
655pub const PR_GET_TIMERSLACK: ::c_int = 30;
656
657pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31;
658pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32;
659
660pub const PR_MCE_KILL: ::c_int = 33;
661pub const PR_MCE_KILL_CLEAR: ::c_int = 0;
662pub const PR_MCE_KILL_SET: ::c_int = 1;
663
664pub const PR_MCE_KILL_LATE: ::c_int = 0;
665pub const PR_MCE_KILL_EARLY: ::c_int = 1;
666pub const PR_MCE_KILL_DEFAULT: ::c_int = 2;
667
668pub const PR_MCE_KILL_GET: ::c_int = 34;
669
670pub const PR_SET_MM: ::c_int = 35;
671pub const PR_SET_MM_START_CODE: ::c_int = 1;
672pub const PR_SET_MM_END_CODE: ::c_int = 2;
673pub const PR_SET_MM_START_DATA: ::c_int = 3;
674pub const PR_SET_MM_END_DATA: ::c_int = 4;
675pub const PR_SET_MM_START_STACK: ::c_int = 5;
676pub const PR_SET_MM_START_BRK: ::c_int = 6;
677pub const PR_SET_MM_BRK: ::c_int = 7;
678pub const PR_SET_MM_ARG_START: ::c_int = 8;
679pub const PR_SET_MM_ARG_END: ::c_int = 9;
680pub const PR_SET_MM_ENV_START: ::c_int = 10;
681pub const PR_SET_MM_ENV_END: ::c_int = 11;
682pub const PR_SET_MM_AUXV: ::c_int = 12;
683pub const PR_SET_MM_EXE_FILE: ::c_int = 13;
684pub const PR_SET_MM_MAP: ::c_int = 14;
685pub const PR_SET_MM_MAP_SIZE: ::c_int = 15;
686
687pub const PR_SET_PTRACER: ::c_int = 0x59616d61;
688
689pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36;
690pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37;
691
692pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38;
693pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39;
694
695pub const PR_GET_TID_ADDRESS: ::c_int = 40;
696
697pub const PR_SET_THP_DISABLE: ::c_int = 41;
698pub const PR_GET_THP_DISABLE: ::c_int = 42;
699
700pub const PR_MPX_ENABLE_MANAGEMENT: ::c_int = 43;
701pub const PR_MPX_DISABLE_MANAGEMENT: ::c_int = 44;
702
703pub const PR_SET_FP_MODE: ::c_int = 45;
704pub const PR_GET_FP_MODE: ::c_int = 46;
705pub const PR_FP_MODE_FR: ::c_int = 1 << 0;
706pub const PR_FP_MODE_FRE: ::c_int = 1 << 1;
707
708pub const PR_CAP_AMBIENT: ::c_int = 47;
709pub const PR_CAP_AMBIENT_IS_SET: ::c_int = 1;
710pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2;
711pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3;
712pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4;
713
Lee Bousfield1a066782017-05-07 15:40:21 -0600714pub const XATTR_CREATE: ::c_int = 0x1;
715pub const XATTR_REPLACE: ::c_int = 0x2;
716
Lee Bousfield98889cf2017-05-15 09:15:53 -0600717// On Linux, libc doesn't define this constant, libattr does instead.
718// We still define it for Linux as it's defined by libc on other platforms,
719// and it's mentioned in the man pages for getxattr and setxattr.
720pub const ENOATTR: ::c_int = ::ENODATA;
721
Alex Crichton8a8bc662016-02-29 23:02:36 -0800722f! {
723 pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
724 for slot in cpuset.bits.iter_mut() {
725 *slot = 0;
726 }
727 }
728
729 pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
NODA, Kaiafa77df2016-04-10 19:13:46 +0800730 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
731 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
Alex Crichton8a8bc662016-02-29 23:02:36 -0800732 cpuset.bits[idx] |= 1 << offset;
733 ()
734 }
735
Philipp Matthias Schaefer2def04a2016-08-18 21:47:08 +0200736 pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
737 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
738 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
739 cpuset.bits[idx] &= !(1 << offset);
740 ()
741 }
742
Alex Crichton8a8bc662016-02-29 23:02:36 -0800743 pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
NODA, Kaiafa77df2016-04-10 19:13:46 +0800744 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]);
745 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
Alex Crichton8a8bc662016-02-29 23:02:36 -0800746 0 != (cpuset.bits[idx] & (1 << offset))
747 }
748
749 pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
750 set1.bits == set2.bits
751 }
Steven Facklerdbdce802017-04-30 13:23:37 -0700752
753 pub fn major(dev: ::dev_t) -> ::c_uint {
754 let mut major = 0;
755 major |= (dev & 0x00000000000fff00) >> 8;
756 major |= (dev & 0xfffff00000000000) >> 32;
757 major as ::c_uint
758 }
759
760 pub fn minor(dev: ::dev_t) -> ::c_uint {
761 let mut minor = 0;
762 minor |= (dev & 0xfffff00000000000) >> 0;
763 minor |= (dev & 0x00000ffffff00000) >> 12;
764 minor as ::c_uint
765 }
766
767 pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
768 let major = major as ::dev_t;
769 let minor = minor as ::dev_t;
770 let mut dev = 0;
771 dev |= (major & 0x00000fff) << 8;
772 dev |= (major & 0xfffff000) << 32;
773 dev |= (minor & 0x000000ff) << 0;
774 dev |= (minor & 0xffffff00) << 12;
775 dev
776 }
Alex Crichton8a8bc662016-02-29 23:02:36 -0800777}
778
Raphael Cohn893d4d82016-05-08 11:40:57 +0100779extern {
Alan Somerse0ff0d62016-11-13 14:35:17 -0700780 pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
781 pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
782 pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
783 pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
784 pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
785 pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int,
786 timeout: *const ::timespec) -> ::c_int;
787 pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
788 pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb,
789 nitems: ::c_int, sevp: *mut ::sigevent) -> ::c_int;
790
knight42c2893652016-08-28 00:32:35 +0800791 pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
792
Knight19fb32a2016-07-31 17:00:15 +0800793 pub fn setpwent();
794 pub fn getpwent() -> *mut passwd;
Philipp Keller26f3eb92016-09-26 22:00:29 +0200795 pub fn setspent();
796 pub fn endspent();
797 pub fn getspent() -> *mut spwd;
798 pub fn getspnam(__name: *const ::c_char) -> *mut spwd;
799
Alex Crichton52605872015-09-15 16:49:37 -0700800 pub fn shm_open(name: *const c_char, oflag: ::c_int,
801 mode: mode_t) -> ::c_int;
Alexander Schlarb75905652016-09-17 22:17:17 +0200802
803 // System V IPC
Alexander Polakov58501562015-12-14 02:09:45 +0300804 pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
Alex Crichton8a8bc662016-02-29 23:02:36 -0800805 pub fn shmat(shmid: ::c_int,
806 shmaddr: *const ::c_void,
807 shmflg: ::c_int) -> *mut ::c_void;
Alexander Polakov58501562015-12-14 02:09:45 +0300808 pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
Alex Crichton8a8bc662016-02-29 23:02:36 -0800809 pub fn shmctl(shmid: ::c_int,
810 cmd: ::c_int,
811 buf: *mut ::shmid_ds) -> ::c_int;
Alexander Schlarb75905652016-09-17 22:17:17 +0200812 pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t;
Andrew Salmon548e4cf2017-05-26 04:35:40 -0700813 pub fn semget(key: ::key_t, nsems: ::c_int, semflag: ::c_int) -> ::c_int;
Andrew Salmon8239c0a2017-05-26 13:11:03 -0700814 pub fn semop(semid: ::c_int,
815 sops: *mut ::sembuf, nsops: ::size_t) -> ::c_int;
816 pub fn semctl(semid: ::c_int,
817 semnum: ::c_int, cmd: ::c_int, ...) -> ::c_int;
Alexander Schlarb75905652016-09-17 22:17:17 +0200818 pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) -> ::c_int;
819 pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
820 pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
821 msgtyp: ::c_long, msgflg: ::c_int) -> ::ssize_t;
822 pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t,
823 msgflg: ::c_int) -> ::c_int;
824
Alex Crichton9d5b8b22015-09-15 17:14:23 -0700825 pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
826 -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700827 pub fn __errno_location() -> *mut ::c_int;
Alex Crichton15b83c22015-09-17 17:25:52 -0700828
Alex Crichton74825222015-10-29 17:36:55 -0700829 pub fn fopen64(filename: *const c_char,
830 mode: *const c_char) -> *mut ::FILE;
831 pub fn freopen64(filename: *const c_char, mode: *const c_char,
832 file: *mut ::FILE) -> *mut ::FILE;
833 pub fn tmpfile64() -> *mut ::FILE;
834 pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
835 pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700836 pub fn fseeko64(stream: *mut ::FILE,
837 offset: ::off64_t,
838 whence: ::c_int) -> ::c_int;
839 pub fn ftello64(stream: *mut ::FILE) -> ::off64_t;
Dan Burkert0b467752015-11-03 20:58:44 -0800840 pub fn fallocate(fd: ::c_int, mode: ::c_int,
841 offset: ::off_t, len: ::off_t) -> ::c_int;
Dan Burkert44bba4c2015-11-03 21:02:46 -0800842 pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
843 len: ::off_t) -> ::c_int;
Dan Burkertfe3968f2015-11-04 22:20:29 -0800844 pub fn readahead(fd: ::c_int, offset: ::off64_t,
845 count: ::size_t) -> ::ssize_t;
Alexander Polakov30baed02015-12-01 15:29:05 +0300846 pub fn getxattr(path: *const c_char, name: *const c_char,
847 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
848 pub fn lgetxattr(path: *const c_char, name: *const c_char,
849 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
850 pub fn fgetxattr(filedes: ::c_int, name: *const c_char,
851 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
852 pub fn setxattr(path: *const c_char, name: *const c_char,
853 value: *const ::c_void, size: ::size_t,
854 flags: ::c_int) -> ::c_int;
855 pub fn lsetxattr(path: *const c_char, name: *const c_char,
856 value: *const ::c_void, size: ::size_t,
857 flags: ::c_int) -> ::c_int;
858 pub fn fsetxattr(filedes: ::c_int, name: *const c_char,
859 value: *const ::c_void, size: ::size_t,
860 flags: ::c_int) -> ::c_int;
861 pub fn listxattr(path: *const c_char, list: *mut c_char,
862 size: ::size_t) -> ::ssize_t;
863 pub fn llistxattr(path: *const c_char, list: *mut c_char,
864 size: ::size_t) -> ::ssize_t;
865 pub fn flistxattr(filedes: ::c_int, list: *mut c_char,
866 size: ::size_t) -> ::ssize_t;
867 pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int;
868 pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
869 pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800870 pub fn signalfd(fd: ::c_int,
871 mask: *const ::sigset_t,
872 flags: ::c_int) -> ::c_int;
873 pub fn pwritev(fd: ::c_int,
874 iov: *const ::iovec,
875 iovcnt: ::c_int,
876 offset: ::off_t) -> ::ssize_t;
877 pub fn preadv(fd: ::c_int,
878 iov: *const ::iovec,
879 iovcnt: ::c_int,
880 offset: ::off_t) -> ::ssize_t;
881 pub fn quotactl(cmd: ::c_int,
882 special: *const ::c_char,
883 id: ::c_int,
884 data: *mut ::c_char) -> ::c_int;
885 pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
886 pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
887 pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
888 pub fn mq_receive(mqd: ::mqd_t,
889 msg_ptr: *mut ::c_char,
890 msg_len: ::size_t,
891 msq_prio: *mut ::c_uint) -> ::ssize_t;
892 pub fn mq_send(mqd: ::mqd_t,
893 msg_ptr: *const ::c_char,
894 msg_len: ::size_t,
895 msq_prio: ::c_uint) -> ::c_int;
896 pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
897 pub fn mq_setattr(mqd: ::mqd_t,
898 newattr: *const ::mq_attr,
899 oldattr: *mut ::mq_attr) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800900 pub fn epoll_pwait(epfd: ::c_int,
901 events: *mut ::epoll_event,
902 maxevents: ::c_int,
903 timeout: ::c_int,
904 sigmask: *const ::sigset_t) -> ::c_int;
905 pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800906 pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
Kamal Marhubi511a7802016-02-15 00:40:19 -0500907 pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
Alex Crichton8a8bc662016-02-29 23:02:36 -0800908 pub fn mkostemps(template: *mut ::c_char,
909 suffixlen: ::c_int,
910 flags: ::c_int) -> ::c_int;
Philipp Matthias Schaeferc1982a42016-02-28 16:06:45 +0100911 pub fn sigtimedwait(set: *const sigset_t,
912 info: *mut siginfo_t,
913 timeout: *const ::timespec) -> ::c_int;
914 pub fn sigwaitinfo(set: *const sigset_t,
915 info: *mut siginfo_t) -> ::c_int;
Kamal Marhubi9c4af102016-02-27 14:58:43 -0500916 pub fn openpty(amaster: *mut ::c_int,
917 aslave: *mut ::c_int,
918 name: *mut ::c_char,
919 termp: *const termios,
920 winp: *const ::winsize) -> ::c_int;
921 pub fn forkpty(amaster: *mut ::c_int,
922 name: *mut ::c_char,
923 termp: *const termios,
924 winp: *const ::winsize) -> ::pid_t;
A.J. Gardner24c84f12016-03-31 20:08:03 -0500925 pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
Kamal Marhubib9750b62016-04-27 14:04:31 -0400926 pub fn getnameinfo(sa: *const ::sockaddr,
927 salen: ::socklen_t,
928 host: *mut ::c_char,
929 hostlen: ::socklen_t,
930 serv: *mut ::c_char,
931 sevlen: ::socklen_t,
932 flags: ::c_int) -> ::c_int;
Kamal Marhubi95695992016-04-27 14:29:19 -0400933 pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit,
934 old_limit: *mut ::rlimit) -> ::c_int;
935 pub fn prlimit64(pid: ::pid_t,
936 resource: ::c_int,
937 new_limit: *const ::rlimit64,
938 old_limit: *mut ::rlimit64) -> ::c_int;
Raphael Cohn72f1fb62016-05-11 18:06:14 +0100939 pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
Julia Evansc9496fe2016-05-11 08:44:27 -0400940 pub fn process_vm_readv(pid: ::pid_t,
941 local_iov: *const ::iovec,
942 liovcnt: ::c_ulong,
943 remote_iov: *const ::iovec,
944 riovcnt: ::c_ulong,
945 flags: ::c_ulong) -> isize;
946 pub fn process_vm_writev(pid: ::pid_t,
947 local_iov: *const ::iovec,
948 liovcnt: ::c_ulong,
949 remote_iov: *const ::iovec,
950 riovcnt: ::c_ulong,
951 flags: ::c_ulong) -> isize;
Sergey Bugaev8b767972016-07-12 20:56:43 +0300952 pub fn reboot(how_to: ::c_int) -> ::c_int;
Boris Faure28d0afa2016-11-05 21:19:53 +0100953 pub fn setfsgid(gid: ::gid_t) -> ::c_int;
954 pub fn setfsuid(uid: ::uid_t) -> ::c_int;
Dylan Reid519ffa02016-10-21 16:05:01 -0700955 pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
956 pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
Axel Viala26ee7822016-06-10 02:33:32 +0200957
958 // Not available now on Android
959 pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
960 mode: ::mode_t) -> ::c_int;
Charles J. Schneider332bd862016-07-12 09:32:42 +0200961 pub fn if_nameindex() -> *mut if_nameindex;
962 pub fn if_freenameindex(ptr: *mut if_nameindex);
Chris Kaminski37552b72016-09-06 20:20:00 -0400963 pub fn sync_file_range(fd: ::c_int, offset: ::off64_t,
964 nbytes: ::off64_t, flags: ::c_uint) -> ::c_int;
Niels Sascha Reedijka3ff9552016-02-02 21:21:36 +0100965 pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
966 pub fn freeifaddrs(ifa: *mut ::ifaddrs);
sankaku545f67d2016-12-27 18:40:18 -0500967
968 pub fn mremap(addr: *mut ::c_void,
969 len: ::size_t,
970 new_len: ::size_t,
971 flags: ::c_int,
972 ...) -> *mut ::c_void;
Marco A L Barbosafab2d302017-02-27 16:41:57 -0300973
974 pub fn glob(pattern: *const c_char,
975 flags: ::c_int,
976 errfunc: Option<extern fn(epath: *const c_char,
977 errno: ::c_int) -> ::c_int>,
Marco A L Barbosaa3759d72017-02-27 17:25:55 -0300978 pglob: *mut ::glob_t) -> ::c_int;
979 pub fn globfree(pglob: *mut ::glob_t);
Marco A L Barbosafab2d302017-02-27 16:41:57 -0300980
981 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
982 -> ::c_int;
983
Marco A L Barbosaa3759d72017-02-27 17:25:55 -0300984 pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
Marco A L Barbosafab2d302017-02-27 16:41:57 -0300985
Marco A L Barbosaa3759d72017-02-27 17:25:55 -0300986 pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
Marco A L Barbosafab2d302017-02-27 16:41:57 -0300987
Marco A L Barbosaa3759d72017-02-27 17:25:55 -0300988 pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
Marco A L Barbosafab2d302017-02-27 16:41:57 -0300989 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
990 -> ::c_int;
991
992 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
993
994 pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
Marco A L Barbosaa3759d72017-02-27 17:25:55 -0300995 flags: ::c_int, addr: *mut ::sockaddr,
996 addrlen: *mut ::socklen_t) -> ::ssize_t;
Marco A L Barbosafab2d302017-02-27 16:41:57 -0300997 pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
998 pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
999 pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
1000
Marco A L Barbosaa3759d72017-02-27 17:25:55 -03001001 pub fn bind(socket: ::c_int, address: *const ::sockaddr,
1002 address_len: ::socklen_t) -> ::c_int;
Marco A L Barbosafab2d302017-02-27 16:41:57 -03001003
1004 pub fn writev(fd: ::c_int,
1005 iov: *const ::iovec,
1006 iovcnt: ::c_int) -> ::ssize_t;
1007 pub fn readv(fd: ::c_int,
1008 iov: *const ::iovec,
1009 iovcnt: ::c_int) -> ::ssize_t;
1010
1011 pub fn sendmsg(fd: ::c_int,
Marco A L Barbosaa3759d72017-02-27 17:25:55 -03001012 msg: *const ::msghdr,
Marco A L Barbosafab2d302017-02-27 16:41:57 -03001013 flags: ::c_int) -> ::ssize_t;
Marco A L Barbosa9a20f932017-02-27 17:54:51 -03001014 pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
1015 -> ::ssize_t;
Alex Crichton50a42e22015-09-15 14:27:15 -07001016}
1017
NODA, Kai61c23fb2016-04-10 22:21:55 +08001018extern {
1019 pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
1020 flags: ::c_int) -> ::c_int;
1021 pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
1022 flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
1023}
1024
Alex Crichton50a42e22015-09-15 14:27:15 -07001025cfg_if! {
Brian Anderson7d1d5752015-11-26 23:27:45 +00001026 if #[cfg(any(target_env = "musl",
Raph Levien517e86d2016-10-11 15:26:47 -07001027 target_os = "fuchsia",
Brian Anderson7d1d5752015-11-26 23:27:45 +00001028 target_os = "emscripten"))] {
Alex Crichton74825222015-10-29 17:36:55 -07001029 mod musl;
1030 pub use self::musl::*;
Wang Xuerui6b729902016-11-14 22:40:05 +08001031 } else if #[cfg(any(target_arch = "mips",
1032 target_arch = "mips64"))] {
Alex Crichton50a42e22015-09-15 14:27:15 -07001033 mod mips;
1034 pub use self::mips::*;
Jorge Aparicioe7480ed2016-09-02 21:08:02 -05001035 } else if #[cfg(any(target_arch = "s390x"))] {
1036 mod s390x;
1037 pub use self::s390x::*;
Alex Crichton50a42e22015-09-15 14:27:15 -07001038 } else {
Alex Crichton62a6c822015-11-09 13:58:44 -08001039 mod other;
1040 pub use self::other::*;
Alex Crichton50a42e22015-09-15 14:27:15 -07001041 }
1042}