interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / libc / src / unix / newlib / horizon / mod.rs

286 lines · 7765 bytes Raw Blame History
1//! ARMv6K Nintendo 3DS C Newlib definitions
2
3use crate::off_t;
4use crate::prelude::*;
5
6pub type wchar_t = c_uint;
7
8pub type u_register_t = c_uint;
9pub type u_char = c_uchar;
10pub type u_short = c_ushort;
11pub type u_int = c_uint;
12pub type u_long = c_ulong;
13pub type ushort = c_ushort;
14pub type uint = c_uint;
15pub type ulong = c_ulong;
16pub type clock_t = c_ulong;
17pub type daddr_t = c_long;
18pub type caddr_t = *mut c_char;
19pub type sbintime_t = c_longlong;
20pub type sigset_t = c_ulong;
21
22s! {
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
90pub const SIGEV_NONE: c_int = 1;
91pub const SIGEV_SIGNAL: c_int = 2;
92pub const SIGEV_THREAD: c_int = 3;
93pub const SA_NOCLDSTOP: c_int = 1;
94pub const MINSIGSTKSZ: c_int = 2048;
95pub const SIGSTKSZ: c_int = 8192;
96pub const SS_ONSTACK: c_int = 1;
97pub const SS_DISABLE: c_int = 2;
98pub const SIG_SETMASK: c_int = 0;
99pub const SIG_BLOCK: c_int = 1;
100pub const SIG_UNBLOCK: c_int = 2;
101pub const SIGHUP: c_int = 1;
102pub const SIGINT: c_int = 2;
103pub const SIGQUIT: c_int = 3;
104pub const SIGILL: c_int = 4;
105pub const SIGTRAP: c_int = 5;
106pub const SIGABRT: c_int = 6;
107pub const SIGEMT: c_int = 7;
108pub const SIGFPE: c_int = 8;
109pub const SIGKILL: c_int = 9;
110pub const SIGBUS: c_int = 10;
111pub const SIGSEGV: c_int = 11;
112pub const SIGSYS: c_int = 12;
113pub const SIGPIPE: c_int = 13;
114pub const SIGALRM: c_int = 14;
115pub const SIGTERM: c_int = 15;
116pub const SIGURG: c_int = 16;
117pub const SIGSTOP: c_int = 17;
118pub const SIGTSTP: c_int = 18;
119pub const SIGCONT: c_int = 19;
120pub const SIGCHLD: c_int = 20;
121pub const SIGCLD: c_int = 20;
122pub const SIGTTIN: c_int = 21;
123pub const SIGTTOU: c_int = 22;
124pub const SIGIO: c_int = 23;
125pub const SIGPOLL: c_int = 23;
126pub const SIGXCPU: c_int = 24;
127pub const SIGXFSZ: c_int = 25;
128pub const SIGVTALRM: c_int = 26;
129pub const SIGPROF: c_int = 27;
130pub const SIGWINCH: c_int = 28;
131pub const SIGLOST: c_int = 29;
132pub const SIGUSR1: c_int = 30;
133pub const SIGUSR2: c_int = 31;
134pub const NSIG: c_int = 32;
135pub const CLOCK_ENABLED: c_uint = 1;
136pub const CLOCK_DISABLED: c_uint = 0;
137pub const CLOCK_ALLOWED: c_uint = 1;
138pub const CLOCK_DISALLOWED: c_uint = 0;
139pub const TIMER_ABSTIME: c_uint = 4;
140pub const SOL_SOCKET: c_int = 65535;
141pub const MSG_OOB: c_int = 1;
142pub const MSG_PEEK: c_int = 2;
143pub const MSG_DONTWAIT: c_int = 4;
144pub const MSG_DONTROUTE: c_int = 0;
145pub const MSG_WAITALL: c_int = 0;
146pub const MSG_MORE: c_int = 0;
147pub const MSG_NOSIGNAL: c_int = 0;
148pub const SOL_CONFIG: c_uint = 65534;
149
150pub const PTHREAD_STACK_MIN: size_t = 4096;
151pub const WNOHANG: c_int = 1;
152
153pub const POLLIN: c_int = 0x0001;
154pub const POLLPRI: c_int = 0x0002;
155pub const POLLOUT: c_int = 0x0008;
156pub const POLLRDNORM: c_int = 0x0040;
157pub const POLLWRNORM: c_int = POLLOUT;
158pub const POLLRDBAND: c_int = 0x0080;
159pub const POLLWRBAND: c_int = 0x0100;
160/// POLLERR behavior on 3DS+HorizonOS is unclear, and it may be unsupported.
161pub const POLLERR: c_int = 0x0008;
162/// POLLHUP behavior on 3DS+HorizonOS is unclear, and it may be unsupported.
163pub const POLLHUP: c_int = 0x0010;
164pub const POLLNVAL: c_int = 0x0020;
165
166pub const EAI_AGAIN: c_int = 2;
167pub const EAI_BADFLAGS: c_int = 3;
168pub const EAI_FAIL: c_int = 4;
169pub const EAI_SERVICE: c_int = 9;
170pub const EAI_SYSTEM: c_int = 11;
171pub const EAI_BADHINTS: c_int = 12;
172pub const EAI_PROTOCOL: c_int = 13;
173pub const EAI_OVERFLOW: c_int = 14;
174
175/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
176/// for details.
177pub const EAI_MAX: c_int = 15;
178
179pub const AF_UNIX: c_int = 1;
180pub const AF_INET6: c_int = 23;
181
182pub const FIONBIO: c_ulong = 1;
183
184pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut();
185
186// For pthread get/setschedparam
187pub const SCHED_FIFO: c_int = 1;
188pub const SCHED_RR: c_int = 2;
189
190// For getrandom()
191pub const GRND_NONBLOCK: c_uint = 0x1;
192pub const GRND_RANDOM: c_uint = 0x2;
193
194// Horizon OS works doesn't or can't hold any of this information
195safe_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
229extern "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
286pub use crate::unix::newlib::generic::dirent;