1 // The following definitions are correct for arm and i686, 2 // but may be wrong for mips 3 4 pub type c_long = i32; 5 pub type c_ulong = u32; 6 pub type mode_t = u16; 7 pub type off64_t = ::c_longlong; 8 pub type sigset_t = ::c_ulong; 9 pub type socklen_t = i32; 10 pub type time64_t = i64; 11 12 s! { 13 pub struct sigaction { 14 pub sa_sigaction: ::sighandler_t, 15 pub sa_mask: ::sigset_t, 16 pub sa_flags: ::c_int, 17 pub sa_restorer: ::Option<extern fn()>, 18 } 19 20 pub struct rlimit64 { 21 pub rlim_cur: u64, 22 pub rlim_max: u64, 23 } 24 25 pub struct stat { 26 pub st_dev: ::c_ulonglong, 27 __pad0: [::c_uchar; 4], 28 __st_ino: ::ino_t, 29 pub st_mode: ::c_uint, 30 pub st_nlink: ::c_uint, 31 pub st_uid: ::uid_t, 32 pub st_gid: ::gid_t, 33 pub st_rdev: ::c_ulonglong, 34 __pad3: [::c_uchar; 4], 35 pub st_size: ::c_longlong, 36 pub st_blksize: ::blksize_t, 37 pub st_blocks: ::c_ulonglong, 38 pub st_atime: ::c_long, 39 pub st_atime_nsec: ::c_long, 40 pub st_mtime: ::c_long, 41 pub st_mtime_nsec: ::c_long, 42 pub st_ctime: ::c_long, 43 pub st_ctime_nsec: ::c_long, 44 pub st_ino: ::c_ulonglong, 45 } 46 47 pub struct stat64 { 48 pub st_dev: ::c_ulonglong, 49 __pad0: [::c_uchar; 4], 50 __st_ino: ::ino_t, 51 pub st_mode: ::c_uint, 52 pub st_nlink: ::c_uint, 53 pub st_uid: ::uid_t, 54 pub st_gid: ::gid_t, 55 pub st_rdev: ::c_ulonglong, 56 __pad3: [::c_uchar; 4], 57 pub st_size: ::c_longlong, 58 pub st_blksize: ::blksize_t, 59 pub st_blocks: ::c_ulonglong, 60 pub st_atime: ::c_long, 61 pub st_atime_nsec: ::c_long, 62 pub st_mtime: ::c_long, 63 pub st_mtime_nsec: ::c_long, 64 pub st_ctime: ::c_long, 65 pub st_ctime_nsec: ::c_long, 66 pub st_ino: ::c_ulonglong, 67 } 68 69 pub struct statfs64 { 70 pub f_type: u32, 71 pub f_bsize: u32, 72 pub f_blocks: u64, 73 pub f_bfree: u64, 74 pub f_bavail: u64, 75 pub f_files: u64, 76 pub f_ffree: u64, 77 f_fsid: [u32; 2], 78 pub f_namelen: u32, 79 pub f_frsize: u32, 80 pub f_flags: u32, 81 pub f_spare: [u32; 4], 82 } 83 84 pub struct statvfs64 { 85 pub f_bsize: ::c_ulong, 86 pub f_frsize: ::c_ulong, 87 pub f_blocks: ::c_ulong, 88 pub f_bfree: ::c_ulong, 89 pub f_bavail: ::c_ulong, 90 pub f_files: ::c_ulong, 91 pub f_ffree: ::c_ulong, 92 pub f_favail: ::c_ulong, 93 pub f_fsid: ::c_ulong, 94 pub f_flag: ::c_ulong, 95 pub f_namemax: ::c_ulong, 96 } 97 98 pub struct pthread_attr_t { 99 pub flags: u32, 100 pub stack_base: *mut ::c_void, 101 pub stack_size: ::size_t, 102 pub guard_size: ::size_t, 103 pub sched_policy: i32, 104 pub sched_priority: i32, 105 } 106 107 pub struct pthread_mutex_t { value: ::c_int } 108 109 pub struct pthread_cond_t { value: ::c_int } 110 111 pub struct pthread_rwlock_t { 112 lock: pthread_mutex_t, 113 cond: pthread_cond_t, 114 numLocks: ::c_int, 115 writerThreadId: ::c_int, 116 pendingReaders: ::c_int, 117 pendingWriters: ::c_int, 118 attr: i32, 119 __reserved: [::c_char; 12], 120 } 121 122 pub struct passwd { 123 pub pw_name: *mut ::c_char, 124 pub pw_passwd: *mut ::c_char, 125 pub pw_uid: ::uid_t, 126 pub pw_gid: ::gid_t, 127 pub pw_dir: *mut ::c_char, 128 pub pw_shell: *mut ::c_char, 129 } 130 131 pub struct statfs { 132 pub f_type: u32, 133 pub f_bsize: u32, 134 pub f_blocks: u64, 135 pub f_bfree: u64, 136 pub f_bavail: u64, 137 pub f_files: u64, 138 pub f_ffree: u64, 139 pub f_fsid: ::__fsid_t, 140 pub f_namelen: u32, 141 pub f_frsize: u32, 142 pub f_flags: u32, 143 pub f_spare: [u32; 4], 144 } 145 146 pub struct sysinfo { 147 pub uptime: ::c_long, 148 pub loads: [::c_ulong; 3], 149 pub totalram: ::c_ulong, 150 pub freeram: ::c_ulong, 151 pub sharedram: ::c_ulong, 152 pub bufferram: ::c_ulong, 153 pub totalswap: ::c_ulong, 154 pub freeswap: ::c_ulong, 155 pub procs: ::c_ushort, 156 pub pad: ::c_ushort, 157 pub totalhigh: ::c_ulong, 158 pub freehigh: ::c_ulong, 159 pub mem_unit: ::c_uint, 160 pub _f: [::c_char; 8], 161 } 162 } 163 164 // These constants must be of the same type of sigaction.sa_flags 165 pub const SA_NOCLDSTOP: ::c_int = 0x00000001; 166 pub const SA_NOCLDWAIT: ::c_int = 0x00000002; 167 pub const SA_NODEFER: ::c_int = 0x40000000; 168 pub const SA_ONSTACK: ::c_int = 0x08000000; 169 pub const SA_RESETHAND: ::c_int = 0x80000000; 170 pub const SA_RESTART: ::c_int = 0x10000000; 171 pub const SA_SIGINFO: ::c_int = 0x00000004; 172 173 pub const RTLD_GLOBAL: ::c_int = 2; 174 pub const RTLD_NOW: ::c_int = 0; 175 pub const RTLD_DEFAULT: *mut ::c_void = -1isize as *mut ::c_void; 176 177 pub const PTRACE_GETFPREGS: ::c_int = 14; 178 pub const PTRACE_SETFPREGS: ::c_int = 15; 179 pub const PTRACE_GETREGS: ::c_int = 12; 180 pub const PTRACE_SETREGS: ::c_int = 13; 181 182 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 183 pthread_mutex_t { value: 0 }; 184 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 185 pthread_cond_t { value: 0 }; 186 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { 187 lock: PTHREAD_MUTEX_INITIALIZER, 188 cond: PTHREAD_COND_INITIALIZER, 189 numLocks: 0, 190 writerThreadId: 0, 191 pendingReaders: 0, 192 pendingWriters: 0, 193 attr: 0, 194 __reserved: [0; 12], 195 }; 196 pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2; 197 pub const CPU_SETSIZE: ::size_t = 32; 198 pub const __CPU_BITS: ::size_t = 32; 199 200 pub const UT_LINESIZE: usize = 8; 201 pub const UT_NAMESIZE: usize = 8; 202 pub const UT_HOSTSIZE: usize = 16; 203 204 pub const SIGSTKSZ: ::size_t = 8192; 205 pub const MINSIGSTKSZ: ::size_t = 2048; 206 207 extern "C" { timegm64(tm: *const ::tm) -> ::time64_t208 pub fn timegm64(tm: *const ::tm) -> ::time64_t; 209 } 210 211 cfg_if! { 212 if #[cfg(target_arch = "x86")] { 213 mod x86; 214 pub use self::x86::*; 215 } else if #[cfg(target_arch = "arm")] { 216 mod arm; 217 pub use self::arm::*; 218 } else { 219 // Unknown target_arch 220 } 221 } 222