Debian Codegraph @

src/vxworks/mod.rs

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