]> git.proxmox.com Git - rustc.git/blob - src/liblibc/src/unix/notbsd/linux/mod.rs
New upstream version 1.14.0+dfsg1
[rustc.git] / src / liblibc / src / unix / notbsd / linux / mod.rs
1 //! Linux-specific definitions for linux-like values
2
3 use dox::mem;
4
5 pub type useconds_t = u32;
6 pub type dev_t = u64;
7 pub type socklen_t = u32;
8 pub type pthread_t = c_ulong;
9 pub type mode_t = u32;
10 pub type ino64_t = u64;
11 pub type off64_t = i64;
12 pub type blkcnt64_t = i64;
13 pub type rlim64_t = u64;
14 pub type shmatt_t = ::c_ulong;
15 pub type mqd_t = ::c_int;
16 pub type msgqnum_t = ::c_ulong;
17 pub type msglen_t = ::c_ulong;
18 pub type nfds_t = ::c_ulong;
19 pub type nl_item = ::c_int;
20
21 pub enum fpos64_t {} // TODO: fill this out with a struct
22
23 s! {
24 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
32 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
45 pub struct glob_t {
46 pub gl_pathc: ::size_t,
47 pub gl_pathv: *mut *mut c_char,
48 pub gl_offs: ::size_t,
49 pub gl_flags: ::c_int,
50
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,
61 pub ifa_flags: ::c_uint,
62 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 }
67
68 pub struct pthread_mutex_t {
69 #[cfg(any(target_arch = "mips", target_arch = "mipsel",
70 target_arch = "arm", target_arch = "powerpc"))]
71 __align: [::c_long; 0],
72 #[cfg(not(any(target_arch = "mips", target_arch = "mipsel",
73 target_arch = "arm", target_arch = "powerpc")))]
74 __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",
80 target_arch = "arm", target_arch = "powerpc"))]
81 __align: [::c_long; 0],
82 #[cfg(not(any(target_arch = "mips", target_arch = "mipsel",
83 target_arch = "arm", target_arch = "powerpc")))]
84 __align: [::c_longlong; 0],
85 size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
86 }
87
88 pub struct pthread_mutexattr_t {
89 #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64",
90 target_arch = "mips64", target_arch = "s390x"))]
91 __align: [::c_int; 0],
92 #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64",
93 target_arch = "mips64", target_arch = "s390x")))]
94 __align: [::c_long; 0],
95 size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
96 }
97
98 pub struct pthread_cond_t {
99 #[cfg(any(target_env = "musl"))]
100 __align: [*const ::c_void; 0],
101 #[cfg(not(any(target_env = "musl")))]
102 __align: [::c_longlong; 0],
103 size: [u8; __SIZEOF_PTHREAD_COND_T],
104 }
105
106 pub struct pthread_condattr_t {
107 __align: [::c_int; 0],
108 size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
109 }
110
111 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 }
120
121 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
133 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,
142 #[cfg(target_endian = "little")]
143 pub f_fsid: ::c_ulong,
144 #[cfg(target_pointer_width = "32")]
145 __f_unused: ::c_int,
146 #[cfg(target_endian = "big")]
147 pub f_fsid: ::c_ulong,
148 pub f_flag: ::c_ulong,
149 pub f_namemax: ::c_ulong,
150 __f_spare: [::c_int; 6],
151 }
152
153 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 }
203
204 pub struct if_nameindex {
205 pub if_index: ::c_uint,
206 pub if_name: *mut ::c_char,
207 }
208
209 // 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 }
220 }
221
222 pub const ABDAY_1: ::nl_item = 0x20000;
223 pub const ABDAY_2: ::nl_item = 0x20001;
224 pub const ABDAY_3: ::nl_item = 0x20002;
225 pub const ABDAY_4: ::nl_item = 0x20003;
226 pub const ABDAY_5: ::nl_item = 0x20004;
227 pub const ABDAY_6: ::nl_item = 0x20005;
228 pub const ABDAY_7: ::nl_item = 0x20006;
229
230 pub const DAY_1: ::nl_item = 0x20007;
231 pub const DAY_2: ::nl_item = 0x20008;
232 pub const DAY_3: ::nl_item = 0x20009;
233 pub const DAY_4: ::nl_item = 0x2000A;
234 pub const DAY_5: ::nl_item = 0x2000B;
235 pub const DAY_6: ::nl_item = 0x2000C;
236 pub const DAY_7: ::nl_item = 0x2000D;
237
238 pub const ABMON_1: ::nl_item = 0x2000E;
239 pub const ABMON_2: ::nl_item = 0x2000F;
240 pub const ABMON_3: ::nl_item = 0x20010;
241 pub const ABMON_4: ::nl_item = 0x20011;
242 pub const ABMON_5: ::nl_item = 0x20012;
243 pub const ABMON_6: ::nl_item = 0x20013;
244 pub const ABMON_7: ::nl_item = 0x20014;
245 pub const ABMON_8: ::nl_item = 0x20015;
246 pub const ABMON_9: ::nl_item = 0x20016;
247 pub const ABMON_10: ::nl_item = 0x20017;
248 pub const ABMON_11: ::nl_item = 0x20018;
249 pub const ABMON_12: ::nl_item = 0x20019;
250
251 pub const CLONE_NEWCGROUP: ::c_int = 0x02000000;
252
253 pub const MON_1: ::nl_item = 0x2001A;
254 pub const MON_2: ::nl_item = 0x2001B;
255 pub const MON_3: ::nl_item = 0x2001C;
256 pub const MON_4: ::nl_item = 0x2001D;
257 pub const MON_5: ::nl_item = 0x2001E;
258 pub const MON_6: ::nl_item = 0x2001F;
259 pub const MON_7: ::nl_item = 0x20020;
260 pub const MON_8: ::nl_item = 0x20021;
261 pub const MON_9: ::nl_item = 0x20022;
262 pub const MON_10: ::nl_item = 0x20023;
263 pub const MON_11: ::nl_item = 0x20024;
264 pub const MON_12: ::nl_item = 0x20025;
265
266 pub const AM_STR: ::nl_item = 0x20026;
267 pub const PM_STR: ::nl_item = 0x20027;
268
269 pub const D_T_FMT: ::nl_item = 0x20028;
270 pub const D_FMT: ::nl_item = 0x20029;
271 pub const T_FMT: ::nl_item = 0x2002A;
272 pub const T_FMT_AMPM: ::nl_item = 0x2002B;
273
274 pub const ERA: ::nl_item = 0x2002C;
275 pub const ERA_D_FMT: ::nl_item = 0x2002E;
276 pub const ALT_DIGITS: ::nl_item = 0x2002F;
277 pub const ERA_D_T_FMT: ::nl_item = 0x20030;
278 pub const ERA_T_FMT: ::nl_item = 0x20031;
279
280 pub const CODESET: ::nl_item = 14;
281
282 pub const CRNCYSTR: ::nl_item = 0x4000F;
283
284 pub const RUSAGE_THREAD: ::c_int = 1;
285 pub const RUSAGE_CHILDREN: ::c_int = -1;
286
287 pub const RADIXCHAR: ::nl_item = 0x10000;
288 pub const THOUSEP: ::nl_item = 0x10001;
289
290 pub const YESEXPR: ::nl_item = 0x50000;
291 pub const NOEXPR: ::nl_item = 0x50001;
292 pub const YESSTR: ::nl_item = 0x50002;
293 pub const NOSTR: ::nl_item = 0x50003;
294
295 pub const FILENAME_MAX: ::c_uint = 4096;
296 pub const L_tmpnam: ::c_uint = 20;
297 pub const _PC_LINK_MAX: ::c_int = 0;
298 pub const _PC_MAX_CANON: ::c_int = 1;
299 pub const _PC_MAX_INPUT: ::c_int = 2;
300 pub const _PC_NAME_MAX: ::c_int = 3;
301 pub const _PC_PATH_MAX: ::c_int = 4;
302 pub const _PC_PIPE_BUF: ::c_int = 5;
303 pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
304 pub const _PC_NO_TRUNC: ::c_int = 7;
305 pub const _PC_VDISABLE: ::c_int = 8;
306
307 pub const _SC_ARG_MAX: ::c_int = 0;
308 pub const _SC_CHILD_MAX: ::c_int = 1;
309 pub const _SC_CLK_TCK: ::c_int = 2;
310 pub const _SC_NGROUPS_MAX: ::c_int = 3;
311 pub const _SC_OPEN_MAX: ::c_int = 4;
312 pub const _SC_STREAM_MAX: ::c_int = 5;
313 pub const _SC_TZNAME_MAX: ::c_int = 6;
314 pub const _SC_JOB_CONTROL: ::c_int = 7;
315 pub const _SC_SAVED_IDS: ::c_int = 8;
316 pub const _SC_REALTIME_SIGNALS: ::c_int = 9;
317 pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10;
318 pub const _SC_TIMERS: ::c_int = 11;
319 pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12;
320 pub const _SC_PRIORITIZED_IO: ::c_int = 13;
321 pub const _SC_SYNCHRONIZED_IO: ::c_int = 14;
322 pub const _SC_FSYNC: ::c_int = 15;
323 pub const _SC_MAPPED_FILES: ::c_int = 16;
324 pub const _SC_MEMLOCK: ::c_int = 17;
325 pub const _SC_MEMLOCK_RANGE: ::c_int = 18;
326 pub const _SC_MEMORY_PROTECTION: ::c_int = 19;
327 pub const _SC_MESSAGE_PASSING: ::c_int = 20;
328 pub const _SC_SEMAPHORES: ::c_int = 21;
329 pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22;
330 pub const _SC_AIO_LISTIO_MAX: ::c_int = 23;
331 pub const _SC_AIO_MAX: ::c_int = 24;
332 pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25;
333 pub const _SC_DELAYTIMER_MAX: ::c_int = 26;
334 pub const _SC_MQ_OPEN_MAX: ::c_int = 27;
335 pub const _SC_MQ_PRIO_MAX: ::c_int = 28;
336 pub const _SC_VERSION: ::c_int = 29;
337 pub const _SC_PAGESIZE: ::c_int = 30;
338 pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
339 pub const _SC_RTSIG_MAX: ::c_int = 31;
340 pub const _SC_SEM_NSEMS_MAX: ::c_int = 32;
341 pub const _SC_SEM_VALUE_MAX: ::c_int = 33;
342 pub const _SC_SIGQUEUE_MAX: ::c_int = 34;
343 pub const _SC_TIMER_MAX: ::c_int = 35;
344 pub const _SC_BC_BASE_MAX: ::c_int = 36;
345 pub const _SC_BC_DIM_MAX: ::c_int = 37;
346 pub const _SC_BC_SCALE_MAX: ::c_int = 38;
347 pub const _SC_BC_STRING_MAX: ::c_int = 39;
348 pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40;
349 pub const _SC_EXPR_NEST_MAX: ::c_int = 42;
350 pub const _SC_LINE_MAX: ::c_int = 43;
351 pub const _SC_RE_DUP_MAX: ::c_int = 44;
352 pub const _SC_2_VERSION: ::c_int = 46;
353 pub const _SC_2_C_BIND: ::c_int = 47;
354 pub const _SC_2_C_DEV: ::c_int = 48;
355 pub const _SC_2_FORT_DEV: ::c_int = 49;
356 pub const _SC_2_FORT_RUN: ::c_int = 50;
357 pub const _SC_2_SW_DEV: ::c_int = 51;
358 pub const _SC_2_LOCALEDEF: ::c_int = 52;
359 pub const _SC_IOV_MAX: ::c_int = 60;
360 pub const _SC_THREADS: ::c_int = 67;
361 pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68;
362 pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69;
363 pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70;
364 pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
365 pub const _SC_TTY_NAME_MAX: ::c_int = 72;
366 pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73;
367 pub const _SC_THREAD_KEYS_MAX: ::c_int = 74;
368 pub const _SC_THREAD_STACK_MIN: ::c_int = 75;
369 pub const _SC_THREAD_THREADS_MAX: ::c_int = 76;
370 pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
371 pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
372 pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79;
373 pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80;
374 pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81;
375 pub const _SC_NPROCESSORS_ONLN: ::c_int = 84;
376 pub const _SC_ATEXIT_MAX: ::c_int = 87;
377 pub const _SC_XOPEN_VERSION: ::c_int = 89;
378 pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90;
379 pub const _SC_XOPEN_UNIX: ::c_int = 91;
380 pub const _SC_XOPEN_CRYPT: ::c_int = 92;
381 pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
382 pub const _SC_XOPEN_SHM: ::c_int = 94;
383 pub const _SC_2_CHAR_TERM: ::c_int = 95;
384 pub const _SC_2_UPE: ::c_int = 97;
385 pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
386 pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
387 pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128;
388 pub const _SC_XOPEN_LEGACY: ::c_int = 129;
389 pub const _SC_XOPEN_REALTIME: ::c_int = 130;
390 pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
391 pub const _SC_HOST_NAME_MAX: ::c_int = 180;
392
393 pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
394 pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
395
396 pub const GLOB_ERR: ::c_int = 1 << 0;
397 pub const GLOB_MARK: ::c_int = 1 << 1;
398 pub const GLOB_NOSORT: ::c_int = 1 << 2;
399 pub const GLOB_DOOFFS: ::c_int = 1 << 3;
400 pub const GLOB_NOCHECK: ::c_int = 1 << 4;
401 pub const GLOB_APPEND: ::c_int = 1 << 5;
402 pub const GLOB_NOESCAPE: ::c_int = 1 << 6;
403
404 pub const GLOB_NOSPACE: ::c_int = 1;
405 pub const GLOB_ABORTED: ::c_int = 2;
406 pub const GLOB_NOMATCH: ::c_int = 3;
407
408 pub const POSIX_MADV_NORMAL: ::c_int = 0;
409 pub const POSIX_MADV_RANDOM: ::c_int = 1;
410 pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
411 pub const POSIX_MADV_WILLNEED: ::c_int = 3;
412
413 pub const S_IEXEC: mode_t = 64;
414 pub const S_IWRITE: mode_t = 128;
415 pub const S_IREAD: mode_t = 256;
416
417 pub const F_LOCK: ::c_int = 1;
418 pub const F_TEST: ::c_int = 3;
419 pub const F_TLOCK: ::c_int = 2;
420 pub const F_ULOCK: ::c_int = 0;
421
422 pub const ST_RDONLY: ::c_ulong = 1;
423 pub const ST_NOSUID: ::c_ulong = 2;
424 pub const ST_NODEV: ::c_ulong = 4;
425 pub const ST_NOEXEC: ::c_ulong = 8;
426 pub const ST_SYNCHRONOUS: ::c_ulong = 16;
427 pub const ST_MANDLOCK: ::c_ulong = 64;
428 pub const ST_WRITE: ::c_ulong = 128;
429 pub const ST_APPEND: ::c_ulong = 256;
430 pub const ST_IMMUTABLE: ::c_ulong = 512;
431 pub const ST_NOATIME: ::c_ulong = 1024;
432 pub const ST_NODIRATIME: ::c_ulong = 2048;
433
434 pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
435 pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
436 pub const RTLD_NODELETE: ::c_int = 0x1000;
437 pub const RTLD_NOW: ::c_int = 0x2;
438
439 pub const TCP_MD5SIG: ::c_int = 14;
440
441 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
442 __align: [],
443 size: [0; __SIZEOF_PTHREAD_MUTEX_T],
444 };
445 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
446 __align: [],
447 size: [0; __SIZEOF_PTHREAD_COND_T],
448 };
449 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
450 __align: [],
451 size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
452 };
453 pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
454 pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
455 pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
456 pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
457 pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
458
459 pub const SCHED_OTHER: ::c_int = 0;
460 pub const SCHED_FIFO: ::c_int = 1;
461 pub const SCHED_RR: ::c_int = 2;
462 pub const SCHED_BATCH: ::c_int = 3;
463 pub const SCHED_IDLE: ::c_int = 5;
464
465 // System V IPC
466 pub const IPC_PRIVATE: ::key_t = 0;
467
468 pub const IPC_CREAT: ::c_int = 0o1000;
469 pub const IPC_EXCL: ::c_int = 0o2000;
470 pub const IPC_NOWAIT: ::c_int = 0o4000;
471
472 pub const IPC_RMID: ::c_int = 0;
473 pub const IPC_SET: ::c_int = 1;
474 pub const IPC_STAT: ::c_int = 2;
475 pub const IPC_INFO: ::c_int = 3;
476 pub const MSG_STAT: ::c_int = 11;
477 pub const MSG_INFO: ::c_int = 12;
478
479 pub const MSG_NOERROR: ::c_int = 0o10000;
480 pub const MSG_EXCEPT: ::c_int = 0o20000;
481 pub const MSG_COPY: ::c_int = 0o40000;
482
483 pub const SHM_R: ::c_int = 0o400;
484 pub const SHM_W: ::c_int = 0o200;
485
486 pub const SHM_RDONLY: ::c_int = 0o10000;
487 pub const SHM_RND: ::c_int = 0o20000;
488 pub const SHM_REMAP: ::c_int = 0o40000;
489 pub const SHM_EXEC: ::c_int = 0o100000;
490
491 pub const SHM_LOCK: ::c_int = 11;
492 pub const SHM_UNLOCK: ::c_int = 12;
493
494 pub const SHM_HUGETLB: ::c_int = 0o4000;
495 pub const SHM_NORESERVE: ::c_int = 0o10000;
496
497 pub const EPOLLRDHUP: ::c_int = 0x2000;
498 pub const EPOLLONESHOT: ::c_int = 0x40000000;
499
500 pub const QFMT_VFS_OLD: ::c_int = 1;
501 pub const QFMT_VFS_V0: ::c_int = 2;
502
503 pub const SFD_CLOEXEC: ::c_int = 0x080000;
504
505 pub const EFD_SEMAPHORE: ::c_int = 0x1;
506
507 pub const NCCS: usize = 32;
508
509 pub const LOG_NFACILITIES: ::c_int = 24;
510
511 pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t;
512
513 pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32;
514 pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32;
515 pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32;
516 pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32;
517 pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32;
518 pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32;
519 pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32;
520
521 pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1;
522 pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2;
523 pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4;
524
525 pub const EAI_SYSTEM: ::c_int = -11;
526
527 f! {
528 pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
529 for slot in cpuset.bits.iter_mut() {
530 *slot = 0;
531 }
532 }
533
534 pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
535 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
536 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
537 cpuset.bits[idx] |= 1 << offset;
538 ()
539 }
540
541 pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
542 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
543 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
544 cpuset.bits[idx] &= !(1 << offset);
545 ()
546 }
547
548 pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
549 let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]);
550 let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
551 0 != (cpuset.bits[idx] & (1 << offset))
552 }
553
554 pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
555 set1.bits == set2.bits
556 }
557 }
558
559 extern {
560 pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
561
562 pub fn setpwent();
563 pub fn getpwent() -> *mut passwd;
564 pub fn setspent();
565 pub fn endspent();
566 pub fn getspent() -> *mut spwd;
567 pub fn getspnam(__name: *const ::c_char) -> *mut spwd;
568
569 pub fn shm_open(name: *const c_char, oflag: ::c_int,
570 mode: mode_t) -> ::c_int;
571
572 // System V IPC
573 pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
574 pub fn shmat(shmid: ::c_int,
575 shmaddr: *const ::c_void,
576 shmflg: ::c_int) -> *mut ::c_void;
577 pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int;
578 pub fn shmctl(shmid: ::c_int,
579 cmd: ::c_int,
580 buf: *mut ::shmid_ds) -> ::c_int;
581 pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t;
582 pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) -> ::c_int;
583 pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
584 pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
585 msgtyp: ::c_long, msgflg: ::c_int) -> ::ssize_t;
586 pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t,
587 msgflg: ::c_int) -> ::c_int;
588
589 pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
590 -> ::c_int;
591 pub fn __errno_location() -> *mut ::c_int;
592
593 pub fn fopen64(filename: *const c_char,
594 mode: *const c_char) -> *mut ::FILE;
595 pub fn freopen64(filename: *const c_char, mode: *const c_char,
596 file: *mut ::FILE) -> *mut ::FILE;
597 pub fn tmpfile64() -> *mut ::FILE;
598 pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
599 pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
600 pub fn fseeko64(stream: *mut ::FILE,
601 offset: ::off64_t,
602 whence: ::c_int) -> ::c_int;
603 pub fn ftello64(stream: *mut ::FILE) -> ::off64_t;
604 pub fn fallocate(fd: ::c_int, mode: ::c_int,
605 offset: ::off_t, len: ::off_t) -> ::c_int;
606 pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
607 len: ::off_t) -> ::c_int;
608 pub fn readahead(fd: ::c_int, offset: ::off64_t,
609 count: ::size_t) -> ::ssize_t;
610 pub fn getxattr(path: *const c_char, name: *const c_char,
611 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
612 pub fn lgetxattr(path: *const c_char, name: *const c_char,
613 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
614 pub fn fgetxattr(filedes: ::c_int, name: *const c_char,
615 value: *mut ::c_void, size: ::size_t) -> ::ssize_t;
616 pub fn setxattr(path: *const c_char, name: *const c_char,
617 value: *const ::c_void, size: ::size_t,
618 flags: ::c_int) -> ::c_int;
619 pub fn lsetxattr(path: *const c_char, name: *const c_char,
620 value: *const ::c_void, size: ::size_t,
621 flags: ::c_int) -> ::c_int;
622 pub fn fsetxattr(filedes: ::c_int, name: *const c_char,
623 value: *const ::c_void, size: ::size_t,
624 flags: ::c_int) -> ::c_int;
625 pub fn listxattr(path: *const c_char, list: *mut c_char,
626 size: ::size_t) -> ::ssize_t;
627 pub fn llistxattr(path: *const c_char, list: *mut c_char,
628 size: ::size_t) -> ::ssize_t;
629 pub fn flistxattr(filedes: ::c_int, list: *mut c_char,
630 size: ::size_t) -> ::ssize_t;
631 pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int;
632 pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
633 pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
634 pub fn signalfd(fd: ::c_int,
635 mask: *const ::sigset_t,
636 flags: ::c_int) -> ::c_int;
637 pub fn pwritev(fd: ::c_int,
638 iov: *const ::iovec,
639 iovcnt: ::c_int,
640 offset: ::off_t) -> ::ssize_t;
641 pub fn preadv(fd: ::c_int,
642 iov: *const ::iovec,
643 iovcnt: ::c_int,
644 offset: ::off_t) -> ::ssize_t;
645 pub fn quotactl(cmd: ::c_int,
646 special: *const ::c_char,
647 id: ::c_int,
648 data: *mut ::c_char) -> ::c_int;
649 pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
650 pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
651 pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
652 pub fn mq_receive(mqd: ::mqd_t,
653 msg_ptr: *mut ::c_char,
654 msg_len: ::size_t,
655 msq_prio: *mut ::c_uint) -> ::ssize_t;
656 pub fn mq_send(mqd: ::mqd_t,
657 msg_ptr: *const ::c_char,
658 msg_len: ::size_t,
659 msq_prio: ::c_uint) -> ::c_int;
660 pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
661 pub fn mq_setattr(mqd: ::mqd_t,
662 newattr: *const ::mq_attr,
663 oldattr: *mut ::mq_attr) -> ::c_int;
664 pub fn epoll_pwait(epfd: ::c_int,
665 events: *mut ::epoll_event,
666 maxevents: ::c_int,
667 timeout: ::c_int,
668 sigmask: *const ::sigset_t) -> ::c_int;
669 pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int;
670 pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
671 pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
672 pub fn mkostemps(template: *mut ::c_char,
673 suffixlen: ::c_int,
674 flags: ::c_int) -> ::c_int;
675 pub fn sigtimedwait(set: *const sigset_t,
676 info: *mut siginfo_t,
677 timeout: *const ::timespec) -> ::c_int;
678 pub fn sigwaitinfo(set: *const sigset_t,
679 info: *mut siginfo_t) -> ::c_int;
680 pub fn openpty(amaster: *mut ::c_int,
681 aslave: *mut ::c_int,
682 name: *mut ::c_char,
683 termp: *const termios,
684 winp: *const ::winsize) -> ::c_int;
685 pub fn forkpty(amaster: *mut ::c_int,
686 name: *mut ::c_char,
687 termp: *const termios,
688 winp: *const ::winsize) -> ::pid_t;
689 pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
690 pub fn getnameinfo(sa: *const ::sockaddr,
691 salen: ::socklen_t,
692 host: *mut ::c_char,
693 hostlen: ::socklen_t,
694 serv: *mut ::c_char,
695 sevlen: ::socklen_t,
696 flags: ::c_int) -> ::c_int;
697 pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit,
698 old_limit: *mut ::rlimit) -> ::c_int;
699 pub fn prlimit64(pid: ::pid_t,
700 resource: ::c_int,
701 new_limit: *const ::rlimit64,
702 old_limit: *mut ::rlimit64) -> ::c_int;
703 pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
704 pub fn process_vm_readv(pid: ::pid_t,
705 local_iov: *const ::iovec,
706 liovcnt: ::c_ulong,
707 remote_iov: *const ::iovec,
708 riovcnt: ::c_ulong,
709 flags: ::c_ulong) -> isize;
710 pub fn process_vm_writev(pid: ::pid_t,
711 local_iov: *const ::iovec,
712 liovcnt: ::c_ulong,
713 remote_iov: *const ::iovec,
714 riovcnt: ::c_ulong,
715 flags: ::c_ulong) -> isize;
716 pub fn reboot(how_to: ::c_int) -> ::c_int;
717 pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int;
718 pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int;
719
720 // Not available now on Android
721 pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
722 mode: ::mode_t) -> ::c_int;
723 pub fn if_nameindex() -> *mut if_nameindex;
724 pub fn if_freenameindex(ptr: *mut if_nameindex);
725 pub fn sync_file_range(fd: ::c_int, offset: ::off64_t,
726 nbytes: ::off64_t, flags: ::c_uint) -> ::c_int;
727 pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
728 pub fn freeifaddrs(ifa: *mut ::ifaddrs);
729 }
730
731 cfg_if! {
732 if #[cfg(any(target_env = "musl",
733 target_os = "fuchsia",
734 target_os = "emscripten"))] {
735 mod musl;
736 pub use self::musl::*;
737 } else if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] {
738 mod mips;
739 pub use self::mips::*;
740 } else if #[cfg(any(target_arch = "s390x"))] {
741 mod s390x;
742 pub use self::s390x::*;
743 } else if #[cfg(any(target_arch = "mips64"))] {
744 mod mips64;
745 pub use self::mips64::*;
746 } else {
747 mod other;
748 pub use self::other::*;
749 }
750 }