xref: /aosp_15_r20/external/cronet/third_party/rust/chromium_crates_io/vendor/libc-0.2.153/src/vxworks/mod.rs (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 //! Interface to VxWorks C library
2 
3 use core::mem::size_of;
4 use core::ptr::null_mut;
5 
6 #[cfg_attr(feature = "extra_traits", derive(Debug))]
7 pub enum DIR {}
8 impl ::Copy for DIR {}
9 impl ::Clone for DIR {
clone(&self) -> DIR10     fn clone(&self) -> DIR {
11         *self
12     }
13 }
14 
15 pub type c_schar = i8;
16 pub type c_uchar = u8;
17 pub type c_short = i16;
18 pub type c_ushort = u16;
19 pub type c_int = i32;
20 pub type c_uint = u32;
21 pub type c_float = f32;
22 pub type c_double = f64;
23 pub type c_longlong = i64;
24 pub type c_ulonglong = u64;
25 pub type intmax_t = i64;
26 pub type uintmax_t = u64;
27 
28 pub type uintptr_t = usize;
29 pub type intptr_t = isize;
30 pub type ptrdiff_t = isize;
31 pub type size_t = ::uintptr_t;
32 pub type ssize_t = ::intptr_t;
33 
34 pub type pid_t = ::c_int;
35 pub type in_addr_t = u32;
36 pub type sighandler_t = ::size_t;
37 pub type cpuset_t = u32;
38 
39 pub type blkcnt_t = ::c_long;
40 pub type blksize_t = ::c_long;
41 pub type ino_t = ::c_ulong;
42 
43 pub type rlim_t = ::c_ulong;
44 pub type suseconds_t = ::c_long;
45 pub type time_t = ::c_long;
46 
47 pub type errno_t = ::c_int;
48 
49 pub type useconds_t = ::c_ulong;
50 
51 pub type socklen_t = ::c_uint;
52 
53 pub type pthread_t = ::c_ulong;
54 
55 pub type clockid_t = ::c_int;
56 
57 //defined for the structs
58 pub type dev_t = ::c_ulong;
59 pub type mode_t = ::c_int;
60 pub type nlink_t = ::c_ulong;
61 pub type uid_t = ::c_ushort;
62 pub type gid_t = ::c_ushort;
63 pub type sigset_t = ::c_ulonglong;
64 pub type key_t = ::c_long;
65 
66 pub type nfds_t = ::c_uint;
67 pub type stat64 = ::stat;
68 
69 pub type pthread_key_t = ::c_ulong;
70 
71 // From b_off_t.h
72 pub type off_t = ::c_longlong;
73 pub type off64_t = off_t;
74 
75 // From b_BOOL.h
76 pub type BOOL = ::c_int;
77 
78 // From vxWind.h ..
79 pub type _Vx_OBJ_HANDLE = ::c_int;
80 pub type _Vx_TASK_ID = ::_Vx_OBJ_HANDLE;
81 pub type _Vx_MSG_Q_ID = ::_Vx_OBJ_HANDLE;
82 pub type _Vx_SEM_ID_KERNEL = ::_Vx_OBJ_HANDLE;
83 pub type _Vx_RTP_ID = ::_Vx_OBJ_HANDLE;
84 pub type _Vx_SD_ID = ::_Vx_OBJ_HANDLE;
85 pub type _Vx_CONDVAR_ID = ::_Vx_OBJ_HANDLE;
86 pub type _Vx_SEM_ID = *mut ::_Vx_semaphore;
87 pub type OBJ_HANDLE = ::_Vx_OBJ_HANDLE;
88 pub type TASK_ID = ::OBJ_HANDLE;
89 pub type MSG_Q_ID = ::OBJ_HANDLE;
90 pub type SEM_ID_KERNEL = ::OBJ_HANDLE;
91 pub type RTP_ID = ::OBJ_HANDLE;
92 pub type SD_ID = ::OBJ_HANDLE;
93 pub type CONDVAR_ID = ::OBJ_HANDLE;
94 
95 // From vxTypes.h
96 pub type _Vx_usr_arg_t = isize;
97 pub type _Vx_exit_code_t = isize;
98 pub type _Vx_ticks_t = ::c_uint;
99 pub type _Vx_ticks64_t = ::c_ulonglong;
100 
101 pub type sa_family_t = ::c_uchar;
102 
103 // mqueue.h
104 pub type mqd_t = ::c_int;
105 
106 #[cfg_attr(feature = "extra_traits", derive(Debug))]
107 pub enum _Vx_semaphore {}
108 impl ::Copy for _Vx_semaphore {}
109 impl ::Clone for _Vx_semaphore {
clone(&self) -> _Vx_semaphore110     fn clone(&self) -> _Vx_semaphore {
111         *self
112     }
113 }
114 
115 impl siginfo_t {
si_addr(&self) -> *mut ::c_void116     pub unsafe fn si_addr(&self) -> *mut ::c_void {
117         self.si_addr
118     }
119 
si_value(&self) -> ::sigval120     pub unsafe fn si_value(&self) -> ::sigval {
121         self.si_value
122     }
123 
si_pid(&self) -> ::pid_t124     pub unsafe fn si_pid(&self) -> ::pid_t {
125         self.si_pid
126     }
127 
si_uid(&self) -> ::uid_t128     pub unsafe fn si_uid(&self) -> ::uid_t {
129         self.si_uid
130     }
131 
si_status(&self) -> ::c_int132     pub unsafe fn si_status(&self) -> ::c_int {
133         self.si_status
134     }
135 }
136 
137 s! {
138     // b_pthread_condattr_t.h
139     pub struct pthread_condattr_t {
140         pub condAttrStatus: ::c_int,
141         pub condAttrPshared: ::c_int,
142         pub condAttrClockId: ::clockid_t,
143     }
144 
145     // b_pthread_cond_t.h
146     pub struct pthread_cond_t{
147         pub condSemId: ::_Vx_SEM_ID,
148         pub condValid: ::c_int,
149         pub condInitted: ::c_int,
150         pub condRefCount: ::c_int,
151         pub condMutex: *mut ::pthread_mutex_t,
152         pub condAttr: ::pthread_condattr_t,
153         pub condSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX]
154     }
155 
156     // b_pthread_rwlockattr_t.h
157     pub struct pthread_rwlockattr_t {
158         pub rwlockAttrStatus: ::c_int,
159         pub rwlockAttrPshared: ::c_int,
160         pub rwlockAttrMaxReaders: ::c_uint,
161         pub rwlockAttrConformOpt: ::c_uint,
162     }
163 
164     // b_pthread_rwlock_t.h
165     pub struct pthread_rwlock_t {
166         pub rwlockSemId: :: _Vx_SEM_ID,
167         pub rwlockReadersRefCount: ::c_uint,
168         pub rwlockValid: ::c_int,
169         pub rwlockInitted: ::c_int,
170         pub rwlockAttr: ::pthread_rwlockattr_t,
171         pub rwlockSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX]
172     }
173 
174     // b_struct_timeval.h
175     pub struct timeval {
176         pub tv_sec: ::time_t,
177         pub tv_usec: ::suseconds_t,
178     }
179 
180     // socket.h
181     pub struct linger {
182         pub l_onoff: ::c_int,
183         pub l_linger: ::c_int,
184     }
185 
186     pub struct sockaddr {
187         pub sa_len    : ::c_uchar,
188         pub sa_family : sa_family_t,
189         pub sa_data   : [::c_char; 14],
190     }
191 
192     pub struct iovec {
193         pub iov_base: *mut ::c_void,
194         pub iov_len: ::size_t,
195     }
196 
197     pub struct msghdr {
198         pub msg_name: *mut c_void,
199         pub msg_namelen: socklen_t,
200         pub msg_iov: *mut iovec,
201         pub msg_iovlen: ::c_int,
202         pub msg_control: *mut c_void,
203         pub msg_controllen: socklen_t,
204         pub msg_flags: ::c_int,
205     }
206 
207     pub struct cmsghdr {
208         pub cmsg_len: socklen_t,
209         pub cmsg_level: ::c_int,
210         pub cmsg_type: ::c_int,
211     }
212 
213     // poll.h
214     pub struct pollfd {
215         pub fd      : ::c_int,
216         pub events  : ::c_short,
217         pub revents : ::c_short,
218     }
219 
220     // resource.h
221     pub struct rlimit {
222                            pub rlim_cur : ::rlim_t,
223                            pub rlim_max : ::rlim_t,
224     }
225 
226     // stat.h
227     pub struct stat {
228                          pub st_dev       : ::dev_t,
229                          pub st_ino       : ::ino_t,
230                          pub st_mode      : ::mode_t,
231                          pub st_nlink     : ::nlink_t,
232                          pub st_uid       : ::uid_t,
233                          pub st_gid       : ::gid_t,
234                          pub st_rdev      : ::dev_t,
235                          pub st_size      : ::off_t,
236                          pub st_atime     : ::time_t,
237                          pub st_mtime     : ::time_t,
238                          pub st_ctime     : ::time_t,
239                          pub st_blksize   : ::blksize_t,
240                          pub st_blocks    : ::blkcnt_t,
241                          pub st_attrib    : ::c_uchar,
242                          pub st_reserved1 : ::c_int,
243                          pub st_reserved2 : ::c_int,
244                          pub st_reserved3 : ::c_int,
245                          pub st_reserved4 : ::c_int,
246     }
247 
248     //b_struct__Timespec.h
249     pub struct _Timespec {
250         pub tv_sec  : ::time_t,
251         pub tv_nsec : ::c_long,
252     }
253 
254     // b_struct__Sched_param.h
255     pub struct _Sched_param {
256         pub sched_priority: ::c_int, /* scheduling priority */
257         pub sched_ss_low_priority: ::c_int,    /* low scheduling priority */
258         pub sched_ss_repl_period: ::_Timespec, /* replenishment period */
259         pub sched_ss_init_budget: ::_Timespec, /* initial budget */
260         pub sched_ss_max_repl: ::c_int,        /* max pending replenishment */
261 
262     }
263 
264     // b_pthread_attr_t.h
265     pub struct pthread_attr_t {
266         pub threadAttrStatus          : ::c_int,
267         pub threadAttrStacksize       : ::size_t,
268         pub threadAttrStackaddr       : *mut ::c_void,
269         pub threadAttrGuardsize       : ::size_t,
270         pub threadAttrDetachstate     : ::c_int,
271         pub threadAttrContentionscope : ::c_int,
272         pub threadAttrInheritsched    : ::c_int,
273         pub threadAttrSchedpolicy     : ::c_int,
274         pub threadAttrName            : *mut ::c_char,
275         pub threadAttrOptions         : ::c_int,
276         pub threadAttrSchedparam      : ::_Sched_param,
277     }
278 
279     // signal.h
280 
281     pub struct sigaction {
282         pub sa_u     : ::sa_u_t,
283         pub sa_mask  : ::sigset_t,
284         pub sa_flags : ::c_int,
285     }
286 
287     // b_stack_t.h
288     pub struct stack_t {
289         pub ss_sp    : *mut ::c_void,
290         pub ss_size  : ::size_t,
291         pub ss_flags : ::c_int,
292     }
293 
294     // signal.h
295     pub struct siginfo_t {
296         pub si_signo : ::c_int,
297         pub si_code  : ::c_int,
298         pub si_value : ::sigval,
299         pub si_errno : ::c_int,
300         pub si_status: ::c_int,
301         pub si_addr: *mut ::c_void,
302         pub si_uid: ::uid_t,
303         pub si_pid: ::pid_t,
304     }
305 
306     // pthread.h (krnl)
307     // b_pthread_mutexattr_t.h (usr)
308     pub struct pthread_mutexattr_t {
309         mutexAttrStatus      : ::c_int,
310         mutexAttrPshared     : ::c_int,
311         mutexAttrProtocol    : ::c_int,
312         mutexAttrPrioceiling : ::c_int,
313         mutexAttrType        : ::c_int,
314     }
315 
316     // pthread.h (krnl)
317     // b_pthread_mutex_t.h (usr)
318     pub struct pthread_mutex_t  {
319         pub mutexSemId: ::_Vx_SEM_ID, /*_Vx_SEM_ID ..*/
320         pub mutexValid: ::c_int,
321         pub mutexInitted: ::c_int,
322         pub mutexCondRefCount: ::c_int,
323         pub mutexSavPriority: ::c_int,
324         pub mutexAttr: ::pthread_mutexattr_t,
325         pub mutexSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX],
326     }
327 
328     // b_struct_timespec.h
329     pub struct timespec {
330         pub tv_sec: ::time_t,
331         pub tv_nsec: ::c_long,
332     }
333 
334     // time.h
335     pub struct tm {
336         pub tm_sec: ::c_int,
337         pub tm_min: ::c_int,
338         pub tm_hour: ::c_int,
339         pub tm_mday: ::c_int,
340         pub tm_mon: ::c_int,
341         pub tm_year: ::c_int,
342         pub tm_wday: ::c_int,
343         pub tm_yday: ::c_int,
344         pub tm_isdst: ::c_int,
345     }
346 
347     // in.h
348     pub struct in_addr {
349         pub s_addr: in_addr_t,
350     }
351 
352     // in.h
353     pub struct ip_mreq {
354         pub imr_multiaddr: in_addr,
355         pub imr_interface: in_addr,
356     }
357 
358     // in6.h
359     #[repr(align(4))]
360     pub struct in6_addr {
361         pub s6_addr: [u8; 16],
362     }
363 
364     // in6.h
365     pub struct ipv6_mreq {
366         pub ipv6mr_multiaddr: in6_addr,
367         pub ipv6mr_interface: ::c_uint,
368     }
369 
370     // netdb.h
371     pub struct addrinfo {
372         pub ai_flags    : ::c_int,
373         pub ai_family   : ::c_int,
374         pub ai_socktype : ::c_int,
375         pub ai_protocol : ::c_int,
376         pub ai_addrlen  : ::size_t,
377         pub ai_canonname: *mut ::c_char,
378         pub ai_addr     : *mut ::sockaddr,
379         pub ai_next     : *mut ::addrinfo,
380     }
381 
382     // in.h
383     pub struct sockaddr_in {
384         pub sin_len   : u8,
385         pub sin_family: u8,
386         pub sin_port  : u16,
387         pub sin_addr  : ::in_addr,
388         pub sin_zero  : [::c_char; 8],
389     }
390 
391     // in6.h
392     pub struct sockaddr_in6 {
393         pub sin6_len     : u8,
394         pub sin6_family  : u8,
395         pub sin6_port    : u16,
396         pub sin6_flowinfo: u32,
397         pub sin6_addr    : ::in6_addr,
398         pub sin6_scope_id: u32,
399     }
400 
401     pub struct Dl_info {
402         pub dli_fname: *const ::c_char,
403         pub dli_fbase: *mut ::c_void,
404         pub dli_sname: *const ::c_char,
405         pub dli_saddr: *mut ::c_void,
406     }
407 
408     pub struct mq_attr {
409         pub mq_maxmsg:  ::c_long,
410         pub mq_msgsize: ::c_long,
411         pub mq_flags:   ::c_long,
412         pub mq_curmsgs: ::c_long,
413     }
414 }
415 
416 s_no_extra_traits! {
417     // dirent.h
418     pub struct dirent {
419         pub d_ino  : ::ino_t,
420         pub d_name : [::c_char; _PARM_NAME_MAX as usize + 1],
421     }
422 
423     pub struct sockaddr_un {
424         pub sun_len: u8,
425         pub sun_family: sa_family_t,
426         pub sun_path: [::c_char; 104]
427     }
428 
429     // rtpLibCommon.h
430     pub struct RTP_DESC {
431         pub status    : ::c_int,
432         pub options   : u32,
433         pub entrAddr  : *mut ::c_void,
434         pub initTaskId: ::TASK_ID,
435         pub parentId  : ::RTP_ID,
436         pub pathName  : [::c_char; VX_RTP_NAME_LENGTH as usize + 1],
437         pub taskCnt   : ::c_int,
438         pub textStart : *mut ::c_void,
439         pub textEnd   : *mut ::c_void,
440     }
441     // socket.h
442     pub struct sockaddr_storage {
443         pub ss_len     : ::c_uchar,
444         pub ss_family  : ::sa_family_t,
445         pub __ss_pad1  : [::c_char; _SS_PAD1SIZE],
446         pub __ss_align : i32,
447         pub __ss_pad2  : [::c_char; _SS_PAD2SIZE],
448     }
449 
450     pub union sa_u_t {
451         pub sa_handler : ::Option<unsafe extern "C" fn(::c_int) -> !>,
452         pub sa_sigaction: ::Option<unsafe extern "C" fn(::c_int,
453                                                         *mut ::siginfo_t,
454                                                         *mut ::c_void) -> !>,
455     }
456 
457     pub union sigval {
458         pub sival_int : ::c_int,
459         pub sival_ptr : *mut ::c_void,
460     }
461 }
462 
463 cfg_if! {
464     if #[cfg(feature = "extra_traits")] {
465         impl ::fmt::Debug for dirent {
466             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
467                 f.debug_struct("dirent")
468                     .field("d_ino", &self.d_ino)
469                     .field("d_name", &&self.d_name[..])
470                     .finish()
471             }
472         }
473 
474         impl ::fmt::Debug for sockaddr_un {
475             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
476                 f.debug_struct("sockaddr_un")
477                     .field("sun_len", &self.sun_len)
478                     .field("sun_family", &self.sun_family)
479                     .field("sun_path", &&self.sun_path[..])
480                     .finish()
481             }
482         }
483 
484         impl ::fmt::Debug for RTP_DESC {
485             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
486                 f.debug_struct("RTP_DESC")
487                     .field("status", &self.status)
488                     .field("options", &self.options)
489                     .field("entrAddr", &self.entrAddr)
490                     .field("initTaskId", &self.initTaskId)
491                     .field("parentId", &self.parentId)
492                     .field("pathName", &&self.pathName[..])
493                     .field("taskCnt", &self.taskCnt)
494                     .field("textStart", &self.textStart)
495                     .field("textEnd", &self.textEnd)
496                     .finish()
497             }
498         }
499         impl ::fmt::Debug for sockaddr_storage {
500             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
501                 f.debug_struct("sockaddr_storage")
502                     .field("ss_len", &self.ss_len)
503                     .field("ss_family", &self.ss_family)
504                     .field("__ss_pad1", &&self.__ss_pad1[..])
505                     .field("__ss_align", &self.__ss_align)
506                     .field("__ss_pad2", &&self.__ss_pad2[..])
507                     .finish()
508             }
509         }
510 
511         impl PartialEq for sa_u_t {
512             fn eq(&self, other: &sa_u_t) -> bool {
513                 unsafe {
514                     let h1 = match self.sa_handler {
515                         Some(handler) => handler as usize,
516                         None => 0 as usize,
517                     };
518                     let h2 = match other.sa_handler {
519                         Some(handler) => handler as usize,
520                         None => 0 as usize,
521                     };
522                     h1 == h2
523                 }
524             }
525         }
526         impl Eq for sa_u_t {}
527         impl ::fmt::Debug for sa_u_t {
528             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
529                 unsafe {
530                     let h = match self.sa_handler {
531                         Some(handler) => handler as usize,
532                         None => 0 as usize,
533                     };
534 
535                     f.debug_struct("sa_u_t")
536                         .field("sa_handler", &h)
537                         .finish()
538                 }
539             }
540         }
541         impl ::hash::Hash for sa_u_t {
542             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
543                 unsafe {
544                     let h = match self.sa_handler {
545                         Some(handler) => handler as usize,
546                         None => 0 as usize,
547                     };
548                     h.hash(state)
549                 }
550             }
551         }
552 
553         impl PartialEq for sigval {
554             fn eq(&self, other: &sigval) -> bool {
555                 unsafe { self.sival_ptr as usize == other.sival_ptr as usize }
556             }
557         }
558         impl Eq for sigval {}
559         impl ::fmt::Debug for sigval {
560             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
561                 f.debug_struct("sigval")
562                     .field("sival_ptr", unsafe { &(self.sival_ptr as usize) })
563                     .finish()
564             }
565         }
566         impl ::hash::Hash for sigval {
567             fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
568                 unsafe { (self.sival_ptr as usize).hash(state) };
569             }
570         }
571     }
572 }
573 
574 pub const STDIN_FILENO: ::c_int = 0;
575 pub const STDOUT_FILENO: ::c_int = 1;
576 pub const STDERR_FILENO: ::c_int = 2;
577 
578 pub const EXIT_SUCCESS: ::c_int = 0;
579 pub const EXIT_FAILURE: ::c_int = 1;
580 
581 pub const EAI_SERVICE: ::c_int = 9;
582 pub const EAI_SOCKTYPE: ::c_int = 10;
583 pub const EAI_SYSTEM: ::c_int = 11;
584 
585 // FIXME: This is not defined in vxWorks, but we have to define it here
586 // to make the building pass for getrandom and std
587 pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
588 
589 //Clock Lib Stuff
590 pub const CLOCK_REALTIME: ::c_int = 0x0;
591 pub const CLOCK_MONOTONIC: ::c_int = 0x1;
592 pub const CLOCK_PROCESS_CPUTIME_ID: ::c_int = 0x2;
593 pub const CLOCK_THREAD_CPUTIME_ID: ::c_int = 0x3;
594 pub const TIMER_ABSTIME: ::c_int = 0x1;
595 pub const TIMER_RELTIME: ::c_int = 0x0;
596 
597 // PTHREAD STUFF
598 pub const PTHREAD_INITIALIZED_OBJ: ::c_int = 0xF70990EF;
599 pub const PTHREAD_DESTROYED_OBJ: ::c_int = -1;
600 pub const PTHREAD_VALID_OBJ: ::c_int = 0xEC542A37;
601 pub const PTHREAD_INVALID_OBJ: ::c_int = -1;
602 pub const PTHREAD_UNUSED_YET_OBJ: ::c_int = -1;
603 
604 pub const PTHREAD_PRIO_NONE: ::c_int = 0;
605 pub const PTHREAD_PRIO_INHERIT: ::c_int = 1;
606 pub const PTHREAD_PRIO_PROTECT: ::c_int = 2;
607 
608 pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
609 pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
610 pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
611 pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
612 pub const PTHREAD_STACK_MIN: usize = 4096;
613 pub const _PTHREAD_SHARED_SEM_NAME_MAX: usize = 30;
614 
615 // ERRNO STUFF
616 pub const OK: ::c_int = 0;
617 pub const EPERM: ::c_int = 1; /* Not owner */
618 pub const ENOENT: ::c_int = 2; /* No such file or directory */
619 pub const ESRCH: ::c_int = 3; /* No such process */
620 pub const EINTR: ::c_int = 4; /* Interrupted system call */
621 pub const EIO: ::c_int = 5; /* I/O error */
622 pub const ENXIO: ::c_int = 6; /* No such device or address */
623 pub const E2BIG: ::c_int = 7; /* Arg list too long */
624 pub const ENOEXEC: ::c_int = 8; /* Exec format error */
625 pub const EBADF: ::c_int = 9; /* Bad file number */
626 pub const ECHILD: ::c_int = 10; /* No children */
627 pub const EAGAIN: ::c_int = 11; /* No more processes */
628 pub const ENOMEM: ::c_int = 12; /* Not enough core */
629 pub const EACCES: ::c_int = 13; /* Permission denied */
630 pub const EFAULT: ::c_int = 14;
631 pub const ENOTEMPTY: ::c_int = 15;
632 pub const EBUSY: ::c_int = 16;
633 pub const EEXIST: ::c_int = 17;
634 pub const EXDEV: ::c_int = 18;
635 pub const ENODEV: ::c_int = 19;
636 pub const ENOTDIR: ::c_int = 20;
637 pub const EISDIR: ::c_int = 21;
638 pub const EINVAL: ::c_int = 22;
639 pub const ENAMETOOLONG: ::c_int = 26;
640 pub const EFBIG: ::c_int = 27;
641 pub const ENOSPC: ::c_int = 28;
642 pub const ESPIPE: ::c_int = 29;
643 pub const EROFS: ::c_int = 30;
644 pub const EMLINK: ::c_int = 31;
645 pub const EPIPE: ::c_int = 32;
646 pub const EDEADLK: ::c_int = 33;
647 pub const ERANGE: ::c_int = 38;
648 pub const EDESTADDRREQ: ::c_int = 40;
649 pub const EPROTOTYPE: ::c_int = 41;
650 pub const ENOPROTOOPT: ::c_int = 42;
651 pub const EPROTONOSUPPORT: ::c_int = 43;
652 pub const ESOCKTNOSUPPORT: ::c_int = 44;
653 pub const EOPNOTSUPP: ::c_int = 45;
654 pub const EPFNOSUPPORT: ::c_int = 46;
655 pub const EAFNOSUPPORT: ::c_int = 47;
656 pub const EADDRINUSE: ::c_int = 48;
657 pub const EADDRNOTAVAIL: ::c_int = 49;
658 pub const ENOTSOCK: ::c_int = 50;
659 pub const ENETUNREACH: ::c_int = 51;
660 pub const ENETRESET: ::c_int = 52;
661 pub const ECONNABORTED: ::c_int = 53;
662 pub const ECONNRESET: ::c_int = 54;
663 pub const ENOBUFS: ::c_int = 55;
664 pub const EISCONN: ::c_int = 56;
665 pub const ENOTCONN: ::c_int = 57;
666 pub const ESHUTDOWN: ::c_int = 58;
667 pub const ETOOMANYREFS: ::c_int = 59;
668 pub const ETIMEDOUT: ::c_int = 60;
669 pub const ECONNREFUSED: ::c_int = 61;
670 pub const ENETDOWN: ::c_int = 62;
671 pub const ETXTBSY: ::c_int = 63;
672 pub const ELOOP: ::c_int = 64;
673 pub const EHOSTUNREACH: ::c_int = 65;
674 pub const EINPROGRESS: ::c_int = 68;
675 pub const EALREADY: ::c_int = 69;
676 pub const EWOULDBLOCK: ::c_int = 70;
677 pub const ENOSYS: ::c_int = 71;
678 pub const EDQUOT: ::c_int = 83;
679 pub const ESTALE: ::c_int = 88;
680 
681 // NFS errnos: Refer to pkgs_v2/storage/fs/nfs/h/nfs/nfsCommon.h
682 const M_nfsStat: ::c_int = 48 << 16;
683 enum nfsstat {
684     NFSERR_REMOTE = 71,
685     NFSERR_WFLUSH = 99,
686     NFSERR_BADHANDLE = 10001,
687     NFSERR_NOT_SYNC = 10002,
688     NFSERR_BAD_COOKIE = 10003,
689     NFSERR_TOOSMALL = 10005,
690     NFSERR_BADTYPE = 10007,
691     NFSERR_JUKEBOX = 10008,
692 }
693 
694 pub const S_nfsLib_NFS_OK: ::c_int = OK;
695 pub const S_nfsLib_NFSERR_PERM: ::c_int = EPERM;
696 pub const S_nfsLib_NFSERR_NOENT: ::c_int = ENOENT;
697 pub const S_nfsLib_NFSERR_IO: ::c_int = EIO;
698 pub const S_nfsLib_NFSERR_NXIO: ::c_int = ENXIO;
699 pub const S_nfsLib_NFSERR_ACCESS: ::c_int = EACCES;
700 pub const S_nfsLib_NFSERR_EXIST: ::c_int = EEXIST;
701 pub const S_nfsLib_NFSERR_ENODEV: ::c_int = ENODEV;
702 pub const S_nfsLib_NFSERR_NOTDIR: ::c_int = ENOTDIR;
703 pub const S_nfsLib_NFSERR_ISDIR: ::c_int = EISDIR;
704 pub const S_nfsLib_NFSERR_INVAL: ::c_int = EINVAL;
705 pub const S_nfsLib_NFSERR_FBIG: ::c_int = EFBIG;
706 pub const S_nfsLib_NFSERR_NOSPC: ::c_int = ENOSPC;
707 pub const S_nfsLib_NFSERR_ROFS: ::c_int = EROFS;
708 pub const S_nfsLib_NFSERR_NAMETOOLONG: ::c_int = ENAMETOOLONG;
709 pub const S_nfsLib_NFSERR_NOTEMPTY: ::c_int = ENOTEMPTY;
710 pub const S_nfsLib_NFSERR_DQUOT: ::c_int = EDQUOT;
711 pub const S_nfsLib_NFSERR_STALE: ::c_int = ESTALE;
712 pub const S_nfsLib_NFSERR_WFLUSH: ::c_int = M_nfsStat | nfsstat::NFSERR_WFLUSH as ::c_int;
713 pub const S_nfsLib_NFSERR_REMOTE: ::c_int = M_nfsStat | nfsstat::NFSERR_REMOTE as ::c_int;
714 pub const S_nfsLib_NFSERR_BADHANDLE: ::c_int = M_nfsStat | nfsstat::NFSERR_BADHANDLE as ::c_int;
715 pub const S_nfsLib_NFSERR_NOT_SYNC: ::c_int = M_nfsStat | nfsstat::NFSERR_NOT_SYNC as ::c_int;
716 pub const S_nfsLib_NFSERR_BAD_COOKIE: ::c_int = M_nfsStat | nfsstat::NFSERR_BAD_COOKIE as ::c_int;
717 pub const S_nfsLib_NFSERR_NOTSUPP: ::c_int = EOPNOTSUPP;
718 pub const S_nfsLib_NFSERR_TOOSMALL: ::c_int = M_nfsStat | nfsstat::NFSERR_TOOSMALL as ::c_int;
719 pub const S_nfsLib_NFSERR_SERVERFAULT: ::c_int = EIO;
720 pub const S_nfsLib_NFSERR_BADTYPE: ::c_int = M_nfsStat | nfsstat::NFSERR_BADTYPE as ::c_int;
721 pub const S_nfsLib_NFSERR_JUKEBOX: ::c_int = M_nfsStat | nfsstat::NFSERR_JUKEBOX as ::c_int;
722 
723 // in.h
724 pub const IPPROTO_IP: ::c_int = 0;
725 pub const IPPROTO_IPV6: ::c_int = 41;
726 
727 pub const IP_TTL: ::c_int = 4;
728 pub const IP_MULTICAST_IF: ::c_int = 9;
729 pub const IP_MULTICAST_TTL: ::c_int = 10;
730 pub const IP_MULTICAST_LOOP: ::c_int = 11;
731 pub const IP_ADD_MEMBERSHIP: ::c_int = 12;
732 pub const IP_DROP_MEMBERSHIP: ::c_int = 13;
733 
734 // in6.h
735 pub const IPV6_V6ONLY: ::c_int = 1;
736 pub const IPV6_UNICAST_HOPS: ::c_int = 4;
737 pub const IPV6_MULTICAST_IF: ::c_int = 9;
738 pub const IPV6_MULTICAST_HOPS: ::c_int = 10;
739 pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
740 pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12;
741 pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13;
742 
743 // STAT Stuff
744 pub const S_IFMT: ::c_int = 0xf000;
745 pub const S_IFIFO: ::c_int = 0x1000;
746 pub const S_IFCHR: ::c_int = 0x2000;
747 pub const S_IFDIR: ::c_int = 0x4000;
748 pub const S_IFBLK: ::c_int = 0x6000;
749 pub const S_IFREG: ::c_int = 0x8000;
750 pub const S_IFLNK: ::c_int = 0xa000;
751 pub const S_IFSHM: ::c_int = 0xb000;
752 pub const S_IFSOCK: ::c_int = 0xc000;
753 pub const S_ISUID: ::c_int = 0x0800;
754 pub const S_ISGID: ::c_int = 0x0400;
755 pub const S_ISTXT: ::c_int = 0x0200;
756 pub const S_IRUSR: ::c_int = 0x0100;
757 pub const S_IWUSR: ::c_int = 0x0080;
758 pub const S_IXUSR: ::c_int = 0x0040;
759 pub const S_IRWXU: ::c_int = 0x01c0;
760 pub const S_IRGRP: ::c_int = 0x0020;
761 pub const S_IWGRP: ::c_int = 0x0010;
762 pub const S_IXGRP: ::c_int = 0x0008;
763 pub const S_IRWXG: ::c_int = 0x0038;
764 pub const S_IROTH: ::c_int = 0x0004;
765 pub const S_IWOTH: ::c_int = 0x0002;
766 pub const S_IXOTH: ::c_int = 0x0001;
767 pub const S_IRWXO: ::c_int = 0x0007;
768 
769 // socket.h
770 pub const SOL_SOCKET: ::c_int = 0xffff;
771 
772 pub const SO_DEBUG: ::c_int = 0x0001;
773 pub const SO_REUSEADDR: ::c_int = 0x0004;
774 pub const SO_KEEPALIVE: ::c_int = 0x0008;
775 pub const SO_DONTROUTE: ::c_int = 0x0010;
776 pub const SO_RCVLOWAT: ::c_int = 0x0012;
777 pub const SO_SNDLOWAT: ::c_int = 0x0013;
778 pub const SO_SNDTIMEO: ::c_int = 0x1005;
779 pub const SO_ACCEPTCONN: ::c_int = 0x001e;
780 pub const SO_BROADCAST: ::c_int = 0x0020;
781 pub const SO_USELOOPBACK: ::c_int = 0x0040;
782 pub const SO_LINGER: ::c_int = 0x0080;
783 pub const SO_REUSEPORT: ::c_int = 0x0200;
784 
785 pub const SO_VLAN: ::c_int = 0x8000;
786 
787 pub const SO_SNDBUF: ::c_int = 0x1001;
788 pub const SO_RCVBUF: ::c_int = 0x1002;
789 pub const SO_RCVTIMEO: ::c_int = 0x1006;
790 pub const SO_ERROR: ::c_int = 0x1007;
791 pub const SO_TYPE: ::c_int = 0x1008;
792 pub const SO_BINDTODEVICE: ::c_int = 0x1010;
793 pub const SO_OOBINLINE: ::c_int = 0x1011;
794 pub const SO_CONNTIMEO: ::c_int = 0x100a;
795 
796 pub const SOCK_STREAM: ::c_int = 1;
797 pub const SOCK_DGRAM: ::c_int = 2;
798 pub const SOCK_RAW: ::c_int = 3;
799 pub const SOCK_RDM: ::c_int = 4;
800 pub const SOCK_SEQPACKET: ::c_int = 5;
801 pub const SOCK_PACKET: ::c_int = 10;
802 
803 pub const _SS_MAXSIZE: usize = 128;
804 pub const _SS_ALIGNSIZE: usize = size_of::<u32>();
805 pub const _SS_PAD1SIZE: usize = _SS_ALIGNSIZE - size_of::<::c_uchar>() - size_of::<::sa_family_t>();
806 pub const _SS_PAD2SIZE: usize = _SS_MAXSIZE
807     - size_of::<::c_uchar>()
808     - size_of::<::sa_family_t>()
809     - _SS_PAD1SIZE
810     - _SS_ALIGNSIZE;
811 
812 pub const MSG_OOB: ::c_int = 0x0001;
813 pub const MSG_PEEK: ::c_int = 0x0002;
814 pub const MSG_DONTROUTE: ::c_int = 0x0004;
815 pub const MSG_EOR: ::c_int = 0x0008;
816 pub const MSG_TRUNC: ::c_int = 0x0010;
817 pub const MSG_CTRUNC: ::c_int = 0x0020;
818 pub const MSG_WAITALL: ::c_int = 0x0040;
819 pub const MSG_DONTWAIT: ::c_int = 0x0080;
820 pub const MSG_EOF: ::c_int = 0x0100;
821 pub const MSG_EXP: ::c_int = 0x0200;
822 pub const MSG_MBUF: ::c_int = 0x0400;
823 pub const MSG_NOTIFICATION: ::c_int = 0x0800;
824 pub const MSG_COMPAT: ::c_int = 0x8000;
825 
826 pub const AF_UNSPEC: ::c_int = 0;
827 pub const AF_LOCAL: ::c_int = 1;
828 pub const AF_UNIX: ::c_int = AF_LOCAL;
829 pub const AF_INET: ::c_int = 2;
830 pub const AF_NETLINK: ::c_int = 16;
831 pub const AF_ROUTE: ::c_int = 17;
832 pub const AF_LINK: ::c_int = 18;
833 pub const AF_PACKET: ::c_int = 19;
834 pub const pseudo_AF_KEY: ::c_int = 27;
835 pub const AF_KEY: ::c_int = pseudo_AF_KEY;
836 pub const AF_INET6: ::c_int = 28;
837 pub const AF_SOCKDEV: ::c_int = 31;
838 pub const AF_TIPC: ::c_int = 33;
839 pub const AF_MIPC: ::c_int = 34;
840 pub const AF_MIPC_SAFE: ::c_int = 35;
841 pub const AF_MAX: ::c_int = 37;
842 
843 pub const SHUT_RD: ::c_int = 0;
844 pub const SHUT_WR: ::c_int = 1;
845 pub const SHUT_RDWR: ::c_int = 2;
846 
847 pub const IPPROTO_TCP: ::c_int = 6;
848 pub const TCP_NODELAY: ::c_int = 1;
849 pub const TCP_MAXSEG: ::c_int = 2;
850 pub const TCP_NOPUSH: ::c_int = 3;
851 pub const TCP_KEEPIDLE: ::c_int = 4;
852 pub const TCP_KEEPINTVL: ::c_int = 5;
853 pub const TCP_KEEPCNT: ::c_int = 6;
854 
855 // ioLib.h
856 pub const FIONREAD: ::c_int = 0x40040001;
857 pub const FIOFLUSH: ::c_int = 2;
858 pub const FIOOPTIONS: ::c_int = 3;
859 pub const FIOBAUDRATE: ::c_int = 4;
860 pub const FIODISKFORMAT: ::c_int = 5;
861 pub const FIODISKINIT: ::c_int = 6;
862 pub const FIOSEEK: ::c_int = 7;
863 pub const FIOWHERE: ::c_int = 8;
864 pub const FIODIRENTRY: ::c_int = 9;
865 pub const FIORENAME: ::c_int = 10;
866 pub const FIOREADYCHANGE: ::c_int = 11;
867 pub const FIODISKCHANGE: ::c_int = 13;
868 pub const FIOCANCEL: ::c_int = 14;
869 pub const FIOSQUEEZE: ::c_int = 15;
870 pub const FIOGETNAME: ::c_int = 18;
871 pub const FIONBIO: ::c_int = 0x90040010;
872 
873 // limits.h
874 pub const PATH_MAX: ::c_int = _PARM_PATH_MAX;
875 pub const _POSIX_PATH_MAX: ::c_int = 256;
876 
877 // Some poll stuff
878 pub const POLLIN: ::c_short = 0x0001;
879 pub const POLLPRI: ::c_short = 0x0002;
880 pub const POLLOUT: ::c_short = 0x0004;
881 pub const POLLRDNORM: ::c_short = 0x0040;
882 pub const POLLWRNORM: ::c_short = POLLOUT;
883 pub const POLLRDBAND: ::c_short = 0x0080;
884 pub const POLLWRBAND: ::c_short = 0x0100;
885 pub const POLLERR: ::c_short = 0x0008;
886 pub const POLLHUP: ::c_short = 0x0010;
887 pub const POLLNVAL: ::c_short = 0x0020;
888 
889 // fnctlcom.h
890 pub const FD_CLOEXEC: ::c_int = 1;
891 pub const F_DUPFD: ::c_int = 0;
892 pub const F_GETFD: ::c_int = 1;
893 pub const F_SETFD: ::c_int = 2;
894 pub const F_GETFL: ::c_int = 3;
895 pub const F_SETFL: ::c_int = 4;
896 pub const F_GETOWN: ::c_int = 5;
897 pub const F_SETOWN: ::c_int = 6;
898 pub const F_GETLK: ::c_int = 7;
899 pub const F_SETLK: ::c_int = 8;
900 pub const F_SETLKW: ::c_int = 9;
901 pub const F_DUPFD_CLOEXEC: ::c_int = 14;
902 
903 // signal.h
904 pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
905 pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
906 pub const SIG_ERR: sighandler_t = -1 as isize as sighandler_t;
907 
908 pub const SIGHUP: ::c_int = 1;
909 pub const SIGINT: ::c_int = 2;
910 pub const SIGQUIT: ::c_int = 3;
911 pub const SIGILL: ::c_int = 4;
912 pub const SIGTRAP: ::c_int = 5;
913 pub const SIGABRT: ::c_int = 6;
914 pub const SIGEMT: ::c_int = 7;
915 pub const SIGFPE: ::c_int = 8;
916 pub const SIGKILL: ::c_int = 9;
917 pub const SIGBUS: ::c_int = 10;
918 pub const SIGSEGV: ::c_int = 11;
919 pub const SIGFMT: ::c_int = 12;
920 pub const SIGPIPE: ::c_int = 13;
921 pub const SIGALRM: ::c_int = 14;
922 pub const SIGTERM: ::c_int = 15;
923 pub const SIGCNCL: ::c_int = 16;
924 pub const SIGSTOP: ::c_int = 17;
925 pub const SIGTSTP: ::c_int = 18;
926 pub const SIGCONT: ::c_int = 19;
927 pub const SIGCHLD: ::c_int = 20;
928 pub const SIGTTIN: ::c_int = 21;
929 pub const SIGTTOU: ::c_int = 22;
930 
931 pub const SIG_BLOCK: ::c_int = 1;
932 pub const SIG_UNBLOCK: ::c_int = 2;
933 pub const SIG_SETMASK: ::c_int = 3;
934 
935 pub const SI_SYNC: ::c_int = 0;
936 pub const SI_USER: ::c_int = -1;
937 pub const SI_QUEUE: ::c_int = -2;
938 pub const SI_TIMER: ::c_int = -3;
939 pub const SI_ASYNCIO: ::c_int = -4;
940 pub const SI_MESGQ: ::c_int = -5;
941 pub const SI_CHILD: ::c_int = -6;
942 pub const SI_KILL: ::c_int = SI_USER;
943 
944 // vxParams.h definitions
945 pub const _PARM_NAME_MAX: ::c_int = 255;
946 pub const _PARM_PATH_MAX: ::c_int = 1024;
947 
948 // WAIT STUFF
949 pub const WNOHANG: ::c_int = 0x01;
950 pub const WUNTRACED: ::c_int = 0x02;
951 
952 const PTHREAD_MUTEXATTR_INITIALIZER: pthread_mutexattr_t = pthread_mutexattr_t {
953     mutexAttrStatus: PTHREAD_INITIALIZED_OBJ,
954     mutexAttrProtocol: PTHREAD_PRIO_NONE,
955     mutexAttrPrioceiling: 0,
956     mutexAttrType: PTHREAD_MUTEX_DEFAULT,
957     mutexAttrPshared: 1,
958 };
959 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
960     mutexSemId: null_mut(),
961     mutexValid: PTHREAD_VALID_OBJ,
962     mutexInitted: PTHREAD_UNUSED_YET_OBJ,
963     mutexCondRefCount: 0,
964     mutexSavPriority: -1,
965     mutexAttr: PTHREAD_MUTEXATTR_INITIALIZER,
966     mutexSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
967 };
968 
969 const PTHREAD_CONDATTR_INITIALIZER: pthread_condattr_t = pthread_condattr_t {
970     condAttrStatus: 0xf70990ef,
971     condAttrPshared: 1,
972     condAttrClockId: CLOCK_REALTIME,
973 };
974 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
975     condSemId: null_mut(),
976     condValid: PTHREAD_VALID_OBJ,
977     condInitted: PTHREAD_UNUSED_YET_OBJ,
978     condRefCount: 0,
979     condMutex: null_mut(),
980     condAttr: PTHREAD_CONDATTR_INITIALIZER,
981     condSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
982 };
983 
984 const PTHREAD_RWLOCKATTR_INITIALIZER: pthread_rwlockattr_t = pthread_rwlockattr_t {
985     rwlockAttrStatus: PTHREAD_INITIALIZED_OBJ,
986     rwlockAttrPshared: 1,
987     rwlockAttrMaxReaders: 0,
988     rwlockAttrConformOpt: 1,
989 };
990 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
991     rwlockSemId: null_mut(),
992     rwlockReadersRefCount: 0,
993     rwlockValid: PTHREAD_VALID_OBJ,
994     rwlockInitted: PTHREAD_UNUSED_YET_OBJ,
995     rwlockAttr: PTHREAD_RWLOCKATTR_INITIALIZER,
996     rwlockSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
997 };
998 
999 pub const SEEK_SET: ::c_int = 0;
1000 pub const SEEK_CUR: ::c_int = 1;
1001 pub const SEEK_END: ::c_int = 2;
1002 
1003 // rtpLibCommon.h
1004 pub const VX_RTP_NAME_LENGTH: ::c_int = 255;
1005 pub const RTP_ID_ERROR: ::RTP_ID = -1;
1006 
1007 // h/public/unistd.h
1008 pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 21; // Via unistd.h
1009 pub const _SC_PAGESIZE: ::c_int = 39;
1010 pub const O_ACCMODE: ::c_int = 3;
1011 pub const O_CLOEXEC: ::c_int = 0x100000; // fcntlcom
1012 pub const O_EXCL: ::c_int = 0x0800;
1013 pub const O_CREAT: ::c_int = 0x0200;
1014 pub const O_TRUNC: ::c_int = 0x0400;
1015 pub const O_APPEND: ::c_int = 0x0008;
1016 pub const O_RDWR: ::c_int = 0x0002;
1017 pub const O_WRONLY: ::c_int = 0x0001;
1018 pub const O_RDONLY: ::c_int = 0;
1019 pub const O_NONBLOCK: ::c_int = 0x4000;
1020 
1021 // mman.h
1022 pub const PROT_NONE: ::c_int = 0x0000;
1023 pub const PROT_READ: ::c_int = 0x0001;
1024 pub const PROT_WRITE: ::c_int = 0x0002;
1025 pub const PROT_EXEC: ::c_int = 0x0004;
1026 
1027 pub const MAP_SHARED: ::c_int = 0x0001;
1028 pub const MAP_PRIVATE: ::c_int = 0x0002;
1029 pub const MAP_ANON: ::c_int = 0x0004;
1030 pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
1031 pub const MAP_FIXED: ::c_int = 0x0010;
1032 pub const MAP_CONTIG: ::c_int = 0x0020;
1033 
1034 pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
1035 
1036 #[cfg_attr(feature = "extra_traits", derive(Debug))]
1037 pub enum FILE {}
1038 impl ::Copy for FILE {}
1039 impl ::Clone for FILE {
clone(&self) -> FILE1040     fn clone(&self) -> FILE {
1041         *self
1042     }
1043 }
1044 #[cfg_attr(feature = "extra_traits", derive(Debug))]
1045 pub enum fpos_t {} // FIXME: fill this out with a struct
1046 impl ::Copy for fpos_t {}
1047 impl ::Clone for fpos_t {
clone(&self) -> fpos_t1048     fn clone(&self) -> fpos_t {
1049         *self
1050     }
1051 }
1052 
1053 f! {
1054     pub {const} fn CMSG_ALIGN(len: usize) -> usize {
1055         len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
1056     }
1057 
1058     pub fn CMSG_NXTHDR(mhdr: *const msghdr,
1059                        cmsg: *const cmsghdr) -> *mut cmsghdr {
1060         let next = cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)
1061             + CMSG_ALIGN(::mem::size_of::<::cmsghdr>());
1062         let max = (*mhdr).msg_control as usize
1063             + (*mhdr).msg_controllen as usize;
1064         if next <= max {
1065             (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize))
1066                 as *mut ::cmsghdr
1067         } else {
1068             0 as *mut ::cmsghdr
1069         }
1070     }
1071 
1072     pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr {
1073         if (*mhdr).msg_controllen as usize > 0  {
1074             (*mhdr).msg_control as *mut cmsghdr
1075         } else {
1076             0 as *mut cmsghdr
1077         }
1078     }
1079 
1080     pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut ::c_uchar {
1081         (cmsg as *mut ::c_uchar)
1082             .offset(CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
1083     }
1084 
1085     pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
1086         (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::<cmsghdr>()))
1087             as ::c_uint
1088     }
1089 
1090     pub {const} fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
1091         CMSG_ALIGN(::mem::size_of::<cmsghdr>()) as ::c_uint + length
1092     }
1093 }
1094 
1095 extern "C" {
isalnum(c: c_int) -> c_int1096     pub fn isalnum(c: c_int) -> c_int;
isalpha(c: c_int) -> c_int1097     pub fn isalpha(c: c_int) -> c_int;
iscntrl(c: c_int) -> c_int1098     pub fn iscntrl(c: c_int) -> c_int;
isdigit(c: c_int) -> c_int1099     pub fn isdigit(c: c_int) -> c_int;
isgraph(c: c_int) -> c_int1100     pub fn isgraph(c: c_int) -> c_int;
islower(c: c_int) -> c_int1101     pub fn islower(c: c_int) -> c_int;
isprint(c: c_int) -> c_int1102     pub fn isprint(c: c_int) -> c_int;
ispunct(c: c_int) -> c_int1103     pub fn ispunct(c: c_int) -> c_int;
isspace(c: c_int) -> c_int1104     pub fn isspace(c: c_int) -> c_int;
isupper(c: c_int) -> c_int1105     pub fn isupper(c: c_int) -> c_int;
isxdigit(c: c_int) -> c_int1106     pub fn isxdigit(c: c_int) -> c_int;
isblank(c: c_int) -> c_int1107     pub fn isblank(c: c_int) -> c_int;
tolower(c: c_int) -> c_int1108     pub fn tolower(c: c_int) -> c_int;
toupper(c: c_int) -> c_int1109     pub fn toupper(c: c_int) -> c_int;
fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE1110     pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE1111     pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
fflush(file: *mut FILE) -> c_int1112     pub fn fflush(file: *mut FILE) -> c_int;
fclose(file: *mut FILE) -> c_int1113     pub fn fclose(file: *mut FILE) -> c_int;
remove(filename: *const c_char) -> c_int1114     pub fn remove(filename: *const c_char) -> c_int;
rename(oldname: *const c_char, newname: *const c_char) -> c_int1115     pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
tmpfile() -> *mut FILE1116     pub fn tmpfile() -> *mut FILE;
setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int1117     pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int;
setbuf(stream: *mut FILE, buf: *mut c_char)1118     pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
getchar() -> c_int1119     pub fn getchar() -> c_int;
putchar(c: c_int) -> c_int1120     pub fn putchar(c: c_int) -> c_int;
fgetc(stream: *mut FILE) -> c_int1121     pub fn fgetc(stream: *mut FILE) -> c_int;
fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char1122     pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
fputc(c: c_int, stream: *mut FILE) -> c_int1123     pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
fputs(s: *const c_char, stream: *mut FILE) -> c_int1124     pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int;
puts(s: *const c_char) -> c_int1125     pub fn puts(s: *const c_char) -> c_int;
ungetc(c: c_int, stream: *mut FILE) -> c_int1126     pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t1127     pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t1128     pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int1129     pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
ftell(stream: *mut FILE) -> c_long1130     pub fn ftell(stream: *mut FILE) -> c_long;
rewind(stream: *mut FILE)1131     pub fn rewind(stream: *mut FILE);
fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int1132     pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int1133     pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
feof(stream: *mut FILE) -> c_int1134     pub fn feof(stream: *mut FILE) -> c_int;
ferror(stream: *mut FILE) -> c_int1135     pub fn ferror(stream: *mut FILE) -> c_int;
perror(s: *const c_char)1136     pub fn perror(s: *const c_char);
atof(s: *const c_char) -> c_double1137     pub fn atof(s: *const c_char) -> c_double;
atoi(s: *const c_char) -> c_int1138     pub fn atoi(s: *const c_char) -> c_int;
atol(s: *const c_char) -> c_long1139     pub fn atol(s: *const c_char) -> c_long;
atoll(s: *const c_char) -> c_longlong1140     pub fn atoll(s: *const c_char) -> c_longlong;
strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double1141     pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float1142     pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long1143     pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong1144     pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong;
strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong1145     pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong1146     pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong;
calloc(nobj: size_t, size: size_t) -> *mut c_void1147     pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
malloc(size: size_t) -> *mut c_void1148     pub fn malloc(size: size_t) -> *mut c_void;
realloc(p: *mut c_void, size: size_t) -> *mut c_void1149     pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
free(p: *mut c_void)1150     pub fn free(p: *mut c_void);
abort() -> !1151     pub fn abort() -> !;
exit(status: c_int) -> !1152     pub fn exit(status: c_int) -> !;
atexit(cb: extern "C" fn()) -> c_int1153     pub fn atexit(cb: extern "C" fn()) -> c_int;
system(s: *const c_char) -> c_int1154     pub fn system(s: *const c_char) -> c_int;
getenv(s: *const c_char) -> *mut c_char1155     pub fn getenv(s: *const c_char) -> *mut c_char;
1156 
strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char1157     pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char1158     pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char1159     pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char1160     pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char;
strcmp(cs: *const c_char, ct: *const c_char) -> c_int1161     pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int1162     pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int;
strcoll(cs: *const c_char, ct: *const c_char) -> c_int1163     pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
strchr(cs: *const c_char, c: c_int) -> *mut c_char1164     pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
strrchr(cs: *const c_char, c: c_int) -> *mut c_char1165     pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
strspn(cs: *const c_char, ct: *const c_char) -> size_t1166     pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
strcspn(cs: *const c_char, ct: *const c_char) -> size_t1167     pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
strdup(cs: *const c_char) -> *mut c_char1168     pub fn strdup(cs: *const c_char) -> *mut c_char;
strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char1169     pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char1170     pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int1171     pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int1172     pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int;
strlen(cs: *const c_char) -> size_t1173     pub fn strlen(cs: *const c_char) -> size_t;
strerror(n: c_int) -> *mut c_char1174     pub fn strerror(n: c_int) -> *mut c_char;
strtok(s: *mut c_char, t: *const c_char) -> *mut c_char1175     pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t1176     pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
wcslen(buf: *const wchar_t) -> size_t1177     pub fn wcslen(buf: *const wchar_t) -> size_t;
wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> ::size_t1178     pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> ::size_t;
1179 
memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void1180     pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t1181     pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t;
memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int1182     pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void1183     pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void1184     pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void1185     pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
1186 }
1187 
1188 extern "C" {
fprintf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int1189     pub fn fprintf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
printf(format: *const ::c_char, ...) -> ::c_int1190     pub fn printf(format: *const ::c_char, ...) -> ::c_int;
snprintf(s: *mut ::c_char, n: ::size_t, format: *const ::c_char, ...) -> ::c_int1191     pub fn snprintf(s: *mut ::c_char, n: ::size_t, format: *const ::c_char, ...) -> ::c_int;
sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int1192     pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int;
fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int1193     pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
scanf(format: *const ::c_char, ...) -> ::c_int1194     pub fn scanf(format: *const ::c_char, ...) -> ::c_int;
sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int1195     pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int;
getchar_unlocked() -> ::c_int1196     pub fn getchar_unlocked() -> ::c_int;
putchar_unlocked(c: ::c_int) -> ::c_int1197     pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
stat(path: *const c_char, buf: *mut stat) -> ::c_int1198     pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE1199     pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
fileno(stream: *mut ::FILE) -> ::c_int1200     pub fn fileno(stream: *mut ::FILE) -> ::c_int;
creat(path: *const c_char, mode: mode_t) -> ::c_int1201     pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
rewinddir(dirp: *mut ::DIR)1202     pub fn rewinddir(dirp: *mut ::DIR);
fchown(fd: ::c_int, owner: ::uid_t, group: ::gid_t) -> ::c_int1203     pub fn fchown(fd: ::c_int, owner: ::uid_t, group: ::gid_t) -> ::c_int;
access(path: *const c_char, amode: ::c_int) -> ::c_int1204     pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
alarm(seconds: ::c_uint) -> ::c_uint1205     pub fn alarm(seconds: ::c_uint) -> ::c_uint;
fchdir(dirfd: ::c_int) -> ::c_int1206     pub fn fchdir(dirfd: ::c_int) -> ::c_int;
chown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int1207     pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> ::c_int;
fpathconf(filedes: ::c_int, name: ::c_int) -> c_long1208     pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
getegid() -> gid_t1209     pub fn getegid() -> gid_t;
geteuid() -> uid_t1210     pub fn geteuid() -> uid_t;
getgroups(ngroups_max: ::c_int, groups: *mut gid_t) -> ::c_int1211     pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) -> ::c_int;
getlogin() -> *mut c_char1212     pub fn getlogin() -> *mut c_char;
getopt(argc: ::c_int, argv: *const *mut c_char, optstr: *const c_char) -> ::c_int1213     pub fn getopt(argc: ::c_int, argv: *const *mut c_char, optstr: *const c_char) -> ::c_int;
pathconf(path: *const c_char, name: ::c_int) -> c_long1214     pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
pause() -> ::c_int1215     pub fn pause() -> ::c_int;
seteuid(uid: uid_t) -> ::c_int1216     pub fn seteuid(uid: uid_t) -> ::c_int;
setegid(gid: gid_t) -> ::c_int1217     pub fn setegid(gid: gid_t) -> ::c_int;
sleep(secs: ::c_uint) -> ::c_uint1218     pub fn sleep(secs: ::c_uint) -> ::c_uint;
ttyname(fd: ::c_int) -> *mut c_char1219     pub fn ttyname(fd: ::c_int) -> *mut c_char;
wait(status: *mut ::c_int) -> pid_t1220     pub fn wait(status: *mut ::c_int) -> pid_t;
umask(mask: mode_t) -> mode_t1221     pub fn umask(mask: mode_t) -> mode_t;
mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int1222     pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
mlockall(flags: ::c_int) -> ::c_int1223     pub fn mlockall(flags: ::c_int) -> ::c_int;
munlockall() -> ::c_int1224     pub fn munlockall() -> ::c_int;
1225 
mmap( addr: *mut ::c_void, len: ::size_t, prot: ::c_int, flags: ::c_int, fd: ::c_int, offset: off_t, ) -> *mut ::c_void1226     pub fn mmap(
1227         addr: *mut ::c_void,
1228         len: ::size_t,
1229         prot: ::c_int,
1230         flags: ::c_int,
1231         fd: ::c_int,
1232         offset: off_t,
1233     ) -> *mut ::c_void;
munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int1234     pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
truncate(path: *const c_char, length: off_t) -> ::c_int1235     pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int1236     pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int;
shm_unlink(name: *const ::c_char) -> ::c_int1237     pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
1238 
gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int1239     pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
pthread_exit(value: *mut ::c_void) -> !1240     pub fn pthread_exit(value: *mut ::c_void) -> !;
pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, state: ::c_int) -> ::c_int1241     pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, state: ::c_int) -> ::c_int;
1242 
strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int1243     pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
1244 
sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int1245     pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
1246 
sigaction(signum: ::c_int, act: *const sigaction, oldact: *mut sigaction) -> ::c_int1247     pub fn sigaction(signum: ::c_int, act: *const sigaction, oldact: *mut sigaction) -> ::c_int;
1248 
utimes(filename: *const ::c_char, times: *const ::timeval) -> ::c_int1249     pub fn utimes(filename: *const ::c_char, times: *const ::timeval) -> ::c_int;
1250 
1251     #[link_name = "_rtld_dlopen"]
dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void1252     pub fn dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void;
1253 
1254     #[link_name = "_rtld_dlerror"]
dlerror() -> *mut ::c_char1255     pub fn dlerror() -> *mut ::c_char;
1256 
1257     #[link_name = "_rtld_dlsym"]
dlsym(handle: *mut ::c_void, symbol: *const ::c_char) -> *mut ::c_void1258     pub fn dlsym(handle: *mut ::c_void, symbol: *const ::c_char) -> *mut ::c_void;
1259 
1260     #[link_name = "_rtld_dlclose"]
dlclose(handle: *mut ::c_void) -> ::c_int1261     pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
1262 
1263     #[link_name = "_rtld_dladdr"]
dladdr(addr: *mut ::c_void, info: *mut Dl_info) -> ::c_int1264     pub fn dladdr(addr: *mut ::c_void, info: *mut Dl_info) -> ::c_int;
1265 
1266     // time.h
gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm1267     pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm1268     pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
mktime(tm: *mut tm) -> time_t1269     pub fn mktime(tm: *mut tm) -> time_t;
time(time: *mut time_t) -> time_t1270     pub fn time(time: *mut time_t) -> time_t;
gmtime(time_p: *const time_t) -> *mut tm1271     pub fn gmtime(time_p: *const time_t) -> *mut tm;
localtime(time_p: *const time_t) -> *mut tm1272     pub fn localtime(time_p: *const time_t) -> *mut tm;
timegm(tm: *mut tm) -> time_t1273     pub fn timegm(tm: *mut tm) -> time_t;
difftime(time1: time_t, time0: time_t) -> ::c_double1274     pub fn difftime(time1: time_t, time0: time_t) -> ::c_double;
gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int1275     pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
usleep(secs: ::useconds_t) -> ::c_int1276     pub fn usleep(secs: ::useconds_t) -> ::c_int;
putenv(string: *mut c_char) -> ::c_int1277     pub fn putenv(string: *mut c_char) -> ::c_int;
setlocale(category: ::c_int, locale: *const ::c_char) -> *mut ::c_char1278     pub fn setlocale(category: ::c_int, locale: *const ::c_char) -> *mut ::c_char;
1279 
sigprocmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int1280     pub fn sigprocmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int;
sigpending(set: *mut sigset_t) -> ::c_int1281     pub fn sigpending(set: *mut sigset_t) -> ::c_int;
1282 
mkfifo(path: *const c_char, mode: mode_t) -> ::c_int1283     pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
1284 
fseeko(stream: *mut ::FILE, offset: ::off_t, whence: ::c_int) -> ::c_int1285     pub fn fseeko(stream: *mut ::FILE, offset: ::off_t, whence: ::c_int) -> ::c_int;
ftello(stream: *mut ::FILE) -> ::off_t1286     pub fn ftello(stream: *mut ::FILE) -> ::off_t;
mkstemp(template: *mut ::c_char) -> ::c_int1287     pub fn mkstemp(template: *mut ::c_char) -> ::c_int;
1288 
tmpnam(ptr: *mut ::c_char) -> *mut ::c_char1289     pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char;
1290 
openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int)1291     pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int);
closelog()1292     pub fn closelog();
setlogmask(maskpri: ::c_int) -> ::c_int1293     pub fn setlogmask(maskpri: ::c_int) -> ::c_int;
syslog(priority: ::c_int, message: *const ::c_char, ...)1294     pub fn syslog(priority: ::c_int, message: *const ::c_char, ...);
getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t1295     pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t;
1296 
1297 }
1298 
1299 extern "C" {
1300     // stdlib.h
memalign(block_size: ::size_t, size_arg: ::size_t) -> *mut ::c_void1301     pub fn memalign(block_size: ::size_t, size_arg: ::size_t) -> *mut ::c_void;
1302 
1303     // ioLib.h
getcwd(buf: *mut ::c_char, size: ::size_t) -> *mut ::c_char1304     pub fn getcwd(buf: *mut ::c_char, size: ::size_t) -> *mut ::c_char;
1305 
1306     // ioLib.h
chdir(attr: *const ::c_char) -> ::c_int1307     pub fn chdir(attr: *const ::c_char) -> ::c_int;
1308 
1309     // pthread.h
pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int1310     pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
1311 
1312     // pthread.h
pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int1313     pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int;
1314 
1315     // pthread.h
pthread_mutexattr_settype(pAttr: *mut ::pthread_mutexattr_t, pType: ::c_int) -> ::c_int1316     pub fn pthread_mutexattr_settype(pAttr: *mut ::pthread_mutexattr_t, pType: ::c_int) -> ::c_int;
1317 
1318     // pthread.h
pthread_mutex_init( mutex: *mut pthread_mutex_t, attr: *const pthread_mutexattr_t, ) -> ::c_int1319     pub fn pthread_mutex_init(
1320         mutex: *mut pthread_mutex_t,
1321         attr: *const pthread_mutexattr_t,
1322     ) -> ::c_int;
1323 
1324     // pthread.h
pthread_mutex_destroy(mutex: *mut pthread_mutex_t) -> ::c_int1325     pub fn pthread_mutex_destroy(mutex: *mut pthread_mutex_t) -> ::c_int;
1326 
1327     // pthread.h
pthread_mutex_lock(mutex: *mut pthread_mutex_t) -> ::c_int1328     pub fn pthread_mutex_lock(mutex: *mut pthread_mutex_t) -> ::c_int;
1329 
1330     // pthread.h
pthread_mutex_trylock(mutex: *mut pthread_mutex_t) -> ::c_int1331     pub fn pthread_mutex_trylock(mutex: *mut pthread_mutex_t) -> ::c_int;
1332 
1333     // pthread.h
pthread_mutex_timedlock(attr: *mut pthread_mutex_t, spec: *const timespec) -> ::c_int1334     pub fn pthread_mutex_timedlock(attr: *mut pthread_mutex_t, spec: *const timespec) -> ::c_int;
1335 
1336     // pthread.h
pthread_mutex_unlock(mutex: *mut pthread_mutex_t) -> ::c_int1337     pub fn pthread_mutex_unlock(mutex: *mut pthread_mutex_t) -> ::c_int;
1338 
1339     // pthread.h
pthread_attr_setname(pAttr: *mut ::pthread_attr_t, name: *mut ::c_char) -> ::c_int1340     pub fn pthread_attr_setname(pAttr: *mut ::pthread_attr_t, name: *mut ::c_char) -> ::c_int;
1341 
1342     // pthread.h
pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, stacksize: ::size_t) -> ::c_int1343     pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, stacksize: ::size_t) -> ::c_int;
1344 
1345     // pthread.h
pthread_attr_getstacksize(attr: *const ::pthread_attr_t, size: *mut ::size_t) -> ::c_int1346     pub fn pthread_attr_getstacksize(attr: *const ::pthread_attr_t, size: *mut ::size_t)
1347         -> ::c_int;
1348 
1349     // pthread.h
pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int1350     pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
1351 
1352     // pthread.h
pthread_create( pThread: *mut ::pthread_t, pAttr: *const ::pthread_attr_t, start_routine: extern "C" fn(*mut ::c_void) -> *mut ::c_void, value: *mut ::c_void, ) -> ::c_int1353     pub fn pthread_create(
1354         pThread: *mut ::pthread_t,
1355         pAttr: *const ::pthread_attr_t,
1356         start_routine: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
1357         value: *mut ::c_void,
1358     ) -> ::c_int;
1359 
1360     // pthread.h
pthread_attr_destroy(thread: *mut ::pthread_attr_t) -> ::c_int1361     pub fn pthread_attr_destroy(thread: *mut ::pthread_attr_t) -> ::c_int;
1362 
1363     // pthread.h
pthread_detach(thread: ::pthread_t) -> ::c_int1364     pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
1365 
1366     // int pthread_atfork (void (*)(void), void (*)(void), void (*)(void));
pthread_atfork( prepare: ::Option<unsafe extern "C" fn()>, parent: ::Option<unsafe extern "C" fn()>, child: ::Option<unsafe extern "C" fn()>, ) -> ::c_int1367     pub fn pthread_atfork(
1368         prepare: ::Option<unsafe extern "C" fn()>,
1369         parent: ::Option<unsafe extern "C" fn()>,
1370         child: ::Option<unsafe extern "C" fn()>,
1371     ) -> ::c_int;
1372     // stat.h
fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int1373     pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
1374 
1375     // stat.h
lstat(path: *const ::c_char, buf: *mut stat) -> ::c_int1376     pub fn lstat(path: *const ::c_char, buf: *mut stat) -> ::c_int;
1377 
1378     // unistd.h
ftruncate(fd: ::c_int, length: off_t) -> ::c_int1379     pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
1380 
1381     // dirent.h
readdir_r(pDir: *mut ::DIR, entry: *mut ::dirent, result: *mut *mut ::dirent) -> ::c_int1382     pub fn readdir_r(pDir: *mut ::DIR, entry: *mut ::dirent, result: *mut *mut ::dirent)
1383         -> ::c_int;
1384 
1385     // dirent.h
readdir(pDir: *mut ::DIR) -> *mut ::dirent1386     pub fn readdir(pDir: *mut ::DIR) -> *mut ::dirent;
1387 
1388     // fcntl.h or
1389     // ioLib.h
open(path: *const ::c_char, oflag: ::c_int, ...) -> ::c_int1390     pub fn open(path: *const ::c_char, oflag: ::c_int, ...) -> ::c_int;
1391 
1392     // poll.h
poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int1393     pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
1394 
1395     // pthread.h
pthread_condattr_init(attr: *mut ::pthread_condattr_t) -> ::c_int1396     pub fn pthread_condattr_init(attr: *mut ::pthread_condattr_t) -> ::c_int;
1397 
1398     // pthread.h
pthread_condattr_destroy(attr: *mut ::pthread_condattr_t) -> ::c_int1399     pub fn pthread_condattr_destroy(attr: *mut ::pthread_condattr_t) -> ::c_int;
1400 
1401     // pthread.h
pthread_condattr_getclock( pAttr: *const ::pthread_condattr_t, pClockId: *mut ::clockid_t, ) -> ::c_int1402     pub fn pthread_condattr_getclock(
1403         pAttr: *const ::pthread_condattr_t,
1404         pClockId: *mut ::clockid_t,
1405     ) -> ::c_int;
1406 
1407     // pthread.h
pthread_condattr_setclock( pAttr: *mut ::pthread_condattr_t, clockId: ::clockid_t, ) -> ::c_int1408     pub fn pthread_condattr_setclock(
1409         pAttr: *mut ::pthread_condattr_t,
1410         clockId: ::clockid_t,
1411     ) -> ::c_int;
1412 
1413     // pthread.h
pthread_cond_init( cond: *mut ::pthread_cond_t, attr: *const ::pthread_condattr_t, ) -> ::c_int1414     pub fn pthread_cond_init(
1415         cond: *mut ::pthread_cond_t,
1416         attr: *const ::pthread_condattr_t,
1417     ) -> ::c_int;
1418 
1419     // pthread.h
pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int1420     pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
1421 
1422     // pthread.h
pthread_cond_signal(cond: *mut ::pthread_cond_t) -> ::c_int1423     pub fn pthread_cond_signal(cond: *mut ::pthread_cond_t) -> ::c_int;
1424 
1425     // pthread.h
pthread_cond_broadcast(cond: *mut ::pthread_cond_t) -> ::c_int1426     pub fn pthread_cond_broadcast(cond: *mut ::pthread_cond_t) -> ::c_int;
1427 
1428     // pthread.h
pthread_cond_wait(cond: *mut ::pthread_cond_t, mutex: *mut ::pthread_mutex_t) -> ::c_int1429     pub fn pthread_cond_wait(cond: *mut ::pthread_cond_t, mutex: *mut ::pthread_mutex_t)
1430         -> ::c_int;
1431 
1432     // pthread.h
pthread_rwlockattr_init(attr: *mut ::pthread_rwlockattr_t) -> ::c_int1433     pub fn pthread_rwlockattr_init(attr: *mut ::pthread_rwlockattr_t) -> ::c_int;
1434 
1435     // pthread.h
pthread_rwlockattr_destroy(attr: *mut ::pthread_rwlockattr_t) -> ::c_int1436     pub fn pthread_rwlockattr_destroy(attr: *mut ::pthread_rwlockattr_t) -> ::c_int;
1437 
1438     // pthread.h
pthread_rwlockattr_setmaxreaders( attr: *mut ::pthread_rwlockattr_t, attr2: ::c_uint, ) -> ::c_int1439     pub fn pthread_rwlockattr_setmaxreaders(
1440         attr: *mut ::pthread_rwlockattr_t,
1441         attr2: ::c_uint,
1442     ) -> ::c_int;
1443 
1444     // pthread.h
pthread_rwlock_init( attr: *mut ::pthread_rwlock_t, host: *const ::pthread_rwlockattr_t, ) -> ::c_int1445     pub fn pthread_rwlock_init(
1446         attr: *mut ::pthread_rwlock_t,
1447         host: *const ::pthread_rwlockattr_t,
1448     ) -> ::c_int;
1449 
1450     // pthread.h
pthread_rwlock_destroy(attr: *mut ::pthread_rwlock_t) -> ::c_int1451     pub fn pthread_rwlock_destroy(attr: *mut ::pthread_rwlock_t) -> ::c_int;
1452 
1453     // pthread.h
pthread_rwlock_rdlock(attr: *mut ::pthread_rwlock_t) -> ::c_int1454     pub fn pthread_rwlock_rdlock(attr: *mut ::pthread_rwlock_t) -> ::c_int;
1455 
1456     // pthread.h
pthread_rwlock_tryrdlock(attr: *mut ::pthread_rwlock_t) -> ::c_int1457     pub fn pthread_rwlock_tryrdlock(attr: *mut ::pthread_rwlock_t) -> ::c_int;
1458 
1459     // pthread.h
pthread_rwlock_timedrdlock( attr: *mut ::pthread_rwlock_t, host: *const ::timespec, ) -> ::c_int1460     pub fn pthread_rwlock_timedrdlock(
1461         attr: *mut ::pthread_rwlock_t,
1462         host: *const ::timespec,
1463     ) -> ::c_int;
1464 
1465     // pthread.h
pthread_rwlock_wrlock(attr: *mut ::pthread_rwlock_t) -> ::c_int1466     pub fn pthread_rwlock_wrlock(attr: *mut ::pthread_rwlock_t) -> ::c_int;
1467 
1468     // pthread.h
pthread_rwlock_trywrlock(attr: *mut ::pthread_rwlock_t) -> ::c_int1469     pub fn pthread_rwlock_trywrlock(attr: *mut ::pthread_rwlock_t) -> ::c_int;
1470 
1471     // pthread.h
pthread_rwlock_timedwrlock( attr: *mut ::pthread_rwlock_t, host: *const ::timespec, ) -> ::c_int1472     pub fn pthread_rwlock_timedwrlock(
1473         attr: *mut ::pthread_rwlock_t,
1474         host: *const ::timespec,
1475     ) -> ::c_int;
1476 
1477     // pthread.h
pthread_rwlock_unlock(attr: *mut ::pthread_rwlock_t) -> ::c_int1478     pub fn pthread_rwlock_unlock(attr: *mut ::pthread_rwlock_t) -> ::c_int;
1479 
1480     // pthread.h
pthread_key_create( key: *mut ::pthread_key_t, dtor: ::Option<unsafe extern "C" fn(*mut ::c_void)>, ) -> ::c_int1481     pub fn pthread_key_create(
1482         key: *mut ::pthread_key_t,
1483         dtor: ::Option<unsafe extern "C" fn(*mut ::c_void)>,
1484     ) -> ::c_int;
1485 
1486     // pthread.h
pthread_key_delete(key: ::pthread_key_t) -> ::c_int1487     pub fn pthread_key_delete(key: ::pthread_key_t) -> ::c_int;
1488 
1489     // pthread.h
pthread_setspecific(key: ::pthread_key_t, value: *const ::c_void) -> ::c_int1490     pub fn pthread_setspecific(key: ::pthread_key_t, value: *const ::c_void) -> ::c_int;
1491 
1492     // pthread.h
pthread_getspecific(key: ::pthread_key_t) -> *mut ::c_void1493     pub fn pthread_getspecific(key: ::pthread_key_t) -> *mut ::c_void;
1494 
1495     // pthread.h
pthread_cond_timedwait( cond: *mut ::pthread_cond_t, mutex: *mut ::pthread_mutex_t, abstime: *const ::timespec, ) -> ::c_int1496     pub fn pthread_cond_timedwait(
1497         cond: *mut ::pthread_cond_t,
1498         mutex: *mut ::pthread_mutex_t,
1499         abstime: *const ::timespec,
1500     ) -> ::c_int;
1501 
1502     // pthread.h
pthread_attr_getname(attr: *mut ::pthread_attr_t, name: *mut *mut ::c_char) -> ::c_int1503     pub fn pthread_attr_getname(attr: *mut ::pthread_attr_t, name: *mut *mut ::c_char) -> ::c_int;
1504 
1505     // pthread.h
pthread_join(thread: ::pthread_t, status: *mut *mut ::c_void) -> ::c_int1506     pub fn pthread_join(thread: ::pthread_t, status: *mut *mut ::c_void) -> ::c_int;
1507 
1508     // pthread.h
pthread_self() -> ::pthread_t1509     pub fn pthread_self() -> ::pthread_t;
1510 
1511     // clockLib.h
clock_gettime(clock_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int1512     pub fn clock_gettime(clock_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
1513 
1514     // clockLib.h
clock_settime(clock_id: ::clockid_t, tp: *const ::timespec) -> ::c_int1515     pub fn clock_settime(clock_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
1516 
1517     // clockLib.h
clock_getres(clock_id: ::clockid_t, res: *mut ::timespec) -> ::c_int1518     pub fn clock_getres(clock_id: ::clockid_t, res: *mut ::timespec) -> ::c_int;
1519 
1520     // clockLib.h
clock_nanosleep( clock_id: ::clockid_t, flags: ::c_int, rqtp: *const ::timespec, rmtp: *mut ::timespec, ) -> ::c_int1521     pub fn clock_nanosleep(
1522         clock_id: ::clockid_t,
1523         flags: ::c_int,
1524         rqtp: *const ::timespec,
1525         rmtp: *mut ::timespec,
1526     ) -> ::c_int;
1527 
1528     // timerLib.h
nanosleep(rqtp: *const ::timespec, rmtp: *mut ::timespec) -> ::c_int1529     pub fn nanosleep(rqtp: *const ::timespec, rmtp: *mut ::timespec) -> ::c_int;
1530 
1531     // socket.h
accept(s: ::c_int, addr: *mut ::sockaddr, addrlen: *mut ::socklen_t) -> ::c_int1532     pub fn accept(s: ::c_int, addr: *mut ::sockaddr, addrlen: *mut ::socklen_t) -> ::c_int;
1533 
1534     // socket.h
bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) -> ::c_int1535     pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) -> ::c_int;
1536 
1537     // socket.h
connect(s: ::c_int, name: *const ::sockaddr, namelen: ::socklen_t) -> ::c_int1538     pub fn connect(s: ::c_int, name: *const ::sockaddr, namelen: ::socklen_t) -> ::c_int;
1539 
1540     // socket.h
getpeername(s: ::c_int, name: *mut ::sockaddr, namelen: *mut ::socklen_t) -> ::c_int1541     pub fn getpeername(s: ::c_int, name: *mut ::sockaddr, namelen: *mut ::socklen_t) -> ::c_int;
1542 
1543     // socket.h
getsockname( socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t, ) -> ::c_int1544     pub fn getsockname(
1545         socket: ::c_int,
1546         address: *mut sockaddr,
1547         address_len: *mut socklen_t,
1548     ) -> ::c_int;
1549 
1550     // socket.h
getsockopt( sockfd: ::c_int, level: ::c_int, optname: ::c_int, optval: *mut ::c_void, optlen: *mut ::socklen_t, ) -> ::c_int1551     pub fn getsockopt(
1552         sockfd: ::c_int,
1553         level: ::c_int,
1554         optname: ::c_int,
1555         optval: *mut ::c_void,
1556         optlen: *mut ::socklen_t,
1557     ) -> ::c_int;
1558 
1559     // socket.h
listen(socket: ::c_int, backlog: ::c_int) -> ::c_int1560     pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
1561 
1562     // socket.h
recv(s: ::c_int, buf: *mut ::c_void, bufLen: ::size_t, flags: ::c_int) -> ::ssize_t1563     pub fn recv(s: ::c_int, buf: *mut ::c_void, bufLen: ::size_t, flags: ::c_int) -> ::ssize_t;
1564 
1565     // socket.h
recvfrom( s: ::c_int, buf: *mut ::c_void, bufLen: ::size_t, flags: ::c_int, from: *mut ::sockaddr, pFromLen: *mut ::socklen_t, ) -> ::ssize_t1566     pub fn recvfrom(
1567         s: ::c_int,
1568         buf: *mut ::c_void,
1569         bufLen: ::size_t,
1570         flags: ::c_int,
1571         from: *mut ::sockaddr,
1572         pFromLen: *mut ::socklen_t,
1573     ) -> ::ssize_t;
1574 
recvmsg(socket: ::c_int, mp: *mut ::msghdr, flags: ::c_int) -> ::ssize_t1575     pub fn recvmsg(socket: ::c_int, mp: *mut ::msghdr, flags: ::c_int) -> ::ssize_t;
1576 
1577     // socket.h
send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t1578     pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t;
1579 
sendmsg(socket: ::c_int, mp: *const ::msghdr, flags: ::c_int) -> ::ssize_t1580     pub fn sendmsg(socket: ::c_int, mp: *const ::msghdr, flags: ::c_int) -> ::ssize_t;
1581 
1582     // socket.h
sendto( socket: ::c_int, buf: *const ::c_void, len: ::size_t, flags: ::c_int, addr: *const sockaddr, addrlen: socklen_t, ) -> ::ssize_t1583     pub fn sendto(
1584         socket: ::c_int,
1585         buf: *const ::c_void,
1586         len: ::size_t,
1587         flags: ::c_int,
1588         addr: *const sockaddr,
1589         addrlen: socklen_t,
1590     ) -> ::ssize_t;
1591 
1592     // socket.h
setsockopt( socket: ::c_int, level: ::c_int, name: ::c_int, value: *const ::c_void, option_len: socklen_t, ) -> ::c_int1593     pub fn setsockopt(
1594         socket: ::c_int,
1595         level: ::c_int,
1596         name: ::c_int,
1597         value: *const ::c_void,
1598         option_len: socklen_t,
1599     ) -> ::c_int;
1600 
1601     // socket.h
shutdown(s: ::c_int, how: ::c_int) -> ::c_int1602     pub fn shutdown(s: ::c_int, how: ::c_int) -> ::c_int;
1603 
1604     // socket.h
socket(domain: ::c_int, _type: ::c_int, protocol: ::c_int) -> ::c_int1605     pub fn socket(domain: ::c_int, _type: ::c_int, protocol: ::c_int) -> ::c_int;
1606 
1607     // icotl.h
ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int1608     pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
1609 
1610     // fcntl.h
fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int1611     pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
1612 
1613     // ntp_rfc2553.h for kernel
1614     // netdb.h for user
gai_strerror(errcode: ::c_int) -> *mut ::c_char1615     pub fn gai_strerror(errcode: ::c_int) -> *mut ::c_char;
1616 
1617     // ioLib.h or
1618     // unistd.h
close(fd: ::c_int) -> ::c_int1619     pub fn close(fd: ::c_int) -> ::c_int;
1620 
1621     // ioLib.h or
1622     // unistd.h
read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ssize_t1623     pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ssize_t;
1624 
1625     // ioLib.h or
1626     // unistd.h
write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t1627     pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t;
1628 
1629     // ioLib.h or
1630     // unistd.h
isatty(fd: ::c_int) -> ::c_int1631     pub fn isatty(fd: ::c_int) -> ::c_int;
1632 
1633     // ioLib.h or
1634     // unistd.h
dup(src: ::c_int) -> ::c_int1635     pub fn dup(src: ::c_int) -> ::c_int;
1636 
1637     // ioLib.h or
1638     // unistd.h
dup2(src: ::c_int, dst: ::c_int) -> ::c_int1639     pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
1640 
1641     // ioLib.h or
1642     // unistd.h
pipe(fds: *mut ::c_int) -> ::c_int1643     pub fn pipe(fds: *mut ::c_int) -> ::c_int;
1644 
1645     // ioLib.h or
1646     // unistd.h
unlink(pathname: *const ::c_char) -> ::c_int1647     pub fn unlink(pathname: *const ::c_char) -> ::c_int;
1648 
1649     // unistd.h and
1650     // ioLib.h
lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t1651     pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
1652 
1653     // netdb.h
getaddrinfo( node: *const ::c_char, service: *const ::c_char, hints: *const addrinfo, res: *mut *mut addrinfo, ) -> ::c_int1654     pub fn getaddrinfo(
1655         node: *const ::c_char,
1656         service: *const ::c_char,
1657         hints: *const addrinfo,
1658         res: *mut *mut addrinfo,
1659     ) -> ::c_int;
1660 
1661     // netdb.h
freeaddrinfo(res: *mut addrinfo)1662     pub fn freeaddrinfo(res: *mut addrinfo);
1663 
1664     // signal.h
signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t1665     pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
1666 
1667     // unistd.h
getpid() -> pid_t1668     pub fn getpid() -> pid_t;
1669 
1670     // unistd.h
getppid() -> pid_t1671     pub fn getppid() -> pid_t;
1672 
1673     // wait.h
waitpid(pid: pid_t, status: *mut ::c_int, optons: ::c_int) -> pid_t1674     pub fn waitpid(pid: pid_t, status: *mut ::c_int, optons: ::c_int) -> pid_t;
1675 
1676     // unistd.h
sysconf(attr: ::c_int) -> ::c_long1677     pub fn sysconf(attr: ::c_int) -> ::c_long;
1678 
1679     // stdlib.h
setenv( envVarName: *const ::c_char, envVarValue: *const ::c_char, overwrite: ::c_int, ) -> ::c_int1680     pub fn setenv(
1681         // setenv.c
1682         envVarName: *const ::c_char,
1683         envVarValue: *const ::c_char,
1684         overwrite: ::c_int,
1685     ) -> ::c_int;
1686 
1687     // stdlib.h
unsetenv( envVarName: *const ::c_char, ) -> ::c_int1688     pub fn unsetenv(
1689         // setenv.c
1690         envVarName: *const ::c_char,
1691     ) -> ::c_int;
1692 
1693     // stdlib.h
realpath(fileName: *const ::c_char, resolvedName: *mut ::c_char) -> *mut ::c_char1694     pub fn realpath(fileName: *const ::c_char, resolvedName: *mut ::c_char) -> *mut ::c_char;
1695 
1696     // unistd.h
link(src: *const ::c_char, dst: *const ::c_char) -> ::c_int1697     pub fn link(src: *const ::c_char, dst: *const ::c_char) -> ::c_int;
1698 
1699     // unistd.h
readlink(path: *const ::c_char, buf: *mut ::c_char, bufsize: ::size_t) -> ::ssize_t1700     pub fn readlink(path: *const ::c_char, buf: *mut ::c_char, bufsize: ::size_t) -> ::ssize_t;
1701 
1702     // unistd.h
symlink(path1: *const ::c_char, path2: *const ::c_char) -> ::c_int1703     pub fn symlink(path1: *const ::c_char, path2: *const ::c_char) -> ::c_int;
1704 
1705     // dirent.h
opendir(name: *const ::c_char) -> *mut ::DIR1706     pub fn opendir(name: *const ::c_char) -> *mut ::DIR;
1707 
1708     // unistd.h
rmdir(path: *const ::c_char) -> ::c_int1709     pub fn rmdir(path: *const ::c_char) -> ::c_int;
1710 
1711     // stat.h
mkdir(dirName: *const ::c_char, mode: ::mode_t) -> ::c_int1712     pub fn mkdir(dirName: *const ::c_char, mode: ::mode_t) -> ::c_int;
1713 
1714     // stat.h
chmod(path: *const ::c_char, mode: ::mode_t) -> ::c_int1715     pub fn chmod(path: *const ::c_char, mode: ::mode_t) -> ::c_int;
1716 
1717     // stat.h
fchmod(attr1: ::c_int, attr2: ::mode_t) -> ::c_int1718     pub fn fchmod(attr1: ::c_int, attr2: ::mode_t) -> ::c_int;
1719 
1720     // unistd.h
fsync(fd: ::c_int) -> ::c_int1721     pub fn fsync(fd: ::c_int) -> ::c_int;
1722 
1723     // dirent.h
closedir(ptr: *mut ::DIR) -> ::c_int1724     pub fn closedir(ptr: *mut ::DIR) -> ::c_int;
1725 
1726     // sched.h
sched_yield() -> ::c_int1727     pub fn sched_yield() -> ::c_int;
1728 
1729     // errnoLib.h
errnoSet(err: ::c_int) -> ::c_int1730     pub fn errnoSet(err: ::c_int) -> ::c_int;
1731 
1732     // errnoLib.h
errnoGet() -> ::c_int1733     pub fn errnoGet() -> ::c_int;
1734 
1735     // unistd.h
_exit(status: ::c_int) -> !1736     pub fn _exit(status: ::c_int) -> !;
1737 
1738     // unistd.h
setgid(gid: ::gid_t) -> ::c_int1739     pub fn setgid(gid: ::gid_t) -> ::c_int;
1740 
1741     // unistd.h
getgid() -> ::gid_t1742     pub fn getgid() -> ::gid_t;
1743 
1744     // unistd.h
setuid(uid: ::uid_t) -> ::c_int1745     pub fn setuid(uid: ::uid_t) -> ::c_int;
1746 
1747     // unistd.h
getuid() -> ::uid_t1748     pub fn getuid() -> ::uid_t;
1749 
1750     // signal.h
sigemptyset(__set: *mut sigset_t) -> ::c_int1751     pub fn sigemptyset(__set: *mut sigset_t) -> ::c_int;
1752 
1753     // pthread.h for kernel
1754     // signal.h for user
pthread_sigmask( __how: ::c_int, __set: *const sigset_t, __oset: *mut sigset_t, ) -> ::c_int1755     pub fn pthread_sigmask(
1756         __how: ::c_int,
1757         __set: *const sigset_t,
1758         __oset: *mut sigset_t,
1759     ) -> ::c_int;
1760 
1761     // signal.h for user
kill(__pid: pid_t, __signo: ::c_int) -> ::c_int1762     pub fn kill(__pid: pid_t, __signo: ::c_int) -> ::c_int;
1763 
1764     // signal.h for user
sigqueue(__pid: pid_t, __signo: ::c_int, __value: ::sigval) -> ::c_int1765     pub fn sigqueue(__pid: pid_t, __signo: ::c_int, __value: ::sigval) -> ::c_int;
1766 
1767     // signal.h for user
_sigqueue( rtpId: ::RTP_ID, signo: ::c_int, pValue: *const ::sigval, sigCode: ::c_int, ) -> ::c_int1768     pub fn _sigqueue(
1769         rtpId: ::RTP_ID,
1770         signo: ::c_int,
1771         pValue: *const ::sigval,
1772         sigCode: ::c_int,
1773     ) -> ::c_int;
1774 
1775     // signal.h
taskKill(taskId: ::TASK_ID, signo: ::c_int) -> ::c_int1776     pub fn taskKill(taskId: ::TASK_ID, signo: ::c_int) -> ::c_int;
1777 
1778     // signal.h
raise(__signo: ::c_int) -> ::c_int1779     pub fn raise(__signo: ::c_int) -> ::c_int;
1780 
1781     // taskLibCommon.h
taskIdSelf() -> ::TASK_ID1782     pub fn taskIdSelf() -> ::TASK_ID;
taskDelay(ticks: ::_Vx_ticks_t) -> ::c_int1783     pub fn taskDelay(ticks: ::_Vx_ticks_t) -> ::c_int;
1784 
1785     // rtpLibCommon.h
rtpInfoGet(rtpId: ::RTP_ID, rtpStruct: *mut ::RTP_DESC) -> ::c_int1786     pub fn rtpInfoGet(rtpId: ::RTP_ID, rtpStruct: *mut ::RTP_DESC) -> ::c_int;
rtpSpawn( pubrtpFileName: *const ::c_char, argv: *mut *const ::c_char, envp: *mut *const ::c_char, priority: ::c_int, uStackSize: ::size_t, options: ::c_int, taskOptions: ::c_int, ) -> RTP_ID1787     pub fn rtpSpawn(
1788         pubrtpFileName: *const ::c_char,
1789         argv: *mut *const ::c_char,
1790         envp: *mut *const ::c_char,
1791         priority: ::c_int,
1792         uStackSize: ::size_t,
1793         options: ::c_int,
1794         taskOptions: ::c_int,
1795     ) -> RTP_ID;
1796 
1797     // ioLib.h
_realpath(fileName: *const ::c_char, resolvedName: *mut ::c_char) -> *mut ::c_char1798     pub fn _realpath(fileName: *const ::c_char, resolvedName: *mut ::c_char) -> *mut ::c_char;
1799 
1800     // pathLib.h
_pathIsAbsolute(filepath: *const ::c_char, pNameTail: *mut *const ::c_char) -> BOOL1801     pub fn _pathIsAbsolute(filepath: *const ::c_char, pNameTail: *mut *const ::c_char) -> BOOL;
1802 
writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t1803     pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t1804     pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
1805 
1806     // randomNumGen.h
randBytes(buf: *mut c_uchar, length: c_int) -> c_int1807     pub fn randBytes(buf: *mut c_uchar, length: c_int) -> c_int;
randABytes(buf: *mut c_uchar, length: c_int) -> c_int1808     pub fn randABytes(buf: *mut c_uchar, length: c_int) -> c_int;
randUBytes(buf: *mut c_uchar, length: c_int) -> c_int1809     pub fn randUBytes(buf: *mut c_uchar, length: c_int) -> c_int;
randSecure() -> c_int1810     pub fn randSecure() -> c_int;
1811 
1812     // mqueue.h
mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t1813     pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
mq_close(mqd: ::mqd_t) -> ::c_int1814     pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
mq_unlink(name: *const ::c_char) -> ::c_int1815     pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
mq_receive( mqd: ::mqd_t, msg_ptr: *mut ::c_char, msg_len: ::size_t, msg_prio: *mut ::c_uint, ) -> ::ssize_t1816     pub fn mq_receive(
1817         mqd: ::mqd_t,
1818         msg_ptr: *mut ::c_char,
1819         msg_len: ::size_t,
1820         msg_prio: *mut ::c_uint,
1821     ) -> ::ssize_t;
mq_timedreceive( mqd: ::mqd_t, msg_ptr: *mut ::c_char, msg_len: ::size_t, msg_prio: *mut ::c_uint, abs_timeout: *const ::timespec, ) -> ::ssize_t1822     pub fn mq_timedreceive(
1823         mqd: ::mqd_t,
1824         msg_ptr: *mut ::c_char,
1825         msg_len: ::size_t,
1826         msg_prio: *mut ::c_uint,
1827         abs_timeout: *const ::timespec,
1828     ) -> ::ssize_t;
mq_send( mqd: ::mqd_t, msg_ptr: *const ::c_char, msg_len: ::size_t, msg_prio: ::c_uint, ) -> ::c_int1829     pub fn mq_send(
1830         mqd: ::mqd_t,
1831         msg_ptr: *const ::c_char,
1832         msg_len: ::size_t,
1833         msg_prio: ::c_uint,
1834     ) -> ::c_int;
mq_timedsend( mqd: ::mqd_t, msg_ptr: *const ::c_char, msg_len: ::size_t, msg_prio: ::c_uint, abs_timeout: *const ::timespec, ) -> ::c_int1835     pub fn mq_timedsend(
1836         mqd: ::mqd_t,
1837         msg_ptr: *const ::c_char,
1838         msg_len: ::size_t,
1839         msg_prio: ::c_uint,
1840         abs_timeout: *const ::timespec,
1841     ) -> ::c_int;
mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int1842     pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int1843     pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int;
1844 }
1845 
1846 //Dummy functions, these don't really exist in VxWorks.
1847 
1848 // wait.h macros
1849 safe_f! {
1850     pub {const} fn WIFEXITED(status: ::c_int) -> bool {
1851         (status & 0xFF00) == 0
1852     }
1853     pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
1854         (status & 0xFF00) != 0
1855     }
1856     pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
1857         (status & 0xFF0000) != 0
1858     }
1859     pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int {
1860         status & 0xFF
1861     }
1862     pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int {
1863         (status >> 8) & 0xFF
1864     }
1865     pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int {
1866         (status >> 16) & 0xFF
1867     }
1868 }
1869 
pread(_fd: ::c_int, _buf: *mut ::c_void, _count: ::size_t, _offset: off64_t) -> ::ssize_t1870 pub fn pread(_fd: ::c_int, _buf: *mut ::c_void, _count: ::size_t, _offset: off64_t) -> ::ssize_t {
1871     -1
1872 }
1873 
pwrite( _fd: ::c_int, _buf: *const ::c_void, _count: ::size_t, _offset: off64_t, ) -> ::ssize_t1874 pub fn pwrite(
1875     _fd: ::c_int,
1876     _buf: *const ::c_void,
1877     _count: ::size_t,
1878     _offset: off64_t,
1879 ) -> ::ssize_t {
1880     -1
1881 }
posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int1882 pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int {
1883     // check to see if align is a power of 2 and if align is a multiple
1884     //  of sizeof(void *)
1885     if (align & align - 1 != 0) || (align as usize % size_of::<::size_t>() != 0) {
1886         return ::EINVAL;
1887     }
1888 
1889     unsafe {
1890         // posix_memalign should not set errno
1891         let e = ::errnoGet();
1892 
1893         let temp = memalign(align, size);
1894         ::errnoSet(e as ::c_int);
1895 
1896         if temp.is_null() {
1897             ::ENOMEM
1898         } else {
1899             *memptr = temp;
1900             0
1901         }
1902     }
1903 }
1904 
1905 cfg_if! {
1906     if #[cfg(libc_core_cvoid)] {
1907         pub use ::ffi::c_void;
1908     } else {
1909         // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
1910         // enable more optimization opportunities around it recognizing things
1911         // like malloc/free.
1912         #[repr(u8)]
1913         #[allow(missing_copy_implementations)]
1914         #[allow(missing_debug_implementations)]
1915         pub enum c_void {
1916             // Two dummy variants so the #[repr] attribute can be used.
1917             #[doc(hidden)]
1918             __variant1,
1919             #[doc(hidden)]
1920             __variant2,
1921         }
1922     }
1923 }
1924 
1925 cfg_if! {
1926     if #[cfg(target_arch = "aarch64")] {
1927         mod aarch64;
1928         pub use self::aarch64::*;
1929     } else if #[cfg(target_arch = "arm")] {
1930         mod arm;
1931         pub use self::arm::*;
1932     }  else if #[cfg(target_arch = "x86")] {
1933         mod x86;
1934         pub use self::x86::*;
1935     } else if #[cfg(target_arch = "x86_64")] {
1936         mod x86_64;
1937         pub use self::x86_64::*;
1938     } else if #[cfg(target_arch = "powerpc")] {
1939         mod powerpc;
1940         pub use self::powerpc::*;
1941     } else if #[cfg(target_arch = "powerpc64")] {
1942         mod powerpc64;
1943         pub use self::powerpc64::*;
1944     } else {
1945         // Unknown target_arch
1946     }
1947 }
1948