]> git.proxmox.com Git - cargo.git/blob - vendor/libc/src/unix/hermit/mod.rs
New upstream version 0.37.0
[cargo.git] / vendor / libc / src / unix / hermit / mod.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // liblibc port for HermitCore (https://hermitcore.org)
12 // HermitCore is a unikernel based on lwIP, newlib, and
13 // pthread-embedded.
14 // Consider these definitions when porting liblibc to another
15 // lwIP/newlib/pte-based target.
16 //
17 // Ported by Colin Finck <colin.finck@rwth-aachen.de>
18
19 pub type c_long = i64;
20 pub type c_ulong = u64;
21
22 pub type speed_t = ::c_uint;
23 pub type mode_t = u32;
24 pub type dev_t = i16;
25 pub type nfds_t = ::c_ulong;
26 pub type socklen_t = u32;
27 pub type sa_family_t = u8;
28 pub type clock_t = c_ulong;
29 pub type time_t = c_long;
30 pub type suseconds_t = c_long;
31 pub type off_t = i64;
32 pub type rlim_t = ::c_ulonglong;
33 pub type sigset_t = ::c_ulong;
34 pub type ino_t = u16;
35 pub type nlink_t = u16;
36 pub type blksize_t = c_long;
37 pub type blkcnt_t = c_long;
38 pub type stat64 = stat;
39 pub type clockid_t = c_ulong;
40 pub type pthread_t = pte_handle_t;
41 pub type pthread_attr_t = usize;
42 pub type pthread_cond_t = usize;
43 pub type pthread_condattr_t = usize;
44 pub type pthread_key_t = usize;
45 pub type pthread_mutex_t = usize;
46 pub type pthread_mutexattr_t = usize;
47 pub type pthread_rwlock_t = usize;
48 pub type pthread_rwlockattr_t = usize;
49
50 s_no_extra_traits! {
51 pub struct dirent {
52 pub d_ino: ::c_long,
53 pub d_off: off_t,
54 pub d_reclen: u16,
55 pub d_name: [::c_char; 256],
56 }
57
58 // Dummy
59 pub struct sockaddr_un {
60 pub sun_family: sa_family_t,
61 pub sun_path: [::c_char; 108],
62 }
63
64 pub struct sockaddr {
65 pub sa_len: u8,
66 pub sa_family: sa_family_t,
67 pub sa_data: [::c_char; 14],
68 }
69
70 pub struct sockaddr_in {
71 pub sin_len: u8,
72 pub sin_family: sa_family_t,
73 pub sin_port: ::in_port_t,
74 pub sin_addr: ::in_addr,
75 pub sin_zero: [::c_char; 8],
76 }
77
78 pub struct fd_set {
79 fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
80 }
81
82 pub struct sockaddr_storage {
83 pub s2_len: u8,
84 pub ss_family: sa_family_t,
85 pub s2_data1: [::c_char; 2],
86 pub s2_data2: [u32; 3],
87 pub s2_data3: [u32; 3],
88 }
89
90 pub struct stat {
91 pub st_dev: ::dev_t,
92 pub st_ino: ::ino_t,
93 pub st_mode: ::mode_t,
94 pub st_nlink: ::nlink_t,
95 pub st_uid: ::uid_t,
96 pub st_gid: ::gid_t,
97 pub st_rdev: dev_t,
98 pub st_size: off_t,
99 pub st_atime: time_t,
100 pub st_atime_nsec: ::c_long,
101 pub st_mtime: time_t,
102 pub st_mtime_nsec: ::c_long,
103 pub st_ctime: time_t,
104 pub st_ctime_nsec: ::c_long,
105 pub st_blksize: blksize_t,
106 pub st_blocks: blkcnt_t,
107 pub st_spare4: [::c_long; 2],
108 }
109 }
110
111 cfg_if! {
112 if #[cfg(feature = "extra_traits")] {
113 impl PartialEq for dirent {
114 fn eq(&self, other: &dirent) -> bool {
115 self.d_ino == other.d_ino
116 && self.d_off == other.d_off
117 && self.d_reclen == other.d_reclen
118 && self
119 .d_name
120 .iter()
121 .zip(other.d_name.iter())
122 .all(|(a,b)| a == b)
123 }
124 }
125 impl Eq for dirent {}
126 impl ::fmt::Debug for dirent {
127 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
128 f.debug_struct("dirent")
129 .field("d_ino", &self.d_ino)
130 .field("d_off", &self.d_off)
131 .field("d_reclen", &self.d_reclen)
132 // FIXME: .field("d_name", &self.d_name)
133 .finish()
134 }
135 }
136 impl ::hash::Hash for dirent {
137 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
138 self.d_ino.hash(state);
139 self.d_off.hash(state);
140 self.d_reclen.hash(state);
141 self.d_name.hash(state);
142 }
143 }
144
145 impl PartialEq for sockaddr_un {
146 fn eq(&self, other: &sockaddr_un) -> bool {
147 self.sun_family == other.sun_family
148 && self
149 .sun_path
150 .iter()
151 .zip(other.sun_path.iter())
152 .all(|(a,b)| a == b)
153 }
154 }
155 impl Eq for sockaddr_un {}
156 impl ::fmt::Debug for sockaddr_un {
157 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
158 f.debug_struct("sockaddr_un")
159 .field("sun_family", &self.sun_family)
160 // FIXME: .field("sun_path", &self.sun_path)
161 .finish()
162 }
163 }
164 impl ::hash::Hash for sockaddr_un {
165 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
166 self.sun_family.hash(state);
167 self.sun_path.hash(state);
168 }
169 }
170
171 impl PartialEq for sockaddr {
172 fn eq(&self, other: &sockaddr) -> bool {
173 self.sa_len == other.sa_len
174 && self.sa_family == other.sa_family
175 && self
176 .sa_data
177 .iter()
178 .zip(other.sa_data.iter())
179 .all(|(a,b)| a == b)
180 }
181 }
182 impl Eq for sockaddr {}
183 impl ::fmt::Debug for sockaddr {
184 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
185 f.debug_struct("sockaddr")
186 .field("sa_len", &self.sa_len)
187 .field("sa_family", &self.sa_family)
188 // FIXME: .field("sa_data", &self.sa_data)
189 .finish()
190 }
191 }
192 impl ::hash::Hash for sockaddr {
193 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
194 self.sa_len.hash(state);
195 self.sa_family.hash(state);
196 self.sa_data.hash(state);
197 }
198 }
199
200 impl PartialEq for sockaddr_in {
201 fn eq(&self, other: &sockaddr_in) -> bool {
202 self.sin_len == other.sin_len
203 && self.sin_family == other.sin_family
204 && self.sin_port == other.sin_port
205 && self.sin_addr == other.sin_addr
206 && self
207 .sin_zero
208 .iter()
209 .zip(other.sin_zero.iter())
210 .all(|(a,b)| a == b)
211 }
212 }
213 impl Eq for sockaddr_in {}
214 impl ::fmt::Debug for sockaddr_in {
215 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
216 f.debug_struct("sockaddr_in")
217 .field("sin_len", &self.sin_len)
218 .field("sin_family", &self.sin_family)
219 .field("sin_port", &self.sin_port)
220 .field("sin_addr", &self.sin_addr)
221 // FIXME: .field("sin_zero", &self.sin_zero)
222 .finish()
223 }
224 }
225 impl ::hash::Hash for sockaddr_in {
226 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
227 self.sin_len.hash(state);
228 self.sin_family.hash(state);
229 self.sin_port.hash(state);
230 self.sin_addr.hash(state);
231 self.sin_zero.hash(state);
232 }
233 }
234
235 impl PartialEq for fd_set {
236 fn eq(&self, other: &fd_set) -> bool {
237 self.fds_bits
238 .iter()
239 .zip(other.fds_bits.iter())
240 .all(|(a,b)| a == b)
241 }
242 }
243 impl Eq for fd_set {}
244 impl ::fmt::Debug for fd_set {
245 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
246 f.debug_struct("fd_set")
247 // FIXME: .field("fds_bits", &self.fds_bits)
248 .finish()
249 }
250 }
251 impl ::hash::Hash for fd_set {
252 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
253 self.fds_bits.hash(state);
254 }
255 }
256
257 impl PartialEq for sockaddr_storage {
258 fn eq(&self, other: &sockaddr_storage) -> bool {
259 self.s2_len == other.s2_len
260 && self.ss_family == other.ss_family
261 && self.s2_data1
262 .iter()
263 .zip(other.s2_data1.iter())
264 .all(|(a,b)| a == b)
265 && self.s2_data2
266 .iter()
267 .zip(other.s2_data2.iter())
268 .all(|(a,b)| a == b)
269 && self.s2_data3
270 .iter()
271 .zip(other.s2_data3.iter())
272 .all(|(a,b)| a == b)
273 }
274 }
275 impl Eq for sockaddr_storage {}
276 impl ::fmt::Debug for sockaddr_storage {
277 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
278 f.debug_struct("sockaddr_storage")
279 .field("s2_len", &self.s2_len)
280 .field("ss_family", &self.ss_family)
281 // FIXME: .field("s2_data1", &self.s2_data1)
282 // FIXME: .field("s2_data2", &self.s2_data2)
283 // FIXME: .field("s2_data3", &self.s2_data3)
284 .finish()
285 }
286 }
287 impl ::hash::Hash for sockaddr_storage {
288 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
289 self.s2_len.hash(state);
290 self.ss_family.hash(state);
291 self.s2_data1.hash(state);
292 self.s2_data2.hash(state);
293 self.s2_data3.hash(state);
294 }
295 }
296
297 impl PartialEq for stat {
298 fn eq(&self, other: &stat) -> bool {
299 self.st_dev == other.st_dev
300 && self.st_ino == other.st_ino
301 && self.st_mode == other.st_mode
302 && self.st_nlink == other.st_nlink
303 && self.st_uid == other.st_uid
304 && self.st_gid == other.st_gid
305 && self.st_rdev == other.st_rdev
306 && self.st_size == other.st_size
307 && self.st_atime == other.st_atime
308 && self.st_atime_nsec == other.st_atime_nsec
309 && self.st_mtime == other.st_mtime
310 && self.st_mtime_nsec == other.st_mtime_nsec
311 && self.st_ctime == other.st_ctime
312 && self.st_ctime_nsec == other.st_ctime_nsec
313 && self.st_blksize == other.st_blksize
314 && self.st_blocks == other.st_blocks
315 && self
316 .st_spare4
317 .iter()
318 .zip(other.st_spare4.iter())
319 .all(|(a,b)| a == b)
320 }
321 }
322 impl Eq for stat {}
323 impl ::fmt::Debug for stat {
324 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
325 f.debug_struct("stat")
326 .field("st_dev", &self.st_dev)
327 .field("st_ino", &self.st_ino)
328 .field("st_mode", &self.st_mode)
329 .field("st_nlink", &self.st_nlink)
330 .field("st_uid", &self.st_uid)
331 .field("st_gid", &self.st_gid)
332 .field("st_rdev", &self.st_rdev)
333 .field("st_size", &self.st_size)
334 .field("st_atime", &self.st_atime)
335 .field("st_atime_nsec", &self.st_atime_nsec)
336 .field("st_mtime", &self.st_mtime)
337 .field("st_mtime_nsec", &self.st_mtime_nsec)
338 .field("st_ctime", &self.st_ctime)
339 .field("st_ctime_nsec", &self.st_ctime_nsec)
340 .field("st_blksize", &self.st_blksize)
341 .field("st_blocks", &self.st_blocks)
342 // FIXME: .field("st_spare4", &self.st_spare4)
343 .finish()
344 }
345 }
346 impl ::hash::Hash for stat {
347 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
348 self.st_dev.hash(state);
349 self.st_ino.hash(state);
350 self.st_mode.hash(state);
351 self.st_nlink.hash(state);
352 self.st_uid.hash(state);
353 self.st_gid.hash(state);
354 self.st_rdev.hash(state);
355 self.st_size.hash(state);
356 self.st_atime.hash(state);
357 self.st_atime_nsec.hash(state);
358 self.st_mtime.hash(state);
359 self.st_mtime_nsec.hash(state);
360 self.st_ctime.hash(state);
361 self.st_ctime_nsec.hash(state);
362 self.st_blksize.hash(state);
363 self.st_blocks.hash(state);
364 self.st_spare4.hash(state);
365 }
366 }
367 }
368 }
369
370 s! {
371 pub struct in_addr {
372 pub s_addr: ::in_addr_t,
373 }
374
375 pub struct ip_mreq {
376 pub imr_multiaddr: in_addr,
377 pub imr_interface: in_addr,
378 }
379
380 pub struct addrinfo {
381 pub ai_flags: ::c_int,
382 pub ai_family: ::c_int,
383 pub ai_socktype: ::c_int,
384 pub ai_protocol: ::c_int,
385 pub ai_addrlen: socklen_t,
386 pub ai_addr: *mut ::sockaddr,
387 pub ai_canonname: *mut c_char,
388 pub ai_next: *mut addrinfo,
389 }
390
391 pub struct Dl_info {}
392
393 pub struct lconv {
394 pub decimal_point: *mut ::c_char,
395 pub thousands_sep: *mut ::c_char,
396 pub grouping: *mut ::c_char,
397 pub int_curr_symbol: *mut ::c_char,
398 pub currency_symbol: *mut ::c_char,
399 pub mon_decimal_point: *mut ::c_char,
400 pub mon_thousands_sep: *mut ::c_char,
401 pub mon_grouping: *mut ::c_char,
402 pub positive_sign: *mut ::c_char,
403 pub negative_sign: *mut ::c_char,
404 pub int_frac_digits: ::c_char,
405 pub frac_digits: ::c_char,
406 pub p_cs_precedes: ::c_char,
407 pub p_sep_by_space: ::c_char,
408 pub n_cs_precedes: ::c_char,
409 pub n_sep_by_space: ::c_char,
410 pub p_sign_posn: ::c_char,
411 pub n_sign_posn: ::c_char,
412 pub int_p_cs_precedes: ::c_char,
413 pub int_p_sep_by_space: ::c_char,
414 pub int_n_cs_precedes: ::c_char,
415 pub int_n_sep_by_space: ::c_char,
416 pub int_p_sign_posn: ::c_char,
417 pub int_n_sign_posn: ::c_char,
418 }
419
420 pub struct passwd { // Unverified
421 pub pw_name: *mut ::c_char,
422 pub pw_passwd: *mut ::c_char,
423 pub pw_uid: ::uid_t,
424 pub pw_gid: ::gid_t,
425 pub pw_gecos: *mut ::c_char,
426 pub pw_dir: *mut ::c_char,
427 pub pw_shell: *mut ::c_char,
428 }
429
430 pub struct pte_handle_t {
431 pub p: usize,
432 pub x: ::c_uint,
433 }
434
435 pub struct sched_param {
436 pub sched_priority: ::c_int,
437 }
438
439 pub struct sem_t {
440 pub value: i32,
441 pub lock: usize,
442 pub sem: usize,
443 }
444
445 pub struct sigaction {
446 pub sa_flags: ::c_int,
447 pub sa_mask: sigset_t,
448 pub sa_handler: usize,
449 }
450
451 pub struct sockaddr_in6 {
452 pub sin6_len: u8,
453 pub sin6_family: sa_family_t,
454 pub sin6_port: ::in_port_t,
455 pub sin6_flowinfo: u32,
456 pub sin6_addr: ::in6_addr,
457 pub sin6_scope_id: u32,
458 }
459
460 pub struct statvfs {}
461
462 pub struct tm {
463 pub tm_sec: ::c_int,
464 pub tm_min: ::c_int,
465 pub tm_hour: ::c_int,
466 pub tm_mday: ::c_int,
467 pub tm_mon: ::c_int,
468 pub tm_year: ::c_int,
469 pub tm_wday: ::c_int,
470 pub tm_yday: ::c_int,
471 pub tm_isdst: ::c_int,
472 }
473
474 pub struct tms {
475 pub tms_utime: ::clock_t,
476 pub tms_stime: ::clock_t,
477 pub tms_cutime: ::clock_t,
478 pub tms_cstime: ::clock_t,
479 }
480
481 pub struct termios {}
482
483 pub struct utsname {}
484 }
485
486 pub const AF_UNSPEC: ::c_int = 0;
487 pub const AF_INET: ::c_int = 2;
488 pub const AF_INET6: ::c_int = 10;
489
490 // Dummy
491 pub const AF_UNIX: ::c_int = 1;
492
493 pub const CLOCK_REALTIME: ::clockid_t = 1;
494 pub const CLOCK_MONOTONIC: ::clockid_t = 4;
495
496 // Dummy
497 pub const EAI_SYSTEM: ::c_int = -11;
498
499 pub const EPERM: ::c_int = 1;
500 pub const ENOENT: ::c_int = 2;
501 pub const ESRCH: ::c_int = 3;
502 pub const EINTR: ::c_int = 4;
503 pub const EIO: ::c_int = 5;
504 pub const ENXIO: ::c_int = 6;
505 pub const E2BIG: ::c_int = 7;
506 pub const ENOEXEC: ::c_int = 8;
507 pub const EBADF: ::c_int = 9;
508 pub const ECHILD: ::c_int = 10;
509 pub const EAGAIN: ::c_int = 11;
510 pub const ENOMEM: ::c_int = 12;
511 pub const EACCES: ::c_int = 13;
512 pub const EFAULT: ::c_int = 14;
513 pub const EBUSY: ::c_int = 16;
514 pub const EEXIST: ::c_int = 17;
515 pub const EXDEV: ::c_int = 18;
516 pub const ENODEV: ::c_int = 19;
517 pub const ENOTDIR: ::c_int = 20;
518 pub const EISDIR: ::c_int = 21;
519 pub const EINVAL: ::c_int = 22;
520 pub const ENFILE: ::c_int = 23;
521 pub const EMFILE: ::c_int = 24;
522 pub const ENOTTY: ::c_int = 25;
523 pub const ETXTBSY: ::c_int = 26;
524 pub const EFBIG: ::c_int = 27;
525 pub const ENOSPC: ::c_int = 28;
526 pub const ESPIPE: ::c_int = 29;
527 pub const EROFS: ::c_int = 30;
528 pub const EMLINK: ::c_int = 31;
529 pub const EPIPE: ::c_int = 32;
530 pub const EDOM: ::c_int = 33;
531 pub const ERANGE: ::c_int = 34;
532 pub const EDEADLK: ::c_int = 35;
533 pub const ENAMETOOLONG: ::c_int = 36;
534 pub const ENOLCK: ::c_int = 37;
535 pub const ENOSYS: ::c_int = 38;
536 pub const ENOTEMPTY: ::c_int = 39;
537 pub const ELOOP: ::c_int = 40;
538 pub const EWOULDBLOCK: ::c_int = EAGAIN;
539 pub const ENOMSG: ::c_int = 42;
540 pub const EIDRM: ::c_int = 43;
541 pub const ECHRNG: ::c_int = 44;
542 pub const EL2NSYNC: ::c_int = 45;
543 pub const EL3HLT: ::c_int = 46;
544 pub const EL3RST: ::c_int = 47;
545 pub const ELNRNG: ::c_int = 48;
546 pub const EUNATCH: ::c_int = 49;
547 pub const ENOCSI: ::c_int = 50;
548 pub const EL2HLT: ::c_int = 51;
549 pub const EBADE: ::c_int = 52;
550 pub const EBADR: ::c_int = 53;
551 pub const EXFULL: ::c_int = 54;
552 pub const ENOANO: ::c_int = 55;
553 pub const EBADRQC: ::c_int = 56;
554 pub const EBADSLT: ::c_int = 57;
555 pub const EDEADLOCK: ::c_int = EDEADLK;
556 pub const EBFONT: ::c_int = 59;
557 pub const ENOSTR: ::c_int = 60;
558 pub const ENODATA: ::c_int = 61;
559 pub const ETIME: ::c_int = 62;
560 pub const ENOSR: ::c_int = 63;
561 pub const ENONET: ::c_int = 64;
562 pub const ENOPKG: ::c_int = 65;
563 pub const EREMOTE: ::c_int = 66;
564 pub const ENOLINK: ::c_int = 67;
565 pub const EADV: ::c_int = 68;
566 pub const ESRMNT: ::c_int = 69;
567 pub const ECOMM: ::c_int = 70;
568 pub const EPROTO: ::c_int = 71;
569 pub const EMULTIHOP: ::c_int = 72;
570 pub const EDOTDOT: ::c_int = 73;
571 pub const EBADMSG: ::c_int = 74;
572 pub const EOVERFLOW: ::c_int = 75;
573 pub const ENOTUNIQ: ::c_int = 76;
574 pub const EBADFD: ::c_int = 77;
575 pub const EREMCHG: ::c_int = 78;
576 pub const ELIBACC: ::c_int = 79;
577 pub const ELIBBAD: ::c_int = 80;
578 pub const ELIBSCN: ::c_int = 81;
579 pub const ELIBMAX: ::c_int = 82;
580 pub const ELIBEXEC: ::c_int = 83;
581 pub const EILSEQ: ::c_int = 84;
582 pub const ERESTART: ::c_int = 85;
583 pub const ESTRPIPE: ::c_int = 86;
584 pub const EUSERS: ::c_int = 87;
585 pub const ENOTSOCK: ::c_int = 88;
586 pub const EDESTADDRREQ: ::c_int = 89;
587 pub const EMSGSIZE: ::c_int = 90;
588 pub const EPROTOTYPE: ::c_int = 91;
589 pub const ENOPROTOOPT: ::c_int = 92;
590 pub const EPROTONOSUPPORT: ::c_int = 93;
591 pub const ESOCKTNOSUPPORT: ::c_int = 94;
592 pub const EOPNOTSUPP: ::c_int = 95;
593 pub const EPFNOSUPPORT: ::c_int = 96;
594 pub const EAFNOSUPPORT: ::c_int = 97;
595 pub const EADDRINUSE: ::c_int = 98;
596 pub const EADDRNOTAVAIL: ::c_int = 99;
597 pub const ENETDOWN: ::c_int = 100;
598 pub const ENETUNREACH: ::c_int = 101;
599 pub const ENETRESET: ::c_int = 102;
600 pub const ECONNABORTED: ::c_int = 103;
601 pub const ECONNRESET: ::c_int = 104;
602 pub const ENOBUFS: ::c_int = 105;
603 pub const EISCONN: ::c_int = 106;
604 pub const ENOTCONN: ::c_int = 107;
605 pub const ESHUTDOWN: ::c_int = 108;
606 pub const ETOOMANYREFS: ::c_int = 109;
607 pub const ETIMEDOUT: ::c_int = 110;
608 pub const ECONNREFUSED: ::c_int = 111;
609 pub const EHOSTDOWN: ::c_int = 112;
610 pub const EHOSTUNREACH: ::c_int = 113;
611 pub const EALREADY: ::c_int = 114;
612 pub const EINPROGRESS: ::c_int = 115;
613 pub const ESTALE: ::c_int = 116;
614 pub const EUCLEAN: ::c_int = 117;
615 pub const ENOTNAM: ::c_int = 118;
616 pub const ENAVAIL: ::c_int = 119;
617 pub const EISNAM: ::c_int = 120;
618 pub const EREMOTEIO: ::c_int = 121;
619 pub const EDQUOT: ::c_int = 122;
620 pub const ENOMEDIUM: ::c_int = 123;
621 pub const EMEDIUMTYPE: ::c_int = 124;
622 pub const ECANCELED: ::c_int = 125;
623 pub const ENOKEY: ::c_int = 126;
624 pub const EKEYEXPIRED: ::c_int = 127;
625 pub const EKEYREVOKED: ::c_int = 128;
626 pub const EKEYREJECTED: ::c_int = 129;
627 pub const EOWNERDEAD: ::c_int = 130;
628 pub const ENOTRECOVERABLE: ::c_int = 131;
629 pub const ERFKILL: ::c_int = 132;
630 pub const EHWPOISON: ::c_int = 133;
631
632 pub const EXIT_FAILURE: ::c_int = 1;
633 pub const EXIT_SUCCESS: ::c_int = 0;
634
635 pub const F_DUPFD: ::c_int = 0;
636 pub const F_GETFD: ::c_int = 1;
637 pub const F_SETFD: ::c_int = 2;
638 pub const F_GETFL: ::c_int = 3;
639 pub const F_SETFL: ::c_int = 4;
640 pub const F_GETOWN: ::c_int = 5;
641 pub const F_SETOWN: ::c_int = 6;
642 pub const F_GETLK: ::c_int = 7;
643 pub const F_SETLK: ::c_int = 8;
644 pub const F_SETLKW: ::c_int = 9;
645 pub const F_RGETLK: ::c_int = 10;
646 pub const F_RSETLK: ::c_int = 11;
647 pub const F_CNVT: ::c_int = 12;
648 pub const F_RSETLKW: ::c_int = 13;
649 pub const F_DUPFD_CLOEXEC: ::c_int = 14;
650
651 pub const FD_SETSIZE: usize = 1024;
652
653 // Dummy
654 pub const FIOCLEX: ::c_int = 0x5451;
655
656 pub const FIONBIO: ::c_int = 0x8004667e;
657 pub const FIONREAD: ::c_int = 0x4004667f;
658
659 pub const IP_ADD_MEMBERSHIP: ::c_int = 3;
660 pub const IP_DROP_MEMBERSHIP: ::c_int = 4;
661
662 pub const IP_TOS: ::c_int = 1;
663 pub const IP_TTL: ::c_int = 2;
664
665 pub const IP_MULTICAST_TTL: ::c_int = 5;
666 pub const IP_MULTICAST_IF: ::c_int = 6;
667 pub const IP_MULTICAST_LOOP: ::c_int = 7;
668
669 pub const IPV6_JOIN_GROUP: ::c_int = 12;
670 pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12;
671 pub const IPV6_LEAVE_GROUP: ::c_int = 13;
672 pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13;
673 pub const IPV6_V6ONLY: ::c_int = 27;
674
675 // Dummy
676 pub const IPV6_MULTICAST_LOOP: ::c_int = 7;
677
678 pub const MSG_PEEK: ::c_int = 0x01;
679 pub const MSG_WAITALL: ::c_int = 0x02;
680 pub const MSG_OOB: ::c_int = 0x04;
681 pub const MSG_DONTWAIT: ::c_int = 0x08;
682 pub const MSG_MORE: ::c_int = 0x10;
683
684 pub const O_ACCMODE: ::c_int = 3;
685 pub const O_RDONLY: ::c_int = 0;
686 pub const O_WRONLY: ::c_int = 1;
687 pub const O_RDWR: ::c_int = 2;
688 pub const O_APPEND: ::c_int = 1024;
689 pub const O_CREAT: ::c_int = 64;
690 pub const O_EXCL: ::c_int = 128;
691 pub const O_NOCTTY: ::c_int = 256;
692 pub const O_NONBLOCK: ::c_int = 2048;
693 pub const O_TRUNC: ::c_int = 512;
694 pub const O_CLOEXEC: ::c_int = 524288;
695
696 pub const POLLIN: ::c_short = 0x1;
697 pub const POLLPRI: ::c_short = 0x2;
698 pub const POLLOUT: ::c_short = 0x4;
699 pub const POLLERR: ::c_short = 0x8;
700 pub const POLLHUP: ::c_short = 0x10;
701 pub const POLLNVAL: ::c_short = 0x20;
702
703 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = usize::max_value();
704 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = usize::max_value();
705 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = usize::max_value();
706
707 pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
708 pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
709 pub const PTHREAD_STACK_MIN: ::size_t = 0;
710
711 // Dummy
712 pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
713
714 pub const _SC_ARG_MAX: ::c_int = 0;
715 pub const _SC_CHILD_MAX: ::c_int = 1;
716 pub const _SC_CLK_TCK: ::c_int = 2;
717 pub const _SC_NGROUPS_MAX: ::c_int = 3;
718 pub const _SC_OPEN_MAX: ::c_int = 4;
719 pub const _SC_JOB_CONTROL: ::c_int = 5;
720 pub const _SC_SAVED_IDS: ::c_int = 6;
721 pub const _SC_VERSION: ::c_int = 7;
722 pub const _SC_PAGESIZE: ::c_int = 8;
723 pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
724 pub const _SC_NPROCESSORS_CONF: ::c_int = 9;
725 pub const _SC_NPROCESSORS_ONLN: ::c_int = 10;
726 pub const _SC_PHYS_PAGES: ::c_int = 11;
727 pub const _SC_AVPHYS_PAGES: ::c_int = 12;
728 pub const _SC_MQ_OPEN_MAX: ::c_int = 13;
729 pub const _SC_MQ_PRIO_MAX: ::c_int = 14;
730 pub const _SC_RTSIG_MAX: ::c_int = 15;
731 pub const _SC_SEM_NSEMS_MAX: ::c_int = 16;
732 pub const _SC_SEM_VALUE_MAX: ::c_int = 17;
733 pub const _SC_SIGQUEUE_MAX: ::c_int = 18;
734 pub const _SC_TIMER_MAX: ::c_int = 19;
735 pub const _SC_TZNAME_MAX: ::c_int = 20;
736 pub const _SC_ASYNCHRONOUS_IO: ::c_int = 21;
737 pub const _SC_FSYNC: ::c_int = 22;
738 pub const _SC_MAPPED_FILES: ::c_int = 23;
739 pub const _SC_MEMLOCK: ::c_int = 24;
740 pub const _SC_MEMLOCK_RANGE: ::c_int = 25;
741 pub const _SC_MEMORY_PROTECTION: ::c_int = 26;
742 pub const _SC_MESSAGE_PASSING: ::c_int = 27;
743 pub const _SC_PRIORITIZED_IO: ::c_int = 28;
744 pub const _SC_REALTIME_SIGNALS: ::c_int = 29;
745 pub const _SC_SEMAPHORES: ::c_int = 30;
746 pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 31;
747 pub const _SC_SYNCHRONIZED_IO: ::c_int = 32;
748 pub const _SC_TIMERS: ::c_int = 33;
749 pub const _SC_AIO_LISTIO_MAX: ::c_int = 34;
750 pub const _SC_AIO_MAX: ::c_int = 35;
751 pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 36;
752 pub const _SC_DELAYTIMER_MAX: ::c_int = 37;
753 pub const _SC_THREAD_KEYS_MAX: ::c_int = 38;
754 pub const _SC_THREAD_STACK_MIN: ::c_int = 39;
755 pub const _SC_THREAD_THREADS_MAX: ::c_int = 40;
756 pub const _SC_TTY_NAME_MAX: ::c_int = 41;
757 pub const _SC_THREADS: ::c_int = 42;
758 pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 43;
759 pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 44;
760 pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 45;
761 pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 46;
762 pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 47;
763 pub const _SC_THREAD_PRIO_CEILING: ::c_int = _SC_THREAD_PRIO_PROTECT;
764 pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 48;
765 pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 49;
766 pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 50;
767 pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51;
768 pub const _SC_LOGIN_NAME_MAX: ::c_int = 52;
769 pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 53;
770 pub const _SC_ADVISORY_INFO: ::c_int = 54;
771 pub const _SC_ATEXIT_MAX: ::c_int = 55;
772 pub const _SC_BARRIERS: ::c_int = 56;
773 pub const _SC_BC_BASE_MAX: ::c_int = 57;
774 pub const _SC_BC_DIM_MAX: ::c_int = 58;
775 pub const _SC_BC_SCALE_MAX: ::c_int = 59;
776 pub const _SC_BC_STRING_MAX: ::c_int = 60;
777 pub const _SC_CLOCK_SELECTION: ::c_int = 61;
778 pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 62;
779 pub const _SC_CPUTIME: ::c_int = 63;
780 pub const _SC_EXPR_NEST_MAX: ::c_int = 64;
781 pub const _SC_HOST_NAME_MAX: ::c_int = 65;
782 pub const _SC_IOV_MAX: ::c_int = 66;
783 pub const _SC_IPV6: ::c_int = 67;
784 pub const _SC_LINE_MAX: ::c_int = 68;
785 pub const _SC_MONOTONIC_CLOCK: ::c_int = 69;
786 pub const _SC_RAW_SOCKETS: ::c_int = 70;
787 pub const _SC_READER_WRITER_LOCKS: ::c_int = 71;
788 pub const _SC_REGEXP: ::c_int = 72;
789 pub const _SC_RE_DUP_MAX: ::c_int = 73;
790 pub const _SC_SHELL: ::c_int = 74;
791 pub const _SC_SPAWN: ::c_int = 75;
792 pub const _SC_SPIN_LOCKS: ::c_int = 76;
793 pub const _SC_SPORADIC_SERVER: ::c_int = 77;
794 pub const _SC_SS_REPL_MAX: ::c_int = 78;
795 pub const _SC_SYMLOOP_MAX: ::c_int = 79;
796 pub const _SC_THREAD_CPUTIME: ::c_int = 80;
797 pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 81;
798 pub const _SC_TIMEOUTS: ::c_int = 82;
799 pub const _SC_TRACE: ::c_int = 83;
800 pub const _SC_TRACE_EVENT_FILTER: ::c_int = 84;
801 pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 85;
802 pub const _SC_TRACE_INHERIT: ::c_int = 86;
803 pub const _SC_TRACE_LOG: ::c_int = 87;
804 pub const _SC_TRACE_NAME_MAX: ::c_int = 88;
805 pub const _SC_TRACE_SYS_MAX: ::c_int = 89;
806 pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 90;
807 pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 91;
808 pub const _SC_V7_ILP32_OFF32: ::c_int = 92;
809 pub const _SC_V6_ILP32_OFF32: ::c_int =_SC_V7_ILP32_OFF32;
810 pub const _SC_XBS5_ILP32_OFF32: ::c_int = _SC_V7_ILP32_OFF32;
811 pub const _SC_V7_ILP32_OFFBIG: ::c_int = 93;
812 pub const _SC_V6_ILP32_OFFBIG: ::c_int = _SC_V7_ILP32_OFFBIG;
813 pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = _SC_V7_ILP32_OFFBIG;
814 pub const _SC_V7_LP64_OFF64: ::c_int = 94;
815 pub const _SC_V6_LP64_OFF64: ::c_int = _SC_V7_LP64_OFF64;
816 pub const _SC_XBS5_LP64_OFF64: ::c_int = _SC_V7_LP64_OFF64;
817 pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 95;
818 pub const _SC_V6_LPBIG_OFFBIG: ::c_int = _SC_V7_LPBIG_OFFBIG;
819 pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = _SC_V7_LPBIG_OFFBIG;
820 pub const _SC_XOPEN_CRYPT: ::c_int = 96;
821 pub const _SC_XOPEN_ENH_I18N: ::c_int = 97;
822 pub const _SC_XOPEN_LEGACY: ::c_int = 98;
823 pub const _SC_XOPEN_REALTIME: ::c_int = 99;
824 pub const _SC_STREAM_MAX: ::c_int = 100;
825 pub const _SC_PRIORITY_SCHEDULING: ::c_int = 101;
826 pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 102;
827 pub const _SC_XOPEN_SHM: ::c_int = 103;
828 pub const _SC_XOPEN_STREAMS: ::c_int = 104;
829 pub const _SC_XOPEN_UNIX: ::c_int = 105;
830 pub const _SC_XOPEN_VERSION: ::c_int = 106;
831 pub const _SC_2_CHAR_TERM: ::c_int = 107;
832 pub const _SC_2_C_BIND: ::c_int = 108;
833 pub const _SC_2_C_DEV: ::c_int = 109;
834 pub const _SC_2_FORT_DEV: ::c_int = 110;
835 pub const _SC_2_FORT_RUN: ::c_int = 111;
836 pub const _SC_2_LOCALEDEF: ::c_int = 112;
837 pub const _SC_2_PBS: ::c_int = 113;
838 pub const _SC_2_PBS_ACCOUNTING: ::c_int = 114;
839 pub const _SC_2_PBS_CHECKPOINT: ::c_int = 115;
840 pub const _SC_2_PBS_LOCATE: ::c_int = 116;
841 pub const _SC_2_PBS_MESSAGE: ::c_int = 117;
842 pub const _SC_2_PBS_TRACK: ::c_int = 118;
843 pub const _SC_2_SW_DEV: ::c_int = 119;
844 pub const _SC_2_UPE: ::c_int = 120;
845 pub const _SC_2_VERSION: ::c_int = 121;
846 pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 122;
847 pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 123;
848 pub const _SC_XOPEN_UUCP: ::c_int = 124;
849 pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 125;
850 pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 126;
851 pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 127;
852 pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 128;
853 pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 129;
854 pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 130;
855 pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 131;
856 pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 132;
857 pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 133;
858 pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 134;
859 pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 135;
860 pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 136;
861 pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 137;
862 pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 138;
863 pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 139;
864
865 pub const S_BLKSIZE: ::mode_t = 1024;
866 pub const S_IREAD: ::mode_t = 256;
867 pub const S_IWRITE: ::mode_t = 128;
868 pub const S_IEXEC: ::mode_t = 64;
869 pub const S_ENFMT: ::mode_t = 1024;
870 pub const S_IFMT: ::mode_t = 61440;
871 pub const S_IFDIR: ::mode_t = 16384;
872 pub const S_IFCHR: ::mode_t = 8192;
873 pub const S_IFBLK: ::mode_t = 24576;
874 pub const S_IFREG: ::mode_t = 32768;
875 pub const S_IFLNK: ::mode_t = 40960;
876 pub const S_IFSOCK: ::mode_t = 49152;
877 pub const S_IFIFO: ::mode_t = 4096;
878 pub const S_IRUSR: ::mode_t = 256;
879 pub const S_IWUSR: ::mode_t = 128;
880 pub const S_IXUSR: ::mode_t = 64;
881 pub const S_IRGRP: ::mode_t = 32;
882 pub const S_IWGRP: ::mode_t = 16;
883 pub const S_IXGRP: ::mode_t = 8;
884 pub const S_IROTH: ::mode_t = 4;
885 pub const S_IWOTH: ::mode_t = 2;
886 pub const S_IXOTH: ::mode_t = 1;
887
888 pub const SEEK_SET: ::c_int = 0;
889 pub const SEEK_CUR: ::c_int = 1;
890 pub const SEEK_END: ::c_int = 2;
891
892 pub const SHUT_RD: ::c_int = 0;
893 pub const SHUT_WR: ::c_int = 1;
894 pub const SHUT_RDWR: ::c_int = 2;
895
896 pub const SIG_SETMASK: ::c_int = 0;
897
898 pub const SIGHUP: ::c_int = 1;
899 pub const SIGINT: ::c_int = 2;
900 pub const SIGQUIT: ::c_int = 3;
901 pub const SIGILL: ::c_int = 4;
902 pub const SIGABRT: ::c_int = 6;
903 pub const SIGEMT: ::c_int = 7;
904 pub const SIGFPE: ::c_int = 8;
905 pub const SIGKILL: ::c_int = 9;
906 pub const SIGSEGV: ::c_int = 11;
907 pub const SIGPIPE: ::c_int = 13;
908 pub const SIGALRM: ::c_int = 14;
909 pub const SIGTERM: ::c_int = 15;
910
911 pub const SO_DEBUG: ::c_int = 0x0001;
912 pub const SO_ACCEPTCONN: ::c_int = 0x0002;
913 pub const SO_REUSEADDR: ::c_int = 0x0004;
914 pub const SO_KEEPALIVE: ::c_int = 0x0008;
915 pub const SO_DONTROUTE: ::c_int = 0x0010;
916 pub const SO_BROADCAST: ::c_int = 0x0020;
917 pub const SO_USELOOPBACK: ::c_int = 0x0040;
918 pub const SO_LINGER: ::c_int = 0x0080;
919 pub const SO_OOBINLINE: ::c_int = 0x0100;
920 pub const SO_REUSEPORT: ::c_int = 0x0200;
921 pub const SO_SNDBUF: ::c_int = 0x1001;
922 pub const SO_RCVBUF: ::c_int = 0x1002;
923 pub const SO_SNDLOWAT: ::c_int = 0x1003;
924 pub const SO_RCVLOWAT: ::c_int = 0x1004;
925 pub const SO_SNDTIMEO: ::c_int = 0x1005;
926 pub const SO_RCVTIMEO: ::c_int = 0x1006;
927 pub const SO_ERROR: ::c_int = 0x1007;
928 pub const SO_TYPE: ::c_int = 0x1008;
929 pub const SO_CONTIMEO: ::c_int = 0x1009;
930 pub const SO_NO_CHECK: ::c_int = 0x100a;
931
932 pub const SOCK_STREAM: ::c_int = 1;
933 pub const SOCK_DGRAM: ::c_int = 2;
934 pub const SOCK_RAW: ::c_int = 3;
935
936 pub const SOL_SOCKET: ::c_int = 0xfff;
937
938 pub const STDIN_FILENO: ::c_int = 0;
939 pub const STDOUT_FILENO: ::c_int = 1;
940 pub const STDERR_FILENO: ::c_int = 2;
941
942 pub const TCP_NODELAY: ::c_int = 0x01;
943 pub const TCP_KEEPALIVE: ::c_int = 0x02;
944 pub const TCP_KEEPIDLE: ::c_int = 0x03;
945 pub const TCP_KEEPINTVL: ::c_int = 0x04;
946 pub const TCP_KEEPCNT: ::c_int = 0x05;
947
948 const ULONG_SIZE: usize = 64;
949
950 pub const WNOHANG: ::c_int = 0x00000001;
951
952 f! {
953 pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
954 (status >> 8) & 0xff
955 }
956
957 pub fn WIFEXITED(status: ::c_int) -> bool {
958 (status & 0xff) == 0
959 }
960
961 pub fn WTERMSIG(status: ::c_int) -> ::c_int {
962 status & 0x7f
963 }
964 }
965
966 extern {
967 pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
968 pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
969 pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
970 buflen: ::size_t) -> ::c_int;
971
972 pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
973 pub fn sem_init(sem: *mut sem_t,
974 pshared: ::c_int,
975 value: ::c_uint)
976 -> ::c_int;
977
978 pub fn abs(i: ::c_int) -> ::c_int;
979 pub fn atof(s: *const ::c_char) -> ::c_double;
980 pub fn labs(i: ::c_long) -> ::c_long;
981 pub fn rand() -> ::c_int;
982 pub fn srand(seed: ::c_uint);
983
984 pub fn bind(s: ::c_int, name: *const ::sockaddr, namelen: ::socklen_t)
985 -> ::c_int;
986
987 pub fn clock_gettime(clock_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
988
989 pub fn gettimeofday(tp: *mut ::timeval,
990 tz: *mut ::c_void) -> ::c_int;
991 pub fn getpwuid_r(uid: ::uid_t, pwd: *mut passwd, buf: *mut ::c_char,
992 buflen: ::size_t, result: *mut *mut passwd) -> ::c_int;
993
994 // Dummy
995 pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
996
997 pub fn memalign(align: ::size_t, nbytes: ::size_t) -> *mut ::c_void;
998
999 pub fn pthread_create(tid: *mut ::pthread_t, attr: *const ::pthread_attr_t,
1000 start: extern fn(*mut ::c_void) -> *mut ::c_void, arg: *mut ::c_void)
1001 -> ::c_int;
1002
1003 pub fn pthread_sigmask(how: ::c_int, set: *const ::sigset_t,
1004 oset: *mut ::sigset_t) -> ::c_int;
1005
1006 pub fn recvfrom(s: ::c_int, mem: *mut ::c_void, len: ::size_t,
1007 flags: ::c_int, from: *mut ::sockaddr, fromlen: *mut ::socklen_t)
1008 -> ::c_int;
1009
1010 pub fn setgroups(ngroups: ::c_int, grouplist: *const ::gid_t) -> ::c_int;
1011 pub fn uname(buf: *mut ::utsname) -> ::c_int;
1012 }
1013
1014 cfg_if! {
1015 if #[cfg(target_arch = "aarch64")] {
1016 mod aarch64;
1017 pub use self::aarch64::*;
1018 } else if #[cfg(target_arch = "x86_64")] {
1019 mod x86_64;
1020 pub use self::x86_64::*;
1021 } else {
1022 // Unknown target_arch
1023 }
1024 }