Alex Crichton | 07d3a0d | 2015-10-30 10:21:32 -0700 | [diff] [blame] | 1 | use dox::mem; |
| 2 | |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 3 | pub type rlim_t = c_ulong; |
| 4 | pub type sa_family_t = u16; |
Alex Crichton | 239f9cd | 2015-09-18 16:31:34 -0700 | [diff] [blame] | 5 | pub type pthread_key_t = ::c_uint; |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 6 | pub type mqd_t = ::c_int; |
| 7 | pub type speed_t = ::c_uint; |
| 8 | pub type tcflag_t = ::c_uint; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 9 | |
| 10 | pub enum timezone {} |
| 11 | |
| 12 | s! { |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 13 | pub struct sockaddr { |
| 14 | pub sa_family: sa_family_t, |
Alex Crichton | f3b9748 | 2015-09-16 14:13:20 -0700 | [diff] [blame] | 15 | pub sa_data: [::c_char; 14], |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 16 | } |
| 17 | |
Alex Crichton | 50a42e2 | 2015-09-15 14:27:15 -0700 | [diff] [blame] | 18 | pub struct sockaddr_in { |
| 19 | pub sin_family: sa_family_t, |
| 20 | pub sin_port: ::in_port_t, |
| 21 | pub sin_addr: ::in_addr, |
| 22 | pub sin_zero: [u8; 8], |
| 23 | } |
| 24 | |
| 25 | pub struct sockaddr_in6 { |
| 26 | pub sin6_family: sa_family_t, |
| 27 | pub sin6_port: ::in_port_t, |
| 28 | pub sin6_flowinfo: u32, |
| 29 | pub sin6_addr: ::in6_addr, |
| 30 | pub sin6_scope_id: u32, |
| 31 | } |
| 32 | |
| 33 | pub struct sockaddr_un { |
| 34 | pub sun_family: sa_family_t, |
| 35 | pub sun_path: [::c_char; 108] |
| 36 | } |
| 37 | |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 38 | pub struct sockaddr_storage { |
| 39 | pub ss_family: sa_family_t, |
Alex Crichton | f3b9748 | 2015-09-16 14:13:20 -0700 | [diff] [blame] | 40 | __ss_align: ::size_t, |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 41 | #[cfg(target_pointer_width = "32")] |
| 42 | __ss_pad2: [u8; 128 - 2 * 4], |
| 43 | #[cfg(target_pointer_width = "64")] |
| 44 | __ss_pad2: [u8; 128 - 2 * 8], |
| 45 | } |
| 46 | |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 47 | pub struct addrinfo { |
Alex Crichton | 239f9cd | 2015-09-18 16:31:34 -0700 | [diff] [blame] | 48 | pub ai_flags: ::c_int, |
| 49 | pub ai_family: ::c_int, |
| 50 | pub ai_socktype: ::c_int, |
| 51 | pub ai_protocol: ::c_int, |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 52 | pub ai_addrlen: socklen_t, |
| 53 | |
| 54 | #[cfg(target_os = "linux")] |
Alex Crichton | 50a42e2 | 2015-09-15 14:27:15 -0700 | [diff] [blame] | 55 | pub ai_addr: *mut ::sockaddr, |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 56 | |
| 57 | pub ai_canonname: *mut c_char, |
| 58 | |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 59 | #[cfg(target_os = "android")] |
Alex Crichton | 50a42e2 | 2015-09-15 14:27:15 -0700 | [diff] [blame] | 60 | pub ai_addr: *mut ::sockaddr, |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 61 | |
| 62 | pub ai_next: *mut addrinfo, |
| 63 | } |
| 64 | |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 65 | pub struct sockaddr_ll { |
Alex Crichton | 239f9cd | 2015-09-18 16:31:34 -0700 | [diff] [blame] | 66 | pub sll_family: ::c_ushort, |
| 67 | pub sll_protocol: ::c_ushort, |
| 68 | pub sll_ifindex: ::c_int, |
| 69 | pub sll_hatype: ::c_ushort, |
| 70 | pub sll_pkttype: ::c_uchar, |
| 71 | pub sll_halen: ::c_uchar, |
| 72 | pub sll_addr: [::c_uchar; 8] |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 73 | } |
Alex Crichton | 07d3a0d | 2015-10-30 10:21:32 -0700 | [diff] [blame] | 74 | |
| 75 | pub struct fd_set { |
| 76 | fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], |
| 77 | } |
Alex Crichton | 568705e | 2015-11-03 14:18:52 -0800 | [diff] [blame] | 78 | |
| 79 | pub struct tm { |
| 80 | pub tm_sec: ::c_int, |
| 81 | pub tm_min: ::c_int, |
| 82 | pub tm_hour: ::c_int, |
| 83 | pub tm_mday: ::c_int, |
| 84 | pub tm_mon: ::c_int, |
| 85 | pub tm_year: ::c_int, |
| 86 | pub tm_wday: ::c_int, |
| 87 | pub tm_yday: ::c_int, |
| 88 | pub tm_isdst: ::c_int, |
| 89 | pub tm_gmtoff: ::c_long, |
| 90 | pub tm_zone: *const ::c_char, |
| 91 | } |
Alexander Polakov | e09951c | 2015-11-26 14:00:03 +0300 | [diff] [blame] | 92 | |
| 93 | pub struct sched_param { |
| 94 | pub sched_priority: ::c_int, |
| 95 | #[cfg(target_env = "musl")] |
| 96 | pub sched_ss_low_priority: ::c_int, |
| 97 | #[cfg(target_env = "musl")] |
| 98 | pub sched_ss_repl_period: ::timespec, |
| 99 | #[cfg(target_env = "musl")] |
| 100 | pub sched_ss_init_budget: ::timespec, |
| 101 | #[cfg(target_env = "musl")] |
| 102 | pub sched_ss_max_repl: ::c_int, |
| 103 | } |
Alex Crichton | 49d7bca | 2015-11-27 09:40:37 -0800 | [diff] [blame] | 104 | |
| 105 | pub struct Dl_info { |
| 106 | pub dli_fname: *const ::c_char, |
| 107 | pub dli_fbase: *mut ::c_void, |
| 108 | pub dli_sname: *const ::c_char, |
| 109 | pub dli_saddr: *mut ::c_void, |
| 110 | } |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 111 | |
| 112 | #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), |
| 113 | repr(packed))] |
| 114 | pub struct epoll_event { |
| 115 | pub events: ::uint32_t, |
| 116 | pub u64: ::uint64_t, |
| 117 | } |
| 118 | |
| 119 | pub struct utsname { |
| 120 | pub sysname: [::c_char; 65], |
| 121 | pub nodename: [::c_char; 65], |
| 122 | pub release: [::c_char; 65], |
| 123 | pub version: [::c_char; 65], |
| 124 | pub machine: [::c_char; 65], |
| 125 | pub domainname: [::c_char; 65] |
| 126 | } |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Alex Crichton | 07d3a0d | 2015-10-30 10:21:32 -0700 | [diff] [blame] | 129 | // intentionally not public, only used for fd_set |
| 130 | #[cfg(target_pointer_width = "32")] |
| 131 | const ULONG_SIZE: usize = 32; |
| 132 | #[cfg(target_pointer_width = "64")] |
| 133 | const ULONG_SIZE: usize = 64; |
| 134 | |
Alex Crichton | 239f9cd | 2015-09-18 16:31:34 -0700 | [diff] [blame] | 135 | pub const EXIT_FAILURE: ::c_int = 1; |
| 136 | pub const EXIT_SUCCESS: ::c_int = 0; |
| 137 | pub const RAND_MAX: ::c_int = 2147483647; |
| 138 | pub const EOF: ::c_int = -1; |
| 139 | pub const SEEK_SET: ::c_int = 0; |
| 140 | pub const SEEK_CUR: ::c_int = 1; |
| 141 | pub const SEEK_END: ::c_int = 2; |
| 142 | pub const _IOFBF: ::c_int = 0; |
| 143 | pub const _IONBF: ::c_int = 2; |
| 144 | pub const _IOLBF: ::c_int = 1; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 145 | |
Alex Crichton | 239f9cd | 2015-09-18 16:31:34 -0700 | [diff] [blame] | 146 | pub const F_DUPFD: ::c_int = 0; |
| 147 | pub const F_GETFD: ::c_int = 1; |
| 148 | pub const F_SETFD: ::c_int = 2; |
| 149 | pub const F_GETFL: ::c_int = 3; |
| 150 | pub const F_SETFL: ::c_int = 4; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 151 | |
Alex Crichton | 239f9cd | 2015-09-18 16:31:34 -0700 | [diff] [blame] | 152 | pub const SIGTRAP: ::c_int = 5; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 153 | |
Alex Crichton | 239f9cd | 2015-09-18 16:31:34 -0700 | [diff] [blame] | 154 | pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; |
| 155 | pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 156 | |
Alex Crichton | 239f9cd | 2015-09-18 16:31:34 -0700 | [diff] [blame] | 157 | pub const CLOCK_REALTIME: ::c_int = 0; |
| 158 | pub const CLOCK_MONOTONIC: ::c_int = 1; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 159 | |
Alex Crichton | 239f9cd | 2015-09-18 16:31:34 -0700 | [diff] [blame] | 160 | pub const RLIMIT_CPU: ::c_int = 0; |
| 161 | pub const RLIMIT_FSIZE: ::c_int = 1; |
| 162 | pub const RLIMIT_DATA: ::c_int = 2; |
| 163 | pub const RLIMIT_STACK: ::c_int = 3; |
| 164 | pub const RLIMIT_CORE: ::c_int = 4; |
| 165 | pub const RLIMIT_LOCKS: ::c_int = 10; |
| 166 | pub const RLIMIT_SIGPENDING: ::c_int = 11; |
| 167 | pub const RLIMIT_MSGQUEUE: ::c_int = 12; |
| 168 | pub const RLIMIT_NICE: ::c_int = 13; |
| 169 | pub const RLIMIT_RTPRIO: ::c_int = 14; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 170 | |
Alex Crichton | 239f9cd | 2015-09-18 16:31:34 -0700 | [diff] [blame] | 171 | pub const RUSAGE_SELF: ::c_int = 0; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 172 | |
| 173 | pub const O_RDONLY: ::c_int = 0; |
| 174 | pub const O_WRONLY: ::c_int = 1; |
| 175 | pub const O_RDWR: ::c_int = 2; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 176 | pub const O_TRUNC: ::c_int = 512; |
Alex Crichton | 14f7e02 | 2015-11-02 14:21:30 -0800 | [diff] [blame] | 177 | pub const O_CLOEXEC: ::c_int = 0x80000; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 178 | pub const S_IFIFO: ::mode_t = 4096; |
| 179 | pub const S_IFCHR: ::mode_t = 8192; |
| 180 | pub const S_IFBLK: ::mode_t = 24576; |
| 181 | pub const S_IFDIR: ::mode_t = 16384; |
| 182 | pub const S_IFREG: ::mode_t = 32768; |
| 183 | pub const S_IFLNK: ::mode_t = 40960; |
| 184 | pub const S_IFSOCK: ::mode_t = 49152; |
| 185 | pub const S_IFMT: ::mode_t = 61440; |
| 186 | pub const S_IRWXU: ::mode_t = 448; |
| 187 | pub const S_IXUSR: ::mode_t = 64; |
| 188 | pub const S_IWUSR: ::mode_t = 128; |
| 189 | pub const S_IRUSR: ::mode_t = 256; |
| 190 | pub const S_IRWXG: ::mode_t = 56; |
| 191 | pub const S_IXGRP: ::mode_t = 8; |
| 192 | pub const S_IWGRP: ::mode_t = 16; |
| 193 | pub const S_IRGRP: ::mode_t = 32; |
| 194 | pub const S_IRWXO: ::mode_t = 7; |
| 195 | pub const S_IXOTH: ::mode_t = 1; |
| 196 | pub const S_IWOTH: ::mode_t = 2; |
| 197 | pub const S_IROTH: ::mode_t = 4; |
| 198 | pub const F_OK: ::c_int = 0; |
| 199 | pub const R_OK: ::c_int = 4; |
| 200 | pub const W_OK: ::c_int = 2; |
| 201 | pub const X_OK: ::c_int = 1; |
| 202 | pub const STDIN_FILENO: ::c_int = 0; |
| 203 | pub const STDOUT_FILENO: ::c_int = 1; |
| 204 | pub const STDERR_FILENO: ::c_int = 2; |
| 205 | pub const SIGHUP: ::c_int = 1; |
| 206 | pub const SIGINT: ::c_int = 2; |
| 207 | pub const SIGQUIT: ::c_int = 3; |
| 208 | pub const SIGILL: ::c_int = 4; |
| 209 | pub const SIGABRT: ::c_int = 6; |
| 210 | pub const SIGFPE: ::c_int = 8; |
| 211 | pub const SIGKILL: ::c_int = 9; |
| 212 | pub const SIGSEGV: ::c_int = 11; |
| 213 | pub const SIGPIPE: ::c_int = 13; |
| 214 | pub const SIGALRM: ::c_int = 14; |
| 215 | pub const SIGTERM: ::c_int = 15; |
| 216 | |
| 217 | pub const PROT_NONE: ::c_int = 0; |
| 218 | pub const PROT_READ: ::c_int = 1; |
| 219 | pub const PROT_WRITE: ::c_int = 2; |
| 220 | pub const PROT_EXEC: ::c_int = 4; |
| 221 | |
| 222 | pub const MAP_FILE: ::c_int = 0x0000; |
| 223 | pub const MAP_SHARED: ::c_int = 0x0001; |
| 224 | pub const MAP_PRIVATE: ::c_int = 0x0002; |
| 225 | pub const MAP_FIXED: ::c_int = 0x0010; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 226 | |
| 227 | pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; |
| 228 | |
| 229 | pub const MCL_CURRENT: ::c_int = 0x0001; |
| 230 | pub const MCL_FUTURE: ::c_int = 0x0002; |
| 231 | |
| 232 | pub const MS_ASYNC: ::c_int = 0x0001; |
| 233 | pub const MS_INVALIDATE: ::c_int = 0x0002; |
| 234 | pub const MS_SYNC: ::c_int = 0x0004; |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 235 | pub const MS_RDONLY: ::c_ulong = 0x01; |
| 236 | pub const MS_NOSUID: ::c_ulong = 0x02; |
| 237 | pub const MS_NODEV: ::c_ulong = 0x04; |
| 238 | pub const MS_NOEXEC: ::c_ulong = 0x08; |
| 239 | pub const MS_SYNCHRONOUS: ::c_ulong = 0x10; |
| 240 | pub const MS_REMOUNT: ::c_ulong = 0x20; |
| 241 | pub const MS_MANDLOCK: ::c_ulong = 0x40; |
| 242 | pub const MS_DIRSYNC: ::c_ulong = 0x80; |
| 243 | pub const MS_NOATIME: ::c_ulong = 0x0400; |
| 244 | pub const MS_NODIRATIME: ::c_ulong = 0x0800; |
| 245 | pub const MS_BIND: ::c_ulong = 0x1000; |
| 246 | pub const MS_MOVE: ::c_ulong = 0x2000; |
| 247 | pub const MS_REC: ::c_ulong = 0x4000; |
| 248 | pub const MS_SILENT: ::c_ulong = 0x8000; |
| 249 | pub const MS_POSIXACL: ::c_ulong = 0x010000; |
| 250 | pub const MS_UNBINDABLE: ::c_ulong = 0x020000; |
| 251 | pub const MS_PRIVATE: ::c_ulong = 0x040000; |
| 252 | pub const MS_SLAVE: ::c_ulong = 0x080000; |
| 253 | pub const MS_SHARED: ::c_ulong = 0x100000; |
| 254 | pub const MS_ACTIVE: ::c_ulong = 0x40000000; |
| 255 | pub const MS_NOUSER: ::c_ulong = 0x80000000; |
| 256 | pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000; |
| 257 | pub const MS_MGC_MSK: ::c_ulong = 0xffff0000; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 258 | |
| 259 | pub const EPERM: ::c_int = 1; |
| 260 | pub const ENOENT: ::c_int = 2; |
| 261 | pub const ESRCH: ::c_int = 3; |
| 262 | pub const EINTR: ::c_int = 4; |
| 263 | pub const EIO: ::c_int = 5; |
| 264 | pub const ENXIO: ::c_int = 6; |
| 265 | pub const E2BIG: ::c_int = 7; |
| 266 | pub const ENOEXEC: ::c_int = 8; |
| 267 | pub const EBADF: ::c_int = 9; |
| 268 | pub const ECHILD: ::c_int = 10; |
| 269 | pub const EAGAIN: ::c_int = 11; |
| 270 | pub const ENOMEM: ::c_int = 12; |
| 271 | pub const EACCES: ::c_int = 13; |
| 272 | pub const EFAULT: ::c_int = 14; |
| 273 | pub const ENOTBLK: ::c_int = 15; |
| 274 | pub const EBUSY: ::c_int = 16; |
| 275 | pub const EEXIST: ::c_int = 17; |
| 276 | pub const EXDEV: ::c_int = 18; |
| 277 | pub const ENODEV: ::c_int = 19; |
| 278 | pub const ENOTDIR: ::c_int = 20; |
| 279 | pub const EISDIR: ::c_int = 21; |
| 280 | pub const EINVAL: ::c_int = 22; |
| 281 | pub const ENFILE: ::c_int = 23; |
| 282 | pub const EMFILE: ::c_int = 24; |
| 283 | pub const ENOTTY: ::c_int = 25; |
| 284 | pub const ETXTBSY: ::c_int = 26; |
| 285 | pub const EFBIG: ::c_int = 27; |
| 286 | pub const ENOSPC: ::c_int = 28; |
| 287 | pub const ESPIPE: ::c_int = 29; |
| 288 | pub const EROFS: ::c_int = 30; |
| 289 | pub const EMLINK: ::c_int = 31; |
| 290 | pub const EPIPE: ::c_int = 32; |
| 291 | pub const EDOM: ::c_int = 33; |
| 292 | pub const ERANGE: ::c_int = 34; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 293 | pub const EWOULDBLOCK: ::c_int = EAGAIN; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 294 | |
| 295 | pub const EBFONT: ::c_int = 59; |
| 296 | pub const ENOSTR: ::c_int = 60; |
| 297 | pub const ENODATA: ::c_int = 61; |
| 298 | pub const ETIME: ::c_int = 62; |
| 299 | pub const ENOSR: ::c_int = 63; |
| 300 | pub const ENONET: ::c_int = 64; |
| 301 | pub const ENOPKG: ::c_int = 65; |
| 302 | pub const EREMOTE: ::c_int = 66; |
| 303 | pub const ENOLINK: ::c_int = 67; |
| 304 | pub const EADV: ::c_int = 68; |
| 305 | pub const ESRMNT: ::c_int = 69; |
| 306 | pub const ECOMM: ::c_int = 70; |
| 307 | pub const EPROTO: ::c_int = 71; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 308 | pub const EDOTDOT: ::c_int = 73; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 309 | |
| 310 | pub const AF_PACKET: ::c_int = 17; |
| 311 | pub const IPPROTO_RAW: ::c_int = 255; |
| 312 | |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 313 | pub const PROT_GROWSDOWN: ::c_int = 0x1000000; |
| 314 | pub const PROT_GROWSUP: ::c_int = 0x2000000; |
| 315 | |
| 316 | pub const MAP_TYPE: ::c_int = 0x000f; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 317 | |
| 318 | pub const MADV_NORMAL: ::c_int = 0; |
| 319 | pub const MADV_RANDOM: ::c_int = 1; |
| 320 | pub const MADV_SEQUENTIAL: ::c_int = 2; |
| 321 | pub const MADV_WILLNEED: ::c_int = 3; |
| 322 | pub const MADV_DONTNEED: ::c_int = 4; |
| 323 | pub const MADV_REMOVE: ::c_int = 9; |
| 324 | pub const MADV_DONTFORK: ::c_int = 10; |
| 325 | pub const MADV_DOFORK: ::c_int = 11; |
| 326 | pub const MADV_MERGEABLE: ::c_int = 12; |
| 327 | pub const MADV_UNMERGEABLE: ::c_int = 13; |
| 328 | pub const MADV_HWPOISON: ::c_int = 100; |
| 329 | |
| 330 | pub const IFF_LOOPBACK: ::c_int = 0x8; |
| 331 | |
| 332 | pub const AF_UNIX: ::c_int = 1; |
| 333 | pub const AF_INET: ::c_int = 2; |
| 334 | pub const AF_INET6: ::c_int = 10; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 335 | pub const SOCK_RAW: ::c_int = 3; |
| 336 | pub const IPPROTO_TCP: ::c_int = 6; |
| 337 | pub const IPPROTO_IP: ::c_int = 0; |
| 338 | pub const IPPROTO_IPV6: ::c_int = 41; |
| 339 | pub const IP_MULTICAST_TTL: ::c_int = 33; |
| 340 | pub const IP_MULTICAST_LOOP: ::c_int = 34; |
| 341 | pub const IP_TTL: ::c_int = 2; |
| 342 | pub const IP_HDRINCL: ::c_int = 3; |
| 343 | pub const IP_ADD_MEMBERSHIP: ::c_int = 35; |
| 344 | pub const IP_DROP_MEMBERSHIP: ::c_int = 36; |
| 345 | pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; |
| 346 | pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; |
| 347 | |
| 348 | pub const TCP_NODELAY: ::c_int = 1; |
| 349 | pub const TCP_MAXSEG: ::c_int = 2; |
| 350 | pub const TCP_CORK: ::c_int = 3; |
| 351 | pub const TCP_KEEPIDLE: ::c_int = 4; |
| 352 | pub const TCP_KEEPINTVL: ::c_int = 5; |
| 353 | pub const TCP_KEEPCNT: ::c_int = 6; |
| 354 | pub const TCP_SYNCNT: ::c_int = 7; |
| 355 | pub const TCP_LINGER2: ::c_int = 8; |
| 356 | pub const TCP_DEFER_ACCEPT: ::c_int = 9; |
| 357 | pub const TCP_WINDOW_CLAMP: ::c_int = 10; |
| 358 | pub const TCP_INFO: ::c_int = 11; |
| 359 | pub const TCP_QUICKACK: ::c_int = 12; |
| 360 | pub const TCP_CONGESTION: ::c_int = 13; |
| 361 | |
Alex Crichton | babf390 | 2015-09-18 17:16:51 -0700 | [diff] [blame] | 362 | pub const IPV6_MULTICAST_LOOP: ::c_int = 19; |
| 363 | pub const IPV6_V6ONLY: ::c_int = 26; |
| 364 | |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 365 | pub const SO_DEBUG: ::c_int = 1; |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 366 | |
| 367 | pub const SHUT_RD: ::c_int = 0; |
| 368 | pub const SHUT_WR: ::c_int = 1; |
| 369 | pub const SHUT_RDWR: ::c_int = 2; |
| 370 | |
| 371 | pub const LOCK_SH: ::c_int = 1; |
| 372 | pub const LOCK_EX: ::c_int = 2; |
| 373 | pub const LOCK_NB: ::c_int = 4; |
| 374 | pub const LOCK_UN: ::c_int = 8; |
| 375 | |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 376 | pub const SIGSTKSZ: ::size_t = 8192; |
| 377 | |
Alex Crichton | 07d3a0d | 2015-10-30 10:21:32 -0700 | [diff] [blame] | 378 | pub const SA_NODEFER: ::c_int = 0x40000000; |
| 379 | pub const SA_RESETHAND: ::c_int = 0x80000000; |
| 380 | pub const SA_RESTART: ::c_int = 0x10000000; |
| 381 | pub const SA_NOCLDSTOP: ::c_int = 0x00000001; |
| 382 | |
David Hotham | 8b296bd | 2015-12-12 11:52:54 +0000 | [diff] [blame] | 383 | pub const PATH_MAX: ::c_int = 4096; |
| 384 | |
Alex Crichton | 07d3a0d | 2015-10-30 10:21:32 -0700 | [diff] [blame] | 385 | pub const FD_SETSIZE: usize = 1024; |
| 386 | |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 387 | pub const EPOLLIN: ::c_int = 0x1; |
| 388 | pub const EPOLLPRI: ::c_int = 0x2; |
| 389 | pub const EPOLLOUT: ::c_int = 0x4; |
| 390 | pub const EPOLLRDNORM: ::c_int = 0x40; |
| 391 | pub const EPOLLRDBAND: ::c_int = 0x80; |
| 392 | pub const EPOLLWRNORM: ::c_int = 0x100; |
| 393 | pub const EPOLLWRBAND: ::c_int = 0x200; |
| 394 | pub const EPOLLMSG: ::c_int = 0x400; |
| 395 | pub const EPOLLERR: ::c_int = 0x8; |
| 396 | pub const EPOLLHUP: ::c_int = 0x10; |
| 397 | pub const EPOLLET: ::c_int = 0x80000000; |
| 398 | |
| 399 | pub const EPOLL_CTL_ADD: ::c_int = 1; |
| 400 | pub const EPOLL_CTL_MOD: ::c_int = 3; |
| 401 | pub const EPOLL_CTL_DEL: ::c_int = 2; |
| 402 | |
| 403 | pub const MNT_DETACH: ::c_int = 0x2; |
| 404 | pub const MNT_EXPIRE: ::c_int = 0x4; |
| 405 | |
| 406 | pub const Q_GETFMT: ::c_int = 0x800004; |
| 407 | pub const Q_GETINFO: ::c_int = 0x800005; |
| 408 | pub const Q_SETINFO: ::c_int = 0x800006; |
| 409 | pub const QIF_BLIMITS: ::uint32_t = 1; |
| 410 | pub const QIF_SPACE: ::uint32_t = 2; |
| 411 | pub const QIF_ILIMITS: ::uint32_t = 4; |
| 412 | pub const QIF_INODES: ::uint32_t = 8; |
| 413 | pub const QIF_BTIME: ::uint32_t = 16; |
| 414 | pub const QIF_ITIME: ::uint32_t = 32; |
| 415 | pub const QIF_LIMITS: ::uint32_t = 5; |
| 416 | pub const QIF_USAGE: ::uint32_t = 10; |
| 417 | pub const QIF_TIMES: ::uint32_t = 48; |
| 418 | pub const QIF_ALL: ::uint32_t = 63; |
| 419 | |
| 420 | pub const CBAUD: ::tcflag_t = 0o0010017; |
| 421 | |
| 422 | pub const EFD_CLOEXEC: ::c_int = 0x80000; |
| 423 | |
| 424 | pub const F_SETLK: ::c_int = 6; |
| 425 | pub const F_SETLKW: ::c_int = 7; |
| 426 | |
| 427 | pub const MNT_FORCE: ::c_int = 0x1; |
| 428 | |
| 429 | pub const Q_SYNC: ::c_int = 0x800001; |
| 430 | pub const Q_QUOTAON: ::c_int = 0x800002; |
| 431 | pub const Q_QUOTAOFF: ::c_int = 0x800003; |
| 432 | pub const Q_GETQUOTA: ::c_int = 0x800007; |
| 433 | pub const Q_SETQUOTA: ::c_int = 0x800008; |
| 434 | |
| 435 | pub const TCIOFF: ::c_int = 2; |
| 436 | pub const TCION: ::c_int = 3; |
| 437 | pub const TCOOFF: ::c_int = 0; |
| 438 | pub const TCOON: ::c_int = 1; |
| 439 | pub const TCIFLUSH: ::c_int = 0; |
| 440 | pub const TCOFLUSH: ::c_int = 1; |
| 441 | pub const TCIOFLUSH: ::c_int = 2; |
| 442 | pub const NL0: ::c_int = 0x00000000; |
| 443 | pub const NL1: ::c_int = 0x00000100; |
| 444 | pub const TAB0: ::c_int = 0x00000000; |
| 445 | pub const TAB1: ::c_int = 0x00000800; |
| 446 | pub const TAB2: ::c_int = 0x00001000; |
| 447 | pub const TAB3: ::c_int = 0x00001800; |
| 448 | pub const CR0: ::c_int = 0x00000000; |
| 449 | pub const CR1: ::c_int = 0x00000200; |
| 450 | pub const CR2: ::c_int = 0x00000400; |
| 451 | pub const CR3: ::c_int = 0x00000600; |
| 452 | pub const FF0: ::c_int = 0x00000000; |
| 453 | pub const FF1: ::c_int = 0x00008000; |
| 454 | pub const BS0: ::c_int = 0x00000000; |
| 455 | pub const BS1: ::c_int = 0x00002000; |
| 456 | pub const VT0: ::c_int = 0x00000000; |
| 457 | pub const VT1: ::c_int = 0x00004000; |
| 458 | pub const VERASE: usize = 2; |
| 459 | pub const VWERASE: usize = 14; |
| 460 | pub const VKILL: usize = 3; |
| 461 | pub const VREPRINT: usize = 12; |
| 462 | pub const VINTR: usize = 0; |
| 463 | pub const VQUIT: usize = 1; |
| 464 | pub const VSUSP: usize = 10; |
| 465 | pub const VSTART: usize = 8; |
| 466 | pub const VSTOP: usize = 9; |
| 467 | pub const VLNEXT: usize = 15; |
| 468 | pub const VDISCARD: usize = 13; |
| 469 | pub const VTIME: usize = 5; |
| 470 | pub const IGNBRK: ::tcflag_t = 0x00000001; |
| 471 | pub const BRKINT: ::tcflag_t = 0x00000002; |
| 472 | pub const IGNPAR: ::tcflag_t = 0x00000004; |
| 473 | pub const PARMRK: ::tcflag_t = 0x00000008; |
| 474 | pub const INPCK: ::tcflag_t = 0x00000010; |
| 475 | pub const ISTRIP: ::tcflag_t = 0x00000020; |
| 476 | pub const INLCR: ::tcflag_t = 0x00000040; |
| 477 | pub const IGNCR: ::tcflag_t = 0x00000080; |
| 478 | pub const ICRNL: ::tcflag_t = 0x00000100; |
| 479 | pub const IXON: ::tcflag_t = 0x00000400; |
| 480 | pub const IXOFF: ::tcflag_t = 0x00001000; |
| 481 | pub const IXANY: ::tcflag_t = 0x00000800; |
| 482 | pub const IMAXBEL: ::tcflag_t = 0x00002000; |
| 483 | pub const OPOST: ::tcflag_t = 0x1; |
| 484 | pub const ONLCR: ::tcflag_t = 0x4; |
| 485 | pub const CSIZE: ::tcflag_t = 0x00000030; |
| 486 | pub const CS5: ::tcflag_t = 0x00000000; |
| 487 | pub const CS6: ::tcflag_t = 0x00000010; |
| 488 | pub const CS7: ::tcflag_t = 0x00000020; |
| 489 | pub const CS8: ::tcflag_t = 0x00000030; |
| 490 | pub const CSTOPB: ::tcflag_t = 0x00000040; |
| 491 | pub const CREAD: ::tcflag_t = 0x00000080; |
| 492 | pub const PARENB: ::tcflag_t = 0x00000100; |
| 493 | pub const PARODD: ::tcflag_t = 0x00000200; |
| 494 | pub const HUPCL: ::tcflag_t = 0x00000400; |
| 495 | pub const CLOCAL: ::tcflag_t = 0x00000800; |
| 496 | pub const CRTSCTS: ::tcflag_t = 0x80000000; |
| 497 | pub const ECHOKE: ::tcflag_t = 0x00000800; |
| 498 | pub const ECHOE: ::tcflag_t = 0x00000010; |
| 499 | pub const ECHOK: ::tcflag_t = 0x00000020; |
| 500 | pub const ECHO: ::tcflag_t = 0x00000008; |
| 501 | pub const ECHONL: ::tcflag_t = 0x00000040; |
| 502 | pub const ECHOPRT: ::tcflag_t = 0x00000400; |
| 503 | pub const ECHOCTL: ::tcflag_t = 0x00000200; |
| 504 | pub const ISIG: ::tcflag_t = 0x00000001; |
| 505 | pub const ICANON: ::tcflag_t = 0x00000002; |
| 506 | pub const PENDIN: ::tcflag_t = 0x00004000; |
| 507 | pub const NOFLSH: ::tcflag_t = 0x00000080; |
| 508 | |
| 509 | pub const CLONE_VM: ::c_int = 0x100; |
| 510 | pub const CLONE_FS: ::c_int = 0x200; |
| 511 | pub const CLONE_FILES: ::c_int = 0x400; |
| 512 | pub const CLONE_SIGHAND: ::c_int = 0x800; |
| 513 | pub const CLONE_PTRACE: ::c_int = 0x2000; |
| 514 | pub const CLONE_VFORK: ::c_int = 0x4000; |
| 515 | pub const CLONE_PARENT: ::c_int = 0x8000; |
| 516 | pub const CLONE_THREAD: ::c_int = 0x10000; |
| 517 | pub const CLONE_NEWNS: ::c_int = 0x20000; |
| 518 | pub const CLONE_SYSVSEM: ::c_int = 0x40000; |
| 519 | pub const CLONE_SETTLS: ::c_int = 0x80000; |
| 520 | pub const CLONE_PARENT_SETTID: ::c_int = 0x100000; |
| 521 | pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000; |
| 522 | pub const CLONE_DETACHED: ::c_int = 0x400000; |
| 523 | pub const CLONE_UNTRACED: ::c_int = 0x800000; |
| 524 | pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000; |
| 525 | |
Alex Crichton | 07d3a0d | 2015-10-30 10:21:32 -0700 | [diff] [blame] | 526 | f! { |
| 527 | pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { |
| 528 | let fd = fd as usize; |
Alex Crichton | ef66d12 | 2015-11-09 23:53:57 -0800 | [diff] [blame] | 529 | let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; |
Alex Crichton | 07d3a0d | 2015-10-30 10:21:32 -0700 | [diff] [blame] | 530 | (*set).fds_bits[fd / size] &= !(1 << (fd % size)); |
| 531 | return |
| 532 | } |
| 533 | |
| 534 | pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { |
| 535 | let fd = fd as usize; |
Alex Crichton | ef66d12 | 2015-11-09 23:53:57 -0800 | [diff] [blame] | 536 | let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; |
Alex Crichton | 07d3a0d | 2015-10-30 10:21:32 -0700 | [diff] [blame] | 537 | return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 |
| 538 | } |
| 539 | |
| 540 | pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { |
| 541 | let fd = fd as usize; |
Alex Crichton | ef66d12 | 2015-11-09 23:53:57 -0800 | [diff] [blame] | 542 | let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; |
Alex Crichton | 07d3a0d | 2015-10-30 10:21:32 -0700 | [diff] [blame] | 543 | (*set).fds_bits[fd / size] |= 1 << (fd % size); |
| 544 | return |
| 545 | } |
| 546 | |
| 547 | pub fn FD_ZERO(set: *mut fd_set) -> () { |
| 548 | for slot in (*set).fds_bits.iter_mut() { |
| 549 | *slot = 0; |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | pub fn WIFEXITED(status: ::c_int) -> bool { |
| 554 | (status & 0xff) == 0 |
| 555 | } |
| 556 | |
| 557 | pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { |
| 558 | (status >> 8) & 0xff |
| 559 | } |
| 560 | |
| 561 | pub fn WTERMSIG(status: ::c_int) -> ::c_int { |
| 562 | status & 0x7f |
| 563 | } |
| 564 | } |
| 565 | |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 566 | extern { |
| 567 | pub fn fdatasync(fd: ::c_int) -> ::c_int; |
Alex Crichton | 8293ced | 2015-09-15 17:05:19 -0700 | [diff] [blame] | 568 | pub fn mincore(addr: *mut ::c_void, len: ::size_t, |
| 569 | vec: *mut ::c_uchar) -> ::c_int; |
Alex Crichton | cd9b33e | 2015-09-17 14:47:40 -0700 | [diff] [blame] | 570 | pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; |
| 571 | pub fn prctl(option: ::c_int, ...) -> ::c_int; |
| 572 | pub fn pthread_getattr_np(native: ::pthread_t, |
| 573 | attr: *mut ::pthread_attr_t) -> ::c_int; |
| 574 | pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, |
| 575 | guardsize: *mut ::size_t) -> ::c_int; |
| 576 | pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, |
| 577 | stackaddr: *mut *mut ::c_void, |
| 578 | stacksize: *mut ::size_t) -> ::c_int; |
Alex Crichton | de9736d | 2015-09-17 15:47:44 -0700 | [diff] [blame] | 579 | pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; |
| 580 | pub fn setgroups(ngroups: ::size_t, |
| 581 | ptr: *const ::gid_t) -> ::c_int; |
Alexander Polakov | e09951c | 2015-11-26 14:00:03 +0300 | [diff] [blame] | 582 | pub fn sched_setscheduler(pid: ::pid_t, policy: ::c_int, param: *const sched_param) -> ::c_int; |
| 583 | pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; |
Alexander Polakov | 557c670 | 2015-11-30 16:55:51 +0300 | [diff] [blame] | 584 | pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; |
| 585 | pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; |
Alex Crichton | 8dce9ad | 2015-12-03 11:44:14 -0800 | [diff] [blame] | 586 | pub fn epoll_create(size: ::c_int) -> ::c_int; |
| 587 | pub fn epoll_ctl(epfd: ::c_int, |
| 588 | op: ::c_int, |
| 589 | fd: ::c_int, |
| 590 | event: *mut epoll_event) -> ::c_int; |
| 591 | pub fn epoll_wait(epfd: ::c_int, |
| 592 | events: *mut epoll_event, |
| 593 | maxevents: ::c_int, |
| 594 | timeout: ::c_int) -> ::c_int; |
| 595 | pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; |
| 596 | pub fn mount(src: *const ::c_char, |
| 597 | target: *const ::c_char, |
| 598 | fstype: *const ::c_char, |
| 599 | flags: ::c_ulong, |
| 600 | data: *const ::c_void) -> ::c_int; |
| 601 | pub fn umount(target: *const ::c_char) -> ::c_int; |
| 602 | pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; |
| 603 | pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int, |
| 604 | child_stack: *mut ::c_void, |
| 605 | flags: ::c_int, |
| 606 | arg: *mut ::c_void, ...) -> ::c_int; |
| 607 | pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; |
| 608 | pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; |
Florian Hahn | 6bb23a1 | 2015-12-16 12:28:51 +0100 | [diff] [blame^] | 609 | pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | cfg_if! { |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 613 | if #[cfg(target_os = "linux")] { |
| 614 | mod linux; |
| 615 | pub use self::linux::*; |
| 616 | } else if #[cfg(target_os = "android")] { |
| 617 | mod android; |
| 618 | pub use self::android::*; |
| 619 | } else { |
| 620 | // ... |
| 621 | } |
| 622 | } |