1 //! Definitions for uclibc on 64bit systems 2 pub type blkcnt_t = i64; 3 pub type blksize_t = i64; 4 pub type clock_t = i64; 5 pub type c_char = u8; 6 pub type c_long = i64; 7 pub type c_ulong = u64; 8 pub type fsblkcnt_t = ::c_ulong; 9 pub type fsfilcnt_t = ::c_ulong; 10 pub type fsword_t = ::c_long; 11 pub type ino_t = ::c_ulong; 12 pub type nlink_t = ::c_uint; 13 pub type off_t = ::c_long; 14 pub type rlim_t = c_ulong; 15 // [uClibc docs] Note stat64 has the same shape as stat for x86-64. 16 pub type stat64 = stat; 17 pub type suseconds_t = ::c_long; 18 pub type time_t = ::c_int; 19 pub type wchar_t = ::c_int; 20 21 pub type fsblkcnt64_t = u64; 22 pub type fsfilcnt64_t = u64; 23 pub type __u64 = ::c_ulong; 24 25 s! { 26 pub struct ipc_perm { 27 pub __key: ::key_t, 28 pub uid: ::uid_t, 29 pub gid: ::gid_t, 30 pub cuid: ::uid_t, 31 pub cgid: ::gid_t, 32 pub mode: ::c_ushort, // read / write 33 __pad1: ::c_ushort, 34 pub __seq: ::c_ushort, 35 __pad2: ::c_ushort, 36 __unused1: ::c_ulong, 37 __unused2: ::c_ulong 38 } 39 40 #[cfg(not(target_os = "l4re"))] 41 pub struct pthread_attr_t { 42 __detachstate: ::c_int, 43 __schedpolicy: ::c_int, 44 __schedparam: __sched_param, 45 __inheritsched: ::c_int, 46 __scope: ::c_int, 47 __guardsize: ::size_t, 48 __stackaddr_set: ::c_int, 49 __stackaddr: *mut ::c_void, // better don't use it 50 __stacksize: ::size_t, 51 } 52 53 pub struct __sched_param { 54 __sched_priority: ::c_int, 55 } 56 57 pub struct siginfo_t { 58 si_signo: ::c_int, // signal number 59 si_errno: ::c_int, // if not zero: error value of signal, see errno.h 60 si_code: ::c_int, // signal code 61 pub _pad: [::c_int; 28], // unported union 62 _align: [usize; 0], 63 } 64 65 pub struct shmid_ds { 66 pub shm_perm: ::ipc_perm, 67 pub shm_segsz: ::size_t, // segment size in bytes 68 pub shm_atime: ::time_t, // time of last shmat() 69 pub shm_dtime: ::time_t, 70 pub shm_ctime: ::time_t, 71 pub shm_cpid: ::pid_t, 72 pub shm_lpid: ::pid_t, 73 pub shm_nattch: ::shmatt_t, 74 __unused1: ::c_ulong, 75 __unused2: ::c_ulong 76 } 77 78 pub struct msqid_ds { 79 pub msg_perm: ::ipc_perm, 80 pub msg_stime: ::time_t, 81 pub msg_rtime: ::time_t, 82 pub msg_ctime: ::time_t, 83 __msg_cbytes: ::c_ulong, 84 pub msg_qnum: ::msgqnum_t, 85 pub msg_qbytes: ::msglen_t, 86 pub msg_lspid: ::pid_t, 87 pub msg_lrpid: ::pid_t, 88 __ignored1: ::c_ulong, 89 __ignored2: ::c_ulong, 90 } 91 92 pub struct sockaddr { 93 pub sa_family: ::sa_family_t, 94 pub sa_data: [::c_char; 14], 95 } 96 97 pub struct sockaddr_in { 98 pub sin_family: ::sa_family_t, 99 pub sin_port: ::in_port_t, 100 pub sin_addr: ::in_addr, 101 pub sin_zero: [u8; 8], 102 } 103 104 pub struct sockaddr_in6 { 105 pub sin6_family: ::sa_family_t, 106 pub sin6_port: ::in_port_t, 107 pub sin6_flowinfo: u32, 108 pub sin6_addr: ::in6_addr, 109 pub sin6_scope_id: u32, 110 } 111 112 // ------------------------------------------------------------ 113 // definitions below are *unverified* and might **break** the software 114 // pub struct in_addr { 115 // pub s_addr: in_addr_t, 116 // } 117 // 118 // pub struct in6_addr { 119 // pub s6_addr: [u8; 16], 120 // #[cfg(not(libc_align))] 121 // __align: [u32; 0], 122 // } 123 124 pub struct stat { 125 pub st_dev: ::c_ulong, 126 pub st_ino: ::ino_t, 127 // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of 128 // nlink and mode are swapped on 64 bit systems. 129 pub st_nlink: ::nlink_t, 130 pub st_mode: ::mode_t, 131 pub st_uid: ::uid_t, 132 pub st_gid: ::gid_t, 133 pub st_rdev: ::c_ulong, // dev_t 134 pub st_size: off_t, // file size 135 pub st_blksize: ::blksize_t, 136 pub st_blocks: ::blkcnt_t, 137 pub st_atime: ::time_t, 138 pub st_atime_nsec: ::c_ulong, 139 pub st_mtime: ::time_t, 140 pub st_mtime_nsec: ::c_ulong, 141 pub st_ctime: ::time_t, 142 pub st_ctime_nsec: ::c_ulong, 143 st_pad4: [::c_long; 3] 144 } 145 146 pub struct sigaction { 147 pub sa_handler: ::sighandler_t, 148 pub sa_flags: ::c_ulong, 149 pub sa_restorer: ::Option<extern fn()>, 150 pub sa_mask: ::sigset_t, 151 } 152 153 pub struct stack_t { // FIXME 154 pub ss_sp: *mut ::c_void, 155 pub ss_flags: ::c_int, 156 pub ss_size: ::size_t 157 } 158 159 pub struct statfs { // FIXME 160 pub f_type: fsword_t, 161 pub f_bsize: fsword_t, 162 pub f_blocks: ::fsblkcnt_t, 163 pub f_bfree: ::fsblkcnt_t, 164 pub f_bavail: ::fsblkcnt_t, 165 pub f_files: ::fsfilcnt_t, 166 pub f_ffree: ::fsfilcnt_t, 167 pub f_fsid: ::fsid_t, 168 pub f_namelen: fsword_t, 169 pub f_frsize: fsword_t, 170 f_spare: [fsword_t; 5], 171 } 172 173 pub struct statfs64 { 174 pub f_type: ::c_int, 175 pub f_bsize: ::c_int, 176 pub f_blocks: ::fsblkcnt64_t, 177 pub f_bfree: ::fsblkcnt64_t, 178 pub f_bavail: ::fsblkcnt64_t, 179 pub f_files: ::fsfilcnt64_t, 180 pub f_ffree: ::fsfilcnt64_t, 181 pub f_fsid: ::fsid_t, 182 pub f_namelen: ::c_int, 183 pub f_frsize: ::c_int, 184 pub f_flags: ::c_int, 185 pub f_spare: [::c_int; 4], 186 } 187 188 pub struct statvfs64 { 189 pub f_bsize: ::c_ulong, 190 pub f_frsize: ::c_ulong, 191 pub f_blocks: u64, 192 pub f_bfree: u64, 193 pub f_bavail: u64, 194 pub f_files: u64, 195 pub f_ffree: u64, 196 pub f_favail: u64, 197 pub f_fsid: ::c_ulong, 198 __f_unused: ::c_int, 199 pub f_flag: ::c_ulong, 200 pub f_namemax: ::c_ulong, 201 __f_spare: [::c_int; 6], 202 } 203 204 pub struct msghdr { // FIXME 205 pub msg_name: *mut ::c_void, 206 pub msg_namelen: ::socklen_t, 207 pub msg_iov: *mut ::iovec, 208 pub msg_iovlen: ::size_t, 209 pub msg_control: *mut ::c_void, 210 pub msg_controllen: ::size_t, 211 pub msg_flags: ::c_int, 212 } 213 214 pub struct termios { // FIXME 215 pub c_iflag: ::tcflag_t, 216 pub c_oflag: ::tcflag_t, 217 pub c_cflag: ::tcflag_t, 218 pub c_lflag: ::tcflag_t, 219 pub c_line: ::cc_t, 220 pub c_cc: [::cc_t; ::NCCS], 221 } 222 223 pub struct sigset_t { // FIXME 224 __val: [::c_ulong; 16], 225 } 226 227 pub struct sysinfo { // FIXME 228 pub uptime: ::c_long, 229 pub loads: [::c_ulong; 3], 230 pub totalram: ::c_ulong, 231 pub freeram: ::c_ulong, 232 pub sharedram: ::c_ulong, 233 pub bufferram: ::c_ulong, 234 pub totalswap: ::c_ulong, 235 pub freeswap: ::c_ulong, 236 pub procs: ::c_ushort, 237 pub pad: ::c_ushort, 238 pub totalhigh: ::c_ulong, 239 pub freehigh: ::c_ulong, 240 pub mem_unit: ::c_uint, 241 pub _f: [::c_char; 0], 242 } 243 244 pub struct glob_t { // FIXME 245 pub gl_pathc: ::size_t, 246 pub gl_pathv: *mut *mut c_char, 247 pub gl_offs: ::size_t, 248 pub gl_flags: ::c_int, 249 __unused1: *mut ::c_void, 250 __unused2: *mut ::c_void, 251 __unused3: *mut ::c_void, 252 __unused4: *mut ::c_void, 253 __unused5: *mut ::c_void, 254 } 255 256 pub struct cpu_set_t { // FIXME 257 #[cfg(target_pointer_width = "32")] 258 bits: [u32; 32], 259 #[cfg(target_pointer_width = "64")] 260 bits: [u64; 16], 261 } 262 263 pub struct fsid_t { // FIXME 264 __val: [::c_int; 2], 265 } 266 267 // FIXME this is actually a union 268 pub struct sem_t { 269 #[cfg(target_pointer_width = "32")] 270 __size: [::c_char; 16], 271 #[cfg(target_pointer_width = "64")] 272 __size: [::c_char; 32], 273 __align: [::c_long; 0], 274 } 275 276 pub struct cmsghdr { 277 pub cmsg_len: ::size_t, 278 pub cmsg_level: ::c_int, 279 pub cmsg_type: ::c_int, 280 } 281 } 282 283 s_no_extra_traits! { 284 #[allow(missing_debug_implementations)] 285 pub struct dirent { 286 pub d_ino: ::ino64_t, 287 pub d_off: ::off64_t, 288 pub d_reclen: u16, 289 pub d_type: u8, 290 pub d_name: [::c_char; 256], 291 } 292 } 293 294 // constants 295 pub const EADDRINUSE: ::c_int = 98; // Address already in use 296 pub const EADDRNOTAVAIL: ::c_int = 99; // Cannot assign requested address 297 pub const ECONNABORTED: ::c_int = 103; // Software caused connection abort 298 pub const ECONNREFUSED: ::c_int = 111; // Connection refused 299 pub const ECONNRESET: ::c_int = 104; // Connection reset by peer 300 pub const EDEADLK: ::c_int = 35; // Resource deadlock would occur 301 pub const ENOSYS: ::c_int = 38; // Function not implemented 302 pub const ENOTCONN: ::c_int = 107; // Transport endpoint is not connected 303 pub const ETIMEDOUT: ::c_int = 110; // connection timed out 304 pub const EOPNOTSUPP: ::c_int = 0x5f; 305 pub const ENODATA: ::c_int = 0x3d; 306 pub const O_APPEND: ::c_int = 02000; 307 pub const O_ACCMODE: ::c_int = 0003; 308 pub const O_CLOEXEC: ::c_int = 0x80000; 309 pub const O_CREAT: ::c_int = 0100; 310 pub const O_DIRECTORY: ::c_int = 0200000; 311 pub const O_EXCL: ::c_int = 0200; 312 pub const O_NONBLOCK: ::c_int = 04000; 313 pub const O_TRUNC: ::c_int = 01000; 314 pub const NCCS: usize = 32; 315 pub const SIG_SETMASK: ::c_int = 2; // Set the set of blocked signals 316 pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; 317 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; 318 pub const SOCK_DGRAM: ::c_int = 2; // connectionless, unreliable datagrams 319 pub const SOCK_STREAM: ::c_int = 1; // …/common/bits/socket_type.h 320 pub const RLIM_INFINITY: u64 = 0xffffffffffffffff; 321 pub const __SIZEOF_PTHREAD_COND_T: usize = 48; 322 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; 323 pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; 324 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; 325 326 cfg_if! { 327 if #[cfg(target_os = "l4re")] { 328 mod l4re; 329 pub use self::l4re::*; 330 } else { 331 mod other; 332 pub use other::*; 333 } 334 } 335