From 8670663952da277fe719e3af6fa64396a20e02e6 Mon Sep 17 00:00:00 2001 From: Aphek Date: Sun, 25 Jun 2023 19:18:05 -0300 Subject: [PATCH 1/2] Add missing PS Vita definitions, fix some unused ones --- src/unix/newlib/mod.rs | 49 +++++++++++++++++++++++++++++-------- src/unix/newlib/vita/mod.rs | 27 +++++++++++++++++--- 2 files changed, 62 insertions(+), 14 deletions(-) diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index ce84f1421f0ea..9769a0ae2e2b2 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -546,8 +546,16 @@ pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast -pub const TCP_NODELAY: ::c_int = 8193; -pub const TCP_MAXSEG: ::c_int = 8194; +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub const TCP_NODELAY: ::c_int = 1; + pub const TCP_MAXSEG: ::c_int = 2; + } else { + pub const TCP_NODELAY: ::c_int = 8193; + pub const TCP_MAXSEG: ::c_int = 8194; + } +} + pub const TCP_NOPUSH: ::c_int = 4; pub const TCP_NOOPT: ::c_int = 8; pub const TCP_KEEPIDLE: ::c_int = 256; @@ -561,13 +569,25 @@ cfg_if! { pub const IP_TOS: ::c_int = 3; } } -pub const IP_TTL: ::c_int = 8; +cfg_if! { + if #[cfg(target_os = "vita")] { + pub const IP_TTL: ::c_int = 4; + } else { + pub const IP_TTL: ::c_int = 8; + } +} pub const IP_MULTICAST_IF: ::c_int = 9; pub const IP_MULTICAST_TTL: ::c_int = 10; pub const IP_MULTICAST_LOOP: ::c_int = 11; -pub const IP_ADD_MEMBERSHIP: ::c_int = 11; -pub const IP_DROP_MEMBERSHIP: ::c_int = 12; - +cfg_if! { + if #[cfg(target_os = "vita")] { + pub const IP_ADD_MEMBERSHIP: ::c_int = 12; + pub const IP_DROP_MEMBERSHIP: ::c_int = 13; + } else { + pub const IP_ADD_MEMBERSHIP: ::c_int = 11; + pub const IP_DROP_MEMBERSHIP: ::c_int = 12; + } +} pub const IPV6_UNICAST_HOPS: ::c_int = 4; pub const IPV6_MULTICAST_IF: ::c_int = 9; pub const IPV6_MULTICAST_HOPS: ::c_int = 10; @@ -598,10 +618,19 @@ pub const NI_NAMEREQD: ::c_int = 4; pub const NI_NUMERICSERV: ::c_int = 0; pub const NI_DGRAM: ::c_int = 0; -pub const EAI_FAMILY: ::c_int = -303; -pub const EAI_MEMORY: ::c_int = -304; -pub const EAI_NONAME: ::c_int = -305; -pub const EAI_SOCKTYPE: ::c_int = -307; +cfg_if! { + if #[cfg(target_os = "vita")] { + pub const EAI_FAMILY: ::c_int = -6; + pub const EAI_MEMORY: ::c_int = -10; + pub const EAI_NONAME: ::c_int = -2; + pub const EAI_SOCKTYPE: ::c_int = -7; + } else { + pub const EAI_FAMILY: ::c_int = -303; + pub const EAI_MEMORY: ::c_int = -304; + pub const EAI_NONAME: ::c_int = -305; + pub const EAI_SOCKTYPE: ::c_int = -307; + } +} pub const EXIT_SUCCESS: ::c_int = 0; pub const EXIT_FAILURE: ::c_int = 1; diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 6e2e4d3ebe89f..d583030bf19a4 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -9,6 +9,16 @@ pub type c_ulong = u32; pub type sigset_t = ::c_ulong; s! { + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::c_int, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::socklen_t, + pub msg_flags: ::c_int, + } + pub struct sockaddr { pub sa_len: u8, pub sa_family: ::sa_family_t, @@ -72,11 +82,19 @@ s! { pub const AF_UNIX: ::c_int = 1; pub const AF_INET6: ::c_int = 24; +pub const SOCK_RAW: ::c_int = 3; +pub const SOCK_RDM: ::c_int = 4; +pub const SOCK_SEQPACKET: ::c_int = 5; + pub const FIONBIO: ::c_ulong = 1; pub const POLLIN: ::c_short = 0x0001; pub const POLLPRI: ::c_short = POLLIN; pub const POLLOUT: ::c_short = 0x0004; +pub const POLLRDNORM: ::c_short = POLLIN; +pub const POLLRDBAND: ::c_short = POLLIN; +pub const POLLWRNORM: ::c_short = POLLOUT; +pub const POLLWRBAND: ::c_short = POLLOUT; pub const POLLERR: ::c_short = 0x0008; pub const POLLHUP: ::c_short = 0x0010; pub const POLLNVAL: ::c_short = 0x0020; @@ -125,15 +143,11 @@ pub const SIGALRM: ::c_int = 14; pub const SIGTERM: ::c_int = 15; pub const EAI_BADFLAGS: ::c_int = -1; -pub const EAI_NONAME: ::c_int = -2; pub const EAI_AGAIN: ::c_int = -3; pub const EAI_FAIL: ::c_int = -4; pub const EAI_NODATA: ::c_int = -5; -pub const EAI_FAMILY: ::c_int = -6; -pub const EAI_SOCKTYPE: ::c_int = -7; pub const EAI_SERVICE: ::c_int = -8; pub const EAI_ADDRFAMILY: ::c_int = -9; -pub const EAI_MEMORY: ::c_int = -10; pub const EAI_SYSTEM: ::c_int = -11; pub const EAI_OVERFLOW: ::c_int = -12; @@ -141,11 +155,16 @@ pub const _SC_PAGESIZE: ::c_int = 8; pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51; pub const PTHREAD_STACK_MIN: ::size_t = 32 * 1024; +pub const IP_HDRINCL: ::c_int = 2; + extern "C" { pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; + pub fn sendmsg(s: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(s: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; + pub fn pthread_create( native: *mut ::pthread_t, attr: *const ::pthread_attr_t, From 4dcb762a97b48d7df81e19de716ef32403645610 Mon Sep 17 00:00:00 2001 From: Aphek Date: Thu, 29 Jun 2023 23:37:31 -0300 Subject: [PATCH 2/2] Fix cfg's target_os --- src/unix/newlib/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 9769a0ae2e2b2..5dad518053222 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -547,7 +547,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 = "horizon")] { + if #[cfg(target_os = "vita")] { pub const TCP_NODELAY: ::c_int = 1; pub const TCP_MAXSEG: ::c_int = 2; } else {