1 pub type shmatt_t = ::c_ulong; 2 pub type msgqnum_t = ::c_ulong; 3 pub type msglen_t = ::c_ulong; 4 pub type regoff_t = ::c_int; 5 pub type __rlimit_resource_t = ::c_uint; 6 pub type __priority_which_t = ::c_uint; 7 8 cfg_if! { 9 if #[cfg(doc)] { 10 // Used in `linux::arch` to define ioctl constants. 11 pub(crate) type Ioctl = ::c_ulong; 12 } else { 13 #[doc(hidden)] 14 pub type Ioctl = ::c_ulong; 15 } 16 } 17 18 s! { 19 pub struct statvfs { // Different than GNU! 20 pub f_bsize: ::c_ulong, 21 pub f_frsize: ::c_ulong, 22 pub f_blocks: ::fsblkcnt_t, 23 pub f_bfree: ::fsblkcnt_t, 24 pub f_bavail: ::fsblkcnt_t, 25 pub f_files: ::fsfilcnt_t, 26 pub f_ffree: ::fsfilcnt_t, 27 pub f_favail: ::fsfilcnt_t, 28 #[cfg(target_endian = "little")] 29 pub f_fsid: ::c_ulong, 30 #[cfg(target_pointer_width = "32")] 31 __f_unused: ::c_int, 32 #[cfg(target_endian = "big")] 33 pub f_fsid: ::c_ulong, 34 pub f_flag: ::c_ulong, 35 pub f_namemax: ::c_ulong, 36 __f_spare: [::c_int; 6], 37 } 38 39 pub struct regex_t { 40 __buffer: *mut ::c_void, 41 __allocated: ::size_t, 42 __used: ::size_t, 43 __syntax: ::c_ulong, 44 __fastmap: *mut ::c_char, 45 __translate: *mut ::c_char, 46 __re_nsub: ::size_t, 47 __bitfield: u8, 48 } 49 50 pub struct rtentry { 51 pub rt_pad1: ::c_ulong, 52 pub rt_dst: ::sockaddr, 53 pub rt_gateway: ::sockaddr, 54 pub rt_genmask: ::sockaddr, 55 pub rt_flags: ::c_ushort, 56 pub rt_pad2: ::c_short, 57 pub rt_pad3: ::c_ulong, 58 pub rt_tos: ::c_uchar, 59 pub rt_class: ::c_uchar, 60 #[cfg(target_pointer_width = "64")] 61 pub rt_pad4: [::c_short; 3usize], 62 #[cfg(not(target_pointer_width = "64"))] 63 pub rt_pad4: ::c_short, 64 pub rt_metric: ::c_short, 65 pub rt_dev: *mut ::c_char, 66 pub rt_mtu: ::c_ulong, 67 pub rt_window: ::c_ulong, 68 pub rt_irtt: ::c_ushort, 69 } 70 71 pub struct __exit_status { 72 pub e_termination: ::c_short, 73 pub e_exit: ::c_short, 74 } 75 76 pub struct ptrace_peeksiginfo_args { 77 pub off: ::__u64, 78 pub flags: ::__u32, 79 pub nr: ::__s32, 80 } 81 } 82 83 pub const MCL_CURRENT: ::c_int = 0x0001; 84 pub const MCL_FUTURE: ::c_int = 0x0002; 85 86 pub const SIGEV_THREAD_ID: ::c_int = 4; 87 88 pub const AF_VSOCK: ::c_int = 40; 89 90 // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the 91 // following are only available on newer Linux versions than the versions 92 // currently used in CI in some configurations, so we define them here. 93 pub const BINDERFS_SUPER_MAGIC: ::c_long = 0x6c6f6f70; 94 pub const XFS_SUPER_MAGIC: ::c_long = 0x58465342; 95 96 pub const PTRACE_TRACEME: ::c_int = 0; 97 pub const PTRACE_PEEKTEXT: ::c_int = 1; 98 pub const PTRACE_PEEKDATA: ::c_int = 2; 99 pub const PTRACE_PEEKUSER: ::c_int = 3; 100 pub const PTRACE_POKETEXT: ::c_int = 4; 101 pub const PTRACE_POKEDATA: ::c_int = 5; 102 pub const PTRACE_POKEUSER: ::c_int = 6; 103 pub const PTRACE_CONT: ::c_int = 7; 104 pub const PTRACE_KILL: ::c_int = 8; 105 pub const PTRACE_SINGLESTEP: ::c_int = 9; 106 pub const PTRACE_GETREGS: ::c_int = 12; 107 pub const PTRACE_SETREGS: ::c_int = 13; 108 pub const PTRACE_GETFPREGS: ::c_int = 14; 109 pub const PTRACE_SETFPREGS: ::c_int = 15; 110 pub const PTRACE_ATTACH: ::c_int = 16; 111 pub const PTRACE_DETACH: ::c_int = 17; 112 pub const PTRACE_GETFPXREGS: ::c_int = 18; 113 pub const PTRACE_SETFPXREGS: ::c_int = 19; 114 pub const PTRACE_SYSCALL: ::c_int = 24; 115 pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; 116 pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; 117 pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; 118 pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; 119 pub const PTRACE_GETREGSET: ::c_int = 0x4204; 120 pub const PTRACE_SETREGSET: ::c_int = 0x4205; 121 pub const PTRACE_SEIZE: ::c_int = 0x4206; 122 pub const PTRACE_INTERRUPT: ::c_int = 0x4207; 123 pub const PTRACE_LISTEN: ::c_int = 0x4208; 124 125 pub const POSIX_FADV_DONTNEED: ::c_int = 4; 126 pub const POSIX_FADV_NOREUSE: ::c_int = 5; 127 128 pub const RLIMIT_CPU: ::c_int = 0; 129 pub const RLIMIT_FSIZE: ::c_int = 1; 130 pub const RLIMIT_DATA: ::c_int = 2; 131 pub const RLIMIT_STACK: ::c_int = 3; 132 pub const RLIMIT_CORE: ::c_int = 4; 133 pub const RLIMIT_LOCKS: ::c_int = 10; 134 pub const RLIMIT_SIGPENDING: ::c_int = 11; 135 pub const RLIMIT_MSGQUEUE: ::c_int = 12; 136 pub const RLIMIT_NICE: ::c_int = 13; 137 pub const RLIMIT_RTPRIO: ::c_int = 14; 138 139 // These are different than GNU! 140 pub const LC_CTYPE: ::c_int = 0; 141 pub const LC_NUMERIC: ::c_int = 1; 142 pub const LC_TIME: ::c_int = 3; 143 pub const LC_COLLATE: ::c_int = 4; 144 pub const LC_MONETARY: ::c_int = 2; 145 pub const LC_MESSAGES: ::c_int = 5; 146 pub const LC_ALL: ::c_int = 6; 147 // end different section 148 149 // MS_ flags for mount(2) 150 pub const MS_RMT_MASK: ::c_ulong = ::MS_RDONLY | ::MS_SYNCHRONOUS | ::MS_MANDLOCK | ::MS_I_VERSION; 151 152 pub const ENOTSUP: ::c_int = EOPNOTSUPP; 153 154 pub const IPV6_JOIN_GROUP: ::c_int = 20; 155 pub const IPV6_LEAVE_GROUP: ::c_int = 21; 156 157 // These are different from GNU 158 pub const ABDAY_1: ::nl_item = 0x300; 159 pub const ABDAY_2: ::nl_item = 0x301; 160 pub const ABDAY_3: ::nl_item = 0x302; 161 pub const ABDAY_4: ::nl_item = 0x303; 162 pub const ABDAY_5: ::nl_item = 0x304; 163 pub const ABDAY_6: ::nl_item = 0x305; 164 pub const ABDAY_7: ::nl_item = 0x306; 165 pub const DAY_1: ::nl_item = 0x307; 166 pub const DAY_2: ::nl_item = 0x308; 167 pub const DAY_3: ::nl_item = 0x309; 168 pub const DAY_4: ::nl_item = 0x30A; 169 pub const DAY_5: ::nl_item = 0x30B; 170 pub const DAY_6: ::nl_item = 0x30C; 171 pub const DAY_7: ::nl_item = 0x30D; 172 pub const ABMON_1: ::nl_item = 0x30E; 173 pub const ABMON_2: ::nl_item = 0x30F; 174 pub const ABMON_3: ::nl_item = 0x310; 175 pub const ABMON_4: ::nl_item = 0x311; 176 pub const ABMON_5: ::nl_item = 0x312; 177 pub const ABMON_6: ::nl_item = 0x313; 178 pub const ABMON_7: ::nl_item = 0x314; 179 pub const ABMON_8: ::nl_item = 0x315; 180 pub const ABMON_9: ::nl_item = 0x316; 181 pub const ABMON_10: ::nl_item = 0x317; 182 pub const ABMON_11: ::nl_item = 0x318; 183 pub const ABMON_12: ::nl_item = 0x319; 184 pub const MON_1: ::nl_item = 0x31A; 185 pub const MON_2: ::nl_item = 0x31B; 186 pub const MON_3: ::nl_item = 0x31C; 187 pub const MON_4: ::nl_item = 0x31D; 188 pub const MON_5: ::nl_item = 0x31E; 189 pub const MON_6: ::nl_item = 0x31F; 190 pub const MON_7: ::nl_item = 0x320; 191 pub const MON_8: ::nl_item = 0x321; 192 pub const MON_9: ::nl_item = 0x322; 193 pub const MON_10: ::nl_item = 0x323; 194 pub const MON_11: ::nl_item = 0x324; 195 pub const MON_12: ::nl_item = 0x325; 196 pub const AM_STR: ::nl_item = 0x326; 197 pub const PM_STR: ::nl_item = 0x327; 198 pub const D_T_FMT: ::nl_item = 0x328; 199 pub const D_FMT: ::nl_item = 0x329; 200 pub const T_FMT: ::nl_item = 0x32A; 201 pub const T_FMT_AMPM: ::nl_item = 0x32B; 202 pub const ERA: ::nl_item = 0x32C; 203 pub const ERA_D_FMT: ::nl_item = 0x32E; 204 pub const ALT_DIGITS: ::nl_item = 0x32F; 205 pub const ERA_D_T_FMT: ::nl_item = 0x330; 206 pub const ERA_T_FMT: ::nl_item = 0x331; 207 pub const CODESET: ::nl_item = 10; 208 pub const CRNCYSTR: ::nl_item = 0x215; 209 pub const RADIXCHAR: ::nl_item = 0x100; 210 pub const THOUSEP: ::nl_item = 0x101; 211 pub const NOEXPR: ::nl_item = 0x501; 212 pub const YESSTR: ::nl_item = 0x502; 213 pub const NOSTR: ::nl_item = 0x503; 214 215 // Different than Gnu. 216 pub const FILENAME_MAX: ::c_uint = 4095; 217 218 pub const PRIO_PROCESS: ::c_int = 0; 219 pub const PRIO_PGRP: ::c_int = 1; 220 pub const PRIO_USER: ::c_int = 2; 221 222 pub const ST_RELATIME: ::c_ulong = 4096; 223 224 pub const AF_NFC: ::c_int = PF_NFC; 225 pub const BUFSIZ: ::c_int = 4096; 226 pub const EDEADLOCK: ::c_int = EDEADLK; 227 pub const EXTA: ::c_uint = B19200; 228 pub const EXTB: ::c_uint = B38400; 229 pub const EXTPROC: ::tcflag_t = 0200000; 230 pub const FAN_MARK_FILESYSTEM: ::c_int = 0x00000100; 231 pub const FAN_MARK_INODE: ::c_int = 0x00000000; 232 pub const FAN_MARK_MOUNT: ::c_int = 0x10; 233 pub const FOPEN_MAX: ::c_int = 16; 234 pub const F_GETOWN: ::c_int = 9; 235 pub const F_OFD_GETLK: ::c_int = 36; 236 pub const F_OFD_SETLK: ::c_int = 37; 237 pub const F_OFD_SETLKW: ::c_int = 38; 238 pub const F_RDLCK: ::c_int = 0; 239 pub const F_SETOWN: ::c_int = 8; 240 pub const F_UNLCK: ::c_int = 2; 241 pub const F_WRLCK: ::c_int = 1; 242 pub const IPV6_MULTICAST_ALL: ::c_int = 29; 243 pub const IPV6_ROUTER_ALERT_ISOLATE: ::c_int = 30; 244 pub const MAP_HUGE_SHIFT: ::c_int = 26; 245 pub const MAP_HUGE_MASK: ::c_int = 0x3f; 246 pub const MAP_HUGE_64KB: ::c_int = 16 << MAP_HUGE_SHIFT; 247 pub const MAP_HUGE_512KB: ::c_int = 19 << MAP_HUGE_SHIFT; 248 pub const MAP_HUGE_1MB: ::c_int = 20 << MAP_HUGE_SHIFT; 249 pub const MAP_HUGE_2MB: ::c_int = 21 << MAP_HUGE_SHIFT; 250 pub const MAP_HUGE_8MB: ::c_int = 23 << MAP_HUGE_SHIFT; 251 pub const MAP_HUGE_16MB: ::c_int = 24 << MAP_HUGE_SHIFT; 252 pub const MAP_HUGE_32MB: ::c_int = 25 << MAP_HUGE_SHIFT; 253 pub const MAP_HUGE_256MB: ::c_int = 28 << MAP_HUGE_SHIFT; 254 pub const MAP_HUGE_512MB: ::c_int = 29 << MAP_HUGE_SHIFT; 255 pub const MAP_HUGE_1GB: ::c_int = 30 << MAP_HUGE_SHIFT; 256 pub const MAP_HUGE_2GB: ::c_int = 31 << MAP_HUGE_SHIFT; 257 pub const MAP_HUGE_16GB: ::c_int = 34 << MAP_HUGE_SHIFT; 258 pub const MINSIGSTKSZ: ::c_int = 2048; 259 pub const MSG_COPY: ::c_int = 040000; 260 pub const NI_MAXHOST: ::socklen_t = 1025; 261 pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; 262 pub const PACKET_MR_UNICAST: ::c_int = 3; 263 pub const PF_NFC: ::c_int = 39; 264 pub const PF_VSOCK: ::c_int = 40; 265 pub const POSIX_MADV_DONTNEED: ::c_int = 4; 266 pub const PTRACE_EVENT_STOP: ::c_int = 128; 267 pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; 268 pub const RLIMIT_AS: ::c_int = 9; 269 pub const RLIMIT_MEMLOCK: ::c_int = 8; 270 pub const RLIMIT_NLIMITS: ::c_int = 15; 271 pub const RLIMIT_NOFILE: ::c_int = 7; 272 pub const RLIMIT_NPROC: ::c_int = 6; 273 pub const RLIMIT_RSS: ::c_int = 5; 274 pub const RLIMIT_RTTIME: ::c_int = 15; 275 pub const RTLD_NOLOAD: ::c_int = 0x00004; 276 pub const RUSAGE_THREAD: ::c_int = 1; 277 pub const SHM_EXEC: ::c_int = 0100000; 278 pub const SIGPOLL: ::c_int = SIGIO; 279 pub const SOCK_DCCP: ::c_int = 6; 280 pub const SOCK_PACKET: ::c_int = 10; 281 pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; 282 pub const UDP_GRO: ::c_int = 104; 283 pub const UDP_SEGMENT: ::c_int = 103; 284 pub const YESEXPR: ::c_int = ((5) << 8) | (0); 285 286 extern "C" { ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int287 pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int288 pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; 289 pthread_rwlockattr_getkind_np( attr: *const ::pthread_rwlockattr_t, val: *mut ::c_int, ) -> ::c_int290 pub fn pthread_rwlockattr_getkind_np( 291 attr: *const ::pthread_rwlockattr_t, 292 val: *mut ::c_int, 293 ) -> ::c_int; pthread_rwlockattr_setkind_np( attr: *mut ::pthread_rwlockattr_t, val: ::c_int, ) -> ::c_int294 pub fn pthread_rwlockattr_setkind_np( 295 attr: *mut ::pthread_rwlockattr_t, 296 val: ::c_int, 297 ) -> ::c_int; 298 ptrace(request: ::c_uint, ...) -> ::c_long299 pub fn ptrace(request: ::c_uint, ...) -> ::c_long; 300 sendmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_int, ) -> ::c_int301 pub fn sendmmsg( 302 sockfd: ::c_int, 303 msgvec: *mut ::mmsghdr, 304 vlen: ::c_uint, 305 flags: ::c_int, 306 ) -> ::c_int; recvmmsg( sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, flags: ::c_int, timeout: *mut ::timespec, ) -> ::c_int307 pub fn recvmmsg( 308 sockfd: ::c_int, 309 msgvec: *mut ::mmsghdr, 310 vlen: ::c_uint, 311 flags: ::c_int, 312 timeout: *mut ::timespec, 313 ) -> ::c_int; 314 openpty( amaster: *mut ::c_int, aslave: *mut ::c_int, name: *mut ::c_char, termp: *mut termios, winp: *mut ::winsize, ) -> ::c_int315 pub fn openpty( 316 amaster: *mut ::c_int, 317 aslave: *mut ::c_int, 318 name: *mut ::c_char, 319 termp: *mut termios, 320 winp: *mut ::winsize, 321 ) -> ::c_int; forkpty( amaster: *mut ::c_int, name: *mut ::c_char, termp: *mut termios, winp: *mut ::winsize, ) -> ::pid_t322 pub fn forkpty( 323 amaster: *mut ::c_int, 324 name: *mut ::c_char, 325 termp: *mut termios, 326 winp: *mut ::winsize, 327 ) -> ::pid_t; 328 getnameinfo( sa: *const ::sockaddr, salen: ::socklen_t, host: *mut ::c_char, hostlen: ::socklen_t, serv: *mut ::c_char, sevlen: ::socklen_t, flags: ::c_int, ) -> ::c_int329 pub fn getnameinfo( 330 sa: *const ::sockaddr, 331 salen: ::socklen_t, 332 host: *mut ::c_char, 333 hostlen: ::socklen_t, 334 serv: *mut ::c_char, 335 sevlen: ::socklen_t, 336 flags: ::c_int, 337 ) -> ::c_int; 338 pwritev( fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off64_t, ) -> ::ssize_t339 pub fn pwritev( 340 fd: ::c_int, 341 iov: *const ::iovec, 342 iovcnt: ::c_int, 343 offset: ::off64_t, 344 ) -> ::ssize_t; preadv( fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off64_t, ) -> ::ssize_t345 pub fn preadv( 346 fd: ::c_int, 347 iov: *const ::iovec, 348 iovcnt: ::c_int, 349 offset: ::off64_t, 350 ) -> ::ssize_t; 351 sethostid(hostid: ::c_long) -> ::c_int352 pub fn sethostid(hostid: ::c_long) -> ::c_int; fanotify_mark( fd: ::c_int, flags: ::c_uint, mask: u64, dirfd: ::c_int, path: *const ::c_char, ) -> ::c_int353 pub fn fanotify_mark( 354 fd: ::c_int, 355 flags: ::c_uint, 356 mask: u64, 357 dirfd: ::c_int, 358 path: *const ::c_char, 359 ) -> ::c_int; getrlimit64(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit64) -> ::c_int360 pub fn getrlimit64(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit64) -> ::c_int; setrlimit64(resource: ::__rlimit_resource_t, rlim: *const ::rlimit64) -> ::c_int361 pub fn setrlimit64(resource: ::__rlimit_resource_t, rlim: *const ::rlimit64) -> ::c_int; getrlimit(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit) -> ::c_int362 pub fn getrlimit(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit) -> ::c_int; setrlimit(resource: ::__rlimit_resource_t, rlim: *const ::rlimit) -> ::c_int363 pub fn setrlimit(resource: ::__rlimit_resource_t, rlim: *const ::rlimit) -> ::c_int; getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int364 pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int; setpriority(which: ::__priority_which_t, who: ::id_t, prio: ::c_int) -> ::c_int365 pub fn setpriority(which: ::__priority_which_t, who: ::id_t, prio: ::c_int) -> ::c_int; 366 } 367 368 cfg_if! { 369 if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { 370 mod mips; 371 pub use self::mips::*; 372 } else if #[cfg(target_arch = "x86_64")] { 373 mod x86_64; 374 pub use self::x86_64::*; 375 } else if #[cfg(target_arch = "arm")] { 376 mod arm; 377 pub use self::arm::*; 378 } else { 379 pub use unsupported_target; 380 } 381 } 382