Skip to content

Commit b1f04a6

Browse files
committed
ARMv6K Horizon OS support
1 parent 8bba79c commit b1f04a6

File tree

2 files changed

+196
-0
lines changed

2 files changed

+196
-0
lines changed

src/unix/newlib/horizon/mod.rs

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
//! ARMv6K Nintendo 3DS C Newlib definitions
2+
3+
pub type c_char = u8;
4+
pub type c_long = i32;
5+
pub type c_ulong = u32;
6+
7+
pub type wchar_t = ::c_uint;
8+
9+
pub type in_port_t = ::c_ushort;
10+
pub type u_register_t = ::c_uint;
11+
pub type u_char = ::c_uchar;
12+
pub type u_short = ::c_ushort;
13+
pub type u_int = ::c_uint;
14+
pub type u_long = c_ulong;
15+
pub type ushort = ::c_ushort;
16+
pub type uint = ::c_uint;
17+
pub type ulong = c_ulong;
18+
pub type clock_t = c_ulong;
19+
pub type daddr_t = c_long;
20+
pub type caddr_t = *mut c_char;
21+
pub type sbintime_t = ::c_longlong;
22+
23+
pub const SIGEV_NONE: ::c_int = 1;
24+
pub const SIGEV_SIGNAL: ::c_int = 2;
25+
pub const SIGEV_THREAD: ::c_int = 3;
26+
pub const SA_NOCLDSTOP: ::c_int = 1;
27+
pub const MINSIGSTKSZ: ::c_int = 2048;
28+
pub const SIGSTKSZ: ::c_int = 8192;
29+
pub const SS_ONSTACK: ::c_int = 1;
30+
pub const SS_DISABLE: ::c_int = 2;
31+
pub const SIG_SETMASK: ::c_int = 0;
32+
pub const SIG_BLOCK: ::c_int = 1;
33+
pub const SIG_UNBLOCK: ::c_int = 2;
34+
pub const SIGHUP: ::c_int = 1;
35+
pub const SIGINT: ::c_int = 2;
36+
pub const SIGQUIT: ::c_int = 3;
37+
pub const SIGILL: ::c_int = 4;
38+
pub const SIGTRAP: ::c_int = 5;
39+
pub const SIGABRT: ::c_int = 6;
40+
pub const SIGEMT: ::c_int = 7;
41+
pub const SIGFPE: ::c_int = 8;
42+
pub const SIGKILL: ::c_int = 9;
43+
pub const SIGBUS: ::c_int = 10;
44+
pub const SIGSEGV: ::c_int = 11;
45+
pub const SIGSYS: ::c_int = 12;
46+
pub const SIGPIPE: ::c_int = 13;
47+
pub const SIGALRM: ::c_int = 14;
48+
pub const SIGTERM: ::c_int = 15;
49+
pub const SIGURG: ::c_int = 16;
50+
pub const SIGSTOP: ::c_int = 17;
51+
pub const SIGTSTP: ::c_int = 18;
52+
pub const SIGCONT: ::c_int = 19;
53+
pub const SIGCHLD: ::c_int = 20;
54+
pub const SIGCLD: ::c_int = 20;
55+
pub const SIGTTIN: ::c_int = 21;
56+
pub const SIGTTOU: ::c_int = 22;
57+
pub const SIGIO: ::c_int = 23;
58+
pub const SIGPOLL: ::c_int = 23;
59+
pub const SIGXCPU: ::c_int = 24;
60+
pub const SIGXFSZ: ::c_int = 25;
61+
pub const SIGVTALRM: ::c_int = 26;
62+
pub const SIGPROF: ::c_int = 27;
63+
pub const SIGWINCH: ::c_int = 28;
64+
pub const SIGLOST: ::c_int = 29;
65+
pub const SIGUSR1: ::c_int = 30;
66+
pub const SIGUSR2: ::c_int = 31;
67+
pub const NSIG: ::c_int = 32;
68+
pub const CLOCK_ENABLED: ::c_uint = 1;
69+
pub const CLOCK_DISABLED: ::c_uint = 0;
70+
pub const CLOCK_ALLOWED: ::c_uint = 1;
71+
pub const CLOCK_DISALLOWED: ::c_uint = 0;
72+
pub const TIMER_ABSTIME: ::c_uint = 4;
73+
pub const SOL_SOCKET: ::c_int = 65535;
74+
pub const MSG_OOB: ::c_int = 1;
75+
pub const MSG_PEEK: ::c_int = 2;
76+
pub const MSG_DONTWAIT: ::c_int = 4;
77+
pub const MSG_DONTROUTE: ::c_int = 0;
78+
pub const MSG_WAITALL: ::c_int = 0;
79+
pub const MSG_MORE: ::c_int = 0;
80+
pub const MSG_NOSIGNAL: ::c_int = 0;
81+
pub const SOL_CONFIG: ::c_uint = 65534;
82+
83+
pub const _SC_PAGESIZE: ::c_int = 8;
84+
pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51;
85+
86+
pub const PTHREAD_STACK_MIN: ::size_t = 4096;
87+
pub const WNOHANG: ::c_int = 1;
88+
89+
pub const POLLIN: ::c_short = 0x0001;
90+
pub const POLLPRI: ::c_short = 0x0002;
91+
pub const POLLOUT: ::c_short = 0x0004;
92+
pub const POLLRDNORM: ::c_short = 0x0040;
93+
pub const POLLWRNORM: ::c_short = POLLOUT;
94+
pub const POLLRDBAND: ::c_short = 0x0080;
95+
pub const POLLWRBAND: ::c_short = 0x0100;
96+
pub const POLLERR: ::c_short = 0x0008;
97+
pub const POLLHUP: ::c_short = 0x0010;
98+
pub const POLLNVAL: ::c_short = 0x0020;
99+
100+
pub const EAI_AGAIN: ::c_int = 2;
101+
pub const EAI_BADFLAGS: ::c_int = 3;
102+
pub const EAI_FAIL: ::c_int = 4;
103+
pub const EAI_SERVICE: ::c_int = 9;
104+
pub const EAI_SYSTEM: ::c_int = 11;
105+
pub const EAI_BADHINTS: ::c_int = 12;
106+
pub const EAI_PROTOCOL: ::c_int = 13;
107+
pub const EAI_OVERFLOW: ::c_int = 14;
108+
pub const EAI_MAX: ::c_int = 15;
109+
110+
pub const AF_UNIX: ::c_int = 1;
111+
pub const AF_INET6: ::c_int = 23;
112+
113+
pub const FIONBIO: ::c_ulong = 1;
114+
115+
pub const RTLD_DEFAULT: *mut ::c_void = 0 as *mut ::c_void;
116+
117+
// External implementations are needed to use networking and threading.
118+
s! {
119+
pub struct sockaddr {
120+
pub sa_family: ::sa_family_t,
121+
pub sa_data: [::c_char; 14],
122+
}
123+
124+
pub struct sockaddr_storage {
125+
pub ss_family: ::sa_family_t,
126+
pub __ss_padding: [c_char; 26usize],
127+
}
128+
129+
pub struct sockaddr_in {
130+
pub sin_family: ::sa_family_t,
131+
pub sin_port: in_port_t,
132+
pub sin_addr: ::in_addr,
133+
pub sin_zero: [::c_uchar; 8usize],
134+
}
135+
136+
pub struct sockaddr_in6 {
137+
pub sin6_family: ::sa_family_t,
138+
pub sin6_port: ::in_port_t,
139+
pub sin6_flowinfo: u32,
140+
pub sin6_addr: ::in6_addr,
141+
pub sin6_scope_id: u32,
142+
}
143+
144+
pub struct sockaddr_un {
145+
pub sun_len: ::c_uchar,
146+
pub sun_family: ::sa_family_t,
147+
pub sun_path: [::c_char; 104usize],
148+
}
149+
}
150+
151+
// Horizon OS works doesn't or can't hold any of this information
152+
safe_f! {
153+
pub {const} fn WIFSTOPPED(_status: ::c_int) -> bool {
154+
false
155+
}
156+
157+
pub {const} fn WSTOPSIG(_status: ::c_int) -> ::c_int {
158+
0
159+
}
160+
161+
pub {const} fn WIFCONTINUED(_status: ::c_int) -> bool {
162+
true
163+
}
164+
165+
pub {const} fn WIFSIGNALED(_status: ::c_int) -> bool {
166+
false
167+
}
168+
169+
pub {const} fn WTERMSIG(_status: ::c_int) -> ::c_int {
170+
0
171+
}
172+
173+
pub {const} fn WIFEXITED(_status: ::c_int) -> bool {
174+
true
175+
}
176+
177+
pub {const} fn WEXITSTATUS(_status: ::c_int) -> ::c_int {
178+
0
179+
}
180+
181+
pub {const} fn WCOREDUMP(_status: ::c_int) -> bool {
182+
false
183+
}
184+
}
185+
186+
extern "C" {
187+
pub fn pthread_create(
188+
native: *mut ::pthread_t,
189+
attr: *const ::pthread_attr_t,
190+
f: extern "C" fn(_: *mut ::c_void) -> *mut ::c_void,
191+
value: *mut ::c_void,
192+
) -> ::c_int;
193+
}

src/unix/newlib/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,9 @@ cfg_if! {
706706
if #[cfg(target_os = "espidf")] {
707707
mod espidf;
708708
pub use self::espidf::*;
709+
} else if #[cfg(target_os = "horizon")] {
710+
mod horizon;
711+
pub use self::horizon::*;
709712
} else if #[cfg(target_arch = "arm")] {
710713
mod arm;
711714
pub use self::arm::*;

0 commit comments

Comments
 (0)