Skip to content

Commit e03d938

Browse files
committed
Auto merge of #1481 - FenrirWolf:newlib-socket-fix, r=gnzlbg
Define newlib socket types by target arch This is a follow-up to #1477. As mentioned in that PR, the primary (only?) users of these newlib definitions are myself and @leo60228. This PR makes it so that my arm-based 3DS target keeps using the old socket definitions while leo's aarch64-based Switch target uses the BSD versions. The 3DS also has inverted definitions for `POLLHUP` and `POLLOUT` for whatever reason, so I figured I'd take care of that here too.
2 parents 50fbf0c + fd03747 commit e03d938

File tree

3 files changed

+58
-25
lines changed

3 files changed

+58
-25
lines changed

src/unix/newlib/aarch64/mod.rs

+28
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,31 @@ pub type wchar_t = u32;
33

44
pub type c_long = i64;
55
pub type c_ulong = u64;
6+
7+
s! {
8+
pub struct sockaddr {
9+
pub sa_len: u8,
10+
pub sa_family: ::sa_family_t,
11+
pub sa_data: [::c_char; 14],
12+
}
13+
14+
pub struct sockaddr_in6 {
15+
pub sin6_len: u8,
16+
pub sin6_family: ::sa_family_t,
17+
pub sin6_port: ::in_port_t,
18+
pub sin6_flowinfo: u32,
19+
pub sin6_addr: ::in6_addr,
20+
pub sin6_scope_id: u32,
21+
}
22+
23+
pub struct sockaddr_in {
24+
pub sin_len: u8,
25+
pub sin_family: ::sa_family_t,
26+
pub sin_port: ::in_port_t,
27+
pub sin_addr: ::in_addr,
28+
pub sin_zero: [::c_char; 8],
29+
}
30+
}
31+
32+
pub const POLLOUT: ::c_short = 0x4;
33+
pub const POLLHUP: ::c_short = 0x10;

src/unix/newlib/arm/mod.rs

+30
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,33 @@ pub type wchar_t = u32;
33

44
pub type c_long = i32;
55
pub type c_ulong = u32;
6+
7+
s! {
8+
pub struct sockaddr {
9+
pub sa_family: ::sa_family_t,
10+
pub sa_data: [::c_char; 14],
11+
}
12+
13+
pub struct sockaddr_in6 {
14+
pub sin6_family: ::sa_family_t,
15+
pub sin6_port: ::in_port_t,
16+
pub sin6_flowinfo: u32,
17+
pub sin6_addr: ::in6_addr,
18+
pub sin6_scope_id: u32,
19+
}
20+
21+
pub struct sockaddr_in {
22+
pub sin_family: ::sa_family_t,
23+
pub sin_port: ::in_port_t,
24+
pub sin_addr: ::in_addr,
25+
pub sin_zero: [u8; 8],
26+
}
27+
28+
pub struct sockaddr_storage {
29+
pub ss_family: ::sa_family_t,
30+
pub __ss_padding: [u8; 26],
31+
}
32+
}
33+
34+
pub const POLLOUT: ::c_short = 0x10;
35+
pub const POLLHUP: ::c_short = 0x4;

src/unix/newlib/mod.rs

-25
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,6 @@ pub type time_t = i32;
2525
pub type useconds_t = u32;
2626

2727
s! {
28-
pub struct sockaddr {
29-
pub sa_len: u8,
30-
pub sa_family: sa_family_t,
31-
pub sa_data: [::c_char; 14],
32-
}
33-
34-
pub struct sockaddr_in6 {
35-
pub sin6_len: u8,
36-
pub sin6_family: sa_family_t,
37-
pub sin6_port: ::in_port_t,
38-
pub sin6_flowinfo: u32,
39-
pub sin6_addr: ::in6_addr,
40-
pub sin6_scope_id: u32,
41-
}
42-
43-
pub struct sockaddr_in {
44-
pub sin_len: u8,
45-
pub sin_family: ::sa_family_t,
46-
pub sin_port: ::in_port_t,
47-
pub sin_addr: ::in_addr,
48-
pub sin_zero: [::c_char; 8],
49-
}
50-
5128
pub struct addrinfo {
5229
pub ai_flags: ::c_int,
5330
pub ai_family: ::c_int,
@@ -389,9 +366,7 @@ pub const O_CLOEXEC: ::c_int = 0x80000;
389366

390367
pub const POLLIN: ::c_short = 0x1;
391368
pub const POLLPRI: ::c_short = 0x2;
392-
pub const POLLOUT: ::c_short = 0x4;
393369
pub const POLLERR: ::c_short = 0x8;
394-
pub const POLLHUP: ::c_short = 0x10;
395370
pub const POLLNVAL: ::c_short = 0x20;
396371

397372
pub const RTLD_LAZY: ::c_int = 0x1;

0 commit comments

Comments
 (0)