1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! C definitions used by libnative that don't belong in liblibc
13 pub use self::select::fd_set;
17 #[cfg(target_os = "macos")]
18 #[cfg(target_os = "freebsd")]
19 pub static FIONBIO: libc::c_ulong = 0x8004667e;
20 #[cfg(target_os = "linux")]
21 #[cfg(target_os = "android")]
22 pub static FIONBIO: libc::c_ulong = 0x5421;
23 #[cfg(target_os = "macos")]
24 #[cfg(target_os = "freebsd")]
25 pub static FIOCLEX: libc::c_ulong = 0x20006601;
26 #[cfg(target_os = "linux")]
27 #[cfg(target_os = "android")]
28 pub static FIOCLEX: libc::c_ulong = 0x5451;
30 #[cfg(target_os = "macos")]
31 #[cfg(target_os = "freebsd")]
32 pub static MSG_DONTWAIT: libc::c_int = 0x80;
33 #[cfg(target_os = "linux")]
34 #[cfg(target_os = "android")]
35 pub static MSG_DONTWAIT: libc::c_int = 0x40;
38 pub fn gettimeofday(timeval: *mut libc::timeval,
39 tzp: *libc::c_void) -> libc::c_int;
40 pub fn select(nfds: libc::c_int,
44 timeout: *libc::timeval) -> libc::c_int;
45 pub fn getsockopt(sockfd: libc::c_int,
48 optval: *mut libc::c_void,
49 optlen: *mut libc::socklen_t) -> libc::c_int;
50 pub fn ioctl(fd: libc::c_int, req: libc::c_ulong, ...) -> libc::c_int;
54 #[cfg(target_os = "macos")]
56 pub static FD_SETSIZE: uint = 1024;
59 fds_bits: [i32, ..(FD_SETSIZE / 32)]
62 pub fn fd_set(set: &mut fd_set, fd: i32) {
63 set.fds_bits[(fd / 32) as uint] |= 1 << (fd % 32);
67 #[cfg(target_os = "android")]
68 #[cfg(target_os = "freebsd")]
69 #[cfg(target_os = "linux")]
73 pub static FD_SETSIZE: uint = 1024;
76 fds_bits: [uint, ..(FD_SETSIZE / uint::BITS)]
79 pub fn fd_set(set: &mut fd_set, fd: i32) {
81 set.fds_bits[fd / uint::BITS] |= 1 << (fd % uint::BITS);