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