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