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