diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs index 9b5978fc538c3..147d08d34187a 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -4,11 +4,13 @@ pub type clock_t = c_long; pub type wchar_t = u32; s! { + #[cfg(not(target_os = "rtems"))] pub struct sockaddr { pub sa_family: crate::sa_family_t, pub sa_data: [c_char; 14], } + #[cfg(not(target_os = "rtems"))] pub struct sockaddr_in6 { pub sin6_family: crate::sa_family_t, pub sin6_port: crate::in_port_t, @@ -17,6 +19,7 @@ s! { pub sin6_scope_id: u32, } + #[cfg(not(target_os = "rtems"))] pub struct sockaddr_in { pub sin_family: crate::sa_family_t, pub sin_port: crate::in_port_t, @@ -24,31 +27,48 @@ s! { pub sin_zero: [u8; 8], } + #[cfg(not(target_os = "rtems"))] pub struct sockaddr_storage { pub ss_family: crate::sa_family_t, __ss_padding: Padding<[u8; 26]>, } } +#[cfg(not(target_os = "rtems"))] pub const AF_INET6: c_int = 23; +#[cfg(not(target_os = "rtems"))] pub const FIONBIO: c_ulong = 1; +#[cfg(not(target_os = "rtems"))] pub const POLLIN: c_short = 0x1; +#[cfg(not(target_os = "rtems"))] pub const POLLPRI: c_short = 0x2; +#[cfg(not(target_os = "rtems"))] pub const POLLHUP: c_short = 0x4; +#[cfg(not(target_os = "rtems"))] pub const POLLERR: c_short = 0x8; +#[cfg(not(target_os = "rtems"))] pub const POLLOUT: c_short = 0x10; +#[cfg(not(target_os = "rtems"))] pub const POLLNVAL: c_short = 0x20; +#[cfg(not(target_os = "rtems"))] pub const SOL_SOCKET: c_int = 65535; +#[cfg(not(target_os = "rtems"))] pub const MSG_OOB: c_int = 1; +#[cfg(not(target_os = "rtems"))] pub const MSG_PEEK: c_int = 2; +#[cfg(not(target_os = "rtems"))] pub const MSG_DONTWAIT: c_int = 4; +#[cfg(not(target_os = "rtems"))] pub const MSG_DONTROUTE: c_int = 0; +#[cfg(not(target_os = "rtems"))] pub const MSG_WAITALL: c_int = 0; +#[cfg(not(target_os = "rtems"))] pub const MSG_MORE: c_int = 0; +#[cfg(not(target_os = "rtems"))] pub const MSG_NOSIGNAL: c_int = 0; pub use crate::unix::newlib::generic::{ diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index ee6abccedfb6a..6ec4be3d0ab7a 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -340,6 +340,8 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { cfg_if! { if #[cfg(target_os = "espidf")] { pub const NCCS: usize = 11; + } else if #[cfg(target_os = "rtems")] { + pub const NCCS: usize = 20; } else { pub const NCCS: usize = 32; } @@ -399,7 +401,7 @@ pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; cfg_if! { if #[cfg(any(target_os = "horizon", target_os = "espidf"))] { pub const FD_SETSIZE: c_int = 64; - } else if #[cfg(target_os = "vita")] { + } else if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const FD_SETSIZE: c_int = 256; } else { pub const FD_SETSIZE: c_int = 1024; @@ -531,7 +533,7 @@ pub const O_NONBLOCK: c_int = 16384; pub const O_ACCMODE: c_int = 3; cfg_if! { - if #[cfg(target_os = "espidf")] { + if #[cfg(any(target_os = "espidf", target_os = "rtems"))] { pub const O_CLOEXEC: c_int = 0x40000; } else { pub const O_CLOEXEC: c_int = 0x80000; @@ -577,6 +579,8 @@ pub const PF_INET: c_int = 2; cfg_if! { if #[cfg(target_os = "espidf")] { pub const PF_INET6: c_int = 10; + } else if #[cfg(target_os = "rtems")] { + pub const PF_INET6: c_int = 28; } else { pub const PF_INET6: c_int = 23; } @@ -638,7 +642,13 @@ cfg_if! { } pub const SO_TYPE: c_int = 0x1008; -pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; +cfg_if! { + if #[cfg(target_os = "rtems")] { + pub const SOCK_CLOEXEC: c_int = 0x10000000; + } else { + pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; + } +} pub const INET_ADDRSTRLEN: c_int = 16; @@ -662,7 +672,7 @@ pub const IFF_ALTPHYS: c_int = IFF_LINK2; // use alternate physical connection pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast cfg_if! { - if #[cfg(target_os = "vita")] { + if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const TCP_NODELAY: c_int = 1; pub const TCP_MAXSEG: c_int = 2; } else if #[cfg(target_os = "espidf")] { @@ -698,7 +708,7 @@ cfg_if! { } } cfg_if! { - if #[cfg(target_os = "vita")] { + if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const IP_TTL: c_int = 4; } else if #[cfg(target_os = "espidf")] { pub const IP_TTL: c_int = 2; @@ -720,7 +730,7 @@ cfg_if! { } cfg_if! { - if #[cfg(target_os = "vita")] { + if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const IP_ADD_MEMBERSHIP: c_int = 12; pub const IP_DROP_MEMBERSHIP: c_int = 13; } else if #[cfg(target_os = "espidf")] { @@ -755,6 +765,11 @@ cfg_if! { pub const NO_DATA: c_int = 211; pub const NO_RECOVERY: c_int = 212; pub const TRY_AGAIN: c_int = 213; + } else if #[cfg(target_os = "rtems")] { + pub const HOST_NOT_FOUND: c_int = 1; + pub const TRY_AGAIN: c_int = 2; + pub const NO_RECOVERY: c_int = 3; + pub const NO_DATA: c_int = 4; } else { pub const HOST_NOT_FOUND: c_int = 1; pub const NO_DATA: c_int = 2; @@ -762,7 +777,13 @@ cfg_if! { pub const TRY_AGAIN: c_int = 4; } } -pub const NO_ADDRESS: c_int = 2; +cfg_if! { + if #[cfg(target_os = "rtems")] { + pub const NO_ADDRESS: c_int = NO_DATA; + } else { + pub const NO_ADDRESS: c_int = 2; + } +} pub const AI_PASSIVE: c_int = 1; pub const AI_CANONNAME: c_int = 2; @@ -771,6 +792,9 @@ cfg_if! { if #[cfg(target_os = "espidf")] { pub const AI_NUMERICSERV: c_int = 8; pub const AI_ADDRCONFIG: c_int = 64; + } else if #[cfg(target_os = "rtems")] { + pub const AI_NUMERICSERV: c_int = 0x00000008; + pub const AI_ADDRCONFIG: c_int = 0x00000400; } else { pub const AI_NUMERICSERV: c_int = 0; pub const AI_ADDRCONFIG: c_int = 0; @@ -783,7 +807,7 @@ pub const NI_NOFQDN: c_int = 1; pub const NI_NUMERICHOST: c_int = 2; pub const NI_NAMEREQD: c_int = 4; cfg_if! { - if #[cfg(target_os = "espidf")] { + if #[cfg(any(target_os = "espidf", target_os = "rtems"))] { pub const NI_NUMERICSERV: c_int = 8; pub const NI_DGRAM: c_int = 16; } else { @@ -799,6 +823,11 @@ cfg_if! { pub const EAI_MEMORY: c_int = 203; pub const EAI_NONAME: c_int = 200; pub const EAI_SOCKTYPE: c_int = 10; + } else if #[cfg(target_os = "rtems")] { + pub const EAI_FAMILY: c_int = 5; + pub const EAI_MEMORY: c_int = 6; + pub const EAI_NONAME: c_int = 8; + pub const EAI_SOCKTYPE: c_int = 10; } else if #[cfg(not(target_os = "vita"))] { pub const EAI_FAMILY: c_int = -303; pub const EAI_MEMORY: c_int = -304; diff --git a/src/unix/newlib/rtems/mod.rs b/src/unix/newlib/rtems/mod.rs index fca95f0e95e3e..6bfe435f66626 100644 --- a/src/unix/newlib/rtems/mod.rs +++ b/src/unix/newlib/rtems/mod.rs @@ -3,13 +3,65 @@ use crate::prelude::*; s! { + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: crate::sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: crate::sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + pub struct sockaddr_un { + pub sun_len: u8, pub sun_family: crate::sa_family_t, - pub sun_path: [c_char; 108usize], + pub sun_path: [c_char; 104usize], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: crate::sa_family_t, + __ss_pad1: Padding<[u8; 6]>, + __ss_align: i64, + __ss_pad2: Padding<[u8; 112]>, } } pub const AF_UNIX: c_int = 1; +pub const AF_INET6: c_int = 28; + +pub const FIONBIO: c_ulong = 0x8004667e; + +pub const POLLIN: c_short = 0x0001; +pub const POLLPRI: c_short = 0x0002; +pub const POLLOUT: c_short = 0x0004; +pub const POLLERR: c_short = 0x0008; +pub const POLLHUP: c_short = 0x0010; +pub const POLLNVAL: c_short = 0x0020; + +pub const SOL_SOCKET: c_int = 0xffff; + +pub const MSG_OOB: c_int = 0x1; +pub const MSG_PEEK: c_int = 0x2; +pub const MSG_DONTROUTE: c_int = 0x4; +pub const MSG_WAITALL: c_int = 0x40; +pub const MSG_DONTWAIT: c_int = 0x80; +pub const MSG_NOSIGNAL: c_int = 0x20000; +pub const MSG_MORE: c_int = 0; pub const RTLD_DEFAULT: *mut c_void = -2isize as *mut c_void;