Skip to content

Commit 09bbb91

Browse files
committed
Auto merge of #3284 - pheki:add-vita-definitions, r=JohnTitor
Add missing PS Vita definitions, fix some unused ones This PR improves vita's newlib support for std by adding some missing definitions and fixing some duplicated ones (e.g. `EAI_NONAME` from `src/unix/newlib/vita/mod.rs` was not being used as it was already defined on `src/unix/newlib/mod.rs`) Previous work: #3209 #3255 cc `@nikarh`
2 parents 92e5d67 + 4dcb762 commit 09bbb91

File tree

2 files changed

+62
-14
lines changed

2 files changed

+62
-14
lines changed

src/unix/newlib/mod.rs

+39-10
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,16 @@ pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
546546
pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
547547
pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
548548

549-
pub const TCP_NODELAY: ::c_int = 8193;
550-
pub const TCP_MAXSEG: ::c_int = 8194;
549+
cfg_if! {
550+
if #[cfg(target_os = "vita")] {
551+
pub const TCP_NODELAY: ::c_int = 1;
552+
pub const TCP_MAXSEG: ::c_int = 2;
553+
} else {
554+
pub const TCP_NODELAY: ::c_int = 8193;
555+
pub const TCP_MAXSEG: ::c_int = 8194;
556+
}
557+
}
558+
551559
pub const TCP_NOPUSH: ::c_int = 4;
552560
pub const TCP_NOOPT: ::c_int = 8;
553561
pub const TCP_KEEPIDLE: ::c_int = 256;
@@ -561,13 +569,25 @@ cfg_if! {
561569
pub const IP_TOS: ::c_int = 3;
562570
}
563571
}
564-
pub const IP_TTL: ::c_int = 8;
572+
cfg_if! {
573+
if #[cfg(target_os = "vita")] {
574+
pub const IP_TTL: ::c_int = 4;
575+
} else {
576+
pub const IP_TTL: ::c_int = 8;
577+
}
578+
}
565579
pub const IP_MULTICAST_IF: ::c_int = 9;
566580
pub const IP_MULTICAST_TTL: ::c_int = 10;
567581
pub const IP_MULTICAST_LOOP: ::c_int = 11;
568-
pub const IP_ADD_MEMBERSHIP: ::c_int = 11;
569-
pub const IP_DROP_MEMBERSHIP: ::c_int = 12;
570-
582+
cfg_if! {
583+
if #[cfg(target_os = "vita")] {
584+
pub const IP_ADD_MEMBERSHIP: ::c_int = 12;
585+
pub const IP_DROP_MEMBERSHIP: ::c_int = 13;
586+
} else {
587+
pub const IP_ADD_MEMBERSHIP: ::c_int = 11;
588+
pub const IP_DROP_MEMBERSHIP: ::c_int = 12;
589+
}
590+
}
571591
pub const IPV6_UNICAST_HOPS: ::c_int = 4;
572592
pub const IPV6_MULTICAST_IF: ::c_int = 9;
573593
pub const IPV6_MULTICAST_HOPS: ::c_int = 10;
@@ -598,10 +618,19 @@ pub const NI_NAMEREQD: ::c_int = 4;
598618
pub const NI_NUMERICSERV: ::c_int = 0;
599619
pub const NI_DGRAM: ::c_int = 0;
600620

601-
pub const EAI_FAMILY: ::c_int = -303;
602-
pub const EAI_MEMORY: ::c_int = -304;
603-
pub const EAI_NONAME: ::c_int = -305;
604-
pub const EAI_SOCKTYPE: ::c_int = -307;
621+
cfg_if! {
622+
if #[cfg(target_os = "vita")] {
623+
pub const EAI_FAMILY: ::c_int = -6;
624+
pub const EAI_MEMORY: ::c_int = -10;
625+
pub const EAI_NONAME: ::c_int = -2;
626+
pub const EAI_SOCKTYPE: ::c_int = -7;
627+
} else {
628+
pub const EAI_FAMILY: ::c_int = -303;
629+
pub const EAI_MEMORY: ::c_int = -304;
630+
pub const EAI_NONAME: ::c_int = -305;
631+
pub const EAI_SOCKTYPE: ::c_int = -307;
632+
}
633+
}
605634

