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