1 pub type pthread_t = *mut ::c_void; 2 pub type clock_t = c_long; 3 pub type time_t = c_long; 4 pub type suseconds_t = c_long; 5 pub type ino_t = u64; 6 pub type off_t = i64; 7 pub type blkcnt_t = i64; 8 9 pub type shmatt_t = ::c_ulong; 10 pub type msgqnum_t = ::c_ulong; 11 pub type msglen_t = ::c_ulong; 12 pub type fsblkcnt_t = ::c_ulonglong; 13 pub type fsfilcnt_t = ::c_ulonglong; 14 pub type rlim_t = ::c_ulonglong; 15 16 pub type flock64 = flock; 17 18 impl siginfo_t { si_addr(&self) -> *mut ::c_void19 pub unsafe fn si_addr(&self) -> *mut ::c_void { 20 #[repr(C)] 21 struct siginfo_sigfault { 22 _si_signo: ::c_int, 23 _si_errno: ::c_int, 24 _si_code: ::c_int, 25 si_addr: *mut ::c_void, 26 } 27 28 (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr 29 } 30 si_value(&self) -> ::sigval31 pub unsafe fn si_value(&self) -> ::sigval { 32 #[repr(C)] 33 struct siginfo_si_value { 34 _si_signo: ::c_int, 35 _si_errno: ::c_int, 36 _si_code: ::c_int, 37 _si_timerid: ::c_int, 38 _si_overrun: ::c_int, 39 si_value: ::sigval, 40 } 41 42 (*(self as *const siginfo_t as *const siginfo_si_value)).si_value 43 } 44 } 45 46 s! { 47 pub struct aiocb { 48 pub aio_fildes: ::c_int, 49 pub aio_lio_opcode: ::c_int, 50 pub aio_reqprio: ::c_int, 51 pub aio_buf: *mut ::c_void, 52 pub aio_nbytes: ::size_t, 53 pub aio_sigevent: ::sigevent, 54 __td: *mut ::c_void, 55 __lock: [::c_int; 2], 56 __err: ::c_int, 57 __ret: ::ssize_t, 58 pub aio_offset: off_t, 59 __next: *mut ::c_void, 60 __prev: *mut ::c_void, 61 #[cfg(target_pointer_width = "32")] 62 __dummy4: [::c_char; 24], 63 #[cfg(target_pointer_width = "64")] 64 __dummy4: [::c_char; 16], 65 } 66 67 pub struct sigaction { 68 pub sa_sigaction: ::sighandler_t, 69 pub sa_mask: ::sigset_t, 70 pub sa_flags: ::c_int, 71 pub sa_restorer: ::Option<extern fn()>, 72 } 73 74 pub struct statvfs { 75 pub f_bsize: ::c_ulong, 76 pub f_frsize: ::c_ulong, 77 pub f_blocks: ::fsblkcnt_t, 78 pub f_bfree: ::fsblkcnt_t, 79 pub f_bavail: ::fsblkcnt_t, 80 pub f_files: ::fsfilcnt_t, 81 pub f_ffree: ::fsfilcnt_t, 82 pub f_favail: ::fsfilcnt_t, 83 #[cfg(target_endian = "little")] 84 pub f_fsid: ::c_ulong, 85 #[cfg(target_pointer_width = "32")] 86 __f_unused: ::c_int, 87 #[cfg(target_endian = "big")] 88 pub f_fsid: ::c_ulong, 89 pub f_flag: ::c_ulong, 90 pub f_namemax: ::c_ulong, 91 __f_spare: [::c_int; 6], 92 } 93 94 pub struct termios { 95 pub c_iflag: ::tcflag_t, 96 pub c_oflag: ::tcflag_t, 97 pub c_cflag: ::tcflag_t, 98 pub c_lflag: ::tcflag_t, 99 pub c_line: ::cc_t, 100 pub c_cc: [::cc_t; ::NCCS], 101 pub __c_ispeed: ::speed_t, 102 pub __c_ospeed: ::speed_t, 103 } 104 105 pub struct flock { 106 pub l_type: ::c_short, 107 pub l_whence: ::c_short, 108 pub l_start: ::off_t, 109 pub l_len: ::off_t, 110 pub l_pid: ::pid_t, 111 } 112 } 113 114 s_no_extra_traits! { 115 pub struct sysinfo { 116 pub uptime: ::c_ulong, 117 pub loads: [::c_ulong; 3], 118 pub totalram: ::c_ulong, 119 pub freeram: ::c_ulong, 120 pub sharedram: ::c_ulong, 121 pub bufferram: ::c_ulong, 122 pub totalswap: ::c_ulong, 123 pub freeswap: ::c_ulong, 124 pub procs: ::c_ushort, 125 pub pad: ::c_ushort, 126 pub totalhigh: ::c_ulong, 127 pub freehigh: ::c_ulong, 128 pub mem_unit: ::c_uint, 129 pub __reserved: [::c_char; 256], 130 } 131 } 132 133 cfg_if! { 134 if #[cfg(feature = "extra_traits")] { 135 impl PartialEq for sysinfo { 136 fn eq(&self, other: &sysinfo) -> bool { 137 self.uptime == other.uptime 138 && self.loads == other.loads 139 && self.totalram == other.totalram 140 && self.freeram == other.freeram 141 && self.sharedram == other.sharedram 142 && self.bufferram == other.bufferram 143 && self.totalswap == other.totalswap 144 && self.freeswap == other.freeswap 145 && self.procs == other.procs 146 && self.pad == other.pad 147 && self.totalhigh == other.totalhigh 148 && self.freehigh == other.freehigh 149 && self.mem_unit == other.mem_unit 150 && self 151 .__reserved 152 .iter() 153 .zip(other.__reserved.iter()) 154 .all(|(a,b)| a == b) 155 } 156 } 157 158 impl Eq for sysinfo {} 159 160 impl ::fmt::Debug for sysinfo { 161 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 162 f.debug_struct("sysinfo") 163 .field("uptime", &self.uptime) 164 .field("loads", &self.loads) 165 .field("totalram", &self.totalram) 166 .field("freeram", &self.freeram) 167 .field("sharedram", &self.sharedram) 168 .field("bufferram", &self.bufferram) 169 .field("totalswap", &self.totalswap) 170 .field("freeswap", &self.freeswap) 171 .field("procs", &self.procs) 172 .field("pad", &self.pad) 173 .field("totalhigh", &self.totalhigh) 174 .field("freehigh", &self.freehigh) 175 .field("mem_unit", &self.mem_unit) 176 // FIXME: .field("__reserved", &self.__reserved) 177 .finish() 178 } 179 } 180 181 impl ::hash::Hash for sysinfo { 182 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 183 self.uptime.hash(state); 184 self.loads.hash(state); 185 self.totalram.hash(state); 186 self.freeram.hash(state); 187 self.sharedram.hash(state); 188 self.bufferram.hash(state); 189 self.totalswap.hash(state); 190 self.freeswap.hash(state); 191 self.procs.hash(state); 192 self.pad.hash(state); 193 self.totalhigh.hash(state); 194 self.freehigh.hash(state); 195 self.mem_unit.hash(state); 196 self.__reserved.hash(state); 197 } 198 } 199 } 200 } 201 202 pub const MS_RMT_MASK: ::c_ulong = 0x02800051; 203 204 pub const SFD_CLOEXEC: ::c_int = 0x080000; 205 206 pub const NCCS: usize = 32; 207 208 pub const O_TRUNC: ::c_int = 512; 209 pub const O_NOATIME: ::c_int = 0o1000000; 210 pub const O_CLOEXEC: ::c_int = 0x80000; 211 pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; 212 213 pub const EBFONT: ::c_int = 59; 214 pub const ENOSTR: ::c_int = 60; 215 pub const ENODATA: ::c_int = 61; 216 pub const ETIME: ::c_int = 62; 217 pub const ENOSR: ::c_int = 63; 218 pub const ENONET: ::c_int = 64; 219 pub const ENOPKG: ::c_int = 65; 220 pub const EREMOTE: ::c_int = 66; 221 pub const ENOLINK: ::c_int = 67; 222 pub const EADV: ::c_int = 68; 223 pub const ESRMNT: ::c_int = 69; 224 pub const ECOMM: ::c_int = 70; 225 pub const EPROTO: ::c_int = 71; 226 pub const EDOTDOT: ::c_int = 73; 227 228 pub const F_RDLCK: ::c_int = 0; 229 pub const F_WRLCK: ::c_int = 1; 230 pub const F_UNLCK: ::c_int = 2; 231 232 pub const SA_NODEFER: ::c_int = 0x40000000; 233 pub const SA_RESETHAND: ::c_int = 0x80000000; 234 pub const SA_RESTART: ::c_int = 0x10000000; 235 pub const SA_NOCLDSTOP: ::c_int = 0x00000001; 236 237 pub const EPOLL_CLOEXEC: ::c_int = 0x80000; 238 239 pub const EFD_CLOEXEC: ::c_int = 0x80000; 240 241 pub const BUFSIZ: ::c_uint = 1024; 242 pub const TMP_MAX: ::c_uint = 10000; 243 pub const FOPEN_MAX: ::c_uint = 1000; 244 pub const O_PATH: ::c_int = 0o10000000; 245 pub const O_EXEC: ::c_int = 0o10000000; 246 pub const O_SEARCH: ::c_int = 0o10000000; 247 pub const O_ACCMODE: ::c_int = 0o10000003; 248 pub const O_NDELAY: ::c_int = O_NONBLOCK; 249 pub const NI_MAXHOST: ::socklen_t = 255; 250 pub const PTHREAD_STACK_MIN: ::size_t = 2048; 251 pub const POSIX_FADV_DONTNEED: ::c_int = 4; 252 pub const POSIX_FADV_NOREUSE: ::c_int = 5; 253 254 pub const POSIX_MADV_DONTNEED: ::c_int = 4; 255 256 pub const RLIM_INFINITY: ::rlim_t = !0; 257 pub const RLIMIT_RTTIME: ::c_int = 15; 258 259 pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; 260 261 pub const SOCK_DCCP: ::c_int = 6; 262 pub const SOCK_PACKET: ::c_int = 10; 263 264 pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; 265 pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; 266 pub const TCP_THIN_DUPACK: ::c_int = 17; 267 pub const TCP_USER_TIMEOUT: ::c_int = 18; 268 pub const TCP_REPAIR: ::c_int = 19; 269 pub const TCP_REPAIR_QUEUE: ::c_int = 20; 270 pub const TCP_QUEUE_SEQ: ::c_int = 21; 271 pub const TCP_REPAIR_OPTIONS: ::c_int = 22; 272 pub const TCP_FASTOPEN: ::c_int = 23; 273 pub const TCP_TIMESTAMP: ::c_int = 24; 274 pub const TCP_FASTOPEN_CONNECT: ::c_int = 30; 275 276 #[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] 277 pub const SIGUNUSED: ::c_int = ::SIGSYS; 278 279 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; 280 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; 281 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; 282 283 pub const CPU_SETSIZE: ::c_int = 128; 284 285 pub const PTRACE_TRACEME: ::c_int = 0; 286 pub const PTRACE_PEEKTEXT: ::c_int = 1; 287 pub const PTRACE_PEEKDATA: ::c_int = 2; 288 pub const PTRACE_PEEKUSER: ::c_int = 3; 289 pub const PTRACE_POKETEXT: ::c_int = 4; 290 pub const PTRACE_POKEDATA: ::c_int = 5; 291 pub const PTRACE_POKEUSER: ::c_int = 6; 292 pub const PTRACE_CONT: ::c_int = 7; 293 pub const PTRACE_KILL: ::c_int = 8; 294 pub const PTRACE_SINGLESTEP: ::c_int = 9; 295 pub const PTRACE_GETREGS: ::c_int = 12; 296 pub const PTRACE_SETREGS: ::c_int = 13; 297 pub const PTRACE_GETFPREGS: ::c_int = 14; 298 pub const PTRACE_SETFPREGS: ::c_int = 15; 299 pub const PTRACE_ATTACH: ::c_int = 16; 300 pub const PTRACE_DETACH: ::c_int = 17; 301 pub const PTRACE_GETFPXREGS: ::c_int = 18; 302 pub const PTRACE_SETFPXREGS: ::c_int = 19; 303 pub const PTRACE_SYSCALL: ::c_int = 24; 304 pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; 305 pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; 306 pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; 307 pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; 308 pub const PTRACE_GETREGSET: ::c_int = 0x4204; 309 pub const PTRACE_SETREGSET: ::c_int = 0x4205; 310 pub const PTRACE_SEIZE: ::c_int = 0x4206; 311 pub const PTRACE_INTERRUPT: ::c_int = 0x4207; 312 pub const PTRACE_LISTEN: ::c_int = 0x4208; 313 pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; 314 315 pub const EPOLLWAKEUP: ::c_int = 0x20000000; 316 317 pub const SEEK_DATA: ::c_int = 3; 318 pub const SEEK_HOLE: ::c_int = 4; 319 320 pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK; 321 322 pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK; 323 324 pub const TCSANOW: ::c_int = 0; 325 pub const TCSADRAIN: ::c_int = 1; 326 pub const TCSAFLUSH: ::c_int = 2; 327 328 pub const RTLD_GLOBAL: ::c_int = 0x100; 329 pub const RTLD_NOLOAD: ::c_int = 0x4; 330 331 pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; 332 333 pub const B0: ::speed_t = 0o000000; 334 pub const B50: ::speed_t = 0o000001; 335 pub const B75: ::speed_t = 0o000002; 336 pub const B110: ::speed_t = 0o000003; 337 pub const B134: ::speed_t = 0o000004; 338 pub const B150: ::speed_t = 0o000005; 339 pub const B200: ::speed_t = 0o000006; 340 pub const B300: ::speed_t = 0o000007; 341 pub const B600: ::speed_t = 0o000010; 342 pub const B1200: ::speed_t = 0o000011; 343 pub const B1800: ::speed_t = 0o000012; 344 pub const B2400: ::speed_t = 0o000013; 345 pub const B4800: ::speed_t = 0o000014; 346 pub const B9600: ::speed_t = 0o000015; 347 pub const B19200: ::speed_t = 0o000016; 348 pub const B38400: ::speed_t = 0o000017; 349 pub const EXTA: ::speed_t = B19200; 350 pub const EXTB: ::speed_t = B38400; 351 352 pub const SO_BINDTODEVICE: ::c_int = 25; 353 pub const SO_TIMESTAMP: ::c_int = 29; 354 pub const SO_MARK: ::c_int = 36; 355 pub const SO_RXQ_OVFL: ::c_int = 40; 356 pub const SO_PEEK_OFF: ::c_int = 42; 357 pub const SO_BUSY_POLL: ::c_int = 46; 358 359 pub const RLIMIT_CPU: ::c_int = 0; 360 pub const RLIMIT_FSIZE: ::c_int = 1; 361 pub const RLIMIT_DATA: ::c_int = 2; 362 pub const RLIMIT_STACK: ::c_int = 3; 363 pub const RLIMIT_CORE: ::c_int = 4; 364 pub const RLIMIT_LOCKS: ::c_int = 10; 365 pub const RLIMIT_SIGPENDING: ::c_int = 11; 366 pub const RLIMIT_MSGQUEUE: ::c_int = 12; 367 pub const RLIMIT_NICE: ::c_int = 13; 368 pub const RLIMIT_RTPRIO: ::c_int = 14; 369 370 extern "C" { sendmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_uint, ) -> ::c_int371 pub fn sendmmsg( 372 sockfd: ::c_int, 373 msgvec: *mut ::mmsghdr, 374 vlen: ::c_uint, 375 flags: ::c_uint, 376 ) -> ::c_int; recvmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_uint, timeout: *mut ::timespec, ) -> ::c_int377 pub fn recvmmsg( 378 sockfd: ::c_int, 379 msgvec: *mut ::mmsghdr, 380 vlen: ::c_uint, 381 flags: ::c_uint, 382 timeout: *mut ::timespec, 383 ) -> ::c_int; 384 getrlimit64(resource: ::c_int, rlim: *mut ::rlimit64) -> ::c_int385 pub fn getrlimit64(resource: ::c_int, rlim: *mut ::rlimit64) -> ::c_int; setrlimit64(resource: ::c_int, rlim: *const ::rlimit64) -> ::c_int386 pub fn setrlimit64(resource: ::c_int, rlim: *const ::rlimit64) -> ::c_int; getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int387 pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int388 pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; prlimit( pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit, old_limit: *mut ::rlimit, ) -> ::c_int389 pub fn prlimit( 390 pid: ::pid_t, 391 resource: ::c_int, 392 new_limit: *const ::rlimit, 393 old_limit: *mut ::rlimit, 394 ) -> ::c_int; prlimit64( pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit64, old_limit: *mut ::rlimit64, ) -> ::c_int395 pub fn prlimit64( 396 pid: ::pid_t, 397 resource: ::c_int, 398 new_limit: *const ::rlimit64, 399 old_limit: *mut ::rlimit64, 400 ) -> ::c_int; 401 gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int402 pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; ptrace(request: ::c_int, ...) -> ::c_long403 pub fn ptrace(request: ::c_int, ...) -> ::c_long; getpriority(which: ::c_int, who: ::id_t) -> ::c_int404 pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int405 pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; pthread_getaffinity_np( thread: ::pthread_t, cpusetsize: ::size_t, cpuset: *mut ::cpu_set_t, ) -> ::c_int406 pub fn pthread_getaffinity_np( 407 thread: ::pthread_t, 408 cpusetsize: ::size_t, 409 cpuset: *mut ::cpu_set_t, 410 ) -> ::c_int; pthread_setaffinity_np( thread: ::pthread_t, cpusetsize: ::size_t, cpuset: *const ::cpu_set_t, ) -> ::c_int411 pub fn pthread_setaffinity_np( 412 thread: ::pthread_t, 413 cpusetsize: ::size_t, 414 cpuset: *const ::cpu_set_t, 415 ) -> ::c_int; sched_getcpu() -> ::c_int416 pub fn sched_getcpu() -> ::c_int; memmem( haystack: *const ::c_void, haystacklen: ::size_t, needle: *const ::c_void, needlelen: ::size_t, ) -> *mut ::c_void417 pub fn memmem( 418 haystack: *const ::c_void, 419 haystacklen: ::size_t, 420 needle: *const ::c_void, 421 needlelen: ::size_t, 422 ) -> *mut ::c_void; 423 } 424 425 cfg_if! { 426 if #[cfg(any(target_arch = "x86_64", 427 target_arch = "aarch64", 428 target_arch = "mips64", 429 target_arch = "powerpc64"))] { 430 mod b64; 431 pub use self::b64::*; 432 } else if #[cfg(any(target_arch = "x86", 433 target_arch = "mips", 434 target_arch = "powerpc", 435 target_arch = "hexagon", 436 target_arch = "arm"))] { 437 mod b32; 438 pub use self::b32::*; 439 } else { } 440 } 441