606635
pub const EXIT_SUCCESS: ::c_int = 0;
607636
pub const EXIT_FAILURE: ::c_int = 1;

src/unix/newlib/vita/mod.rs

+23-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ pub type c_ulong = u32;
99
pub type sigset_t = ::c_ulong;
1010

1111
s! {
12+
pub struct msghdr {
13+
pub msg_name: *mut ::c_void,
14+
pub msg_namelen: ::socklen_t,
15+
pub msg_iov: *mut ::iovec,
16+
pub msg_iovlen: ::c_int,
17+
pub msg_control: *mut ::c_void,
18+
pub msg_controllen: ::socklen_t,
19+
pub msg_flags: ::c_int,
20+
}
21+
1222
pub struct sockaddr {
1323
pub sa_len: u8,
1424
pub sa_family: ::sa_family_t,
@@ -72,11 +82,19 @@ s! {
7282
pub const AF_UNIX: ::c_int = 1;
7383
pub const AF_INET6: ::c_int = 24;
7484

85+
pub const SOCK_RAW: ::c_int = 3;
86+
pub const SOCK_RDM: ::c_int = 4;
87+
pub const SOCK_SEQPACKET: ::c_int = 5;
88+
7589
pub const FIONBIO: ::c_ulong = 1;
7690

7791
pub const POLLIN: ::c_short = 0x0001;
7892
pub const POLLPRI: ::c_short = POLLIN;
7993
pub const POLLOUT: ::c_short = 0x0004;
94+
pub const POLLRDNORM: ::c_short = POLLIN;
95+
pub const POLLRDBAND: ::c_short = POLLIN;
96+
pub const POLLWRNORM: ::c_short = POLLOUT;
97+
pub const POLLWRBAND: ::c_short = POLLOUT;
8098
pub const POLLERR: ::c_short = 0x0008;
8199
pub const POLLHUP: ::c_short = 0x0010;
82100
pub const POLLNVAL: ::c_short = 0x0020;
@@ -125,27 +143,28 @@ pub const SIGALRM: ::c_int = 14;
125143
pub const SIGTERM: ::c_int = 15;
126144

127145
pub const EAI_BADFLAGS: ::c_int = -1;
128-
pub const EAI_NONAME: ::c_int = -2;
129146
pub const EAI_AGAIN: ::c_int = -3;
130147
pub const EAI_FAIL: ::c_int = -4;
131148
pub const EAI_NODATA: ::c_int = -5;
132-
pub const EAI_FAMILY: ::c_int = -6;
133-
pub const EAI_SOCKTYPE: ::c_int = -7;
134149
pub const EAI_SERVICE: ::c_int = -8;
135150
pub const EAI_ADDRFAMILY: ::c_int = -9;
136-
pub const EAI_MEMORY: ::c_int = -10;
137151
pub const EAI_SYSTEM: ::c_int = -11;
138152
pub const EAI_OVERFLOW: ::c_int = -12;
139153

140154
pub const _SC_PAGESIZE: ::c_int = 8;
141155
pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51;
142156
pub const PTHREAD_STACK_MIN: ::size_t = 32 * 1024;
143157

158+
pub const IP_HDRINCL: ::c_int = 2;
159+
144160
extern "C" {
145161
pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
146162
pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
147163
pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
148164

165+
pub fn sendmsg(s: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t;
166+
pub fn recvmsg(s: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t;
167+
149168
pub fn pthread_create(
150169
native: *mut ::pthread_t,
151170
attr: *const ::pthread_attr_t,

0 commit comments

Comments
 (0)