Skip to content

Commit 47aa345

Browse files
committed
Fix 1.13.0 support by gating use of target_vendor
Use a custom cfg to gate devkitppc support behind rust version 1.33+
1 parent cd7b947 commit 47aa345

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ newer Rust features are only available on newer Rust toolchains:
5252
| `extra_traits` | 1.25.0 |
5353
| `core::ffi::c_void` | 1.30.0 |
5454
| `repr(packed(N))` | 1.33.0 |
55+
| `cfg(target_vendor)` | 1.33.0 |
5556

5657
## Platform support
5758

build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ fn main() {
6565
println!("cargo:rustc-cfg=libc_core_cvoid");
6666
}
6767

68-
// Rust >= 1.33 supports repr(packed(N))
68+
// Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor).
6969
if rustc_minor_ver >= 33 || rustc_dep_of_std {
7070
println!("cargo:rustc-cfg=libc_packedN");
71+
println!("cargo:rustc-cfg=libc_cfg_target_vendor");
7172
}
7273

7374
// #[thread_local] is currently unstable

src/unix/mod.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,13 @@ extern "C" {
596596
pub fn getchar_unlocked() -> ::c_int;
597597
pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
598598

599-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
599+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
600+
target_vendor = "nintendo")))]
600601
#[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
601602
#[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")]
602603
pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
603-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
604+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
605+
target_vendor = "nintendo")))]
604606
#[cfg_attr(
605607
all(target_os = "macos", target_arch = "x86"),
606608
link_name = "connect$UNIX2003"
@@ -616,7 +618,8 @@ extern "C" {
616618
link_name = "listen$UNIX2003"
617619
)]
618620
pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
619-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
621+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
622+
target_vendor = "nintendo")))]
620623
#[cfg_attr(
621624
all(target_os = "macos", target_arch = "x86"),
622625
link_name = "accept$UNIX2003"
@@ -626,7 +629,8 @@ extern "C" {
626629
address: *mut sockaddr,
627630
address_len: *mut socklen_t,
628631
) -> ::c_int;
629-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
632+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
633+
target_vendor = "nintendo")))]
630634
#[cfg_attr(
631635
all(target_os = "macos", target_arch = "x86"),
632636
link_name = "getpeername$UNIX2003"
@@ -636,7 +640,8 @@ extern "C" {
636640
address: *mut sockaddr,
637641
address_len: *mut socklen_t,
638642
) -> ::c_int;
639-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
643+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
644+
target_vendor = "nintendo")))]
640645
#[cfg_attr(
641646
all(target_os = "macos", target_arch = "x86"),
642647
link_name = "getsockname$UNIX2003"
@@ -664,7 +669,8 @@ extern "C" {
664669
protocol: ::c_int,
665670
socket_vector: *mut ::c_int,
666671
) -> ::c_int;
667-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
672+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
673+
target_vendor = "nintendo")))]
668674
#[cfg_attr(
669675
all(target_os = "macos", target_arch = "x86"),
670676
link_name = "sendto$UNIX2003"
@@ -1240,15 +1246,17 @@ extern "C" {
12401246
pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
12411247
pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
12421248

1243-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
1249+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
1250+
target_vendor = "nintendo")))]
12441251
#[cfg_attr(target_os = "illumos", link_name = "__xnet_getaddrinfo")]
12451252
pub fn getaddrinfo(
12461253
node: *const c_char,
12471254
service: *const c_char,
12481255
hints: *const addrinfo,
12491256
res: *mut *mut addrinfo,
12501257
) -> ::c_int;
1251-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
1258+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
1259+
target_vendor = "nintendo")))]
12521260
pub fn freeaddrinfo(res: *mut addrinfo);
12531261
pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
12541262
#[cfg_attr(

src/unix/newlib/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ s! {
3333
pub ai_protocol: ::c_int,
3434
pub ai_addrlen: socklen_t,
3535

36-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
36+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
37+
target_vendor = "nintendo")))]
3738
#[cfg(target_arch = "xtensa")]
3839
pub ai_addr: *mut sockaddr,
3940

4041
pub ai_canonname: *mut ::c_char,
4142

42-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
43+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
44+
target_vendor = "nintendo")))]
4345
#[cfg(not(target_arch = "xtensa"))]
4446
pub ai_addr: *mut sockaddr,
4547

@@ -600,7 +602,8 @@ extern "C" {
600602
pub fn rand() -> ::c_int;
601603
pub fn srand(seed: ::c_uint);
602604

603-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
605+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
606+
target_vendor = "nintendo")))]
604607
pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t)
605608
-> ::c_int;
606609
pub fn clock_settime(
@@ -617,7 +620,8 @@ extern "C" {
617620
) -> ::c_int;
618621
pub fn closesocket(sockfd: ::c_int) -> ::c_int;
619622
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
620-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
623+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
624+
target_vendor = "nintendo")))]
621625
pub fn recvfrom(
622626
fd: ::c_int,
623627
buf: *mut ::c_void,
@@ -626,7 +630,8 @@ extern "C" {
626630
addr: *mut sockaddr,
627631
addr_len: *mut socklen_t,
628632
) -> isize;
629-
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
633+
#[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc",
634+
target_vendor = "nintendo")))]
630635
pub fn getnameinfo(
631636
sa: *const sockaddr,
632637
salen: socklen_t,

0 commit comments

Comments
 (0)