]> git.proxmox.com Git - rustc.git/blame - src/vendor/libc/src/unix/notbsd/mod.rs
New upstream version 1.15.0+dfsg1
[rustc.git] / src / vendor / libc / src / unix / notbsd / mod.rs
CommitLineData
476ff2be
SL
1use dox::mem;
2
3pub type sa_family_t = u16;
4pub type pthread_key_t = ::c_uint;
5pub type speed_t = ::c_uint;
6pub type tcflag_t = ::c_uint;
7pub type loff_t = ::c_longlong;
8pub type clockid_t = ::c_int;
9pub type key_t = ::c_int;
10pub type id_t = ::c_uint;
11
12pub enum timezone {}
13
14s! {
15 pub struct sockaddr {
16 pub sa_family: sa_family_t,
17 pub sa_data: [::c_char; 14],
18 }
19
20 pub struct sockaddr_in {
21 pub sin_family: sa_family_t,
22 pub sin_port: ::in_port_t,
23 pub sin_addr: ::in_addr,
24 pub sin_zero: [u8; 8],
25 }
26
27 pub struct sockaddr_in6 {
28 pub sin6_family: sa_family_t,
29 pub sin6_port: ::in_port_t,
30 pub sin6_flowinfo: u32,
31 pub sin6_addr: ::in6_addr,
32 pub sin6_scope_id: u32,
33 }
34
35 pub struct sockaddr_un {
36 pub sun_family: sa_family_t,
37 pub sun_path: [::c_char; 108]
38 }
39
40 pub struct sockaddr_storage {
41 pub ss_family: sa_family_t,
42 __ss_align: ::size_t,
43 #[cfg(target_pointer_width = "32")]
44 __ss_pad2: [u8; 128 - 2 * 4],
45 #[cfg(target_pointer_width = "64")]
46 __ss_pad2: [u8; 128 - 2 * 8],
47 }
48
49 pub struct addrinfo {
50 pub ai_flags: ::c_int,
51 pub ai_family: ::c_int,
52 pub ai_socktype: ::c_int,
53 pub ai_protocol: ::c_int,
54 pub ai_addrlen: socklen_t,
55
56 #[cfg(any(target_os = "linux", target_os = "emscripten"))]
57 pub ai_addr: *mut ::sockaddr,
58
59 pub ai_canonname: *mut c_char,
60
61 #[cfg(target_os = "android")]
62 pub ai_addr: *mut ::sockaddr,
63
64 pub ai_next: *mut addrinfo,
65 }
66
67 pub struct sockaddr_nl {
68 pub nl_family: ::sa_family_t,
69 nl_pad: ::c_ushort,
70 pub nl_pid: u32,
71 pub nl_groups: u32
72 }
73
74 pub struct sockaddr_ll {
75 pub sll_family: ::c_ushort,
76 pub sll_protocol: ::c_ushort,
77 pub sll_ifindex: ::c_int,
78 pub sll_hatype: ::c_ushort,
79 pub sll_pkttype: ::c_uchar,
80 pub sll_halen: ::c_uchar,
81 pub sll_addr: [::c_uchar; 8]
82 }
83
84 pub struct fd_set {
85 fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
86 }
87
88 pub struct tm {
89 pub tm_sec: ::c_int,
90 pub tm_min: ::c_int,
91 pub tm_hour: ::c_int,
92 pub tm_mday: ::c_int,
93 pub tm_mon: ::c_int,
94 pub tm_year: ::c_int,
95 pub tm_wday: ::c_int,
96 pub tm_yday: ::c_int,
97 pub tm_isdst: ::c_int,
98 pub tm_gmtoff: ::c_long,
99 pub tm_zone: *const ::c_char,
100 }
101
102 pub struct sched_param {
103 pub sched_priority: ::c_int,
104 #[cfg(any(target_env = "musl"))]
105 pub sched_ss_low_priority: ::c_int,
106 #[cfg(any(target_env = "musl"))]
107 pub sched_ss_repl_period: ::timespec,
108 #[cfg(any(target_env = "musl"))]
109 pub sched_ss_init_budget: ::timespec,
110 #[cfg(any(target_env = "musl"))]
111 pub sched_ss_max_repl: ::c_int,
112 }
113
114 pub struct Dl_info {
115 pub dli_fname: *const ::c_char,
116 pub dli_fbase: *mut ::c_void,
117 pub dli_sname: *const ::c_char,
118 pub dli_saddr: *mut ::c_void,
119 }
120
121 #[cfg_attr(any(all(target_arch = "x86", not(target_env = "musl")),
122 target_arch = "x86_64"),
123 repr(packed))]
124 pub struct epoll_event {
125 pub events: ::uint32_t,
126 pub u64: ::uint64_t,
127 }
128
129 pub struct utsname {
130 pub sysname: [::c_char; 65],
131 pub nodename: [::c_char; 65],
132 pub release: [::c_char; 65],
133 pub version: [::c_char; 65],
134 pub machine: [::c_char; 65],
135 pub domainname: [::c_char; 65]
136 }
137
138 pub struct lconv {
139 pub decimal_point: *mut ::c_char,
140 pub thousands_sep: *mut ::c_char,
141 pub grouping: *mut ::c_char,
142 pub int_curr_symbol: *mut ::c_char,
143 pub currency_symbol: *mut ::c_char,
144 pub mon_decimal_point: *mut ::c_char,
145 pub mon_thousands_sep: *mut ::c_char,
146 pub mon_grouping: *mut ::c_char,
147 pub positive_sign: *mut ::c_char,
148 pub negative_sign: *mut ::c_char,
149 pub int_frac_digits: ::c_char,
150 pub frac_digits: ::c_char,
151 pub p_cs_precedes: ::c_char,
152 pub p_sep_by_space: ::c_char,
153 pub n_cs_precedes: ::c_char,
154 pub n_sep_by_space: ::c_char,
155 pub p_sign_posn: ::c_char,
156 pub n_sign_posn: ::c_char,
157 pub int_p_cs_precedes: ::c_char,
158 pub int_p_sep_by_space: ::c_char,
159 pub int_n_cs_precedes: ::c_char,
160 pub int_n_sep_by_space: ::c_char,
161 pub int_p_sign_posn: ::c_char,
162 pub int_n_sign_posn: ::c_char,
163 }
164}
165
166// intentionally not public, only used for fd_set
167cfg_if! {
168 if #[cfg(target_pointer_width = "32")] {
169 const ULONG_SIZE: usize = 32;
170 } else if #[cfg(target_pointer_width = "64")] {
171 const ULONG_SIZE: usize = 64;
172 } else {
173 // Unknown target_pointer_width
174 }
175}
176
177pub const EXIT_FAILURE: ::c_int = 1;
178pub const EXIT_SUCCESS: ::c_int = 0;
179pub const RAND_MAX: ::c_int = 2147483647;
180pub const EOF: ::c_int = -1;
181pub const SEEK_SET: ::c_int = 0;
182pub const SEEK_CUR: ::c_int = 1;
183pub const SEEK_END: ::c_int = 2;
184pub const _IOFBF: ::c_int = 0;
185pub const _IONBF: ::c_int = 2;
186pub const _IOLBF: ::c_int = 1;
187
188pub const F_DUPFD: ::c_int = 0;
189pub const F_GETFD: ::c_int = 1;
190pub const F_SETFD: ::c_int = 2;
191pub const F_GETFL: ::c_int = 3;
192pub const F_SETFL: ::c_int = 4;
193
194// Linux-specific fcntls
195pub const F_SETLEASE: ::c_int = 1024;
196pub const F_GETLEASE: ::c_int = 1025;
197pub const F_NOTIFY: ::c_int = 1026;
198pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
199pub const F_SETPIPE_SZ: ::c_int = 1031;
200pub const F_GETPIPE_SZ: ::c_int = 1032;
201
202// TODO(#235): Include file sealing fcntls once we have a way to verify them.
203
204pub const SIGTRAP: ::c_int = 5;
205
206pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
207pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
208
209pub const CLOCK_REALTIME: clockid_t = 0;
210pub const CLOCK_MONOTONIC: clockid_t = 1;
211pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2;
212pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3;
213pub const CLOCK_MONOTONIC_RAW: clockid_t = 4;
214pub const CLOCK_REALTIME_COARSE: clockid_t = 5;
215pub const CLOCK_MONOTONIC_COARSE: clockid_t = 6;
216pub const CLOCK_BOOTTIME: clockid_t = 7;
217pub const CLOCK_REALTIME_ALARM: clockid_t = 8;
218pub const CLOCK_BOOTTIME_ALARM: clockid_t = 9;
219// TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep
220// 2014.) See also musl/mod.rs
221// pub const CLOCK_SGI_CYCLE: clockid_t = 10;
222// pub const CLOCK_TAI: clockid_t = 11;
223pub const TIMER_ABSTIME: ::c_int = 1;
224
225pub const RLIMIT_CPU: ::c_int = 0;
226pub const RLIMIT_FSIZE: ::c_int = 1;
227pub const RLIMIT_DATA: ::c_int = 2;
228pub const RLIMIT_STACK: ::c_int = 3;
229pub const RLIMIT_CORE: ::c_int = 4;
230pub const RLIMIT_LOCKS: ::c_int = 10;
231pub const RLIMIT_SIGPENDING: ::c_int = 11;
232pub const RLIMIT_MSGQUEUE: ::c_int = 12;
233pub const RLIMIT_NICE: ::c_int = 13;
234pub const RLIMIT_RTPRIO: ::c_int = 14;
235
236pub const RUSAGE_SELF: ::c_int = 0;
237
238pub const O_RDONLY: ::c_int = 0;
239pub const O_WRONLY: ::c_int = 1;
240pub const O_RDWR: ::c_int = 2;
241pub const O_TRUNC: ::c_int = 512;
242pub const O_CLOEXEC: ::c_int = 0x80000;
243
244pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
245
246pub const S_IFIFO: ::mode_t = 4096;
247pub const S_IFCHR: ::mode_t = 8192;
248pub const S_IFBLK: ::mode_t = 24576;
249pub const S_IFDIR: ::mode_t = 16384;
250pub const S_IFREG: ::mode_t = 32768;
251pub const S_IFLNK: ::mode_t = 40960;
252pub const S_IFSOCK: ::mode_t = 49152;
253pub const S_IFMT: ::mode_t = 61440;
254pub const S_IRWXU: ::mode_t = 448;
255pub const S_IXUSR: ::mode_t = 64;
256pub const S_IWUSR: ::mode_t = 128;
257pub const S_IRUSR: ::mode_t = 256;
258pub const S_IRWXG: ::mode_t = 56;
259pub const S_IXGRP: ::mode_t = 8;
260pub const S_IWGRP: ::mode_t = 16;
261pub const S_IRGRP: ::mode_t = 32;
262pub const S_IRWXO: ::mode_t = 7;
263pub const S_IXOTH: ::mode_t = 1;
264pub const S_IWOTH: ::mode_t = 2;
265pub const S_IROTH: ::mode_t = 4;
266pub const F_OK: ::c_int = 0;
267pub const R_OK: ::c_int = 4;
268pub const W_OK: ::c_int = 2;
269pub const X_OK: ::c_int = 1;
270pub const STDIN_FILENO: ::c_int = 0;
271pub const STDOUT_FILENO: ::c_int = 1;
272pub const STDERR_FILENO: ::c_int = 2;
273pub const SIGHUP: ::c_int = 1;
274pub const SIGINT: ::c_int = 2;
275pub const SIGQUIT: ::c_int = 3;
276pub const SIGILL: ::c_int = 4;
277pub const SIGABRT: ::c_int = 6;
278pub const SIGFPE: ::c_int = 8;
279pub const SIGKILL: ::c_int = 9;
280pub const SIGSEGV: ::c_int = 11;
281pub const SIGPIPE: ::c_int = 13;
282pub const SIGALRM: ::c_int = 14;
283pub const SIGTERM: ::c_int = 15;
284
285pub const PROT_NONE: ::c_int = 0;
286pub const PROT_READ: ::c_int = 1;
287pub const PROT_WRITE: ::c_int = 2;
288pub const PROT_EXEC: ::c_int = 4;
289
290pub const LC_CTYPE: ::c_int = 0;
291pub const LC_NUMERIC: ::c_int = 1;
292pub const LC_TIME: ::c_int = 2;
293pub const LC_COLLATE: ::c_int = 3;
294pub const LC_MONETARY: ::c_int = 4;
295pub const LC_MESSAGES: ::c_int = 5;
296pub const LC_ALL: ::c_int = 6;
297pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE);
298pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC);
299pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME);
300pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE);
301pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY);
302pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES);
303// LC_ALL_MASK defined per platform
304
305pub const MAP_FILE: ::c_int = 0x0000;
306pub const MAP_SHARED: ::c_int = 0x0001;
307pub const MAP_PRIVATE: ::c_int = 0x0002;
308pub const MAP_FIXED: ::c_int = 0x0010;
309
310pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
311
312// MS_ flags for msync(2)
313pub const MS_ASYNC: ::c_int = 0x0001;
314pub const MS_INVALIDATE: ::c_int = 0x0002;
315pub const MS_SYNC: ::c_int = 0x0004;
316
317// MS_ flags for mount(2)
318pub const MS_RDONLY: ::c_ulong = 0x01;
319pub const MS_NOSUID: ::c_ulong = 0x02;
320pub const MS_NODEV: ::c_ulong = 0x04;
321pub const MS_NOEXEC: ::c_ulong = 0x08;
322pub const MS_SYNCHRONOUS: ::c_ulong = 0x10;
323pub const MS_REMOUNT: ::c_ulong = 0x20;
324pub const MS_MANDLOCK: ::c_ulong = 0x40;
325pub const MS_DIRSYNC: ::c_ulong = 0x80;
326pub const MS_NOATIME: ::c_ulong = 0x0400;
327pub const MS_NODIRATIME: ::c_ulong = 0x0800;
328pub const MS_BIND: ::c_ulong = 0x1000;
329pub const MS_MOVE: ::c_ulong = 0x2000;
330pub const MS_REC: ::c_ulong = 0x4000;
331pub const MS_SILENT: ::c_ulong = 0x8000;
332pub const MS_POSIXACL: ::c_ulong = 0x010000;
333pub const MS_UNBINDABLE: ::c_ulong = 0x020000;
334pub const MS_PRIVATE: ::c_ulong = 0x040000;
335pub const MS_SLAVE: ::c_ulong = 0x080000;
336pub const MS_SHARED: ::c_ulong = 0x100000;
337pub const MS_RELATIME: ::c_ulong = 0x200000;
338pub const MS_KERNMOUNT: ::c_ulong = 0x400000;
339pub const MS_I_VERSION: ::c_ulong = 0x800000;
340pub const MS_STRICTATIME: ::c_ulong = 0x1000000;
341pub const MS_ACTIVE: ::c_ulong = 0x40000000;
342pub const MS_NOUSER: ::c_ulong = 0x80000000;
343pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000;
344pub const MS_MGC_MSK: ::c_ulong = 0xffff0000;
345pub const MS_RMT_MASK: ::c_ulong = 0x800051;
346
347pub const EPERM: ::c_int = 1;
348pub const ENOENT: ::c_int = 2;
349pub const ESRCH: ::c_int = 3;
350pub const EINTR: ::c_int = 4;
351pub const EIO: ::c_int = 5;
352pub const ENXIO: ::c_int = 6;
353pub const E2BIG: ::c_int = 7;
354pub const ENOEXEC: ::c_int = 8;
355pub const EBADF: ::c_int = 9;
356pub const ECHILD: ::c_int = 10;
357pub const EAGAIN: ::c_int = 11;
358pub const ENOMEM: ::c_int = 12;
359pub const EACCES: ::c_int = 13;
360pub const EFAULT: ::c_int = 14;
361pub const ENOTBLK: ::c_int = 15;
362pub const EBUSY: ::c_int = 16;
363pub const EEXIST: ::c_int = 17;
364pub const EXDEV: ::c_int = 18;
365pub const ENODEV: ::c_int = 19;
366pub const ENOTDIR: ::c_int = 20;
367pub const EISDIR: ::c_int = 21;
368pub const EINVAL: ::c_int = 22;
369pub const ENFILE: ::c_int = 23;
370pub const EMFILE: ::c_int = 24;
371pub const ENOTTY: ::c_int = 25;
372pub const ETXTBSY: ::c_int = 26;
373pub const EFBIG: ::c_int = 27;
374pub const ENOSPC: ::c_int = 28;
375pub const ESPIPE: ::c_int = 29;
376pub const EROFS: ::c_int = 30;
377pub const EMLINK: ::c_int = 31;
378pub const EPIPE: ::c_int = 32;
379pub const EDOM: ::c_int = 33;
380pub const ERANGE: ::c_int = 34;
381pub const EWOULDBLOCK: ::c_int = EAGAIN;
382
383pub const EBFONT: ::c_int = 59;
384pub const ENOSTR: ::c_int = 60;
385pub const ENODATA: ::c_int = 61;
386pub const ETIME: ::c_int = 62;
387pub const ENOSR: ::c_int = 63;
388pub const ENONET: ::c_int = 64;
389pub const ENOPKG: ::c_int = 65;
390pub const EREMOTE: ::c_int = 66;
391pub const ENOLINK: ::c_int = 67;
392pub const EADV: ::c_int = 68;
393pub const ESRMNT: ::c_int = 69;
394pub const ECOMM: ::c_int = 70;
395pub const EPROTO: ::c_int = 71;
396pub const EDOTDOT: ::c_int = 73;
397
398pub const AF_PACKET: ::c_int = 17;
399pub const IPPROTO_RAW: ::c_int = 255;
400
401pub const PROT_GROWSDOWN: ::c_int = 0x1000000;
402pub const PROT_GROWSUP: ::c_int = 0x2000000;
403
404pub const MAP_TYPE: ::c_int = 0x000f;
405
406pub const MADV_NORMAL: ::c_int = 0;
407pub const MADV_RANDOM: ::c_int = 1;
408pub const MADV_SEQUENTIAL: ::c_int = 2;
409pub const MADV_WILLNEED: ::c_int = 3;
410pub const MADV_DONTNEED: ::c_int = 4;
411pub const MADV_REMOVE: ::c_int = 9;
412pub const MADV_DONTFORK: ::c_int = 10;
413pub const MADV_DOFORK: ::c_int = 11;
414pub const MADV_MERGEABLE: ::c_int = 12;
415pub const MADV_UNMERGEABLE: ::c_int = 13;
416pub const MADV_HWPOISON: ::c_int = 100;
417
418pub const IFF_UP: ::c_int = 0x1;
419pub const IFF_BROADCAST: ::c_int = 0x2;
420pub const IFF_DEBUG: ::c_int = 0x4;
421pub const IFF_LOOPBACK: ::c_int = 0x8;
422pub const IFF_POINTOPOINT: ::c_int = 0x10;
423pub const IFF_NOTRAILERS: ::c_int = 0x20;
424pub const IFF_RUNNING: ::c_int = 0x40;
425pub const IFF_NOARP: ::c_int = 0x80;
426pub const IFF_PROMISC: ::c_int = 0x100;
427pub const IFF_ALLMULTI: ::c_int = 0x200;
428pub const IFF_MASTER: ::c_int = 0x400;
429pub const IFF_SLAVE: ::c_int = 0x800;
430pub const IFF_MULTICAST: ::c_int = 0x1000;
431pub const IFF_PORTSEL: ::c_int = 0x2000;
432pub const IFF_AUTOMEDIA: ::c_int = 0x4000;
433pub const IFF_DYNAMIC: ::c_int = 0x8000;
434
435pub const AF_UNIX: ::c_int = 1;
436pub const AF_INET: ::c_int = 2;
437pub const AF_INET6: ::c_int = 10;
438pub const AF_NETLINK: ::c_int = 16;
439pub const SOCK_RAW: ::c_int = 3;
440pub const IPPROTO_TCP: ::c_int = 6;
441pub const IPPROTO_IP: ::c_int = 0;
442pub const IPPROTO_IPV6: ::c_int = 41;
443pub const IP_MULTICAST_TTL: ::c_int = 33;
444pub const IP_MULTICAST_LOOP: ::c_int = 34;
445pub const IP_TTL: ::c_int = 2;
446pub const IP_HDRINCL: ::c_int = 3;
447pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
448pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
449pub const IP_TRANSPARENT: ::c_int = 19;
450pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20;
451pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21;
452
453pub const TCP_NODELAY: ::c_int = 1;
454pub const TCP_MAXSEG: ::c_int = 2;
455pub const TCP_CORK: ::c_int = 3;
456pub const TCP_KEEPIDLE: ::c_int = 4;
457pub const TCP_KEEPINTVL: ::c_int = 5;
458pub const TCP_KEEPCNT: ::c_int = 6;
459pub const TCP_SYNCNT: ::c_int = 7;
460pub const TCP_LINGER2: ::c_int = 8;
461pub const TCP_DEFER_ACCEPT: ::c_int = 9;
462pub const TCP_WINDOW_CLAMP: ::c_int = 10;
463pub const TCP_INFO: ::c_int = 11;
464pub const TCP_QUICKACK: ::c_int = 12;
465pub const TCP_CONGESTION: ::c_int = 13;
466
467pub const IPV6_MULTICAST_LOOP: ::c_int = 19;
468pub const IPV6_V6ONLY: ::c_int = 26;
469
470pub const SO_DEBUG: ::c_int = 1;
471
472pub const MSG_NOSIGNAL: ::c_int = 0x4000;
473
474pub const SHUT_RD: ::c_int = 0;
475pub const SHUT_WR: ::c_int = 1;
476pub const SHUT_RDWR: ::c_int = 2;
477
478pub const LOCK_SH: ::c_int = 1;
479pub const LOCK_EX: ::c_int = 2;
480pub const LOCK_NB: ::c_int = 4;
481pub const LOCK_UN: ::c_int = 8;
482
483pub const SA_NODEFER: ::c_int = 0x40000000;
484pub const SA_RESETHAND: ::c_int = 0x80000000;
485pub const SA_RESTART: ::c_int = 0x10000000;
486pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
487
488pub const SS_ONSTACK: ::c_int = 1;
489pub const SS_DISABLE: ::c_int = 2;
490
491pub const PATH_MAX: ::c_int = 4096;
492
493pub const FD_SETSIZE: usize = 1024;
494
495pub const EPOLLIN: ::c_int = 0x1;
496pub const EPOLLPRI: ::c_int = 0x2;
497pub const EPOLLOUT: ::c_int = 0x4;
498pub const EPOLLRDNORM: ::c_int = 0x40;
499pub const EPOLLRDBAND: ::c_int = 0x80;
500pub const EPOLLWRNORM: ::c_int = 0x100;
501pub const EPOLLWRBAND: ::c_int = 0x200;
502pub const EPOLLMSG: ::c_int = 0x400;
503pub const EPOLLERR: ::c_int = 0x8;
504pub const EPOLLHUP: ::c_int = 0x10;
505pub const EPOLLET: ::c_int = 0x80000000;
506
507pub const EPOLL_CTL_ADD: ::c_int = 1;
508pub const EPOLL_CTL_MOD: ::c_int = 3;
509pub const EPOLL_CTL_DEL: ::c_int = 2;
510
511pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
512
513pub const MNT_DETACH: ::c_int = 0x2;
514pub const MNT_EXPIRE: ::c_int = 0x4;
515
516pub const Q_GETFMT: ::c_int = 0x800004;
517pub const Q_GETINFO: ::c_int = 0x800005;
518pub const Q_SETINFO: ::c_int = 0x800006;
519pub const QIF_BLIMITS: ::uint32_t = 1;
520pub const QIF_SPACE: ::uint32_t = 2;
521pub const QIF_ILIMITS: ::uint32_t = 4;
522pub const QIF_INODES: ::uint32_t = 8;
523pub const QIF_BTIME: ::uint32_t = 16;
524pub const QIF_ITIME: ::uint32_t = 32;
525pub const QIF_LIMITS: ::uint32_t = 5;
526pub const QIF_USAGE: ::uint32_t = 10;
527pub const QIF_TIMES: ::uint32_t = 48;
528pub const QIF_ALL: ::uint32_t = 63;
529
530pub const EFD_CLOEXEC: ::c_int = 0x80000;
531
532pub const MNT_FORCE: ::c_int = 0x1;
533
534pub const Q_SYNC: ::c_int = 0x800001;
535pub const Q_QUOTAON: ::c_int = 0x800002;
536pub const Q_QUOTAOFF: ::c_int = 0x800003;
537pub const Q_GETQUOTA: ::c_int = 0x800007;
538pub const Q_SETQUOTA: ::c_int = 0x800008;
539
540pub const TCIOFF: ::c_int = 2;
541pub const TCION: ::c_int = 3;
542pub const TCOOFF: ::c_int = 0;
543pub const TCOON: ::c_int = 1;
544pub const TCIFLUSH: ::c_int = 0;
545pub const TCOFLUSH: ::c_int = 1;
546pub const TCIOFLUSH: ::c_int = 2;
547pub const NL0: ::c_int = 0x00000000;
548pub const NL1: ::c_int = 0x00000100;
549pub const TAB0: ::c_int = 0x00000000;
550pub const CR0: ::c_int = 0x00000000;
551pub const FF0: ::c_int = 0x00000000;
552pub const BS0: ::c_int = 0x00000000;
553pub const VT0: ::c_int = 0x00000000;
554pub const VERASE: usize = 2;
555pub const VKILL: usize = 3;
556pub const VINTR: usize = 0;
557pub const VQUIT: usize = 1;
558pub const VLNEXT: usize = 15;
559pub const IGNBRK: ::tcflag_t = 0x00000001;
560pub const BRKINT: ::tcflag_t = 0x00000002;
561pub const IGNPAR: ::tcflag_t = 0x00000004;
562pub const PARMRK: ::tcflag_t = 0x00000008;
563pub const INPCK: ::tcflag_t = 0x00000010;
564pub const ISTRIP: ::tcflag_t = 0x00000020;
565pub const INLCR: ::tcflag_t = 0x00000040;
566pub const IGNCR: ::tcflag_t = 0x00000080;
567pub const ICRNL: ::tcflag_t = 0x00000100;
568pub const IXANY: ::tcflag_t = 0x00000800;
569pub const IMAXBEL: ::tcflag_t = 0x00002000;
570pub const OPOST: ::tcflag_t = 0x1;
571pub const CS5: ::tcflag_t = 0x00000000;
572pub const CRTSCTS: ::tcflag_t = 0x80000000;
573pub const ECHO: ::tcflag_t = 0x00000008;
574
575pub const CLONE_VM: ::c_int = 0x100;
576pub const CLONE_FS: ::c_int = 0x200;
577pub const CLONE_FILES: ::c_int = 0x400;
578pub const CLONE_SIGHAND: ::c_int = 0x800;
579pub const CLONE_PTRACE: ::c_int = 0x2000;
580pub const CLONE_VFORK: ::c_int = 0x4000;
581pub const CLONE_PARENT: ::c_int = 0x8000;
582pub const CLONE_THREAD: ::c_int = 0x10000;
583pub const CLONE_NEWNS: ::c_int = 0x20000;
584pub const CLONE_SYSVSEM: ::c_int = 0x40000;
585pub const CLONE_SETTLS: ::c_int = 0x80000;
586pub const CLONE_PARENT_SETTID: ::c_int = 0x100000;
587pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000;
588pub const CLONE_DETACHED: ::c_int = 0x400000;
589pub const CLONE_UNTRACED: ::c_int = 0x800000;
590pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000;
591pub const CLONE_NEWUTS: ::c_int = 0x04000000;
592pub const CLONE_NEWIPC: ::c_int = 0x08000000;
593pub const CLONE_NEWUSER: ::c_int = 0x10000000;
594pub const CLONE_NEWPID: ::c_int = 0x20000000;
595pub const CLONE_NEWNET: ::c_int = 0x40000000;
596pub const CLONE_IO: ::c_int = 0x80000000;
597
598pub const WNOHANG: ::c_int = 0x00000001;
599pub const WUNTRACED: ::c_int = 0x00000002;
600pub const WSTOPPED: ::c_int = WUNTRACED;
601pub const WEXITED: ::c_int = 0x00000004;
602pub const WCONTINUED: ::c_int = 0x00000008;
603pub const WNOWAIT: ::c_int = 0x01000000;
604
605pub const __WNOTHREAD: ::c_int = 0x20000000;
606pub const __WALL: ::c_int = 0x40000000;
607pub const __WCLONE: ::c_int = 0x80000000;
608
609pub const SPLICE_F_MOVE: ::c_uint = 0x01;
610pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02;
611pub const SPLICE_F_MORE: ::c_uint = 0x04;
612pub const SPLICE_F_GIFT: ::c_uint = 0x08;
613
614pub const RTLD_LOCAL: ::c_int = 0;
615
616pub const POSIX_FADV_NORMAL: ::c_int = 0;
617pub const POSIX_FADV_RANDOM: ::c_int = 1;
618pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2;
619pub const POSIX_FADV_WILLNEED: ::c_int = 3;
620
621pub const AT_FDCWD: ::c_int = -100;
622pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100;
623
624pub const LOG_CRON: ::c_int = 9 << 3;
625pub const LOG_AUTHPRIV: ::c_int = 10 << 3;
626pub const LOG_FTP: ::c_int = 11 << 3;
627pub const LOG_PERROR: ::c_int = 0x20;
628
629pub const PIPE_BUF: usize = 4096;
630
631pub const SI_LOAD_SHIFT: ::c_uint = 16;
632
633f! {
634 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
635 let fd = fd as usize;
636 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
637 (*set).fds_bits[fd / size] &= !(1 << (fd % size));
638 return
639 }
640
641 pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
642 let fd = fd as usize;
643 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
644 return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
645 }
646
647 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
648 let fd = fd as usize;
649 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
650 (*set).fds_bits[fd / size] |= 1 << (fd % size);
651 return
652 }
653
654 pub fn FD_ZERO(set: *mut fd_set) -> () {
655 for slot in (*set).fds_bits.iter_mut() {
656 *slot = 0;
657 }
658 }
659
660 pub fn WIFSTOPPED(status: ::c_int) -> bool {
661 (status & 0xff) == 0x7f
662 }
663
664 pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
665 (status >> 8) & 0xff
666 }
667
668 pub fn WIFSIGNALED(status: ::c_int) -> bool {
669 (status & 0x7f) + 1 >= 2
670 }
671
672 pub fn WTERMSIG(status: ::c_int) -> ::c_int {
673 status & 0x7f
674 }
675
676 pub fn WIFEXITED(status: ::c_int) -> bool {
677 (status & 0x7f) == 0
678 }
679
680 pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
681 (status >> 8) & 0xff
682 }
683
684 pub fn WCOREDUMP(status: ::c_int) -> bool {
685 (status & 0x80) != 0
686 }
687}
688
689extern {
690 pub fn getpwnam_r(name: *const ::c_char,
691 pwd: *mut passwd,
692 buf: *mut ::c_char,
693 buflen: ::size_t,
694 result: *mut *mut passwd) -> ::c_int;
695 pub fn getpwuid_r(uid: ::uid_t,
696 pwd: *mut passwd,
697 buf: *mut ::c_char,
698 buflen: ::size_t,
699 result: *mut *mut passwd) -> ::c_int;
700 pub fn fdatasync(fd: ::c_int) -> ::c_int;
701 pub fn mincore(addr: *mut ::c_void, len: ::size_t,
702 vec: *mut ::c_uchar) -> ::c_int;
703 pub fn clock_getres(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int;
704 pub fn clock_gettime(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int;
705 pub fn clock_nanosleep(clk_id: clockid_t,
706 flags: ::c_int,
707 rqtp: *const ::timespec,
708 rmtp: *mut ::timespec) -> ::c_int;
709 pub fn prctl(option: ::c_int, ...) -> ::c_int;
710 pub fn pthread_getattr_np(native: ::pthread_t,
711 attr: *mut ::pthread_attr_t) -> ::c_int;
712 pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
713 guardsize: *mut ::size_t) -> ::c_int;
714 pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t,
715 stackaddr: *mut *mut ::c_void,
716 stacksize: *mut ::size_t) -> ::c_int;
717 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
718 pub fn setgroups(ngroups: ::size_t,
719 ptr: *const ::gid_t) -> ::c_int;
720 pub fn sched_setscheduler(pid: ::pid_t,
721 policy: ::c_int,
722 param: *const sched_param) -> ::c_int;
723 pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
724 pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
725 pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;
726 pub fn epoll_create(size: ::c_int) -> ::c_int;
727 pub fn epoll_create1(flags: ::c_int) -> ::c_int;
728 pub fn epoll_ctl(epfd: ::c_int,
729 op: ::c_int,
730 fd: ::c_int,
731 event: *mut epoll_event) -> ::c_int;
732 pub fn epoll_wait(epfd: ::c_int,
733 events: *mut epoll_event,
734 maxevents: ::c_int,
735 timeout: ::c_int) -> ::c_int;
736 pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
737 pub fn mount(src: *const ::c_char,
738 target: *const ::c_char,
739 fstype: *const ::c_char,
740 flags: ::c_ulong,
741 data: *const ::c_void) -> ::c_int;
742 pub fn umount(target: *const ::c_char) -> ::c_int;
743 pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int;
744 pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int,
745 child_stack: *mut ::c_void,
746 flags: ::c_int,
747 arg: *mut ::c_void, ...) -> ::c_int;
748 pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
749 pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
750 pub fn memrchr(cx: *const ::c_void,
751 c: ::c_int,
752 n: ::size_t) -> *mut ::c_void;
753 pub fn syscall(num: ::c_long, ...) -> ::c_long;
754 pub fn sendfile(out_fd: ::c_int,
755 in_fd: ::c_int,
756 offset: *mut off_t,
757 count: ::size_t) -> ::ssize_t;
758 pub fn splice(fd_in: ::c_int,
759 off_in: *mut ::loff_t,
760 fd_out: ::c_int,
761 off_out: *mut ::loff_t,
762 len: ::size_t,
763 flags: ::c_uint) -> ::ssize_t;
764 pub fn tee(fd_in: ::c_int,
765 fd_out: ::c_int,
766 len: ::size_t,
767 flags: ::c_uint) -> ::ssize_t;
768 pub fn vmsplice(fd: ::c_int,
769 iov: *const ::iovec,
770 nr_segs: ::size_t,
771 flags: ::c_uint) -> ::ssize_t;
772
773 pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
774 advise: ::c_int) -> ::c_int;
775 pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
776 pub fn utimensat(dirfd: ::c_int, path: *const ::c_char,
777 times: *const ::timespec, flag: ::c_int) -> ::c_int;
778 pub fn duplocale(base: ::locale_t) -> ::locale_t;
779 pub fn freelocale(loc: ::locale_t);
780 pub fn newlocale(mask: ::c_int,
781 locale: *const ::c_char,
782 base: ::locale_t) -> ::locale_t;
783 pub fn uselocale(loc: ::locale_t) -> ::locale_t;
784 pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int;
785 pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int;
786 pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int;
787 pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int;
788 pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t;
789 pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
790 pub fn mmap64(addr: *mut ::c_void,
791 len: ::size_t,
792 prot: ::c_int,
793 flags: ::c_int,
794 fd: ::c_int,
795 offset: off64_t)
796 -> *mut ::c_void;
797 pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
798 pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
799 offset: off64_t) -> ::ssize_t;
800 pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
801 offset: off64_t) -> ::ssize_t;
802 pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64,
803 result: *mut *mut ::dirent64) -> ::c_int;
804 pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int;
805 pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
806 pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
807 pub fn sysinfo (info: *mut ::sysinfo) -> ::c_int;
808
809 pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
810 flags: ::c_int, ...) -> ::c_int;
811 pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char,
812 mode: ::c_int, flags: ::c_int) -> ::c_int;
813 pub fn fchmodat(dirfd: ::c_int, pathname: *const ::c_char,
814 mode: ::mode_t, flags: ::c_int) -> ::c_int;
815 pub fn fchownat(dirfd: ::c_int, pathname: *const ::c_char,
816 owner: ::uid_t, group: ::gid_t,
817 flags: ::c_int) -> ::c_int;
818 pub fn fstatat(dirfd: ::c_int, pathname: *const ::c_char,
819 buf: *mut stat, flags: ::c_int) -> ::c_int;
820 pub fn linkat(olddirfd: ::c_int, oldpath: *const ::c_char,
821 newdirfd: ::c_int, newpath: *const ::c_char,
822 flags: ::c_int) -> ::c_int;
823 pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
824 mode: ::mode_t) -> ::c_int;
825 pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char,
826 mode: ::mode_t, dev: dev_t) -> ::c_int;
827 pub fn readlinkat(dirfd: ::c_int, pathname: *const ::c_char,
828 buf: *mut ::c_char, bufsiz: ::size_t) -> ::ssize_t;
829 pub fn renameat(olddirfd: ::c_int, oldpath: *const ::c_char,
830 newdirfd: ::c_int, newpath: *const ::c_char)
831 -> ::c_int;
832 pub fn symlinkat(target: *const ::c_char, newdirfd: ::c_int,
833 linkpath: *const ::c_char) -> ::c_int;
834 pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char,
835 flags: ::c_int) -> ::c_int;
836 pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t,
837 clock_id: *mut clockid_t) -> ::c_int;
838 pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
839 clock_id: clockid_t) -> ::c_int;
840 pub fn sched_getaffinity(pid: ::pid_t,
841 cpusetsize: ::size_t,
842 cpuset: *mut cpu_set_t) -> ::c_int;
843 pub fn sched_setaffinity(pid: ::pid_t,
844 cpusetsize: ::size_t,
845 cpuset: *const cpu_set_t) -> ::c_int;
846 pub fn unshare(flags: ::c_int) -> ::c_int;
847 pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int;
848 pub fn sem_timedwait(sem: *mut sem_t,
849 abstime: *const ::timespec) -> ::c_int;
850 pub fn accept4(fd: ::c_int, addr: *mut ::sockaddr, len: *mut ::socklen_t,
851 flg: ::c_int) -> ::c_int;
852 pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
853 abstime: *const ::timespec) -> ::c_int;
854}
855
856cfg_if! {
857 if #[cfg(any(target_os = "linux",
858 target_os = "emscripten"))] {
859 mod linux;
860 pub use self::linux::*;
861 } else if #[cfg(target_os = "android")] {
862 mod android;
863 pub use self::android::*;
864 } else {
865 // Unknown target_os
866 }
867}