|
| 1 | +pub type c_char = i8; |
| 2 | +pub type c_long = i32; |
| 3 | +pub type c_ulong = u32; |
| 4 | +pub type clock_t = i32; |
| 5 | +pub type time_t = i32; |
| 6 | +pub type suseconds_t = i32; |
| 7 | +pub type wchar_t = i32; |
| 8 | +pub type off_t = i32; |
| 9 | +pub type ino_t = u32; |
| 10 | +pub type blkcnt_t = i32; |
| 11 | +pub type blksize_t = i32; |
| 12 | +pub type nlink_t = u32; |
| 13 | +pub type fsblkcnt_t = ::c_ulong; |
| 14 | +pub type fsfilcnt_t = ::c_ulong; |
| 15 | +pub type rlim_t = c_ulong; |
| 16 | + |
| 17 | +s! { |
| 18 | + pub struct stat { |
| 19 | + pub st_dev: ::dev_t, |
| 20 | + st_pad1: [::c_long; 2], |
| 21 | + pub st_ino: ::ino_t, |
| 22 | + pub st_mode: ::mode_t, |
| 23 | + pub st_nlink: ::nlink_t, |
| 24 | + pub st_uid: ::uid_t, |
| 25 | + pub st_gid: ::gid_t, |
| 26 | + pub st_rdev: ::dev_t, |
| 27 | + pub st_pad2: [::c_long; 1], |
| 28 | + pub st_size: ::off_t, |
| 29 | + st_pad3: ::c_long, |
| 30 | + pub st_atime: ::time_t, |
| 31 | + pub st_atime_nsec: ::c_long, |
| 32 | + pub st_mtime: ::time_t, |
| 33 | + pub st_mtime_nsec: ::c_long, |
| 34 | + pub st_ctime: ::time_t, |
| 35 | + pub st_ctime_nsec: ::c_long, |
| 36 | + pub st_blksize: ::blksize_t, |
| 37 | + pub st_blocks: ::blkcnt_t, |
| 38 | + st_pad5: [::c_long; 14], |
| 39 | + } |
| 40 | + |
| 41 | + pub struct stat64 { |
| 42 | + pub st_dev: ::dev_t, |
| 43 | + st_pad1: [::c_long; 2], |
| 44 | + pub st_ino: ::ino64_t, |
| 45 | + pub st_mode: ::mode_t, |
| 46 | + pub st_nlink: ::nlink_t, |
| 47 | + pub st_uid: ::uid_t, |
| 48 | + pub st_gid: ::gid_t, |
| 49 | + pub st_rdev: ::dev_t, |
| 50 | + st_pad2: [::c_long; 2], |
| 51 | + pub st_size: ::off64_t, |
| 52 | + pub st_atime: ::time_t, |
| 53 | + pub st_atime_nsec: ::c_long, |
| 54 | + pub st_mtime: ::time_t, |
| 55 | + pub st_mtime_nsec: ::c_long, |
| 56 | + pub st_ctime: ::time_t, |
| 57 | + pub st_ctime_nsec: ::c_long, |
| 58 | + pub st_blksize: ::blksize_t, |
| 59 | + st_pad3: ::c_long, |
| 60 | + pub st_blocks: ::blkcnt64_t, |
| 61 | + st_pad5: [::c_long; 14], |
| 62 | + } |
| 63 | + |
| 64 | + pub struct pthread_attr_t { |
| 65 | + __size: [u32; 9] |
| 66 | + } |
| 67 | + |
| 68 | + pub struct sigaction { |
| 69 | + pub sa_flags: ::c_uint, |
| 70 | + pub sa_sigaction: ::sighandler_t, |
| 71 | + pub sa_mask: sigset_t, |
| 72 | + _restorer: *mut ::c_void, |
| 73 | + } |
| 74 | + |
| 75 | + pub struct stack_t { |
| 76 | + pub ss_sp: *mut ::c_void, |
| 77 | + pub ss_size: ::size_t, |
| 78 | + pub ss_flags: ::c_int, |
| 79 | + } |
| 80 | + |
| 81 | + pub struct sigset_t { |
| 82 | + __val: [::c_ulong; 4], |
| 83 | + } |
| 84 | + |
| 85 | + pub struct siginfo_t { |
| 86 | + pub si_signo: ::c_int, |
| 87 | + pub si_code: ::c_int, |
| 88 | + pub si_errno: ::c_int, |
| 89 | + pub _pad: [::c_int; 29], |
| 90 | + } |
| 91 | + |
| 92 | + pub struct glob64_t { |
| 93 | + pub gl_pathc: ::size_t, |
| 94 | + pub gl_pathv: *mut *mut ::c_char, |
| 95 | + pub gl_offs: ::size_t, |
| 96 | + pub gl_flags: ::c_int, |
| 97 | + |
| 98 | + __unused1: *mut ::c_void, |
| 99 | + __unused2: *mut ::c_void, |
| 100 | + __unused3: *mut ::c_void, |
| 101 | + __unused4: *mut ::c_void, |
| 102 | + __unused5: *mut ::c_void, |
| 103 | + } |
| 104 | + |
| 105 | + pub struct ipc_perm { |
| 106 | + pub __key: ::key_t, |
| 107 | + pub uid: ::uid_t, |
| 108 | + pub gid: ::gid_t, |
| 109 | + pub cuid: ::uid_t, |
| 110 | + pub cgid: ::gid_t, |
| 111 | + pub mode: ::c_uint, |
| 112 | + pub __seq: ::c_ushort, |
| 113 | + __pad1: ::c_ushort, |
| 114 | + __unused1: ::c_ulong, |
| 115 | + __unused2: ::c_ulong |
| 116 | + } |
| 117 | + |
| 118 | + pub struct shmid_ds { |
| 119 | + pub shm_perm: ::ipc_perm, |
| 120 | + pub shm_segsz: ::size_t, |
| 121 | + pub shm_atime: ::time_t, |
| 122 | + pub shm_dtime: ::time_t, |
| 123 | + pub shm_ctime: ::time_t, |
| 124 | + pub shm_cpid: ::pid_t, |
| 125 | + pub shm_lpid: ::pid_t, |
| 126 | + pub shm_nattch: ::shmatt_t, |
| 127 | + __unused4: ::c_ulong, |
| 128 | + __unused5: ::c_ulong |
| 129 | + } |
| 130 | + |
| 131 | + pub struct msqid_ds { |
| 132 | + pub msg_perm: ::ipc_perm, |
| 133 | + #[cfg(target_endian = "big")] |
| 134 | + __glibc_reserved1: ::c_ulong, |
| 135 | + pub msg_stime: ::time_t, |
| 136 | + #[cfg(target_endian = "little")] |
| 137 | + __glibc_reserved1: ::c_ulong, |
| 138 | + #[cfg(target_endian = "big")] |
| 139 | + __glibc_reserved2: ::c_ulong, |
| 140 | + pub msg_rtime: ::time_t, |
| 141 | + #[cfg(target_endian = "little")] |
| 142 | + __glibc_reserved2: ::c_ulong, |
| 143 | + #[cfg(target_endian = "big")] |
| 144 | + __glibc_reserved3: ::c_ulong, |
| 145 | + pub msg_ctime: ::time_t, |
| 146 | + #[cfg(target_endian = "little")] |
| 147 | + __glibc_reserved3: ::c_ulong, |
| 148 | + __msg_cbytes: ::c_ulong, |
| 149 | + pub msg_qnum: ::msgqnum_t, |
| 150 | + pub msg_qbytes: ::msglen_t, |
| 151 | + pub msg_lspid: ::pid_t, |
| 152 | + pub msg_lrpid: ::pid_t, |
| 153 | + __glibc_reserved4: ::c_ulong, |
| 154 | + __glibc_reserved5: ::c_ulong, |
| 155 | + } |
| 156 | + |
| 157 | + pub struct statfs { |
| 158 | + pub f_type: ::c_long, |
| 159 | + pub f_bsize: ::c_long, |
| 160 | + pub f_frsize: ::c_long, |
| 161 | + pub f_blocks: ::fsblkcnt_t, |
| 162 | + pub f_bfree: ::fsblkcnt_t, |
| 163 | + pub f_files: ::fsblkcnt_t, |
| 164 | + pub f_ffree: ::fsblkcnt_t, |
| 165 | + pub f_bavail: ::fsblkcnt_t, |
| 166 | + pub f_fsid: ::fsid_t, |
| 167 | + |
| 168 | + pub f_namelen: ::c_long, |
| 169 | + f_spare: [::c_long; 6], |
| 170 | + } |
| 171 | + |
| 172 | + pub struct msghdr { |
| 173 | + pub msg_name: *mut ::c_void, |
| 174 | + pub msg_namelen: ::socklen_t, |
| 175 | + pub msg_iov: *mut ::iovec, |
| 176 | + pub msg_iovlen: ::c_int, |
| 177 | + pub msg_control: *mut ::c_void, |
| 178 | + pub msg_controllen: ::size_t, |
| 179 | + pub msg_flags: ::c_int, |
| 180 | + } |
| 181 | + |
| 182 | + pub struct cmsghdr { |
| 183 | + pub cmsg_len: ::size_t, |
| 184 | + pub cmsg_level: ::c_int, |
| 185 | + pub cmsg_type: ::c_int, |
| 186 | + } |
| 187 | + |
| 188 | + pub struct termios { |
| 189 | + pub c_iflag: ::tcflag_t, |
| 190 | + pub c_oflag: ::tcflag_t, |
| 191 | + pub c_cflag: ::tcflag_t, |
| 192 | + pub c_lflag: ::tcflag_t, |
| 193 | + pub c_line: ::cc_t, |
| 194 | + pub c_cc: [::cc_t; ::NCCS], |
| 195 | + } |
| 196 | + |
| 197 | + pub struct flock { |
| 198 | + pub l_type: ::c_short, |
| 199 | + pub l_whence: ::c_short, |
| 200 | + pub l_start: ::off_t, |
| 201 | + pub l_len: ::off_t, |
| 202 | + pub l_sysid: ::c_long, |
| 203 | + pub l_pid: ::pid_t, |
| 204 | + pad: [::c_long; 4], |
| 205 | + } |
| 206 | + |
| 207 | + pub struct sysinfo { |
| 208 | + pub uptime: ::c_long, |
| 209 | + pub loads: [::c_ulong; 3], |
| 210 | + pub totalram: ::c_ulong, |
| 211 | + pub freeram: ::c_ulong, |
| 212 | + pub sharedram: ::c_ulong, |
| 213 | + pub bufferram: ::c_ulong, |
| 214 | + pub totalswap: ::c_ulong, |
| 215 | + pub freeswap: ::c_ulong, |
| 216 | + pub procs: ::c_ushort, |
| 217 | + pub pad: ::c_ushort, |
| 218 | + pub totalhigh: ::c_ulong, |
| 219 | + pub freehigh: ::c_ulong, |
| 220 | + pub mem_unit: ::c_uint, |
| 221 | + pub _f: [::c_char; 8], |
| 222 | + } |
| 223 | + |
| 224 | + // FIXME this is actually a union |
| 225 | + pub struct sem_t { |
| 226 | + #[cfg(target_pointer_width = "32")] |
| 227 | + __size: [::c_char; 16], |
| 228 | + #[cfg(target_pointer_width = "64")] |
| 229 | + __size: [::c_char; 32], |
| 230 | + __align: [::c_long; 0], |
| 231 | + } |
| 232 | +} |
| 233 | + |
| 234 | +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; |
| 235 | +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; |
| 236 | +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; |
| 237 | +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; |
| 238 | + |
| 239 | +pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; |
| 240 | + |
| 241 | +pub const SYS_gettid: ::c_long = 4222; // Valid for O32 |
| 242 | + |
| 243 | +#[link(name = "util")] |
| 244 | +extern { |
| 245 | + pub fn sysctl(name: *mut ::c_int, |
| 246 | + namelen: ::c_int, |
| 247 | + oldp: *mut ::c_void, |
| 248 | + oldlenp: *mut ::size_t, |
| 249 | + newp: *mut ::c_void, |
| 250 | + newlen: ::size_t) |
| 251 | + -> ::c_int; |
| 252 | + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; |
| 253 | + pub fn backtrace(buf: *mut *mut ::c_void, |
| 254 | + sz: ::c_int) -> ::c_int; |
| 255 | + pub fn glob64(pattern: *const ::c_char, |
| 256 | + flags: ::c_int, |
| 257 | + errfunc: ::dox::Option<extern fn(epath: *const ::c_char, |
| 258 | + errno: ::c_int) |
| 259 | + -> ::c_int>, |
| 260 | + pglob: *mut glob64_t) -> ::c_int; |
| 261 | + pub fn globfree64(pglob: *mut glob64_t); |
| 262 | + pub fn ptrace(request: ::c_uint, ...) -> ::c_long; |
| 263 | + pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t, |
| 264 | + cpusetsize: ::size_t, |
| 265 | + cpuset: *mut ::cpu_set_t) -> ::c_int; |
| 266 | + pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t, |
| 267 | + cpusetsize: ::size_t, |
| 268 | + cpuset: *const ::cpu_set_t) -> ::c_int; |
| 269 | +} |
0 commit comments