summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeziu <meziu210@icloud.com>2021-09-14 19:24:38 +0200
committerAndrea Ciliberti <meziu210@icloud.com>2022-01-23 00:45:33 +0100
commitb1f04a69c2864d3ac143c341b3f1a1db273ed293 (patch)
tree2c3d047e55b5e1a0b87d9b8eede52da936e9dde3
parent8bba79c467c81073a9da736d00239f6dd70fc32b (diff)
downloadrust-libc-b1f04a69c2864d3ac143c341b3f1a1db273ed293.tar.gz
ARMv6K Horizon OS support
-rw-r--r--src/unix/newlib/horizon/mod.rs193
-rw-r--r--src/unix/newlib/mod.rs3
2 files changed, 196 insertions, 0 deletions
diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs
new file mode 100644
index 0000000000..e25bd82345
--- /dev/null
+++ b/src/unix/newlib/horizon/mod.rs
@@ -0,0 +1,193 @@
+//! ARMv6K Nintendo 3DS C Newlib definitions
+
+pub type c_char = u8;
+pub type c_long = i32;
+pub type c_ulong = u32;
+
+pub type wchar_t = ::c_uint;
+
+pub type in_port_t = ::c_ushort;
+pub type u_register_t = ::c_uint;
+pub type u_char = ::c_uchar;
+pub type u_short = ::c_ushort;
+pub type u_int = ::c_uint;
+pub type u_long = c_ulong;
+pub type ushort = ::c_ushort;
+pub type uint = ::c_uint;
+pub type ulong = c_ulong;
+pub type clock_t = c_ulong;
+pub type daddr_t = c_long;
+pub type caddr_t = *mut c_char;
+pub type sbintime_t = ::c_longlong;
+
+pub const SIGEV_NONE: ::c_int = 1;
+pub const SIGEV_SIGNAL: ::c_int = 2;
+pub const SIGEV_THREAD: ::c_int = 3;
+pub const SA_NOCLDSTOP: ::c_int = 1;
+pub const MINSIGSTKSZ: ::c_int = 2048;
+pub const SIGSTKSZ: ::c_int = 8192;
+pub const SS_ONSTACK: ::c_int = 1;
+pub const SS_DISABLE: ::c_int = 2;
+pub const SIG_SETMASK: ::c_int = 0;
+pub const SIG_BLOCK: ::c_int = 1;
+pub const SIG_UNBLOCK: ::c_int = 2;
+pub const SIGHUP: ::c_int = 1;
+pub const SIGINT: ::c_int = 2;
+pub const SIGQUIT: ::c_int = 3;
+pub const SIGILL: ::c_int = 4;
+pub const SIGTRAP: ::c_int = 5;
+pub const SIGABRT: ::c_int = 6;
+pub const SIGEMT: ::c_int = 7;
+pub const SIGFPE: ::c_int = 8;
+pub const SIGKILL: ::c_int = 9;
+pub const SIGBUS: ::c_int = 10;
+pub const SIGSEGV: ::c_int = 11;
+pub const SIGSYS: ::c_int = 12;
+pub const SIGPIPE: ::c_int = 13;
+pub const SIGALRM: ::c_int = 14;
+pub const SIGTERM: ::c_int = 15;
+pub const SIGURG: ::c_int = 16;
+pub const SIGSTOP: ::c_int = 17;
+pub const SIGTSTP: ::c_int = 18;
+pub const SIGCONT: ::c_int = 19;
+pub const SIGCHLD: ::c_int = 20;
+pub const SIGCLD: ::c_int = 20;
+pub const SIGTTIN: ::c_int = 21;
+pub const SIGTTOU: ::c_int = 22;
+pub const SIGIO: ::c_int = 23;
+pub const SIGPOLL: ::c_int = 23;
+pub const SIGXCPU: ::c_int = 24;
+pub const SIGXFSZ: ::c_int = 25;
+pub const SIGVTALRM: ::c_int = 26;
+pub const SIGPROF: ::c_int = 27;
+pub const SIGWINCH: ::c_int = 28;
+pub const SIGLOST: ::c_int = 29;
+pub const SIGUSR1: ::c_int = 30;
+pub const SIGUSR2: ::c_int = 31;
+pub const NSIG: ::c_int = 32;
+pub const CLOCK_ENABLED: ::c_uint = 1;
+pub const CLOCK_DISABLED: ::c_uint = 0;
+pub const CLOCK_ALLOWED: ::c_uint = 1;
+pub const CLOCK_DISALLOWED: ::c_uint = 0;
+pub const TIMER_ABSTIME: ::c_uint = 4;
+pub const SOL_SOCKET: ::c_int = 65535;
+pub const MSG_OOB: ::c_int = 1;
+pub const MSG_PEEK: ::c_int = 2;
+pub const MSG_DONTWAIT: ::c_int = 4;
+pub const MSG_DONTROUTE: ::c_int = 0;
+pub const MSG_WAITALL: ::c_int = 0;
+pub const MSG_MORE: ::c_int = 0;
+pub const MSG_NOSIGNAL: ::c_int = 0;
+pub const SOL_CONFIG: ::c_uint = 65534;
+
+pub const _SC_PAGESIZE: ::c_int = 8;
+pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51;
+
+pub const PTHREAD_STACK_MIN: ::size_t = 4096;
+pub const WNOHANG: ::c_int = 1;
+
+pub const POLLIN: ::c_short = 0x0001;
+pub const POLLPRI: ::c_short = 0x0002;
+pub const POLLOUT: ::c_short = 0x0004;
+pub const POLLRDNORM: ::c_short = 0x0040;
+pub const POLLWRNORM: ::c_short = POLLOUT;
+pub const POLLRDBAND: ::c_short = 0x0080;
+pub const POLLWRBAND: ::c_short = 0x0100;
+pub const POLLERR: ::c_short = 0x0008;
+pub const POLLHUP: ::c_short = 0x0010;
+pub const POLLNVAL: ::c_short = 0x0020;
+
+pub const EAI_AGAIN: ::c_int = 2;
+pub const EAI_BADFLAGS: ::c_int = 3;
+pub const EAI_FAIL: ::c_int = 4;
+pub const EAI_SERVICE: ::c_int = 9;
+pub const EAI_SYSTEM: ::c_int = 11;
+pub const EAI_BADHINTS: ::c_int = 12;
+pub const EAI_PROTOCOL: ::c_int = 13;
+pub const EAI_OVERFLOW: ::c_int = 14;
+pub const EAI_MAX: ::c_int = 15;
+
+pub const AF_UNIX: ::c_int = 1;
+pub const AF_INET6: ::c_int = 23;
+
+pub const FIONBIO: ::c_ulong = 1;
+
+pub const RTLD_DEFAULT: *mut ::c_void = 0 as *mut ::c_void;
+
+// External implementations are needed to use networking and threading.
+s! {
+ pub struct sockaddr {
+ pub sa_family: ::sa_family_t,
+ pub sa_data: [::c_char; 14],
+ }
+
+ pub struct sockaddr_storage {
+ pub ss_family: ::sa_family_t,
+ pub __ss_padding: [c_char; 26usize],
+ }
+
+ pub struct sockaddr_in {
+ pub sin_family: ::sa_family_t,
+ pub sin_port: in_port_t,
+ pub sin_addr: ::in_addr,
+ pub sin_zero: [::c_uchar; 8usize],
+ }
+
+ pub struct sockaddr_in6 {
+ pub sin6_family: ::sa_family_t,
+ pub sin6_port: ::in_port_t,
+ pub sin6_flowinfo: u32,
+ pub sin6_addr: ::in6_addr,
+ pub sin6_scope_id: u32,
+ }
+
+ pub struct sockaddr_un {
+ pub sun_len: ::c_uchar,
+ pub sun_family: ::sa_family_t,
+ pub sun_path: [::c_char; 104usize],
+ }
+}
+
+// Horizon OS works doesn't or can't hold any of this information
+safe_f! {
+ pub {const} fn WIFSTOPPED(_status: ::c_int) -> bool {
+ false
+ }
+
+ pub {const} fn WSTOPSIG(_status: ::c_int) -> ::c_int {
+ 0
+ }
+
+ pub {const} fn WIFCONTINUED(_status: ::c_int) -> bool {
+ true
+ }
+
+ pub {const} fn WIFSIGNALED(_status: ::c_int) -> bool {
+ false
+ }
+
+ pub {const} fn WTERMSIG(_status: ::c_int) -> ::c_int {
+ 0
+ }
+
+ pub {const} fn WIFEXITED(_status: ::c_int) -> bool {
+ true
+ }
+
+ pub {const} fn WEXITSTATUS(_status: ::c_int) -> ::c_int {
+ 0
+ }
+
+ pub {const} fn WCOREDUMP(_status: ::c_int) -> bool {
+ false
+ }
+}
+
+extern "C" {
+ pub fn pthread_create(
+ native: *mut ::pthread_t,
+ attr: *const ::pthread_attr_t,
+ f: extern "C" fn(_: *mut ::c_void) -> *mut ::c_void,
+ value: *mut ::c_void,
+ ) -> ::c_int;
+}
diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs
index 3a7cfa4a25..642c13f61c 100644
--- a/src/unix/newlib/mod.rs
+++ b/src/unix/newlib/mod.rs
@@ -706,6 +706,9 @@ cfg_if! {
if #[cfg(target_os = "espidf")] {
mod espidf;
pub use self::espidf::*;
+ } else if #[cfg(target_os = "horizon")] {
+ mod horizon;
+ pub use self::horizon::*;
} else if #[cfg(target_arch = "arm")] {
mod arm;
pub use self::arm::*;