Debian Codegraph @

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