xref: /rust-libc-0.2.174/src/vxworks/mod.rs (revision 54e402ff)
1 //! Interface to VxWorks C library
2 
3 use core::mem::size_of;
4 use core::ptr::null_mut;
5 
6 use crate::prelude::*;
7 
8 #[cfg_attr(feature = "extra_traits", derive(Debug))]
9 pub enum DIR {}
10 impl Copy for DIR {}
11 impl Clone for DIR {
12     fn clone(&self) -> DIR {
13         *self
14     }
15 }
16 
17 pub type intmax_t = i64;
18 pub type uintmax_t = u64;
19 
20 pub type uintptr_t = usize;
21 pub type intptr_t = isize;
22 pub type ptrdiff_t = isize;
23 pub type size_t = crate::uintptr_t;
24 pub type ssize_t = intptr_t;
25 
26 pub type pid_t = c_int;
27 pub type in_addr_t = u32;
28 pub type sighandler_t = size_t;
29 pub type cpuset_t = u32;
30 
31 pub type blkcnt_t = c_long;
32 pub type blksize_t = c_long;
33 pub type ino_t = c_ulong;
34 
35 pub type rlim_t = c_ulong;
36 pub type suseconds_t = c_long;
37 pub type time_t = c_longlong;
38 
39 pub type errno_t = c_int;
40 
41 pub type useconds_t = c_ulong;
42 
43 pub type socklen_t = c_uint;
44 
45 pub type pthread_t = c_ulong;
46 
47 pub type clockid_t = c_int;
48 
49 //defined for the structs
50 pub type dev_t = c_ulong;
51 pub type mode_t = c_int;
52 pub type nlink_t = c_ulong;
53 pub type uid_t = c_ushort;
54 pub type gid_t = c_ushort;
55 pub type sigset_t = c_ulonglong;
56 pub type key_t = c_long;
57 
58 pub type nfds_t = c_uint;
59 pub type stat64 = crate::stat;
60 
61 pub type pthread_key_t = c_ulong;
62 
63 // From b_off_t.h
64 pub type off_t = c_longlong;
65 pub type off64_t = off_t;
66 
67 // From b_BOOL.h
68 pub type BOOL = c_int;
69 
70 // From vxWind.h ..
71 pub type _Vx_OBJ_HANDLE = c_int;
72 pub type _Vx_TASK_ID = crate::_Vx_OBJ_HANDLE;
73 pub type _Vx_MSG_Q_ID = crate::_Vx_OBJ_HANDLE;
74 pub type _Vx_SEM_ID_KERNEL = crate::_Vx_OBJ_HANDLE;
75 pub type _Vx_RTP_ID = crate::_Vx_OBJ_HANDLE;
76 pub type _Vx_SD_ID = crate::_Vx_OBJ_HANDLE;
77 pub type _Vx_CONDVAR_ID = crate::_Vx_OBJ_HANDLE;
78 pub type _Vx_SEM_ID = *mut crate::_Vx_semaphore;
79 pub type OBJ_HANDLE = crate::_Vx_OBJ_HANDLE;
80 pub type TASK_ID = crate::OBJ_HANDLE;
81 pub type MSG_Q_ID = crate::OBJ_HANDLE;
82 pub type SEM_ID_KERNEL = crate::OBJ_HANDLE;
83 pub type RTP_ID = crate::OBJ_HANDLE;
84 pub type SD_ID = crate::OBJ_HANDLE;
85 pub type CONDVAR_ID = crate::OBJ_HANDLE;
86 pub type STATUS = crate::OBJ_HANDLE;
87 
88 // From vxTypes.h
89 pub type _Vx_usr_arg_t = isize;
90 pub type _Vx_exit_code_t = isize;
91 pub type _Vx_ticks_t = c_uint;
92 pub type _Vx_ticks64_t = c_ulonglong;
93 
94 pub type sa_family_t = c_uchar;
95 
96 // mqueue.h
97 pub type mqd_t = c_int;
98 
99 #[cfg_attr(feature = "extra_traits", derive(Debug))]
100 pub enum _Vx_semaphore {}
101 impl Copy for _Vx_semaphore {}
102 impl Clone for _Vx_semaphore {
103     fn clone(&self) -> _Vx_semaphore {
104         *self
105     }
106 }
107 
108 impl siginfo_t {
109     pub unsafe fn si_addr(&self) -> *mut c_void {
110         self.si_addr
111     }
112 
113     pub unsafe fn si_value(&self) -> crate::sigval {
114         self.si_value
115     }
116 
117     pub unsafe fn si_pid(&self) -> crate::pid_t {
118         self.si_pid
119     }
120 
121     pub unsafe fn si_uid(&self) -> crate::uid_t {
122         self.si_uid
123     }
124 
125     pub unsafe fn si_status(&self) -> c_int {
126         self.si_status
127     }
128 }
129 
130 s! {
131     // b_pthread_condattr_t.h
132     pub struct pthread_condattr_t {
133         pub condAttrStatus: c_int,
134         pub condAttrPshared: c_int,
135         pub condAttrClockId: crate::clockid_t,
136     }
137 
138     // b_pthread_cond_t.h
139     pub struct pthread_cond_t {
140         pub condSemId: crate::_Vx_SEM_ID,
141         pub condValid: c_int,
142         pub condInitted: c_int,
143         pub condRefCount: c_int,
144         pub condMutex: *mut crate::pthread_mutex_t,
145         pub condAttr: crate::pthread_condattr_t,
146         pub condSemName: [c_char; _PTHREAD_SHARED_SEM_NAME_MAX],
147     }
148 
149     // b_pthread_rwlockattr_t.h
150     pub struct pthread_rwlockattr_t {
151         pub rwlockAttrStatus: c_int,
152         pub rwlockAttrPshared: c_int,
153         pub rwlockAttrMaxReaders: c_uint,
154         pub rwlockAttrConformOpt: c_uint,
155     }
156 
157     // b_pthread_rwlock_t.h
158     pub struct pthread_rwlock_t {
159         pub rwlockSemId: crate::_Vx_SEM_ID,
160         pub rwlockReadersRefCount: c_uint,
161         pub rwlockValid: c_int,
162         pub rwlockInitted: c_int,
163         pub rwlockAttr: crate::pthread_rwlockattr_t,
164         pub rwlockSemName: [c_char; _PTHREAD_SHARED_SEM_NAME_MAX],
165     }
166 
167     // b_struct_timeval.h
168     pub struct timeval {
169         pub tv_sec: crate::time_t,
170         pub tv_usec: crate::suseconds_t,
171     }
172 
173     // socket.h
174     pub struct linger {
175         pub l_onoff: c_int,
176         pub l_linger: c_int,
177     }
178 
179     pub struct sockaddr {
180         pub sa_len: c_uchar,
181         pub sa_family: sa_family_t,
182         pub sa_data: [c_char; 14],
183     }
184 
185     pub struct iovec {
186         pub iov_base: *mut c_void,
187         pub iov_len: size_t,
188     }
189 
190     pub struct msghdr {
191         pub msg_name: *mut c_void,
192         pub msg_namelen: socklen_t,
193         pub msg_iov: *mut iovec,
194         pub msg_iovlen: c_int,
195         pub msg_control: *mut c_void,
196         pub msg_controllen: socklen_t,
197         pub msg_flags: c_int,
198     }
199 
200     pub struct cmsghdr {
201         pub cmsg_len: socklen_t,
202         pub cmsg_level: c_int,
203         pub cmsg_type: c_int,
204     }
205 
206     // poll.h
207     pub struct pollfd {
208         pub fd: c_int,
209         pub events: c_short,
210         pub revents: c_short,
211     }
212 
213     // resource.h
214     pub struct rlimit {
215         pub rlim_cur: crate::rlim_t,
216         pub rlim_max: crate::rlim_t,
217     }
218 
219     // stat.h
220     pub struct stat {
221         pub st_dev: crate::dev_t,
222         pub st_ino: crate::ino_t,
223         pub st_mode: crate::mode_t,
224         pub st_nlink: crate::nlink_t,
225         pub st_uid: crate::uid_t,
226         pub st_gid: crate::gid_t,
227         pub st_rdev: crate::dev_t,
228         pub st_size: off_t,
229         pub st_atime: crate::time_t,
230         pub st_mtime: crate::time_t,
231         pub st_ctime: crate::time_t,
232         pub st_blksize: crate::blksize_t,
233         pub st_blocks: crate::blkcnt_t,
234         pub st_attrib: c_uchar,
235         pub st_reserved1: c_int,
236         pub st_reserved2: c_int,
237         pub st_reserved3: c_int,
238         pub st_reserved4: c_int,
239     }
240 
241     //b_struct__Timespec.h
242     pub struct _Timespec {
243         pub tv_sec: crate::time_t,
244         pub tv_nsec: c_long,
245     }
246 
247     // b_struct__Sched_param.h
248     pub struct sched_param {
249         pub sched_priority: c_int,                  /* scheduling priority */
250         pub sched_ss_low_priority: c_int,           /* low scheduling priority */
251         pub sched_ss_repl_period: crate::_Timespec, /* replenishment period */
252         pub sched_ss_init_budget: crate::_Timespec, /* initial budget */
253         pub sched_ss_max_repl: c_int,               /* max pending replenishment */
254     }
255 
256     // b_pthread_attr_t.h
257     pub struct pthread_attr_t {
258         pub threadAttrStatus: c_int,
259         pub threadAttrStacksize: size_t,
260         pub threadAttrStackaddr: *mut c_void,
261         pub threadAttrGuardsize: size_t,
262         pub threadAttrDetachstate: c_int,
263         pub threadAttrContentionscope: c_int,
264         pub threadAttrInheritsched: c_int,
265         pub threadAttrSchedpolicy: c_int,
266         pub threadAttrName: *mut c_char,
267         pub threadAttrOptions: c_int,
268         pub threadAttrSchedparam: crate::sched_param,
269     }
270 
271     // signal.h
272 
273     pub struct sigaction {
274         pub sa_u: crate::sa_u_t,
275         pub sa_mask: crate::sigset_t,
276         pub sa_flags: c_int,
277     }
278 
279     // b_stack_t.h
280     pub struct stack_t {
281         pub ss_sp: *mut c_void,
282         pub ss_size: size_t,
283         pub ss_flags: c_int,
284     }
285 
286     // signal.h
287     pub struct siginfo_t {
288         pub si_signo: c_int,
289         pub si_code: c_int,
290         pub si_value: crate::sigval,
291         pub si_errno: c_int,
292         pub si_status: c_int,
293         pub si_addr: *mut c_void,
294         pub si_uid: crate::uid_t,
295         pub si_pid: crate::pid_t,
296     }
297 
298     // pthread.h (krnl)
299     // b_pthread_mutexattr_t.h (usr)
300     pub struct pthread_mutexattr_t {
301         mutexAttrStatus: c_int,
302         mutexAttrPshared: c_int,
303         mutexAttrProtocol: c_int,
304         mutexAttrPrioceiling: c_int,
305         mutexAttrType: c_int,
306     }
307 
308     // pthread.h (krnl)
309     // b_pthread_mutex_t.h (usr)
310     pub struct pthread_mutex_t {
311         pub mutexSemId: crate::_Vx_SEM_ID, /*_Vx_SEM_ID ..*/
312         pub mutexValid: c_int,
313         pub mutexInitted: c_int,
314         pub mutexCondRefCount: c_int,
315         pub mutexSavPriority: c_int,
316         pub mutexAttr: crate::pthread_mutexattr_t,
317         pub mutexSemName: [c_char; _PTHREAD_SHARED_SEM_NAME_MAX],
318     }
319 
320     // b_struct_timespec.h
321     pub struct timespec {
322         pub tv_sec: crate::time_t,
323         pub tv_nsec: c_long,
324     }
325 
326     // time.h
327     pub struct tm {
328         pub tm_sec: c_int,
329         pub tm_min: c_int,
330         pub tm_hour: c_int,
331         pub tm_mday: c_int,
332         pub tm_mon: c_int,
333         pub tm_year: c_int,
334         pub tm_wday: c_int,
335         pub tm_yday: c_int,
336         pub tm_isdst: c_int,
337     }
338 
339     // in.h
340     pub struct in_addr {
341         pub s_addr: in_addr_t,
342     }
343 
344     // in.h
345     pub struct ip_mreq {
346         pub imr_multiaddr: in_addr,
347         pub imr_interface: in_addr,
348     }
349 
350     // in6.h
351     #[repr(align(4))]
352     pub struct in6_addr {
353         pub s6_addr: [u8; 16],
354     }
355 
356     // in6.h
357     pub struct ipv6_mreq {
358         pub ipv6mr_multiaddr: in6_addr,
359         pub ipv6mr_interface: c_uint,
360     }
361 
362     // netdb.h
363     pub struct addrinfo {
364         pub ai_flags: c_int,
365         pub ai_family: c_int,
366         pub ai_socktype: c_int,
367         pub ai_protocol: c_int,
368         pub ai_addrlen: size_t,
369         pub ai_canonname: *mut c_char,
370         pub ai_addr: *mut crate::sockaddr,
371         pub ai_next: *mut crate::addrinfo,
372     }
373 
374     // in.h
375     pub struct sockaddr_in {
376         pub sin_len: u8,
377         pub sin_family: u8,
378         pub sin_port: u16,
379         pub sin_addr: crate::in_addr,
380         pub sin_zero: [c_char; 8],
381     }
382 
383     // in6.h
384     pub struct sockaddr_in6 {
385         pub sin6_len: u8,
386         pub sin6_family: u8,
387         pub sin6_port: u16,
388         pub sin6_flowinfo: u32,
389         pub sin6_addr: crate::in6_addr,
390         pub sin6_scope_id: u32,
391     }
392 
393     pub struct Dl_info {
394         pub dli_fname: *const c_char,
395         pub dli_fbase: *mut c_void,
396         pub dli_sname: *const c_char,
397         pub dli_saddr: *mut c_void,
398     }
399 
400     pub struct mq_attr {
401         pub mq_maxmsg: c_long,
402         pub mq_msgsize: c_long,
403         pub mq_flags: c_long,
404         pub mq_curmsgs: c_long,
405     }
406 }
407 
408 s_no_extra_traits! {
409     // dirent.h
410     pub struct dirent {
411         pub d_ino: crate::ino_t,
412         pub d_name: [c_char; _PARM_NAME_MAX as usize + 1],
413         pub d_type: c_uchar,
414     }
415 
416     pub struct sockaddr_un {
417         pub sun_len: u8,
418         pub sun_family: sa_family_t,
419         pub sun_path: [c_char; 104],
420     }
421 
422     // rtpLibCommon.h
423     pub struct RTP_DESC {
424         pub status: c_int,
425         pub options: u32,
426         pub entrAddr: *mut c_void,
427         pub initTaskId: crate::TASK_ID,
428         pub parentId: crate::RTP_ID,
429         pub pathName: [c_char; VX_RTP_NAME_LENGTH as usize + 1],
430         pub taskCnt: c_int,
431         pub textStart: *mut c_void,
432         pub textEnd: *mut c_void,
433     }
434     // socket.h
435     pub struct sockaddr_storage {
436         pub ss_len: c_uchar,
437         pub ss_family: crate::sa_family_t,
438         pub __ss_pad1: [c_char; _SS_PAD1SIZE],
439         pub __ss_align: i32,
440         pub __ss_pad2: [c_char; _SS_PAD2SIZE],
441     }
442 
443     pub union sa_u_t {
444         pub sa_handler: Option<unsafe extern "C" fn(c_int) -> !>,
445         pub sa_sigaction:
446             Option<unsafe extern "C" fn(c_int, *mut crate::siginfo_t, *mut c_void) -> !>,
447     }
448 
449     pub union sigval {
450         pub sival_int: c_int,
451         pub sival_ptr: *mut c_void,
452     }
453 }
454 
455 cfg_if! {
456     if #[cfg(feature = "extra_traits")] {
457         impl fmt::Debug for dirent {
458             fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
459                 f.debug_struct("dirent")
460                     .field("d_ino", &self.d_ino)
461                     .field("d_name", &&self.d_name[..])
462                     .field("d_type", &self.d_type)
463                     .finish()
464             }
465         }
466 
467         impl fmt::Debug for sockaddr_un {
468             fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
469                 f.debug_struct("sockaddr_un")
470                     .field("sun_len", &self.sun_len)
471                     .field("sun_family", &self.sun_family)
472                     .field("sun_path", &&self.sun_path[..])
473                     .finish()
474             }
475         }
476 
477         impl fmt::Debug for RTP_DESC {
478             fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
479                 f.debug_struct("RTP_DESC")
480                     .field("status", &self.status)
481                     .field("options", &self.options)
482                     .field("entrAddr", &self.entrAddr)
483                     .field("initTaskId", &self.initTaskId)
484                     .field("parentId", &self.parentId)
485                     .field("pathName", &&self.pathName[..])
486                     .field("taskCnt", &self.taskCnt)
487                     .field("textStart", &self.textStart)
488                     .field("textEnd", &self.textEnd)
489                     .finish()
490             }
491         }
492         impl fmt::Debug for sockaddr_storage {
493             fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
494                 f.debug_struct("sockaddr_storage")
495                     .field("ss_len", &self.ss_len)
496                     .field("ss_family", &self.ss_family)
497                     .field("__ss_pad1", &&self.__ss_pad1[..])
498                     .field("__ss_align", &self.__ss_align)
499                     .field("__ss_pad2", &&self.__ss_pad2[..])
500                     .finish()
501             }
502         }
503 
504         impl PartialEq for sa_u_t {
505             fn eq(&self, other: &sa_u_t) -> bool {
506                 unsafe {
507                     let h1 = match self.sa_handler {
508                         Some(handler) => handler as usize,
509                         None => 0 as usize,
510                     };
511                     let h2 = match other.sa_handler {
512                         Some(handler) => handler as usize,
513                         None => 0 as usize,
514                     };
515                     h1 == h2
516                 }
517             }
518         }
519         impl Eq for sa_u_t {}
520         impl hash::Hash for sa_u_t {
521             fn hash<H: hash::Hasher>(&self, state: &mut H) {
522                 unsafe {
523                     let h = match self.sa_handler {
524                         Some(handler) => handler as usize,
525                         None => 0 as usize,
526                     };
527                     h.hash(state)
528                 }
529             }
530         }
531 
532         impl PartialEq for sigval {
533             fn eq(&self, other: &sigval) -> bool {
534                 unsafe { self.sival_ptr as usize == other.sival_ptr as usize }
535             }
536         }
537         impl Eq for sigval {}
538         impl hash::Hash for sigval {
539             fn hash<H: hash::Hasher>(&self, state: &mut H) {
540                 unsafe { (self.sival_ptr as usize).hash(state) };
541             }
542         }
543     }
544 }
545 
546 pub const STDIN_FILENO: c_int = 0;
547 pub const STDOUT_FILENO: c_int = 1;
548 pub const STDERR_FILENO: c_int = 2;
549 
550 pub const EXIT_SUCCESS: c_int = 0;
551 pub const EXIT_FAILURE: c_int = 1;
552 
553 pub const EAI_SERVICE: c_int = 9;
554 pub const EAI_SOCKTYPE: c_int = 10;
555 pub const EAI_SYSTEM: c_int = 11;
556 
557 // FIXME(vxworks): This is not defined in vxWorks, but we have to define it here
558 // to make the building pass for getrandom and std
559 pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void;
560 
561 //Clock Lib Stuff
562 pub const CLOCK_REALTIME: c_int = 0x0;
563 pub const CLOCK_MONOTONIC: c_int = 0x1;
564 pub const CLOCK_PROCESS_CPUTIME_ID: c_int = 0x2;
565 pub const CLOCK_THREAD_CPUTIME_ID: c_int = 0x3;
566 pub const TIMER_ABSTIME: c_int = 0x1;
567 pub const TIMER_RELTIME: c_int = 0x0;
568 
569 // PTHREAD STUFF
570 pub const PTHREAD_INITIALIZED_OBJ: c_int = 0xF70990EF;
571 pub const PTHREAD_DESTROYED_OBJ: c_int = -1;
572 pub const PTHREAD_VALID_OBJ: c_int = 0xEC542A37;
573 pub const PTHREAD_INVALID_OBJ: c_int = -1;
574 pub const PTHREAD_UNUSED_YET_OBJ: c_int = -1;
575 
576 pub const PTHREAD_PRIO_NONE: c_int = 0;
577 pub const PTHREAD_PRIO_INHERIT: c_int = 1;
578 pub const PTHREAD_PRIO_PROTECT: c_int = 2;
579 
580 pub const PTHREAD_MUTEX_NORMAL: c_int = 0;
581 pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1;
582 pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2;
583 pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL;
584 pub const PTHREAD_STACK_MIN: usize = 4096;
585 pub const _PTHREAD_SHARED_SEM_NAME_MAX: usize = 30;
586 
587 //sched.h
588 pub const SCHED_FIFO: c_int = 0x01;
589 pub const SCHED_RR: c_int = 0x02;
590 pub const SCHED_OTHER: c_int = 0x04;
591 pub const SCHED_SPORADIC: c_int = 0x08;
592 pub const PRIO_PROCESS: c_uint = 0;
593 pub const SCHED_FIFO_HIGH_PRI: c_int = 255;
594 pub const SCHED_FIFO_LOW_PRI: c_int = 0;
595 pub const SCHED_RR_HIGH_PRI: c_int = 255;
596 pub const SCHED_RR_LOW_PRI: c_int = 0;
597 pub const SCHED_SPORADIC_HIGH_PRI: c_int = 255;
598 pub const SCHED_SPORADIC_LOW_PRI: c_int = 0;
599 
600 // ERRNO STUFF
601 pub const ERROR: c_int = -1;
602 pub const OK: c_int = 0;
603 pub const EPERM: c_int = 1; /* Not owner */
604 pub const ENOENT: c_int = 2; /* No such file or directory */
605 pub const ESRCH: c_int = 3; /* No such process */
606 pub const EINTR: c_int = 4; /* Interrupted system call */
607 pub const EIO: c_int = 5; /* I/O error */
608 pub const ENXIO: c_int = 6; /* No such device or address */
609 pub const E2BIG: c_int = 7; /* Arg list too long */
610 pub const ENOEXEC: c_int = 8; /* Exec format error */
611 pub const EBADF: c_int = 9; /* Bad file number */
612 pub const ECHILD: c_int = 10; /* No children */
613 pub const EAGAIN: c_int = 11; /* No more processes */
614 pub const ENOMEM: c_int = 12; /* Not enough core */
615 pub const EACCES: c_int = 13; /* Permission denied */
616 pub const EFAULT: c_int = 14;
617 pub const ENOTEMPTY: c_int = 15;
618 pub const EBUSY: c_int = 16;
619 pub const EEXIST: c_int = 17;
620 pub const EXDEV: c_int = 18;
621 pub const ENODEV: c_int = 19;
622 pub const ENOTDIR: c_int = 20;
623 pub const EISDIR: c_int = 21;
624 pub const EINVAL: c_int = 22;
625 pub const ENFILE: c_int = 23;
626 pub const EMFILE: c_int = 24;
627 pub const ENOTTY: c_int = 25;
628 pub const ENAMETOOLONG: c_int = 26;
629 pub const EFBIG: c_int = 27;
630 pub const ENOSPC: c_int = 28;
631 pub const ESPIPE: c_int = 29;
632 pub const EROFS: c_int = 30;
633 pub const EMLINK: c_int = 31;
634 pub const EPIPE: c_int = 32;
635 pub const EDEADLK: c_int = 33;
636 pub const ENOLCK: c_int = 34;
637 pub const ENOTSUP: c_int = 35;
638 pub const EMSGSIZE: c_int = 36;
639 pub const EDOM: c_int = 37;
640 pub const ERANGE: c_int = 38;
641 pub const EDOOM: c_int = 39;
642 pub const EDESTADDRREQ: c_int = 40;
643 pub const EPROTOTYPE: c_int = 41;
644 pub const ENOPROTOOPT: c_int = 42;
645 pub const EPROTONOSUPPORT: c_int = 43;
646 pub const ESOCKTNOSUPPORT: c_int = 44;
647 pub const EOPNOTSUPP: c_int = 45;
648 pub const EPFNOSUPPORT: c_int = 46;
649 pub const EAFNOSUPPORT: c_int = 47;
650 pub const EADDRINUSE: c_int = 48;
651 pub const EADDRNOTAVAIL: c_int = 49;
652 pub const ENOTSOCK: c_int = 50;
653 pub const ENETUNREACH: c_int = 51;
654 pub const ENETRESET: c_int = 52;
655 pub const ECONNABORTED: c_int = 53;
656 pub const ECONNRESET: c_int = 54;
657 pub const ENOBUFS: c_int = 55;
658 pub const EISCONN: c_int = 56;
659 pub const ENOTCONN: c_int = 57;
660 pub const ESHUTDOWN: c_int = 58;
661 pub const ETOOMANYREFS: c_int = 59;
662 pub const ETIMEDOUT: c_int = 60;
663 pub const ECONNREFUSED: c_int = 61;
664 pub const ENETDOWN: c_int = 62;
665 pub const ETXTBSY: c_int = 63;
666 pub const ELOOP: c_int = 64;
667 pub const EHOSTUNREACH: c_int = 65;
668 pub const ENOTBLK: c_int = 66;
669 pub const EHOSTDOWN: c_int = 67;
670 pub const EINPROGRESS: c_int = 68;
671 pub const EALREADY: c_int = 69;
672 pub const EWOULDBLOCK: c_int = 70;
673 pub const ENOSYS: c_int = 71;
674 pub const ECANCELED: c_int = 72;
675 pub const ENOSR: c_int = 74;
676 pub const ENOSTR: c_int = 75;
677 pub const EPROTO: c_int = 76;
678 pub const EBADMSG: c_int = 77;
679 pub const ENODATA: c_int = 78;
680 pub const ETIME: c_int = 79;
681 pub const ENOMSG: c_int = 80;
682 pub const EFPOS: c_int = 81;
683 pub const EILSEQ: c_int = 82;
684 pub const EDQUOT: c_int = 83;
685 pub const EIDRM: c_int = 84;
686 pub const EOVERFLOW: c_int = 85;
687 pub const EMULTIHOP: c_int = 86;
688 pub const ENOLINK: c_int = 87;
689 pub const ESTALE: c_int = 88;
690 pub const EOWNERDEAD: c_int = 89;
691 pub const ENOTRECOVERABLE: c_int = 90;
692 
693 // NFS errnos: Refer to pkgs_v2/storage/fs/nfs/h/nfs/nfsCommon.h
694 const M_nfsStat: c_int = 48 << 16;
695 enum nfsstat {
696     NFSERR_REMOTE = 71,
697     NFSERR_WFLUSH = 99,
698     NFSERR_BADHANDLE = 10001,
699     NFSERR_NOT_SYNC = 10002,
700     NFSERR_BAD_COOKIE = 10003,
701     NFSERR_TOOSMALL = 10005,
702     NFSERR_BADTYPE = 10007,
703     NFSERR_JUKEBOX = 10008,
704 }
705 
706 pub const S_nfsLib_NFS_OK: c_int = OK;
707 pub const S_nfsLib_NFSERR_PERM: c_int = EPERM;
708 pub const S_nfsLib_NFSERR_NOENT: c_int = ENOENT;
709 pub const S_nfsLib_NFSERR_IO: c_int = EIO;
710 pub const S_nfsLib_NFSERR_NXIO: c_int = ENXIO;
711 pub const S_nfsLib_NFSERR_ACCESS: c_int = EACCES;
712 pub const S_nfsLib_NFSERR_EXIST: c_int = EEXIST;
713 pub const S_nfsLib_NFSERR_ENODEV: c_int = ENODEV;
714 pub const S_nfsLib_NFSERR_NOTDIR: c_int = ENOTDIR;
715 pub const S_nfsLib_NFSERR_ISDIR: c_int = EISDIR;
716 pub const S_nfsLib_NFSERR_INVAL: c_int = EINVAL;
717 pub const S_nfsLib_NFSERR_FBIG: c_int = EFBIG;
718 pub const S_nfsLib_NFSERR_NOSPC: c_int = ENOSPC;
719 pub const S_nfsLib_NFSERR_ROFS: c_int = EROFS;
720 pub const S_nfsLib_NFSERR_NAMETOOLONG: c_int = ENAMETOOLONG;
721 pub const S_nfsLib_NFSERR_NOTEMPTY: c_int = ENOTEMPTY;
722 pub const S_nfsLib_NFSERR_DQUOT: c_int = EDQUOT;
723 pub const S_nfsLib_NFSERR_STALE: c_int = ESTALE;
724 pub const S_nfsLib_NFSERR_WFLUSH: c_int = M_nfsStat | nfsstat::NFSERR_WFLUSH as c_int;
725 pub const S_nfsLib_NFSERR_REMOTE: c_int = M_nfsStat | nfsstat::NFSERR_REMOTE as c_int;
726 pub const S_nfsLib_NFSERR_BADHANDLE: c_int = M_nfsStat | nfsstat::NFSERR_BADHANDLE as c_int;
727 pub const S_nfsLib_NFSERR_NOT_SYNC: c_int = M_nfsStat | nfsstat::NFSERR_NOT_SYNC as c_int;
728 pub const S_nfsLib_NFSERR_BAD_COOKIE: c_int = M_nfsStat | nfsstat::NFSERR_BAD_COOKIE as c_int;
729 pub const S_nfsLib_NFSERR_NOTSUPP: c_int = EOPNOTSUPP;
730 pub const S_nfsLib_NFSERR_TOOSMALL: c_int = M_nfsStat | nfsstat::NFSERR_TOOSMALL as c_int;
731 pub const S_nfsLib_NFSERR_SERVERFAULT: c_int = EIO;
732 pub const S_nfsLib_NFSERR_BADTYPE: c_int = M_nfsStat | nfsstat::NFSERR_BADTYPE as c_int;
733 pub const S_nfsLib_NFSERR_JUKEBOX: c_int = M_nfsStat | nfsstat::NFSERR_JUKEBOX as c_int;
734 
735 // internal offset values for below constants
736 const taskErrorBase: c_int = 0x00030000;
737 const semErrorBase: c_int = 0x00160000;
738 const objErrorBase: c_int = 0x003d0000;
739 
740 // taskLibCommon.h
741 pub const S_taskLib_NAME_NOT_FOUND: c_int = taskErrorBase + 0x0065;
742 pub const S_taskLib_TASK_HOOK_TABLE_FULL: c_int = taskErrorBase + 0x0066;
743 pub const S_taskLib_TASK_HOOK_NOT_FOUND: c_int = taskErrorBase + 0x0067;
744 pub const S_taskLib_ILLEGAL_PRIORITY: c_int = taskErrorBase + 0x0068;
745 
746 // FIXME(vxworks): could also be useful for TASK_DESC type
747 pub const VX_TASK_NAME_LENGTH: c_int = 31;
748 
749 // semLibCommon.h
750 pub const S_semLib_INVALID_STATE: c_int = semErrorBase + 0x0065;
751 pub const S_semLib_INVALID_OPTION: c_int = semErrorBase + 0x0066;
752 pub const S_semLib_INVALID_QUEUE_TYPE: c_int = semErrorBase + 0x0067;
753 pub const S_semLib_INVALID_OPERATION: c_int = semErrorBase + 0x0068;
754 
755 // objLibCommon.h
756 pub const S_objLib_OBJ_ID_ERROR: c_int = objErrorBase + 0x0001;
757 pub const S_objLib_OBJ_UNAVAILABLE: c_int = objErrorBase + 0x0002;
758 pub const S_objLib_OBJ_DELETED: c_int = objErrorBase + 0x0003;
759 pub const S_objLib_OBJ_TIMEOUT: c_int = objErrorBase + 0x0004;
760 pub const S_objLib_OBJ_NO_METHOD: c_int = objErrorBase + 0x0005;
761 
762 // in.h
763 pub const IPPROTO_IP: c_int = 0;
764 pub const IPPROTO_IPV6: c_int = 41;
765 
766 pub const IP_TTL: c_int = 4;
767 pub const IP_MULTICAST_IF: c_int = 9;
768 pub const IP_MULTICAST_TTL: c_int = 10;
769 pub const IP_MULTICAST_LOOP: c_int = 11;
770 pub const IP_ADD_MEMBERSHIP: c_int = 12;
771 pub const IP_DROP_MEMBERSHIP: c_int = 13;
772 
773 // in6.h
774 pub const IPV6_V6ONLY: c_int = 1;
775 pub const IPV6_UNICAST_HOPS: c_int = 4;
776 pub const IPV6_MULTICAST_IF: c_int = 9;
777 pub const IPV6_MULTICAST_HOPS: c_int = 10;
778 pub const IPV6_MULTICAST_LOOP: c_int = 11;
779 pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
780 pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
781 
782 // STAT Stuff
783 pub const S_IFMT: c_int = 0o17_0000;
784 pub const S_IFIFO: c_int = 0o1_0000;
785 pub const S_IFCHR: c_int = 0o2_0000;
786 pub const S_IFDIR: c_int = 0o4_0000;
787 pub const S_IFBLK: c_int = 0o6_0000;
788 pub const S_IFREG: c_int = 0o10_0000;
789 pub const S_IFLNK: c_int = 0o12_0000;
790 pub const S_IFSHM: c_int = 0o13_0000;
791 pub const S_IFSOCK: c_int = 0o14_0000;
792 pub const S_ISUID: c_int = 0o4000;
793 pub const S_ISGID: c_int = 0o2000;
794 pub const S_ISTXT: c_int = 0o1000;
795 pub const S_ISVTX: c_int = 0o1000;
796 pub const S_IRUSR: c_int = 0o0400;
797 pub const S_IWUSR: c_int = 0o0200;
798 pub const S_IXUSR: c_int = 0o0100;
799 pub const S_IRWXU: c_int = 0o0700;
800 pub const S_IRGRP: c_int = 0o0040;
801 pub const S_IWGRP: c_int = 0o0020;
802 pub const S_IXGRP: c_int = 0o0010;
803 pub const S_IRWXG: c_int = 0o0070;
804 pub const S_IROTH: c_int = 0o0004;
805 pub const S_IWOTH: c_int = 0o0002;
806 pub const S_IXOTH: c_int = 0o0001;
807 pub const S_IRWXO: c_int = 0o0007;
808 
809 // socket.h
810 pub const SOL_SOCKET: c_int = 0xffff;
811 pub const SOMAXCONN: c_int = 128;
812 
813 pub const SO_DEBUG: c_int = 0x0001;
814 pub const SO_REUSEADDR: c_int = 0x0004;
815 pub const SO_KEEPALIVE: c_int = 0x0008;
816 pub const SO_DONTROUTE: c_int = 0x0010;
817 pub const SO_RCVLOWAT: c_int = 0x0012;
818 pub const SO_SNDLOWAT: c_int = 0x0013;
819 pub const SO_SNDTIMEO: c_int = 0x1005;
820 pub const SO_ACCEPTCONN: c_int = 0x001e;
821 pub const SO_BROADCAST: c_int = 0x0020;
822 pub const SO_USELOOPBACK: c_int = 0x0040;
823 pub const SO_LINGER: c_int = 0x0080;
824 pub const SO_REUSEPORT: c_int = 0x0200;
825 
826 pub const SO_VLAN: c_int = 0x8000;
827 
828 pub const SO_SNDBUF: c_int = 0x1001;
829 pub const SO_RCVBUF: c_int = 0x1002;
830 pub const SO_RCVTIMEO: c_int = 0x1006;
831 pub const SO_ERROR: c_int = 0x1007;
832 pub const SO_TYPE: c_int = 0x1008;
833 pub const SO_BINDTODEVICE: c_int = 0x1010;
834 pub const SO_OOBINLINE: c_int = 0x1011;
835 pub const SO_CONNTIMEO: c_int = 0x100a;
836 
837 pub const SOCK_STREAM: c_int = 1;
838 pub const SOCK_DGRAM: c_int = 2;
839 pub const SOCK_RAW: c_int = 3;
840 pub const SOCK_RDM: c_int = 4;
841 pub const SOCK_SEQPACKET: c_int = 5;
842 pub const SOCK_PACKET: c_int = 10;
843 
844 pub const _SS_MAXSIZE: usize = 128;
845 pub const _SS_ALIGNSIZE: usize = size_of::<u32>();
846 pub const _SS_PAD1SIZE: usize =
847     _SS_ALIGNSIZE - size_of::<c_uchar>() - size_of::<crate::sa_family_t>();
848 pub const _SS_PAD2SIZE: usize = _SS_MAXSIZE
849     - size_of::<c_uchar>()
850     - size_of::<crate::sa_family_t>()
851     - _SS_PAD1SIZE
852     - _SS_ALIGNSIZE;
853 
854 pub const MSG_OOB: c_int = 0x0001;
855 pub const MSG_PEEK: c_int = 0x0002;
856 pub const MSG_DONTROUTE: c_int = 0x0004;
857 pub const MSG_EOR: c_int = 0x0008;
858 pub const MSG_TRUNC: c_int = 0x0010;
859 pub const MSG_CTRUNC: c_int = 0x0020;
860 pub const MSG_WAITALL: c_int = 0x0040;
861 pub const MSG_DONTWAIT: c_int = 0x0080;
862 pub const MSG_EOF: c_int = 0x0100;
863 pub const MSG_EXP: c_int = 0x0200;
864 pub const MSG_MBUF: c_int = 0x0400;
865 pub const MSG_NOTIFICATION: c_int = 0x0800;
866 pub const MSG_COMPAT: c_int = 0x8000;
867 
868 pub const AF_UNSPEC: c_int = 0;
869 pub const AF_LOCAL: c_int = 1;
870 pub const AF_UNIX: c_int = AF_LOCAL;
871 pub const AF_INET: c_int = 2;
872 pub const AF_NETLINK: c_int = 16;
873 pub const AF_ROUTE: c_int = 17;
874 pub const AF_LINK: c_int = 18;
875 pub const AF_PACKET: c_int = 19;
876 pub const pseudo_AF_KEY: c_int = 27;
877 pub const AF_KEY: c_int = pseudo_AF_KEY;
878 pub const AF_INET6: c_int = 28;
879 pub const AF_SOCKDEV: c_int = 31;
880 pub const AF_TIPC: c_int = 33;
881 pub const AF_MIPC: c_int = 34;
882 pub const AF_MIPC_SAFE: c_int = 35;
883 pub const AF_MAX: c_int = 37;
884 
885 pub const SHUT_RD: c_int = 0;
886 pub const SHUT_WR: c_int = 1;
887 pub const SHUT_RDWR: c_int = 2;
888 
889 pub const IPPROTO_TCP: c_int = 6;
890 pub const TCP_NODELAY: c_int = 1;
891 pub const TCP_MAXSEG: c_int = 2;
892 pub const TCP_NOPUSH: c_int = 3;
893 pub const TCP_KEEPIDLE: c_int = 4;
894 pub const TCP_KEEPINTVL: c_int = 5;
895 pub const TCP_KEEPCNT: c_int = 6;
896 
897 // ioLib.h
898 pub const FIONREAD: c_int = 0x40040001;
899 pub const FIOFLUSH: c_int = 2;
900 pub const FIOOPTIONS: c_int = 3;
901 pub const FIOBAUDRATE: c_int = 4;
902 pub const FIODISKFORMAT: c_int = 5;
903 pub const FIODISKINIT: c_int = 6;
904 pub const FIOSEEK: c_int = 7;
905 pub const FIOWHERE: c_int = 8;
906 pub const FIODIRENTRY: c_int = 9;
907 pub const FIORENAME: c_int = 10;
908 pub const FIOREADYCHANGE: c_int = 11;
909 pub const FIODISKCHANGE: c_int = 13;
910 pub const FIOCANCEL: c_int = 14;
911 pub const FIOSQUEEZE: c_int = 15;
912 pub const FIOGETNAME: c_int = 18;
913 pub const FIONBIO: c_int = 0x90040010;
914 
915 // limits.h
916 pub const PATH_MAX: c_int = _PARM_PATH_MAX;
917 pub const _POSIX_PATH_MAX: c_int = 256;
918 
919 // Some poll stuff
920 pub const POLLIN: c_short = 0x0001;
921 pub const POLLPRI: c_short = 0x0002;
922 pub const POLLOUT: c_short = 0x0004;
923 pub const POLLRDNORM: c_short = 0x0040;
924 pub const POLLWRNORM: c_short = POLLOUT;
925 pub const POLLRDBAND: c_short = 0x0080;
926 pub const POLLWRBAND: c_short = 0x0100;
927 pub const POLLERR: c_short = 0x0008;
928 pub const POLLHUP: c_short = 0x0010;
929 pub const POLLNVAL: c_short = 0x0020;
930 
931 // fnctlcom.h
932 pub const FD_CLOEXEC: c_int = 1;
933 pub const F_DUPFD: c_int = 0;
934 pub const F_GETFD: c_int = 1;
935 pub const F_SETFD: c_int = 2;
936 pub const F_GETFL: c_int = 3;
937 pub const F_SETFL: c_int = 4;
938 pub const F_GETOWN: c_int = 5;
939 pub const F_SETOWN: c_int = 6;
940 pub const F_GETLK: c_int = 7;
941 pub const F_SETLK: c_int = 8;
942 pub const F_SETLKW: c_int = 9;
943 pub const F_DUPFD_CLOEXEC: c_int = 14;
944 
945 // signal.h
946 pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
947 pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
948 pub const SIG_ERR: sighandler_t = -1 as isize as sighandler_t;
949 
950 pub const SIGHUP: c_int = 1;
951 pub const SIGINT: c_int = 2;
952 pub const SIGQUIT: c_int = 3;
953 pub const SIGILL: c_int = 4;
954 pub const SIGTRAP: c_int = 5;
955 pub const SIGABRT: c_int = 6;
956 pub const SIGEMT: c_int = 7;
957 pub const SIGFPE: c_int = 8;
958 pub const SIGKILL: c_int = 9;
959 pub const SIGBUS: c_int = 10;
960 pub const SIGSEGV: c_int = 11;
961 pub const SIGFMT: c_int = 12;
962 pub const SIGPIPE: c_int = 13;
963 pub const SIGALRM: c_int = 14;
964 pub const SIGTERM: c_int = 15;
965 pub const SIGCNCL: c_int = 16;
966 pub const SIGSTOP: c_int = 17;
967 pub const SIGTSTP: c_int = 18;
968 pub const SIGCONT: c_int = 19;
969 pub const SIGCHLD: c_int = 20;
970 pub const SIGTTIN: c_int = 21;
971 pub const SIGTTOU: c_int = 22;
972 pub const SIGUSR1: c_int = 30;
973 pub const SIGUSR2: c_int = 31;
974 pub const SIGPOLL: c_int = 32;
975 pub const SIGPROF: c_int = 33;
976 pub const SIGSYS: c_int = 34;
977 pub const SIGURG: c_int = 35;
978 pub const SIGVTALRM: c_int = 36;
979 pub const SIGXCPU: c_int = 37;
980 pub const SIGXFSZ: c_int = 38;
981 pub const SIGRTMIN: c_int = 48;
982 
983 pub const SIGIO: c_int = SIGRTMIN;
984 pub const SIGWINCH: c_int = SIGRTMIN + 5;
985 pub const SIGLOST: c_int = SIGRTMIN + 6;
986 
987 pub const SIG_BLOCK: c_int = 1;
988 pub const SIG_UNBLOCK: c_int = 2;
989 pub const SIG_SETMASK: c_int = 3;
990 
991 pub const SA_NOCLDSTOP: c_int = 0x0001;
992 pub const SA_SIGINFO: c_int = 0x0002;
993 pub const SA_ONSTACK: c_int = 0x0004;
994 pub const SA_INTERRUPT: c_int = 0x0008;
995 pub const SA_RESETHAND: c_int = 0x0010;
996 pub const SA_RESTART: c_int = 0x0020;
997 pub const SA_NODEFER: c_int = 0x0040;
998 pub const SA_NOCLDWAIT: c_int = 0x0080;
999 
1000 pub const SI_SYNC: c_int = 0;
1001 pub const SI_USER: c_int = -1;
1002 pub const SI_QUEUE: c_int = -2;
1003 pub const SI_TIMER: c_int = -3;
1004 pub const SI_ASYNCIO: c_int = -4;
1005 pub const SI_MESGQ: c_int = -5;
1006 pub const SI_CHILD: c_int = -6;
1007 pub const SI_KILL: c_int = SI_USER;
1008 
1009 // vxParams.h definitions
1010 pub const _PARM_NAME_MAX: c_int = 255;
1011 pub const _PARM_PATH_MAX: c_int = 1024;
1012 
1013 // WAIT STUFF
1014 pub const WNOHANG: c_int = 0x01;
1015 pub const WUNTRACED: c_int = 0x02;
1016 
1017 const PTHREAD_MUTEXATTR_INITIALIZER: pthread_mutexattr_t = pthread_mutexattr_t {
1018     mutexAttrStatus: PTHREAD_INITIALIZED_OBJ,
1019     mutexAttrProtocol: PTHREAD_PRIO_NONE,
1020     mutexAttrPrioceiling: 0,
1021     mutexAttrType: PTHREAD_MUTEX_DEFAULT,
1022     mutexAttrPshared: 1,
1023 };
1024 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
1025     mutexSemId: null_mut(),
1026     mutexValid: PTHREAD_VALID_OBJ,
1027     mutexInitted: PTHREAD_UNUSED_YET_OBJ,
1028     mutexCondRefCount: 0,
1029     mutexSavPriority: -1,
1030     mutexAttr: PTHREAD_MUTEXATTR_INITIALIZER,
1031     mutexSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
1032 };
1033 
1034 const PTHREAD_CONDATTR_INITIALIZER: pthread_condattr_t = pthread_condattr_t {
1035     condAttrStatus: 0xf70990ef,
1036     condAttrPshared: 1,
1037     condAttrClockId: CLOCK_REALTIME,
1038 };
1039 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
1040     condSemId: null_mut(),
1041     condValid: PTHREAD_VALID_OBJ,
1042     condInitted: PTHREAD_UNUSED_YET_OBJ,
1043     condRefCount: 0,
1044     condMutex: null_mut(),
1045     condAttr: PTHREAD_CONDATTR_INITIALIZER,
1046     condSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
1047 };
1048 
1049 const PTHREAD_RWLOCKATTR_INITIALIZER: pthread_rwlockattr_t = pthread_rwlockattr_t {
1050     rwlockAttrStatus: PTHREAD_INITIALIZED_OBJ,
1051     rwlockAttrPshared: 1,
1052     rwlockAttrMaxReaders: 0,
1053     rwlockAttrConformOpt: 1,
1054 };
1055 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
1056     rwlockSemId: null_mut(),
1057     rwlockReadersRefCount: 0,
1058     rwlockValid: PTHREAD_VALID_OBJ,
1059     rwlockInitted: PTHREAD_UNUSED_YET_OBJ,
1060     rwlockAttr: PTHREAD_RWLOCKATTR_INITIALIZER,
1061     rwlockSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
1062 };
1063 
1064 pub const SEEK_SET: c_int = 0;
1065 pub const SEEK_CUR: c_int = 1;
1066 pub const SEEK_END: c_int = 2;
1067 
1068 // rtpLibCommon.h
1069 pub const VX_RTP_NAME_LENGTH: c_int = 255;
1070 pub const RTP_ID_ERROR: crate::RTP_ID = -1;
1071 
1072 // h/public/unistd.h
1073 pub const _SC_GETPW_R_SIZE_MAX: c_int = 21; // Via unistd.h
1074 pub const _SC_PAGESIZE: c_int = 39;
1075 pub const O_ACCMODE: c_int = 3;
1076 pub const O_CLOEXEC: c_int = 0x100000; // fcntlcom
1077 pub const O_EXCL: c_int = 0x0800;
1078 pub const O_CREAT: c_int = 0x0200;
1079 pub const O_TRUNC: c_int = 0x0400;
1080 pub const O_APPEND: c_int = 0x0008;
1081 pub const O_RDWR: c_int = 0x0002;
1082 pub const O_WRONLY: c_int = 0x0001;
1083 pub const O_RDONLY: c_int = 0;
1084 pub const O_NONBLOCK: c_int = 0x4000;
1085 
1086 // mman.h
1087 pub const PROT_NONE: c_int = 0x0000;
1088 pub const PROT_READ: c_int = 0x0001;
1089 pub const PROT_WRITE: c_int = 0x0002;
1090 pub const PROT_EXEC: c_int = 0x0004;
1091 
1092 pub const MAP_SHARED: c_int = 0x0001;
1093 pub const MAP_PRIVATE: c_int = 0x0002;
1094 pub const MAP_ANON: c_int = 0x0004;
1095 pub const MAP_ANONYMOUS: c_int = MAP_ANON;
1096 pub const MAP_FIXED: c_int = 0x0010;
1097 pub const MAP_CONTIG: c_int = 0x0020;
1098 
1099 pub const MAP_FAILED: *mut c_void = !0 as *mut c_void;
1100 
1101 #[cfg_attr(feature = "extra_traits", derive(Debug))]
1102 pub enum FILE {}
1103 impl Copy for FILE {}
1104 impl Clone for FILE {
1105     fn clone(&self) -> FILE {
1106         *self
1107     }
1108 }
1109 #[cfg_attr(feature = "extra_traits", derive(Debug))]
1110 pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct
1111 impl Copy for fpos_t {}
1112 impl Clone for fpos_t {
1113     fn clone(&self) -> fpos_t {
1114         *self
1115     }
1116 }
1117 
1118 f! {
1119     pub {const} fn CMSG_ALIGN(len: usize) -> usize {
1120         len + mem::size_of::<usize>() - 1 & !(mem::size_of::<usize>() - 1)
1121     }
1122 
1123     pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr {
1124         let next = cmsg as usize
1125             + CMSG_ALIGN((*cmsg).cmsg_len as usize)
1126             + CMSG_ALIGN(mem::size_of::<cmsghdr>());
1127         let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
1128         if next <= max {
1129             (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr
1130         } else {
1131             0 as *mut cmsghdr
1132         }
1133     }
1134 
1135     pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr {
1136         if (*mhdr).msg_controllen as usize > 0 {
1137             (*mhdr).msg_control as *mut cmsghdr
1138         } else {
1139             0 as *mut cmsghdr
1140         }
1141     }
1142 
1143     pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar {
1144         (cmsg as *mut c_uchar).offset(CMSG_ALIGN(mem::size_of::<cmsghdr>()) as isize)
1145     }
1146 
1147     pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint {
1148         (CMSG_ALIGN(length as usize) + CMSG_ALIGN(mem::size_of::<cmsghdr>())) as c_uint
1149     }
1150 
1151     pub {const} fn CMSG_LEN(length: c_uint) -> c_uint {
1152         CMSG_ALIGN(mem::size_of::<cmsghdr>()) as c_uint + length
1153     }
1154 }
1155 
1156 extern "C" {
1157     pub fn isalnum(c: c_int) -> c_int;
1158     pub fn isalpha(c: c_int) -> c_int;
1159     pub fn iscntrl(c: c_int) -> c_int;
1160     pub fn isdigit(c: c_int) -> c_int;
1161     pub fn isgraph(c: c_int) -> c_int;
1162     pub fn islower(c: c_int) -> c_int;
1163     pub fn isprint(c: c_int) -> c_int;
1164     pub fn ispunct(c: c_int) -> c_int;
1165     pub fn isspace(c: c_int) -> c_int;
1166     pub fn isupper(c: c_int) -> c_int;
1167     pub fn isxdigit(c: c_int) -> c_int;
1168     pub fn isblank(c: c_int) -> c_int;
1169     pub fn tolower(c: c_int) -> c_int;
1170     pub fn toupper(c: c_int) -> c_int;
1171     pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
1172     pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE;
1173     pub fn fflush(file: *mut FILE) -> c_int;
1174     pub fn fclose(file: *mut FILE) -> c_int;
1175     pub fn remove(filename: *const c_char) -> c_int;
1176     pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
1177     pub fn tmpfile() -> *mut FILE;
1178     pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int;
1179     pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
1180     pub fn getchar() -> c_int;
1181     pub fn putchar(c: c_int) -> c_int;
1182     pub fn fgetc(stream: *mut FILE) -> c_int;
1183     pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
1184     pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
1185     pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int;
1186     pub fn puts(s: *const c_char) -> c_int;
1187     pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
1188     pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
1189     pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t;
1190     pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
1191     pub fn ftell(stream: *mut FILE) -> c_long;
1192     pub fn rewind(stream: *mut FILE);
1193     pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
1194     pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
1195     pub fn feof(stream: *mut FILE) -> c_int;
1196     pub fn ferror(stream: *mut FILE) -> c_int;
1197     pub fn perror(s: *const c_char);
1198     pub fn atof(s: *const c_char) -> c_double;
1199     pub fn atoi(s: *const c_char) -> c_int;
1200     pub fn atol(s: *const c_char) -> c_long;
1201     pub fn atoll(s: *const c_char) -> c_longlong;
1202     pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
1203     pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
1204     pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
1205     pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong;
1206     pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
1207     pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong;
1208     pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
1209     pub fn malloc(size: size_t) -> *mut c_void;
1210     pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
1211     pub fn free(p: *mut c_void);
1212     pub fn abort() -> !;
1213     pub fn exit(status: c_int) -> !;
1214     pub fn atexit(cb: extern "C" fn()) -> c_int;
1215     pub fn system(s: *const c_char) -> c_int;
1216     pub fn getenv(s: *const c_char) -> *mut c_char;
1217 
1218     pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
1219     pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
1220     pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
1221     pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char;
1222     pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
1223     pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int;
1224     pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
1225     pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
1226     pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
1227     pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
1228     pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
1229     pub fn strdup(cs: *const c_char) -> *mut c_char;
1230     pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
1231     pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
1232     pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
1233     pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int;
1234     pub fn strlen(cs: *const c_char) -> size_t;
1235     pub fn strerror(n: c_int) -> *mut c_char;
1236     pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
1237     pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
1238     pub fn wcslen(buf: *const wchar_t) -> size_t;
1239     pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> size_t;
1240 
1241     pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
1242     pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t;
1243     pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
1244     pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
1245     pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
1246     pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
1247 }
1248 
1249 extern "C" {
1250     pub fn fprintf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int;
1251     pub fn printf(format: *const c_char, ...) -> c_int;
1252     pub fn snprintf(s: *mut c_char, n: size_t, format: *const c_char, ...) -> c_int;
1253     pub fn sprintf(s: *mut c_char, format: *const c_char, ...) -> c_int;
1254     pub fn fscanf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int;
1255     pub fn scanf(format: *const c_char, ...) -> c_int;
1256     pub fn sscanf(s: *const c_char, format: *const c_char, ...) -> c_int;
1257     pub fn getchar_unlocked() -> c_int;
1258     pub fn putchar_unlocked(c: c_int) -> c_int;
1259     pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
1260     pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut crate::FILE;
1261     pub fn fileno(stream: *mut crate::FILE) -> c_int;
1262     pub fn creat(path: *const c_char, mode: mode_t) -> c_int;
1263     pub fn rewinddir(dirp: *mut crate::DIR);
1264     pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int;
1265     pub fn access(path: *const c_char, amode: c_int) -> c_int;
1266     pub fn alarm(seconds: c_uint) -> c_uint;
1267     pub fn fchdir(dirfd: c_int) -> c_int;
1268     pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int;
1269     pub fn fpathconf(filedes: c_int, name: c_int) -> c_long;
1270     pub fn getegid() -> gid_t;
1271     pub fn geteuid() -> uid_t;
1272     pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int;
1273     pub fn getlogin() -> *mut c_char;
1274     pub fn getopt(argc: c_int, argv: *const *mut c_char, optstr: *const c_char) -> c_int;
1275     pub fn pathconf(path: *const c_char, name: c_int) -> c_long;
1276     pub fn pause() -> c_int;
1277     pub fn seteuid(uid: uid_t) -> c_int;
1278     pub fn setegid(gid: gid_t) -> c_int;
1279     pub fn sleep(secs: c_uint) -> c_uint;
1280     pub fn ttyname(fd: c_int) -> *mut c_char;
1281     pub fn wait(status: *mut c_int) -> pid_t;
1282     pub fn umask(mask: mode_t) -> mode_t;
1283     pub fn mlock(addr: *const c_void, len: size_t) -> c_int;
1284     pub fn mlockall(flags: c_int) -> c_int;
1285     pub fn munlock(addr: *const c_void, len: size_t) -> c_int;
1286     pub fn munlockall() -> c_int;
1287 
1288     pub fn mmap(
1289         addr: *mut c_void,
1290         len: size_t,
1291         prot: c_int,
1292         flags: c_int,
1293         fd: c_int,
1294         offset: off_t,
1295     ) -> *mut c_void;
1296     pub fn munmap(addr: *mut c_void, len: size_t) -> c_int;
1297 
1298     pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
1299     pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int;
1300 
1301     pub fn truncate(path: *const c_char, length: off_t) -> c_int;
1302     pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int;
1303     pub fn shm_unlink(name: *const c_char) -> c_int;
1304 
1305     pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int;
1306     pub fn pthread_exit(value: *mut c_void) -> !;
1307     pub fn pthread_attr_setdetachstate(attr: *mut crate::pthread_attr_t, state: c_int) -> c_int;
1308 
1309     pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int;
1310 
1311     pub fn sigaddset(set: *mut sigset_t, signum: c_int) -> c_int;
1312 
1313     pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction) -> c_int;
1314 
1315     pub fn utimes(filename: *const c_char, times: *const crate::timeval) -> c_int;
1316 
1317     pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int;
1318 
1319     #[link_name = "_rtld_dlopen"]
1320     pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
1321 
1322     #[link_name = "_rtld_dlerror"]
1323     pub fn dlerror() -> *mut c_char;
1324 
1325     #[link_name = "_rtld_dlsym"]
1326     pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
1327 
1328     #[link_name = "_rtld_dlclose"]
1329     pub fn dlclose(handle: *mut c_void) -> c_int;
1330 
1331     #[link_name = "_rtld_dladdr"]
1332     pub fn dladdr(addr: *mut c_void, info: *mut Dl_info) -> c_int;
1333 
1334     // time.h
1335     pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1336     pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
1337     pub fn mktime(tm: *mut tm) -> time_t;
1338     pub fn time(time: *mut time_t) -> time_t;
1339     pub fn gmtime(time_p: *const time_t) -> *mut tm;
1340     pub fn localtime(time_p: *const time_t) -> *mut tm;
1341     pub fn timegm(tm: *mut tm) -> time_t;
1342     pub fn difftime(time1: time_t, time0: time_t) -> c_double;
1343     pub fn gethostname(name: *mut c_char, len: size_t) -> c_int;
1344     pub fn usleep(secs: crate::useconds_t) -> c_int;
1345     pub fn putenv(string: *mut c_char) -> c_int;
1346     pub fn setlocale(category: c_int, locale: *const c_char) -> *mut c_char;
1347 
1348     pub fn sigprocmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int;
1349     pub fn sigpending(set: *mut sigset_t) -> c_int;
1350 
1351     pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int;
1352 
1353     pub fn fseeko(stream: *mut crate::FILE, offset: off_t, whence: c_int) -> c_int;
1354     pub fn ftello(stream: *mut crate::FILE) -> off_t;
1355     pub fn mkstemp(template: *mut c_char) -> c_int;
1356 
1357     pub fn tmpnam(ptr: *mut c_char) -> *mut c_char;
1358 
1359     pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int);
1360     pub fn closelog();
1361     pub fn setlogmask(maskpri: c_int) -> c_int;
1362     pub fn syslog(priority: c_int, message: *const c_char, ...);
1363     pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t;
1364 
1365 }
1366 
1367 extern "C" {
1368     // stdlib.h
1369     pub fn memalign(block_size: size_t, size_arg: size_t) -> *mut c_void;
1370 
1371     // ioLib.h
1372     pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
1373 
1374     // ioLib.h
1375     pub fn chdir(attr: *const c_char) -> c_int;
1376 
1377     // pthread.h
1378     pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int;
1379 
1380     // pthread.h
1381     pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int;
1382 
1383     // pthread.h
1384     pub fn pthread_mutexattr_settype(pAttr: *mut crate::pthread_mutexattr_t, pType: c_int)
1385         -> c_int;
1386 
1387     // pthread.h
1388     pub fn pthread_mutex_init(
1389         mutex: *mut pthread_mutex_t,
1390         attr: *const pthread_mutexattr_t,
1391     ) -> c_int;
1392 
1393     // pthread.h
1394     pub fn pthread_mutex_destroy(mutex: *mut pthread_mutex_t) -> c_int;
1395 
1396     // pthread.h
1397     pub fn pthread_mutex_lock(mutex: *mut pthread_mutex_t) -> c_int;
1398 
1399     // pthread.h
1400     pub fn pthread_mutex_trylock(mutex: *mut pthread_mutex_t) -> c_int;
1401 
1402     // pthread.h
1403     pub fn pthread_mutex_timedlock(attr: *mut pthread_mutex_t, spec: *const timespec) -> c_int;
1404 
1405     // pthread.h
1406     pub fn pthread_mutex_unlock(mutex: *mut pthread_mutex_t) -> c_int;
1407 
1408     // pthread.h
1409     pub fn pthread_attr_setname(pAttr: *mut crate::pthread_attr_t, name: *mut c_char) -> c_int;
1410 
1411     // pthread.h
1412     pub fn pthread_attr_setstacksize(attr: *mut crate::pthread_attr_t, stacksize: size_t) -> c_int;
1413 
1414     // pthread.h
1415     pub fn pthread_attr_getstacksize(
1416         attr: *const crate::pthread_attr_t,
1417         size: *mut size_t,
1418     ) -> c_int;
1419 
1420     // pthread.h
1421     pub fn pthread_attr_init(attr: *mut crate::pthread_attr_t) -> c_int;
1422 
1423     // pthread.h
1424     pub fn pthread_create(
1425         pThread: *mut crate::pthread_t,
1426         pAttr: *const crate::pthread_attr_t,
1427         start_routine: extern "C" fn(*mut c_void) -> *mut c_void,
1428         value: *mut c_void,
1429     ) -> c_int;
1430 
1431     //pthread.h
1432     pub fn pthread_setschedparam(
1433         native: crate::pthread_t,
1434         policy: c_int,
1435         param: *const crate::sched_param,
1436     ) -> c_int;
1437 
1438     //pthread.h
1439     pub fn pthread_getschedparam(
1440         native: crate::pthread_t,
1441         policy: *mut c_int,
1442         param: *mut crate::sched_param,
1443     ) -> c_int;
1444 
1445     //pthread.h
1446     pub fn pthread_attr_setinheritsched(
1447         attr: *mut crate::pthread_attr_t,
1448         inheritsched: c_int,
1449     ) -> c_int;
1450 
1451     //pthread.h
1452     pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int;
1453 
1454     // pthread.h
1455     pub fn pthread_attr_destroy(thread: *mut crate::pthread_attr_t) -> c_int;
1456 
1457     // pthread.h
1458     pub fn pthread_detach(thread: crate::pthread_t) -> c_int;
1459 
1460     // int pthread_atfork (void (*)(void), void (*)(void), void (*)(void));
1461     pub fn pthread_atfork(
1462         prepare: Option<unsafe extern "C" fn()>,
1463         parent: Option<unsafe extern "C" fn()>,
1464         child: Option<unsafe extern "C" fn()>,
1465     ) -> c_int;
1466 
1467     // stat.h
1468     pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
1469 
1470     // stat.h
1471     pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
1472 
1473     // unistd.h
1474     pub fn ftruncate(fd: c_int, length: off_t) -> c_int;
1475 
1476     // dirent.h
1477     pub fn readdir_r(
1478         pDir: *mut crate::DIR,
1479         entry: *mut crate::dirent,
1480         result: *mut *mut crate::dirent,
1481     ) -> c_int;
1482 
1483     // dirent.h
1484     pub fn readdir(pDir: *mut crate::DIR) -> *mut crate::dirent;
1485 
1486     // fcntl.h or
1487     // ioLib.h
1488     pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int;
1489 
1490     // poll.h
1491     pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int;
1492 
1493     // pthread.h
1494     pub fn pthread_condattr_init(attr: *mut crate::pthread_condattr_t) -> c_int;
1495 
1496     // pthread.h
1497     pub fn pthread_condattr_destroy(attr: *mut crate::pthread_condattr_t) -> c_int;
1498 
1499     // pthread.h
1500     pub fn pthread_condattr_getclock(
1501         pAttr: *const crate::pthread_condattr_t,
1502         pClockId: *mut crate::clockid_t,
1503     ) -> c_int;
1504 
1505     // pthread.h
1506     pub fn pthread_condattr_setclock(
1507         pAttr: *mut crate::pthread_condattr_t,
1508         clockId: crate::clockid_t,
1509     ) -> c_int;
1510 
1511     // pthread.h
1512     pub fn pthread_cond_init(
1513         cond: *mut crate::pthread_cond_t,
1514         attr: *const crate::pthread_condattr_t,
1515     ) -> c_int;
1516 
1517     // pthread.h
1518     pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int;
1519 
1520     // pthread.h
1521     pub fn pthread_cond_signal(cond: *mut crate::pthread_cond_t) -> c_int;
1522 
1523     // pthread.h
1524     pub fn pthread_cond_broadcast(cond: *mut crate::pthread_cond_t) -> c_int;
1525 
1526     // pthread.h
1527     pub fn pthread_cond_wait(
1528         cond: *mut crate::pthread_cond_t,
1529         mutex: *mut crate::pthread_mutex_t,
1530     ) -> c_int;
1531 
1532     // pthread.h
1533     pub fn pthread_rwlockattr_init(attr: *mut crate::pthread_rwlockattr_t) -> c_int;
1534 
1535     // pthread.h
1536     pub fn pthread_rwlockattr_destroy(attr: *mut crate::pthread_rwlockattr_t) -> c_int;
1537 
1538     // pthread.h
1539     pub fn pthread_rwlockattr_setmaxreaders(
1540         attr: *mut crate::pthread_rwlockattr_t,
1541         attr2: c_uint,
1542     ) -> c_int;
1543 
1544     // pthread.h
1545     pub fn pthread_rwlock_init(
1546         attr: *mut crate::pthread_rwlock_t,
1547         host: *const crate::pthread_rwlockattr_t,
1548     ) -> c_int;
1549 
1550     // pthread.h
1551     pub fn pthread_rwlock_destroy(attr: *mut crate::pthread_rwlock_t) -> c_int;
1552 
1553     // pthread.h
1554     pub fn pthread_rwlock_rdlock(attr: *mut crate::pthread_rwlock_t) -> c_int;
1555 
1556     // pthread.h
1557     pub fn pthread_rwlock_tryrdlock(attr: *mut crate::pthread_rwlock_t) -> c_int;
1558 
1559     // pthread.h
1560     pub fn pthread_rwlock_timedrdlock(
1561         attr: *mut crate::pthread_rwlock_t,
1562         host: *const crate::timespec,
1563     ) -> c_int;
1564 
1565     // pthread.h
1566     pub fn pthread_rwlock_wrlock(attr: *mut crate::pthread_rwlock_t) -> c_int;
1567 
1568     // pthread.h
1569     pub fn pthread_rwlock_trywrlock(attr: *mut crate::pthread_rwlock_t) -> c_int;
1570 
1571     // pthread.h
1572     pub fn pthread_rwlock_timedwrlock(
1573         attr: *mut crate::pthread_rwlock_t,
1574         host: *const crate::timespec,
1575     ) -> c_int;
1576 
1577     // pthread.h
1578     pub fn pthread_rwlock_unlock(attr: *mut crate::pthread_rwlock_t) -> c_int;
1579 
1580     // pthread.h
1581     pub fn pthread_key_create(
1582         key: *mut crate::pthread_key_t,
1583         dtor: Option<unsafe extern "C" fn(*mut c_void)>,
1584     ) -> c_int;
1585 
1586     // pthread.h
1587     pub fn pthread_key_delete(key: crate::pthread_key_t) -> c_int;
1588 
1589     // pthread.h
1590     pub fn pthread_setspecific(key: crate::pthread_key_t, value: *const c_void) -> c_int;
1591 
1592     // pthread.h
1593     pub fn pthread_getspecific(key: crate::pthread_key_t) -> *mut c_void;
1594 
1595     // pthread.h
1596     pub fn pthread_cond_timedwait(
1597         cond: *mut crate::pthread_cond_t,
1598         mutex: *mut crate::pthread_mutex_t,
1599         abstime: *const crate::timespec,
1600     ) -> c_int;
1601 
1602     // pthread.h
1603     pub fn pthread_attr_getname(attr: *mut crate::pthread_attr_t, name: *mut *mut c_char) -> c_int;
1604 
1605     // pthread.h
1606     pub fn pthread_join(thread: crate::pthread_t, status: *mut *mut c_void) -> c_int;
1607 
1608     // pthread.h
1609     pub fn pthread_self() -> crate::pthread_t;
1610 
1611     // clockLib.h
1612     pub fn clock_gettime(clock_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
1613 
1614     // clockLib.h
1615     pub fn clock_settime(clock_id: crate::clockid_t, tp: *const crate::timespec) -> c_int;
1616 
1617     // clockLib.h
1618     pub fn clock_getres(clock_id: crate::clockid_t, res: *mut crate::timespec) -> c_int;
1619 
1620     // clockLib.h
1621     pub fn clock_nanosleep(
1622         clock_id: crate::clockid_t,
1623         flags: c_int,
1624         rqtp: *const crate::timespec,
1625         rmtp: *mut crate::timespec,
1626     ) -> c_int;
1627 
1628     // timerLib.h
1629     pub fn nanosleep(rqtp: *const crate::timespec, rmtp: *mut crate::timespec) -> c_int;
1630 
1631     // socket.h
1632     pub fn accept(s: c_int, addr: *mut crate::sockaddr, addrlen: *mut crate::socklen_t) -> c_int;
1633 
1634     // socket.h
1635     pub fn bind(fd: c_int, addr: *const sockaddr, len: socklen_t) -> c_int;
1636 
1637     // socket.h
1638     pub fn connect(s: c_int, name: *const crate::sockaddr, namelen: crate::socklen_t) -> c_int;
1639 
1640     // socket.h
1641     pub fn getpeername(
1642         s: c_int,
1643         name: *mut crate::sockaddr,
1644         namelen: *mut crate::socklen_t,
1645     ) -> c_int;
1646 
1647     // socket.h
1648     pub fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t)
1649         -> c_int;
1650 
1651     // socket.h
1652     pub fn getsockopt(
1653         sockfd: c_int,
1654         level: c_int,
1655         optname: c_int,
1656         optval: *mut c_void,
1657         optlen: *mut crate::socklen_t,
1658     ) -> c_int;
1659 
1660     // socket.h
1661     pub fn listen(socket: c_int, backlog: c_int) -> c_int;
1662 
1663     // socket.h
1664     pub fn recv(s: c_int, buf: *mut c_void, bufLen: size_t, flags: c_int) -> ssize_t;
1665 
1666     // socket.h
1667     pub fn recvfrom(
1668         s: c_int,
1669         buf: *mut c_void,
1670         bufLen: size_t,
1671         flags: c_int,
1672         from: *mut crate::sockaddr,
1673         pFromLen: *mut crate::socklen_t,
1674     ) -> ssize_t;
1675 
1676     pub fn recvmsg(socket: c_int, mp: *mut crate::msghdr, flags: c_int) -> ssize_t;
1677 
1678     // socket.h
1679     pub fn send(socket: c_int, buf: *const c_void, len: size_t, flags: c_int) -> ssize_t;
1680 
1681     pub fn sendmsg(socket: c_int, mp: *const crate::msghdr, flags: c_int) -> ssize_t;
1682 
1683     // socket.h
1684     pub fn sendto(
1685         socket: c_int,
1686         buf: *const c_void,
1687         len: size_t,
1688         flags: c_int,
1689         addr: *const sockaddr,
1690         addrlen: socklen_t,
1691     ) -> ssize_t;
1692 
1693     // socket.h
1694     pub fn setsockopt(
1695         socket: c_int,
1696         level: c_int,
1697         name: c_int,
1698         value: *const c_void,
1699         option_len: socklen_t,
1700     ) -> c_int;
1701 
1702     // socket.h
1703     pub fn shutdown(s: c_int, how: c_int) -> c_int;
1704 
1705     // socket.h
1706     pub fn socket(domain: c_int, _type: c_int, protocol: c_int) -> c_int;
1707 
1708     // icotl.h
1709     pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int;
1710 
1711     // fcntl.h
1712     pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
1713 
1714     // ntp_rfc2553.h for kernel
1715     // netdb.h for user
1716     pub fn gai_strerror(errcode: c_int) -> *mut c_char;
1717 
1718     // ioLib.h or
1719     // unistd.h
1720     pub fn close(fd: c_int) -> c_int;
1721 
1722     // ioLib.h or
1723     // unistd.h
1724     pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t;
1725 
1726     // ioLib.h or
1727     // unistd.h
1728     pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t;
1729 
1730     // ioLib.h or
1731     // unistd.h
1732     pub fn isatty(fd: c_int) -> c_int;
1733 
1734     // ioLib.h or
1735     // unistd.h
1736     pub fn dup(src: c_int) -> c_int;
1737 
1738     // ioLib.h or
1739     // unistd.h
1740     pub fn dup2(src: c_int, dst: c_int) -> c_int;
1741 
1742     // ioLib.h or
1743     // unistd.h
1744     pub fn pipe(fds: *mut c_int) -> c_int;
1745 
1746     // ioLib.h or
1747     // unistd.h
1748     pub fn unlink(pathname: *const c_char) -> c_int;
1749 
1750     // unistd.h and
1751     // ioLib.h
1752     pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t;
1753 
1754     // netdb.h
1755     pub fn getaddrinfo(
1756         node: *const c_char,
1757         service: *const c_char,
1758         hints: *const addrinfo,
1759         res: *mut *mut addrinfo,
1760     ) -> c_int;
1761 
1762     // netdb.h
1763     pub fn freeaddrinfo(res: *mut addrinfo);
1764 
1765     // signal.h
1766     pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t;
1767 
1768     // unistd.h
1769     pub fn getpid() -> pid_t;
1770 
1771     // unistd.h
1772     pub fn getppid() -> pid_t;
1773 
1774     // wait.h
1775     pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t;
1776 
1777     // unistd.h
1778     pub fn sysconf(attr: c_int) -> c_long;
1779 
1780     // stdlib.h
1781     pub fn setenv(
1782         // setenv.c
1783         envVarName: *const c_char,
1784         envVarValue: *const c_char,
1785         overwrite: c_int,
1786     ) -> c_int;
1787 
1788     // stdlib.h
1789     pub fn unsetenv(
1790         // setenv.c
1791         envVarName: *const c_char,
1792     ) -> c_int;
1793 
1794     // stdlib.h
1795     pub fn realpath(fileName: *const c_char, resolvedName: *mut c_char) -> *mut c_char;
1796 
1797     // unistd.h
1798     pub fn link(src: *const c_char, dst: *const c_char) -> c_int;
1799 
1800     // unistd.h
1801     pub fn readlink(path: *const c_char, buf: *mut c_char, bufsize: size_t) -> ssize_t;
1802 
1803     // unistd.h
1804     pub fn symlink(path1: *const c_char, path2: *const c_char) -> c_int;
1805 
1806     // dirent.h
1807     pub fn opendir(name: *const c_char) -> *mut crate::DIR;
1808 
1809     // unistd.h
1810     pub fn rmdir(path: *const c_char) -> c_int;
1811 
1812     // stat.h
1813     pub fn mkdir(dirName: *const c_char, mode: crate::mode_t) -> c_int;
1814 
1815     // stat.h
1816     pub fn chmod(path: *const c_char, mode: crate::mode_t) -> c_int;
1817 
1818     // stat.h
1819     pub fn fchmod(attr1: c_int, attr2: crate::mode_t) -> c_int;
1820 
1821     // unistd.h
1822     pub fn fsync(fd: c_int) -> c_int;
1823 
1824     // dirent.h
1825     pub fn closedir(ptr: *mut crate::DIR) -> c_int;
1826 
1827     //sched.h
1828     pub fn sched_get_priority_max(policy: c_int) -> c_int;
1829 
1830     //sched.h
1831     pub fn sched_get_priority_min(policy: c_int) -> c_int;
1832 
1833     //sched.h
1834     pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int;
1835 
1836     //sched.h
1837     pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int;
1838 
1839     //sched.h
1840     pub fn sched_setscheduler(
1841         pid: crate::pid_t,
1842         policy: c_int,
1843         param: *const crate::sched_param,
1844     ) -> c_int;
1845 
1846     //sched.h
1847     pub fn sched_getscheduler(pid: crate::pid_t) -> c_int;
1848 
1849     //sched.h
1850     pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int;
1851 
1852     // sched.h
1853     pub fn sched_yield() -> c_int;
1854 
1855     // errnoLib.h
1856     pub fn errnoSet(err: c_int) -> c_int;
1857 
1858     // errnoLib.h
1859     pub fn errnoGet() -> c_int;
1860 
1861     // unistd.h
1862     pub fn _exit(status: c_int) -> !;
1863 
1864     // unistd.h
1865     pub fn setgid(gid: crate::gid_t) -> c_int;
1866 
1867     // unistd.h
1868     pub fn getgid() -> crate::gid_t;
1869 
1870     // unistd.h
1871     pub fn setuid(uid: crate::uid_t) -> c_int;
1872 
1873     // unistd.h
1874     pub fn getuid() -> crate::uid_t;
1875 
1876     // signal.h
1877     pub fn sigemptyset(__set: *mut sigset_t) -> c_int;
1878 
1879     // pthread.h for kernel
1880     // signal.h for user
1881     pub fn pthread_sigmask(__how: c_int, __set: *const sigset_t, __oset: *mut sigset_t) -> c_int;
1882 
1883     // signal.h for user
1884     pub fn kill(__pid: pid_t, __signo: c_int) -> c_int;
1885 
1886     // signal.h for user
1887     pub fn sigqueue(__pid: pid_t, __signo: c_int, __value: crate::sigval) -> c_int;
1888 
1889     // signal.h for user
1890     pub fn _sigqueue(
1891         rtpId: crate::RTP_ID,
1892         signo: c_int,
1893         pValue: *const crate::sigval,
1894         sigCode: c_int,
1895     ) -> c_int;
1896 
1897     // signal.h
1898     pub fn taskKill(taskId: crate::TASK_ID, signo: c_int) -> c_int;
1899 
1900     // signal.h
1901     pub fn raise(__signo: c_int) -> c_int;
1902 
1903     // taskLibCommon.h
1904     pub fn taskIdSelf() -> crate::TASK_ID;
1905     pub fn taskDelay(ticks: crate::_Vx_ticks_t) -> c_int;
1906 
1907     // taskLib.h
1908     pub fn taskNameSet(task_id: crate::TASK_ID, task_name: *mut c_char) -> c_int;
1909     pub fn taskNameGet(task_id: crate::TASK_ID, buf_name: *mut c_char, bufsize: size_t) -> c_int;
1910 
1911     // rtpLibCommon.h
1912     pub fn rtpInfoGet(rtpId: crate::RTP_ID, rtpStruct: *mut crate::RTP_DESC) -> c_int;
1913     pub fn rtpSpawn(
1914         pubrtpFileName: *const c_char,
1915         argv: *mut *const c_char,
1916         envp: *mut *const c_char,
1917         priority: c_int,
1918         uStackSize: size_t,
1919         options: c_int,
1920         taskOptions: c_int,
1921     ) -> RTP_ID;
1922 
1923     // ioLib.h
1924     pub fn _realpath(fileName: *const c_char, resolvedName: *mut c_char) -> *mut c_char;
1925 
1926     // pathLib.h
1927     pub fn _pathIsAbsolute(filepath: *const c_char, pNameTail: *mut *const c_char) -> BOOL;
1928 
1929     pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t;
1930     pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t;
1931 
1932     // randomNumGen.h
1933     pub fn randBytes(buf: *mut c_uchar, length: c_int) -> c_int;
1934     pub fn randABytes(buf: *mut c_uchar, length: c_int) -> c_int;
1935     pub fn randUBytes(buf: *mut c_uchar, length: c_int) -> c_int;
1936     pub fn randSecure() -> c_int;
1937 
1938     // mqueue.h
1939     pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t;
1940     pub fn mq_close(mqd: crate::mqd_t) -> c_int;
1941     pub fn mq_unlink(name: *const c_char) -> c_int;
1942     pub fn mq_receive(
1943         mqd: crate::mqd_t,
1944         msg_ptr: *mut c_char,
1945         msg_len: size_t,
1946         msg_prio: *mut c_uint,
1947     ) -> ssize_t;
1948     pub fn mq_timedreceive(
1949         mqd: crate::mqd_t,
1950         msg_ptr: *mut c_char,
1951         msg_len: size_t,
1952         msg_prio: *mut c_uint,
1953         abs_timeout: *const crate::timespec,
1954     ) -> ssize_t;
1955     pub fn mq_send(
1956         mqd: crate::mqd_t,
1957         msg_ptr: *const c_char,
1958         msg_len: size_t,
1959         msg_prio: c_uint,
1960     ) -> c_int;
1961     pub fn mq_timedsend(
1962         mqd: crate::mqd_t,
1963         msg_ptr: *const c_char,
1964         msg_len: size_t,
1965         msg_prio: c_uint,
1966         abs_timeout: *const crate::timespec,
1967     ) -> c_int;
1968     pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int;
1969     pub fn mq_setattr(
1970         mqd: crate::mqd_t,
1971         newattr: *const crate::mq_attr,
1972         oldattr: *mut crate::mq_attr,
1973     ) -> c_int;
1974 
1975     // vxCpuLib.h
1976     pub fn vxCpuEnabledGet() -> crate::cpuset_t; // Get set of running CPU's in the system
1977     pub fn vxCpuConfiguredGet() -> crate::cpuset_t; // Get set of Configured CPU's in the system
1978 }
1979 
1980 //Dummy functions, these don't really exist in VxWorks.
1981 
1982 // wait.h macros
1983 safe_f! {
1984     pub {const} fn WIFEXITED(status: c_int) -> bool {
1985         (status & 0xFF00) == 0
1986     }
1987     pub {const} fn WIFSIGNALED(status: c_int) -> bool {
1988         (status & 0xFF00) != 0
1989     }
1990     pub {const} fn WIFSTOPPED(status: c_int) -> bool {
1991         (status & 0xFF0000) != 0
1992     }
1993     pub {const} fn WEXITSTATUS(status: c_int) -> c_int {
1994         status & 0xFF
1995     }
1996     pub {const} fn WTERMSIG(status: c_int) -> c_int {
1997         (status >> 8) & 0xFF
1998     }
1999     pub {const} fn WSTOPSIG(status: c_int) -> c_int {
2000         (status >> 16) & 0xFF
2001     }
2002 }
2003 
2004 pub fn pread(_fd: c_int, _buf: *mut c_void, _count: size_t, _offset: off64_t) -> ssize_t {
2005     -1
2006 }
2007 
2008 pub fn pwrite(_fd: c_int, _buf: *const c_void, _count: size_t, _offset: off64_t) -> ssize_t {
2009     -1
2010 }
2011 pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int {
2012     // check to see if align is a power of 2 and if align is a multiple
2013     //  of sizeof(void *)
2014     if (align & align - 1 != 0) || (align as usize % size_of::<size_t>() != 0) {
2015         return crate::EINVAL;
2016     }
2017 
2018     unsafe {
2019         // posix_memalign should not set errno
2020         let e = crate::errnoGet();
2021 
2022         let temp = memalign(align, size);
2023         crate::errnoSet(e as c_int);
2024 
2025         if temp.is_null() {
2026             crate::ENOMEM
2027         } else {
2028             *memptr = temp;
2029             0
2030         }
2031     }
2032 }
2033 
2034 cfg_if! {
2035     if #[cfg(target_arch = "aarch64")] {
2036         mod aarch64;
2037         pub use self::aarch64::*;
2038     } else if #[cfg(target_arch = "arm")] {
2039         mod arm;
2040         pub use self::arm::*;
2041     } else if #[cfg(target_arch = "x86")] {
2042         mod x86;
2043         pub use self::x86::*;
2044     } else if #[cfg(target_arch = "x86_64")] {
2045         mod x86_64;
2046         pub use self::x86_64::*;
2047     } else if #[cfg(target_arch = "powerpc")] {
2048         mod powerpc;
2049         pub use self::powerpc::*;
2050     } else if #[cfg(target_arch = "powerpc64")] {
2051         mod powerpc64;
2052         pub use self::powerpc64::*;
2053     } else if #[cfg(target_arch = "riscv32")] {
2054         mod riscv32;
2055         pub use self::riscv32::*;
2056     } else if #[cfg(target_arch = "riscv64")] {
2057         mod riscv64;
2058         pub use self::riscv64::*;
2059     } else {
2060         // Unknown target_arch
2061     }
2062 }
2063