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