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;
31 pub fn gettimeofday(timeval: *mut libc::timeval,
32 tzp: *libc::c_void) -> libc::c_int;
33 pub fn select(nfds: libc::c_int,
37 timeout: *libc::timeval) -> libc::c_int;
38 pub fn getsockopt(sockfd: libc::c_int,
41 optval: *mut libc::c_void,
42 optlen: *mut libc::socklen_t) -> libc::c_int;
43 pub fn ioctl(fd: libc::c_int, req: libc::c_ulong, ...) -> libc::c_int;
47 #[cfg(target_os = "macos")]
49 pub static FD_SETSIZE: uint = 1024;
52 fds_bits: [i32, ..(FD_SETSIZE / 32)]
55 pub fn fd_set(set: &mut fd_set, fd: i32) {
56 set.fds_bits[(fd / 32) as uint] |= 1 << (fd % 32);
60 #[cfg(target_os = "android")]
61 #[cfg(target_os = "freebsd")]
62 #[cfg(target_os = "linux")]
66 pub static FD_SETSIZE: uint = 1024;
69 fds_bits: [uint, ..(FD_SETSIZE / uint::BITS)]
72 pub fn fd_set(set: &mut fd_set, fd: i32) {
74 set.fds_bits[fd / uint::BITS] |= 1 << (fd % uint::BITS);