blob: 46ed80712e769d4bb7592a8da696c8117d55a158 [file] [log] [blame]
Alex Crichton50a42e22015-09-15 14:27:15 -07001//! Linux-specific definitions for linux-like values
2
Peter Jin1a190c72016-02-05 15:06:39 -08003use dox::mem;
4
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;
Alex Crichton74825222015-10-29 17:36:55 -070020
21pub enum fpos64_t {} // TODO: fill this out with a struct
Alex Crichton918f8e12015-09-15 16:39:51 -070022
Alex Crichton50a42e22015-09-15 14:27:15 -070023s! {
Alex Crichtond6e07e22015-10-29 22:59:44 -070024 pub struct dirent {
25 pub d_ino: ::ino_t,
26 pub d_off: ::off_t,
27 pub d_reclen: ::c_ushort,
28 pub d_type: ::c_uchar,
29 pub d_name: [::c_char; 256],
30 }
31
Alex Crichton74825222015-10-29 17:36:55 -070032 pub struct dirent64 {
33 pub d_ino: ::ino64_t,
34 pub d_off: ::off64_t,
35 pub d_reclen: ::c_ushort,
36 pub d_type: ::c_uchar,
37 pub d_name: [::c_char; 256],
38 }
39
40 pub struct rlimit64 {
41 pub rlim_cur: rlim64_t,
42 pub rlim_max: rlim64_t,
43 }
44
Alex Crichton50a42e22015-09-15 14:27:15 -070045 pub struct glob_t {
Alex Crichton17910462015-09-22 19:11:04 -070046 pub gl_pathc: ::size_t,
Alex Crichton50a42e22015-09-15 14:27:15 -070047 pub gl_pathv: *mut *mut c_char,
Alex Crichton17910462015-09-22 19:11:04 -070048 pub gl_offs: ::size_t,
Alex Crichton52605872015-09-15 16:49:37 -070049 pub gl_flags: ::c_int,
Alex Crichton50a42e22015-09-15 14:27:15 -070050
51 __unused1: *mut ::c_void,
52 __unused2: *mut ::c_void,
53 __unused3: *mut ::c_void,
54 __unused4: *mut ::c_void,
55 __unused5: *mut ::c_void,
56 }
57
58 pub struct ifaddrs {
59 pub ifa_next: *mut ifaddrs,
60 pub ifa_name: *mut c_char,
Alex Crichton52605872015-09-15 16:49:37 -070061 pub ifa_flags: ::c_uint,
Alex Crichton50a42e22015-09-15 14:27:15 -070062 pub ifa_addr: *mut ::sockaddr,
63 pub ifa_netmask: *mut ::sockaddr,
64 pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union
65 pub ifa_data: *mut ::c_void
66 }
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070067
68 pub struct pthread_mutex_t {
69 #[cfg(any(target_arch = "mips", target_arch = "mipsel",
Alex Crichton8018a502016-08-26 22:54:58 -070070 target_arch = "arm", target_arch = "powerpc"))]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070071 __align: [::c_long; 0],
72 #[cfg(not(any(target_arch = "mips", target_arch = "mipsel",
Alex Crichton8018a502016-08-26 22:54:58 -070073 target_arch = "arm", target_arch = "powerpc")))]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070074 __align: [::c_longlong; 0],
75 size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
76 }
77
78 pub struct pthread_rwlock_t {
79 #[cfg(any(target_arch = "mips", target_arch = "mipsel",
Alex Crichton8018a502016-08-26 22:54:58 -070080 target_arch = "arm", target_arch = "powerpc"))]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070081 __align: [::c_long; 0],
82 #[cfg(not(any(target_arch = "mips", target_arch = "mipsel",
Alex Crichton8018a502016-08-26 22:54:58 -070083 target_arch = "arm", target_arch = "powerpc")))]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070084 __align: [::c_longlong; 0],
85 size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
86 }
87
88 pub struct pthread_mutexattr_t {
Jorge Aparicio196b0e82016-08-26 22:30:42 -050089 #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64",
Jorge Aparicioe7480ed2016-09-02 21:08:02 -050090 target_arch = "mips64", target_arch = "s390x"))]
Alex Crichtonb347b442015-09-17 15:48:30 -070091 __align: [::c_int; 0],
Jorge Aparicio196b0e82016-08-26 22:30:42 -050092 #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64",
Jorge Aparicioe7480ed2016-09-02 21:08:02 -050093 target_arch = "mips64", target_arch = "s390x")))]
Alex Crichton684cfa42015-09-17 15:18:18 -070094 __align: [::c_long; 0],
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070095 size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
96 }
97
98 pub struct pthread_cond_t {
Jorge Aparicio23a50922016-07-26 16:13:03 -050099 #[cfg(any(target_env = "musl"))]
Jorge Aparicio751bea32016-01-30 01:28:50 -0500100 __align: [*const ::c_void; 0],
Jorge Aparicio23a50922016-07-26 16:13:03 -0500101 #[cfg(not(any(target_env = "musl")))]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700102 __align: [::c_longlong; 0],
103 size: [u8; __SIZEOF_PTHREAD_COND_T],
104 }
105
Tomasz MiÄ…skocb644852016-07-20 07:31:48 +0200106 pub struct pthread_condattr_t {
107 __align: [::c_int; 0],
108 size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
109 }
110
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700111 pub struct passwd {
112 pub pw_name: *mut ::c_char,
113 pub pw_passwd: *mut ::c_char,
114 pub pw_uid: ::uid_t,
115 pub pw_gid: ::gid_t,
116 pub pw_gecos: *mut ::c_char,
117 pub pw_dir: *mut ::c_char,
118 pub pw_shell: *mut ::c_char,
119 }
Dan Burkert85a76f82015-11-04 20:26:27 -0800120
Philipp Keller26f3eb92016-09-26 22:00:29 +0200121 pub struct spwd {
122 pub sp_namp: *mut ::c_char,
123 pub sp_pwdp: *mut ::c_char,
124 pub sp_lstchg: ::c_long,
125 pub sp_min: ::c_long,
126 pub sp_max: ::c_long,
127 pub sp_warn: ::c_long,
128 pub sp_inact: ::c_long,
129 pub sp_expire: ::c_long,
130 pub sp_flag: ::c_ulong,
131 }
132
Dan Burkert85a76f82015-11-04 20:26:27 -0800133 pub struct statvfs {
134 pub f_bsize: ::c_ulong,
135 pub f_frsize: ::c_ulong,
136 pub f_blocks: ::fsblkcnt_t,
137 pub f_bfree: ::fsblkcnt_t,
138 pub f_bavail: ::fsblkcnt_t,
139 pub f_files: ::fsfilcnt_t,
140 pub f_ffree: ::fsfilcnt_t,
141 pub f_favail: ::fsfilcnt_t,
Jorge Aparicio3df00572016-09-11 23:57:37 -0500142 #[cfg(target_endian = "little")]
Dan Burkert85a76f82015-11-04 20:26:27 -0800143 pub f_fsid: ::c_ulong,
144 #[cfg(target_pointer_width = "32")]
Jorge Aparicio41101f22016-09-12 23:41:17 -0500145 __f_unused: ::c_int,
Jorge Aparicio3df00572016-09-11 23:57:37 -0500146 #[cfg(target_endian = "big")]
147 pub f_fsid: ::c_ulong,
Dan Burkert85a76f82015-11-04 20:26:27 -0800148 pub f_flag: ::c_ulong,
149 pub f_namemax: ::c_ulong,
150 __f_spare: [::c_int; 6],
151 }
Alexander Polakov440bd532015-11-07 15:42:38 +0300152
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800153 pub struct dqblk {
154 pub dqb_bhardlimit: ::uint64_t,
155 pub dqb_bsoftlimit: ::uint64_t,
156 pub dqb_curspace: ::uint64_t,
157 pub dqb_ihardlimit: ::uint64_t,
158 pub dqb_isoftlimit: ::uint64_t,
159 pub dqb_curinodes: ::uint64_t,
160 pub dqb_btime: ::uint64_t,
161 pub dqb_itime: ::uint64_t,
162 pub dqb_valid: ::uint32_t,
163 }
164
165 pub struct signalfd_siginfo {
166 pub ssi_signo: ::uint32_t,
167 pub ssi_errno: ::int32_t,
168 pub ssi_code: ::int32_t,
169 pub ssi_pid: ::uint32_t,
170 pub ssi_uid: ::uint32_t,
171 pub ssi_fd: ::int32_t,
172 pub ssi_tid: ::uint32_t,
173 pub ssi_band: ::uint32_t,
174 pub ssi_overrun: ::uint32_t,
175 pub ssi_trapno: ::uint32_t,
176 pub ssi_status: ::int32_t,
177 pub ssi_int: ::int32_t,
178 pub ssi_ptr: ::uint64_t,
179 pub ssi_utime: ::uint64_t,
180 pub ssi_stime: ::uint64_t,
181 pub ssi_addr: ::uint64_t,
182 _pad: [::uint8_t; 48],
183 }
184
185 pub struct fsid_t {
186 __val: [::c_int; 2],
187 }
188
189 pub struct mq_attr {
190 pub mq_flags: ::c_long,
191 pub mq_maxmsg: ::c_long,
192 pub mq_msgsize: ::c_long,
193 pub mq_curmsgs: ::c_long,
194 pad: [::c_long; 4]
195 }
196
197 pub struct cpu_set_t {
198 #[cfg(target_pointer_width = "32")]
199 bits: [u32; 32],
200 #[cfg(target_pointer_width = "64")]
201 bits: [u64; 16],
202 }
Charles J. Schneider332bd862016-07-12 09:32:42 +0200203
204 pub struct if_nameindex {
205 pub if_index: ::c_uint,
206 pub if_name: *mut ::c_char,
207 }
208
Alexander Schlarb75905652016-09-17 22:17:17 +0200209 // System V IPC
210 pub struct msginfo {
211 pub msgpool: ::c_int,
212 pub msgmap: ::c_int,
213 pub msgmax: ::c_int,
214 pub msgmnb: ::c_int,
215 pub msgmni: ::c_int,
216 pub msgssz: ::c_int,
217 pub msgtql: ::c_int,
218 pub msgseg: ::c_ushort,
219 }
Alex Crichton50a42e22015-09-15 14:27:15 -0700220}
221
A.J. Gardner24c84f12016-03-31 20:08:03 -0500222pub const ABDAY_1: ::nl_item = 0x20000;
223pub const ABDAY_2: ::nl_item = 0x20001;
224pub const ABDAY_3: ::nl_item = 0x20002;
225pub const ABDAY_4: ::nl_item = 0x20003;
226pub const ABDAY_5: ::nl_item = 0x20004;
227pub const ABDAY_6: ::nl_item = 0x20005;
228pub const ABDAY_7: ::nl_item = 0x20006;
229
230pub const DAY_1: ::nl_item = 0x20007;
231pub const DAY_2: ::nl_item = 0x20008;
232pub const DAY_3: ::nl_item = 0x20009;
233pub const DAY_4: ::nl_item = 0x2000A;
234pub const DAY_5: ::nl_item = 0x2000B;
235pub const DAY_6: ::nl_item = 0x2000C;
236pub const DAY_7: ::nl_item = 0x2000D;
237
238pub const ABMON_1: ::nl_item = 0x2000E;
239pub const ABMON_2: ::nl_item = 0x2000F;
240pub const ABMON_3: ::nl_item = 0x20010;
241pub const ABMON_4: ::nl_item = 0x20011;
242pub const ABMON_5: ::nl_item = 0x20012;
243pub const ABMON_6: ::nl_item = 0x20013;
244pub const ABMON_7: ::nl_item = 0x20014;
245pub const ABMON_8: ::nl_item = 0x20015;
246pub const ABMON_9: ::nl_item = 0x20016;
247pub const ABMON_10: ::nl_item = 0x20017;
248pub const ABMON_11: ::nl_item = 0x20018;
249pub const ABMON_12: ::nl_item = 0x20019;
250
Ian Denhardt2faafb32016-10-02 15:02:28 -0400251pub const CLONE_NEWCGROUP: ::c_int = 0x02000000;
252
A.J. Gardner24c84f12016-03-31 20:08:03 -0500253pub const MON_1: ::nl_item = 0x2001A;
254pub const MON_2: ::nl_item = 0x2001B;
255pub const MON_3: ::nl_item = 0x2001C;
256pub const MON_4: ::nl_item = 0x2001D;
257pub const MON_5: ::nl_item = 0x2001E;
258pub const MON_6: ::nl_item = 0x2001F;
259pub const MON_7: ::nl_item = 0x20020;
260pub const MON_8: ::nl_item = 0x20021;
261pub const MON_9: ::nl_item = 0x20022;
262pub const MON_10: ::nl_item = 0x20023;
263pub const MON_11: ::nl_item = 0x20024;
264pub const MON_12: ::nl_item = 0x20025;
265
266pub const AM_STR: ::nl_item = 0x20026;
267pub const PM_STR: ::nl_item = 0x20027;
268
269pub const D_T_FMT: ::nl_item = 0x20028;
270pub const D_FMT: ::nl_item = 0x20029;
271pub const T_FMT: ::nl_item = 0x2002A;
272pub const T_FMT_AMPM: ::nl_item = 0x2002B;
273
274pub const ERA: ::nl_item = 0x2002C;
275pub const ERA_D_FMT: ::nl_item = 0x2002E;
276pub const ALT_DIGITS: ::nl_item = 0x2002F;
277pub const ERA_D_T_FMT: ::nl_item = 0x20030;
278pub const ERA_T_FMT: ::nl_item = 0x20031;
279
280pub const CODESET: ::nl_item = 14;
281
282pub const CRNCYSTR: ::nl_item = 0x4000F;
283
284pub const RADIXCHAR: ::nl_item = 0x10000;
285pub const THOUSEP: ::nl_item = 0x10001;
286
287pub const YESEXPR: ::nl_item = 0x50000;
288pub const NOEXPR: ::nl_item = 0x50001;
289pub const YESSTR: ::nl_item = 0x50002;
290pub const NOSTR: ::nl_item = 0x50003;
291
Alex Crichton52605872015-09-15 16:49:37 -0700292pub const FILENAME_MAX: ::c_uint = 4096;
Alex Crichton52605872015-09-15 16:49:37 -0700293pub const L_tmpnam: ::c_uint = 20;
Philipp Keller2cad6ca2016-07-06 21:15:38 +0200294pub const _PC_LINK_MAX: ::c_int = 0;
295pub const _PC_MAX_CANON: ::c_int = 1;
296pub const _PC_MAX_INPUT: ::c_int = 2;
Alex Crichton52605872015-09-15 16:49:37 -0700297pub const _PC_NAME_MAX: ::c_int = 3;
Philipp Keller2cad6ca2016-07-06 21:15:38 +0200298pub const _PC_PATH_MAX: ::c_int = 4;
299pub const _PC_PIPE_BUF: ::c_int = 5;
300pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
301pub const _PC_NO_TRUNC: ::c_int = 7;
302pub const _PC_VDISABLE: ::c_int = 8;
Alex Crichton50a42e22015-09-15 14:27:15 -0700303
Alex Crichton52605872015-09-15 16:49:37 -0700304pub const _SC_ARG_MAX: ::c_int = 0;
305pub const _SC_CHILD_MAX: ::c_int = 1;
306pub const _SC_CLK_TCK: ::c_int = 2;
307pub const _SC_NGROUPS_MAX: ::c_int = 3;
308pub const _SC_OPEN_MAX: ::c_int = 4;
309pub const _SC_STREAM_MAX: ::c_int = 5;
310pub const _SC_TZNAME_MAX: ::c_int = 6;
311pub const _SC_JOB_CONTROL: ::c_int = 7;
312pub const _SC_SAVED_IDS: ::c_int = 8;
313pub const _SC_REALTIME_SIGNALS: ::c_int = 9;
314pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10;
315pub const _SC_TIMERS: ::c_int = 11;
316pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12;
317pub const _SC_PRIORITIZED_IO: ::c_int = 13;
318pub const _SC_SYNCHRONIZED_IO: ::c_int = 14;
319pub const _SC_FSYNC: ::c_int = 15;
320pub const _SC_MAPPED_FILES: ::c_int = 16;
321pub const _SC_MEMLOCK: ::c_int = 17;
322pub const _SC_MEMLOCK_RANGE: ::c_int = 18;
323pub const _SC_MEMORY_PROTECTION: ::c_int = 19;
324pub const _SC_MESSAGE_PASSING: ::c_int = 20;
325pub const _SC_SEMAPHORES: ::c_int = 21;
326pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22;
327pub const _SC_AIO_LISTIO_MAX: ::c_int = 23;
328pub const _SC_AIO_MAX: ::c_int = 24;
329pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25;
330pub const _SC_DELAYTIMER_MAX: ::c_int = 26;
331pub const _SC_MQ_OPEN_MAX: ::c_int = 27;
332pub const _SC_MQ_PRIO_MAX: ::c_int = 28;
333pub const _SC_VERSION: ::c_int = 29;
334pub const _SC_PAGESIZE: ::c_int = 30;
Brian Campbell11f29f52016-01-31 21:28:16 -0500335pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
Alex Crichton52605872015-09-15 16:49:37 -0700336pub const _SC_RTSIG_MAX: ::c_int = 31;
337pub const _SC_SEM_NSEMS_MAX: ::c_int = 32;
338pub const _SC_SEM_VALUE_MAX: ::c_int = 33;
339pub const _SC_SIGQUEUE_MAX: ::c_int = 34;
340pub const _SC_TIMER_MAX: ::c_int = 35;
341pub const _SC_BC_BASE_MAX: ::c_int = 36;
342pub const _SC_BC_DIM_MAX: ::c_int = 37;
343pub const _SC_BC_SCALE_MAX: ::c_int = 38;
344pub const _SC_BC_STRING_MAX: ::c_int = 39;
345pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40;
346pub const _SC_EXPR_NEST_MAX: ::c_int = 42;
347pub const _SC_LINE_MAX: ::c_int = 43;
348pub const _SC_RE_DUP_MAX: ::c_int = 44;
349pub const _SC_2_VERSION: ::c_int = 46;
350pub const _SC_2_C_BIND: ::c_int = 47;
351pub const _SC_2_C_DEV: ::c_int = 48;
352pub const _SC_2_FORT_DEV: ::c_int = 49;
353pub const _SC_2_FORT_RUN: ::c_int = 50;
354pub const _SC_2_SW_DEV: ::c_int = 51;
355pub const _SC_2_LOCALEDEF: ::c_int = 52;
356pub const _SC_IOV_MAX: ::c_int = 60;
357pub const _SC_THREADS: ::c_int = 67;
358pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68;
359pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69;
360pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70;
361pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
362pub const _SC_TTY_NAME_MAX: ::c_int = 72;
363pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73;
364pub const _SC_THREAD_KEYS_MAX: ::c_int = 74;
365pub const _SC_THREAD_STACK_MIN: ::c_int = 75;
366pub const _SC_THREAD_THREADS_MAX: ::c_int = 76;
367pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
368pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
369pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79;
370pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80;
371pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81;
372pub const _SC_NPROCESSORS_ONLN: ::c_int = 84;
373pub const _SC_ATEXIT_MAX: ::c_int = 87;
374pub const _SC_XOPEN_VERSION: ::c_int = 89;
375pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90;
376pub const _SC_XOPEN_UNIX: ::c_int = 91;
377pub const _SC_XOPEN_CRYPT: ::c_int = 92;
378pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
379pub const _SC_XOPEN_SHM: ::c_int = 94;
380pub const _SC_2_CHAR_TERM: ::c_int = 95;
Alex Crichton52605872015-09-15 16:49:37 -0700381pub const _SC_2_UPE: ::c_int = 97;
382pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
383pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
384pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128;
385pub const _SC_XOPEN_LEGACY: ::c_int = 129;
386pub const _SC_XOPEN_REALTIME: ::c_int = 130;
387pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
Raphael Cohnf3651112016-05-04 10:35:08 +0100388pub const _SC_HOST_NAME_MAX: ::c_int = 180;
Alex Crichton50a42e22015-09-15 14:27:15 -0700389
390pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
391pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
392
Alex Crichton52605872015-09-15 16:49:37 -0700393pub const GLOB_ERR: ::c_int = 1 << 0;
394pub const GLOB_MARK: ::c_int = 1 << 1;
395pub const GLOB_NOSORT: ::c_int = 1 << 2;
396pub const GLOB_DOOFFS: ::c_int = 1 << 3;
397pub const GLOB_NOCHECK: ::c_int = 1 << 4;
398pub const GLOB_APPEND: ::c_int = 1 << 5;
399pub const GLOB_NOESCAPE: ::c_int = 1 << 6;
Alex Crichton50a42e22015-09-15 14:27:15 -0700400
Alex Crichton52605872015-09-15 16:49:37 -0700401pub const GLOB_NOSPACE: ::c_int = 1;
402pub const GLOB_ABORTED: ::c_int = 2;
403pub const GLOB_NOMATCH: ::c_int = 3;
Alex Crichton50a42e22015-09-15 14:27:15 -0700404
Alex Crichton52605872015-09-15 16:49:37 -0700405pub const POSIX_MADV_NORMAL: ::c_int = 0;
406pub const POSIX_MADV_RANDOM: ::c_int = 1;
407pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
408pub const POSIX_MADV_WILLNEED: ::c_int = 3;
Alex Crichton50a42e22015-09-15 14:27:15 -0700409
410pub const S_IEXEC: mode_t = 64;
411pub const S_IWRITE: mode_t = 128;
412pub const S_IREAD: mode_t = 256;
413
Alex Crichton52605872015-09-15 16:49:37 -0700414pub const F_LOCK: ::c_int = 1;
415pub const F_TEST: ::c_int = 3;
416pub const F_TLOCK: ::c_int = 2;
417pub const F_ULOCK: ::c_int = 0;
Alex Crichton50a42e22015-09-15 14:27:15 -0700418
Dan Burkert85a76f82015-11-04 20:26:27 -0800419pub const ST_RDONLY: ::c_ulong = 1;
420pub const ST_NOSUID: ::c_ulong = 2;
421pub const ST_NODEV: ::c_ulong = 4;
422pub const ST_NOEXEC: ::c_ulong = 8;
423pub const ST_SYNCHRONOUS: ::c_ulong = 16;
424pub const ST_MANDLOCK: ::c_ulong = 64;
425pub const ST_WRITE: ::c_ulong = 128;
426pub const ST_APPEND: ::c_ulong = 256;
427pub const ST_IMMUTABLE: ::c_ulong = 512;
428pub const ST_NOATIME: ::c_ulong = 1024;
429pub const ST_NODIRATIME: ::c_ulong = 2048;
430
Dong Zhou188bef62015-11-29 22:24:10 -0500431pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
432pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
Alex Crichton29de5982016-02-04 13:48:13 -0800433pub const RTLD_NODELETE: ::c_int = 0x1000;
434pub const RTLD_NOW: ::c_int = 0x2;
Dong Zhou51ed5742015-11-29 21:42:14 -0500435
Alex Crichton52605872015-09-15 16:49:37 -0700436pub const TCP_MD5SIG: ::c_int = 14;
Alex Crichton50a42e22015-09-15 14:27:15 -0700437
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700438pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
439 __align: [],
440 size: [0; __SIZEOF_PTHREAD_MUTEX_T],
441};
442pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
443 __align: [],
444 size: [0; __SIZEOF_PTHREAD_COND_T],
445};
446pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
447 __align: [],
448 size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
449};
Amanieu d'Antrasb2b9f292016-05-21 06:40:14 +0100450pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700451pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
Amanieu d'Antrasb2b9f292016-05-21 06:40:14 +0100452pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
453pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700454pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700455
Alexander Polakov26974c72015-11-27 03:02:44 +0300456pub const SCHED_OTHER: ::c_int = 0;
457pub const SCHED_FIFO: ::c_int = 1;
458pub const SCHED_RR: ::c_int = 2;
459pub const SCHED_BATCH: ::c_int = 3;
460pub const SCHED_IDLE: ::c_int = 5;
461
Alexander Schlarb75905652016-09-17 22:17:17 +0200462// System V IPC
463pub const IPC_PRIVATE: ::key_t = 0;
464
Alexander Polakov58501562015-12-14 02:09:45 +0300465pub const IPC_CREAT: ::c_int = 0o1000;
466pub const IPC_EXCL: ::c_int = 0o2000;
467pub const IPC_NOWAIT: ::c_int = 0o4000;
468
469pub const IPC_RMID: ::c_int = 0;
470pub const IPC_SET: ::c_int = 1;
471pub const IPC_STAT: ::c_int = 2;
472pub const IPC_INFO: ::c_int = 3;
Alexander Schlarb75905652016-09-17 22:17:17 +0200473pub const MSG_STAT: ::c_int = 11;
474pub const MSG_INFO: ::c_int = 12;
475
476pub const MSG_NOERROR: ::c_int = 0o10000;
477pub const MSG_EXCEPT: ::c_int = 0o20000;
478pub const MSG_COPY: ::c_int = 0o40000;
Alexander Polakov58501562015-12-14 02:09:45 +0300479
480pub const SHM_R: ::c_int = 0o400;
481pub const SHM_W: ::c_int = 0o200;
482
483pub const SHM_RDONLY: ::c_int = 0o10000;
484pub const SHM_RND: ::c_int = 0o20000;
485pub const SHM_REMAP: ::c_int = 0o40000;
486pub const SHM_EXEC: ::c_int = 0o100000;
487
488pub const SHM_LOCK: ::c_int = 11;
489pub const SHM_UNLOCK: ::c_int = 12;
490
491pub const SHM_HUGETLB: ::c_int = 0o4000;
492pub const SHM_NORESERVE: ::c_int = 0o10000;
493
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800494pub const EPOLLRDHUP: ::c_int = 0x2000;
495pub const EPOLLONESHOT: ::c_int = 0x40000000;
496
497pub const QFMT_VFS_OLD: ::c_int = 1;
498pub const QFMT_VFS_V0: ::c_int = 2;
499
500pub const SFD_CLOEXEC: ::c_int = 0x080000;
501
502pub const EFD_SEMAPHORE: ::c_int = 0x1;
503
504pub const NCCS: usize = 32;
505
Alex Crichton8a8bc662016-02-29 23:02:36 -0800506pub const AF_NETLINK: ::c_int = 16;
507
Raphael Cohn1c6c0ca2016-05-05 17:45:29 +0100508pub const LOG_NFACILITIES: ::c_int = 24;
509
Steven Fackler41699f72016-06-03 21:02:56 -0700510pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t;
511
Philipp Matthias Schaefer5a68b6a2016-07-15 23:19:00 +0200512pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32;
513pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32;
514pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32;
515pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32;
516pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32;
517pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32;
518pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32;
Sergey Bugaev5d65c3f2016-07-12 20:55:08 +0300519
Chris Kaminskiae6cbcd2016-09-07 13:15:49 -0400520pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1;
521pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2;
522pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4;
Chris Kaminski37552b72016-09-06 20:20:00 -0400523
Tomasz MiÄ…skof514d462016-09-19 12:29:45 +0200524pub const EAI_SYSTEM: ::c_int = -11;
525
Alex Crichton8a8bc662016-02-29 23:02:36 -0800526f! {
527 pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
528 for slot in cpuset.bits.iter_mut() {
529 *slot = 0;
530 }
531 }
532
533 pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
NODA, Kaiafa77df2016-04-10 19:13:46 +0800534 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
535 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
Alex Crichton8a8bc662016-02-29 23:02:36 -0800536 cpuset.bits[idx] |= 1 << offset;
537 ()
538 }
539
Philipp Matthias Schaefer2def04a2016-08-18 21:47:08 +0200540 pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
541 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
542 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
543 cpuset.bits[idx] &= !(1 << offset);
544 ()
545 }
546
Alex Crichton8a8bc662016-02-29 23:02:36 -0800547 pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
NODA, Kaiafa77df2016-04-10 19:13:46 +0800548 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]);
549 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
Alex Crichton8a8bc662016-02-29 23:02:36 -0800550 0 != (cpuset.bits[idx] & (1 << offset))
551 }
552
553 pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
554 set1.bits == set2.bits
555 }
556}
557
Raphael Cohn893d4d82016-05-08 11:40:57 +0100558extern {
knight42c2893652016-08-28 00:32:35 +0800559 pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
560
Knight19fb32a2016-07-31 17:00:15 +0800561 pub fn setpwent();
562 pub fn getpwent() -> *mut passwd;
Philipp Keller26f3eb92016-09-26 22:00:29 +0200563 pub fn setspent();
564 pub fn endspent();
565 pub fn getspent() -> *mut spwd;
566 pub fn getspnam(__name: *const ::c_char) -> *mut spwd;
567
Alex Crichton52605872015-09-15 16:49:37 -0700568 pub fn shm_open(name: *const c_char, oflag: ::c_int,
569 mode: mode_t) -> ::c_int;
Alexander Schlarb75905652016-09-17 22:17:17 +0200570
571 // System V IPC
Alexander Polakov58501562015-12-14 02:09:45 +0300572 pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
Alex Crichton8a8bc662016-02-29 23:02:36 -0800573 pub fn shmat(shmid: ::c_int,
574 shmaddr: *const ::c_void,
575 shmflg: ::c_int) -> *mut ::c_void;
Alexander Polakov58501562015-12-14 02:09:45 +0300576 pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
Alex Crichton8a8bc662016-02-29 23:02:36 -0800577 pub fn shmctl(shmid: ::c_int,
578 cmd: ::c_int,
579 buf: *mut ::shmid_ds) -> ::c_int;
Alexander Schlarb75905652016-09-17 22:17:17 +0200580 pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t;
581 pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) -> ::c_int;
582 pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
583 pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
584 msgtyp: ::c_long, msgflg: ::c_int) -> ::ssize_t;
585 pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t,
586 msgflg: ::c_int) -> ::c_int;
587
Alex Crichton9d5b8b22015-09-15 17:14:23 -0700588 pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
589 -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700590 pub fn __errno_location() -> *mut ::c_int;
Alex Crichton15b83c22015-09-17 17:25:52 -0700591
Alex Crichton74825222015-10-29 17:36:55 -0700592 pub fn fopen64(filename: *const c_char,
593 mode: *const c_char) -> *mut ::FILE;
594 pub fn freopen64(filename: *const c_char, mode: *const c_char,
595 file: *mut ::FILE) -> *mut ::FILE;
596 pub fn tmpfile64() -> *mut ::FILE;
597 pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
598 pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700599 pub fn fseeko64(stream: *mut ::FILE,
600 offset: ::off64_t,
601 whence: ::c_int) -> ::c_int;
602 pub fn ftello64(stream: *mut ::FILE) -> ::off64_t;
Dan Burkert0b467752015-11-03 20:58:44 -0800603 pub fn fallocate(fd: ::c_int, mode: ::c_int,
604 offset: ::off_t, len: ::off_t) -> ::c_int;
Dan Burkert44bba4c2015-11-03 21:02:46 -0800605 pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
606 len: ::off_t) -> ::c_int;
Dan Burkertfe3968f2015-11-04 22:20:29 -0800607 pub fn readahead(fd: ::c_int, offset: ::off64_t,
608 count: ::size_t) -> ::ssize_t;
Alexander Polakov30baed02015-12-01 15:29:05 +0300609 pub fn getxattr(path: *const c_char, name: *const c_char,
610 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
611 pub fn lgetxattr(path: *const c_char, name: *const c_char,
612 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
613 pub fn fgetxattr(filedes: ::c_int, name: *const c_char,
614 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
615 pub fn setxattr(path: *const c_char, name: *const c_char,
616 value: *const ::c_void, size: ::size_t,
617 flags: ::c_int) -> ::c_int;
618 pub fn lsetxattr(path: *const c_char, name: *const c_char,
619 value: *const ::c_void, size: ::size_t,
620 flags: ::c_int) -> ::c_int;
621 pub fn fsetxattr(filedes: ::c_int, name: *const c_char,
622 value: *const ::c_void, size: ::size_t,
623 flags: ::c_int) -> ::c_int;
624 pub fn listxattr(path: *const c_char, list: *mut c_char,
625 size: ::size_t) -> ::ssize_t;
626 pub fn llistxattr(path: *const c_char, list: *mut c_char,
627 size: ::size_t) -> ::ssize_t;
628 pub fn flistxattr(filedes: ::c_int, list: *mut c_char,
629 size: ::size_t) -> ::ssize_t;
630 pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int;
631 pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
632 pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800633 pub fn signalfd(fd: ::c_int,
634 mask: *const ::sigset_t,
635 flags: ::c_int) -> ::c_int;
636 pub fn pwritev(fd: ::c_int,
637 iov: *const ::iovec,
638 iovcnt: ::c_int,
639 offset: ::off_t) -> ::ssize_t;
640 pub fn preadv(fd: ::c_int,
641 iov: *const ::iovec,
642 iovcnt: ::c_int,
643 offset: ::off_t) -> ::ssize_t;
644 pub fn quotactl(cmd: ::c_int,
645 special: *const ::c_char,
646 id: ::c_int,
647 data: *mut ::c_char) -> ::c_int;
648 pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
649 pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
650 pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
651 pub fn mq_receive(mqd: ::mqd_t,
652 msg_ptr: *mut ::c_char,
653 msg_len: ::size_t,
654 msq_prio: *mut ::c_uint) -> ::ssize_t;
655 pub fn mq_send(mqd: ::mqd_t,
656 msg_ptr: *const ::c_char,
657 msg_len: ::size_t,
658 msq_prio: ::c_uint) -> ::c_int;
659 pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
660 pub fn mq_setattr(mqd: ::mqd_t,
661 newattr: *const ::mq_attr,
662 oldattr: *mut ::mq_attr) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800663 pub fn epoll_pwait(epfd: ::c_int,
664 events: *mut ::epoll_event,
665 maxevents: ::c_int,
666 timeout: ::c_int,
667 sigmask: *const ::sigset_t) -> ::c_int;
668 pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800669 pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
Kamal Marhubi511a7802016-02-15 00:40:19 -0500670 pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
Alex Crichton8a8bc662016-02-29 23:02:36 -0800671 pub fn mkostemps(template: *mut ::c_char,
672 suffixlen: ::c_int,
673 flags: ::c_int) -> ::c_int;
Philipp Matthias Schaeferc1982a42016-02-28 16:06:45 +0100674 pub fn sigtimedwait(set: *const sigset_t,
675 info: *mut siginfo_t,
676 timeout: *const ::timespec) -> ::c_int;
677 pub fn sigwaitinfo(set: *const sigset_t,
678 info: *mut siginfo_t) -> ::c_int;
Kamal Marhubi9c4af102016-02-27 14:58:43 -0500679 pub fn openpty(amaster: *mut ::c_int,
680 aslave: *mut ::c_int,
681 name: *mut ::c_char,
682 termp: *const termios,
683 winp: *const ::winsize) -> ::c_int;
684 pub fn forkpty(amaster: *mut ::c_int,
685 name: *mut ::c_char,
686 termp: *const termios,
687 winp: *const ::winsize) -> ::pid_t;
A.J. Gardner24c84f12016-03-31 20:08:03 -0500688 pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
Kamal Marhubib9750b62016-04-27 14:04:31 -0400689 pub fn getnameinfo(sa: *const ::sockaddr,
690 salen: ::socklen_t,
691 host: *mut ::c_char,
692 hostlen: ::socklen_t,
693 serv: *mut ::c_char,
694 sevlen: ::socklen_t,
695 flags: ::c_int) -> ::c_int;
Kamal Marhubi95695992016-04-27 14:29:19 -0400696 pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit,
697 old_limit: *mut ::rlimit) -> ::c_int;
698 pub fn prlimit64(pid: ::pid_t,
699 resource: ::c_int,
700 new_limit: *const ::rlimit64,
701 old_limit: *mut ::rlimit64) -> ::c_int;
Raphael Cohn72f1fb62016-05-11 18:06:14 +0100702 pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
Julia Evansc9496fe2016-05-11 08:44:27 -0400703 pub fn process_vm_readv(pid: ::pid_t,
704 local_iov: *const ::iovec,
705 liovcnt: ::c_ulong,
706 remote_iov: *const ::iovec,
707 riovcnt: ::c_ulong,
708 flags: ::c_ulong) -> isize;
709 pub fn process_vm_writev(pid: ::pid_t,
710 local_iov: *const ::iovec,
711 liovcnt: ::c_ulong,
712 remote_iov: *const ::iovec,
713 riovcnt: ::c_ulong,
714 flags: ::c_ulong) -> isize;
Sergey Bugaev8b767972016-07-12 20:56:43 +0300715 pub fn reboot(how_to: ::c_int) -> ::c_int;
Axel Viala26ee7822016-06-10 02:33:32 +0200716
717 // Not available now on Android
718 pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
719 mode: ::mode_t) -> ::c_int;
Charles J. Schneider332bd862016-07-12 09:32:42 +0200720 pub fn if_nameindex() -> *mut if_nameindex;
721 pub fn if_freenameindex(ptr: *mut if_nameindex);
Chris Kaminski37552b72016-09-06 20:20:00 -0400722 pub fn sync_file_range(fd: ::c_int, offset: ::off64_t,
723 nbytes: ::off64_t, flags: ::c_uint) -> ::c_int;
Niels Sascha Reedijka3ff9552016-02-02 21:21:36 +0100724 pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
725 pub fn freeifaddrs(ifa: *mut ::ifaddrs);
Alex Crichton50a42e22015-09-15 14:27:15 -0700726}
727
728cfg_if! {
Brian Anderson7d1d5752015-11-26 23:27:45 +0000729 if #[cfg(any(target_env = "musl",
730 target_os = "emscripten"))] {
Alex Crichton74825222015-10-29 17:36:55 -0700731 mod musl;
732 pub use self::musl::*;
Alex Crichton62a6c822015-11-09 13:58:44 -0800733 } else if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] {
Alex Crichton50a42e22015-09-15 14:27:15 -0700734 mod mips;
735 pub use self::mips::*;
Jorge Aparicioe7480ed2016-09-02 21:08:02 -0500736 } else if #[cfg(any(target_arch = "s390x"))] {
737 mod s390x;
738 pub use self::s390x::*;
Jorge Aparicio196b0e82016-08-26 22:30:42 -0500739 } else if #[cfg(any(target_arch = "mips64"))] {
740 mod mips64;
741 pub use self::mips64::*;
Alex Crichton50a42e22015-09-15 14:27:15 -0700742 } else {
Alex Crichton62a6c822015-11-09 13:58:44 -0800743 mod other;
744 pub use self::other::*;
Alex Crichton50a42e22015-09-15 14:27:15 -0700745 }
746}