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 / newlib / horizon / mod.rs
| 1 | //! ARMv6K Nintendo 3DS C Newlib definitions |
| 2 | |
| 3 | use crate::off_t; |
| 4 | use crate::prelude::*; |
| 5 | |
| 6 | pub type wchar_t = c_uint; |
| 7 | |
| 8 | pub type u_register_t = c_uint; |
| 9 | pub type u_char = c_uchar; |
| 10 | pub type u_short = c_ushort; |
| 11 | pub type u_int = c_uint; |
| 12 | pub type u_long = c_ulong; |
| 13 | pub type ushort = c_ushort; |
| 14 | pub type uint = c_uint; |
| 15 | pub type ulong = c_ulong; |
| 16 | pub type clock_t = c_ulong; |
| 17 | pub type daddr_t = c_long; |
| 18 | pub type caddr_t = *mut c_char; |
| 19 | pub type sbintime_t = c_longlong; |
| 20 | pub type sigset_t = c_ulong; |
| 21 | |
| 22 | s! { |
| 23 | pub struct hostent { |
| 24 | pub h_name: *mut c_char, |
| 25 | pub h_aliases: *mut *mut c_char, |
| 26 | pub h_addrtype: u16, |
| 27 | pub h_length: u16, |
| 28 | pub h_addr_list: *mut *mut c_char, |
| 29 | } |
| 30 | |
| 31 | pub struct pollfd { |
| 32 | pub fd: c_int, |
| 33 | pub events: c_int, |
| 34 | pub revents: c_int, |
| 35 | } |
| 36 | |
| 37 | pub struct sockaddr { |
| 38 | pub sa_family: crate::sa_family_t, |
| 39 | pub sa_data: [c_char; 26usize], |
| 40 | } |
| 41 | |
| 42 | pub struct sockaddr_storage { |
| 43 | pub ss_family: crate::sa_family_t, |
| 44 | __ss_padding: Padding<[c_char; 26usize]>, |
| 45 | } |
| 46 | |
| 47 | pub struct sockaddr_in { |
| 48 | pub sin_family: crate::sa_family_t, |
| 49 | pub sin_port: crate::in_port_t, |
| 50 | pub sin_addr: crate::in_addr, |
| 51 | pub sin_zero: [c_char; 8], |
| 52 | } |
| 53 | |
| 54 | pub struct sockaddr_in6 { |
| 55 | pub sin6_family: crate::sa_family_t, |
| 56 | pub sin6_port: crate::in_port_t, |
| 57 | pub sin6_flowinfo: u32, |
| 58 | pub sin6_addr: crate::in6_addr, |
| 59 | pub sin6_scope_id: u32, |
| 60 | } |
| 61 | |
| 62 | pub struct sockaddr_un { |
| 63 | pub sun_len: c_uchar, |
| 64 | pub sun_family: crate::sa_family_t, |
| 65 | pub sun_path: [c_char; 104usize], |
| 66 | } |
| 67 | |
| 68 | pub struct sched_param { |
| 69 | pub sched_priority: c_int, |
| 70 | } |
| 71 | |
| 72 | pub struct stat { |
| 73 | pub st_dev: crate::dev_t, |
| 74 | pub st_ino: crate::ino_t, |
| 75 | pub st_mode: crate::mode_t, |
| 76 | pub st_nlink: crate::nlink_t, |
| 77 | pub st_uid: crate::uid_t, |
| 78 | pub st_gid: crate::gid_t, |
| 79 | pub st_rdev: crate::dev_t, |
| 80 | pub st_size: off_t, |
| 81 | pub st_atim: crate::timespec, |
| 82 | pub st_mtim: crate::timespec, |
| 83 | pub st_ctim: crate::timespec, |
| 84 | pub st_blksize: crate::blksize_t, |
| 85 | pub st_blocks: crate::blkcnt_t, |
| 86 | pub st_spare4: [c_long; 2usize], |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | pub const SIGEV_NONE: c_int = 1; |
| 91 | pub const SIGEV_SIGNAL: c_int = 2; |
| 92 | pub const SIGEV_THREAD: c_int = 3; |
| 93 | pub const SA_NOCLDSTOP: c_int = 1; |
| 94 | pub const MINSIGSTKSZ: c_int = 2048; |
| 95 | pub const SIGSTKSZ: c_int = 8192; |
| 96 | pub const SS_ONSTACK: c_int = 1; |
| 97 | pub const SS_DISABLE: c_int = 2; |
| 98 | pub const SIG_SETMASK: c_int = 0; |
| 99 | pub const SIG_BLOCK: c_int = 1; |
| 100 | pub const SIG_UNBLOCK: c_int = 2; |
| 101 | pub const SIGHUP: c_int = 1; |
| 102 | pub const SIGINT: c_int = 2; |
| 103 | pub const SIGQUIT: c_int = 3; |
| 104 | pub const SIGILL: c_int = 4; |
| 105 | pub const SIGTRAP: c_int = 5; |
| 106 | pub const SIGABRT: c_int = 6; |
| 107 | pub const SIGEMT: c_int = 7; |
| 108 | pub const SIGFPE: c_int = 8; |
| 109 | pub const SIGKILL: c_int = 9; |
| 110 | pub const SIGBUS: c_int = 10; |
| 111 | pub const SIGSEGV: c_int = 11; |
| 112 | pub const SIGSYS: c_int = 12; |
| 113 | pub const SIGPIPE: c_int = 13; |
| 114 | pub const SIGALRM: c_int = 14; |
| 115 | pub const SIGTERM: c_int = 15; |
| 116 | pub const SIGURG: c_int = 16; |
| 117 | pub const SIGSTOP: c_int = 17; |
| 118 | pub const SIGTSTP: c_int = 18; |
| 119 | pub const SIGCONT: c_int = 19; |
| 120 | pub const SIGCHLD: c_int = 20; |
| 121 | pub const SIGCLD: c_int = 20; |
| 122 | pub const SIGTTIN: c_int = 21; |
| 123 | pub const SIGTTOU: c_int = 22; |
| 124 | pub const SIGIO: c_int = 23; |
| 125 | pub const SIGPOLL: c_int = 23; |
| 126 | pub const SIGXCPU: c_int = 24; |
| 127 | pub const SIGXFSZ: c_int = 25; |
| 128 | pub const SIGVTALRM: c_int = 26; |
| 129 | pub const SIGPROF: c_int = 27; |
| 130 | pub const SIGWINCH: c_int = 28; |
| 131 | pub const SIGLOST: c_int = 29; |
| 132 | pub const SIGUSR1: c_int = 30; |
| 133 | pub const SIGUSR2: c_int = 31; |
| 134 | pub const NSIG: c_int = 32; |
| 135 | pub const CLOCK_ENABLED: c_uint = 1; |
| 136 | pub const CLOCK_DISABLED: c_uint = 0; |
| 137 | pub const CLOCK_ALLOWED: c_uint = 1; |
| 138 | pub const CLOCK_DISALLOWED: c_uint = 0; |
| 139 | pub const TIMER_ABSTIME: c_uint = 4; |
| 140 | pub const SOL_SOCKET: c_int = 65535; |
| 141 | pub const MSG_OOB: c_int = 1; |
| 142 | pub const MSG_PEEK: c_int = 2; |
| 143 | pub const MSG_DONTWAIT: c_int = 4; |
| 144 | pub const MSG_DONTROUTE: c_int = 0; |
| 145 | pub const MSG_WAITALL: c_int = 0; |
| 146 | pub const MSG_MORE: c_int = 0; |
| 147 | pub const MSG_NOSIGNAL: c_int = 0; |
| 148 | pub const SOL_CONFIG: c_uint = 65534; |
| 149 | |
| 150 | pub const PTHREAD_STACK_MIN: size_t = 4096; |
| 151 | pub const WNOHANG: c_int = 1; |
| 152 | |
| 153 | pub const POLLIN: c_int = 0x0001; |
| 154 | pub const POLLPRI: c_int = 0x0002; |
| 155 | pub const POLLOUT: c_int = 0x0008; |
| 156 | pub const POLLRDNORM: c_int = 0x0040; |
| 157 | pub const POLLWRNORM: c_int = POLLOUT; |
| 158 | pub const POLLRDBAND: c_int = 0x0080; |
| 159 | pub const POLLWRBAND: c_int = 0x0100; |
| 160 | /// POLLERR behavior on 3DS+HorizonOS is unclear, and it may be unsupported. |
| 161 | pub const POLLERR: c_int = 0x0008; |
| 162 | /// POLLHUP behavior on 3DS+HorizonOS is unclear, and it may be unsupported. |
| 163 | pub const POLLHUP: c_int = 0x0010; |
| 164 | pub const POLLNVAL: c_int = 0x0020; |
| 165 | |
| 166 | pub const EAI_AGAIN: c_int = 2; |
| 167 | pub const EAI_BADFLAGS: c_int = 3; |
| 168 | pub const EAI_FAIL: c_int = 4; |
| 169 | pub const EAI_SERVICE: c_int = 9; |
| 170 | pub const EAI_SYSTEM: c_int = 11; |
| 171 | pub const EAI_BADHINTS: c_int = 12; |
| 172 | pub const EAI_PROTOCOL: c_int = 13; |
| 173 | pub const EAI_OVERFLOW: c_int = 14; |
| 174 | |
| 175 | /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) |
| 176 | /// for details. |
| 177 | pub const EAI_MAX: c_int = 15; |
| 178 | |
| 179 | pub const AF_UNIX: c_int = 1; |
| 180 | pub const AF_INET6: c_int = 23; |
| 181 | |
| 182 | pub const FIONBIO: c_ulong = 1; |
| 183 | |
| 184 | pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); |
| 185 | |
| 186 | // For pthread get/setschedparam |
| 187 | pub const SCHED_FIFO: c_int = 1; |
| 188 | pub const SCHED_RR: c_int = 2; |
| 189 | |
| 190 | // For getrandom() |
| 191 | pub const GRND_NONBLOCK: c_uint = 0x1; |
| 192 | pub const GRND_RANDOM: c_uint = 0x2; |
| 193 | |
| 194 | // Horizon OS works doesn't or can't hold any of this information |
| 195 | safe_f! { |
| 196 | pub const safe fn WIFSTOPPED(_status: c_int) -> bool { |
| 197 | false |
| 198 | } |
| 199 | |
| 200 | pub const safe fn WSTOPSIG(_status: c_int) -> c_int { |
| 201 | 0 |
| 202 | } |
| 203 | |
| 204 | pub const safe fn WIFCONTINUED(_status: c_int) -> bool { |
| 205 | true |
| 206 | } |
| 207 | |
| 208 | pub const safe fn WIFSIGNALED(_status: c_int) -> bool { |
| 209 | false |
| 210 | } |
| 211 | |
| 212 | pub const safe fn WTERMSIG(_status: c_int) -> c_int { |
| 213 | 0 |
| 214 | } |
| 215 | |
| 216 | pub const safe fn WIFEXITED(_status: c_int) -> bool { |
| 217 | true |
| 218 | } |
| 219 | |
| 220 | pub const safe fn WEXITSTATUS(_status: c_int) -> c_int { |
| 221 | 0 |
| 222 | } |
| 223 | |
| 224 | pub const safe fn WCOREDUMP(_status: c_int) -> bool { |
| 225 | false |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | extern "C" { |
| 230 | pub fn pthread_create( |
| 231 | native: *mut crate::pthread_t, |
| 232 | attr: *const crate::pthread_attr_t, |
| 233 | f: extern "C" fn(_: *mut c_void) -> *mut c_void, |
| 234 | value: *mut c_void, |
| 235 | ) -> c_int; |
| 236 | |
| 237 | pub fn pthread_attr_getschedparam( |
| 238 | attr: *const crate::pthread_attr_t, |
| 239 | param: *mut sched_param, |
| 240 | ) -> c_int; |
| 241 | |
| 242 | pub fn pthread_attr_setschedparam( |
| 243 | attr: *mut crate::pthread_attr_t, |
| 244 | param: *const sched_param, |
| 245 | ) -> c_int; |
| 246 | |
| 247 | pub fn pthread_attr_getprocessorid_np( |
| 248 | attr: *const crate::pthread_attr_t, |
| 249 | processor_id: *mut c_int, |
| 250 | ) -> c_int; |
| 251 | |
| 252 | pub fn pthread_attr_setprocessorid_np( |
| 253 | attr: *mut crate::pthread_attr_t, |
| 254 | processor_id: c_int, |
| 255 | ) -> c_int; |
| 256 | |
| 257 | pub fn pthread_getschedparam( |
| 258 | native: crate::pthread_t, |
| 259 | policy: *mut c_int, |
| 260 | param: *mut crate::sched_param, |
| 261 | ) -> c_int; |
| 262 | |
| 263 | pub fn pthread_setschedparam( |
| 264 | native: crate::pthread_t, |
| 265 | policy: c_int, |
| 266 | param: *const crate::sched_param, |
| 267 | ) -> c_int; |
| 268 | |
| 269 | pub fn pthread_condattr_getclock( |
| 270 | attr: *const crate::pthread_condattr_t, |
| 271 | clock_id: *mut crate::clockid_t, |
| 272 | ) -> c_int; |
| 273 | |
| 274 | pub fn pthread_condattr_setclock( |
| 275 | attr: *mut crate::pthread_condattr_t, |
| 276 | clock_id: crate::clockid_t, |
| 277 | ) -> c_int; |
| 278 | |
| 279 | pub fn pthread_getprocessorid_np() -> c_int; |
| 280 | |
| 281 | pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; |
| 282 | |
| 283 | pub fn gethostid() -> c_long; |
| 284 | } |
| 285 | |
| 286 | pub use crate::unix::newlib::generic::dirent; |