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