diff --git a/README.md b/README.md index 31bb4e8e18d5d498c4c4c97f79a87cae7d1869a8..51ef2722f9ca4aeaa86c9072eda21bf899f2bc97 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ newer Rust features are only available on newer Rust toolchains: | `extra_traits` | 1.25.0 | | `core::ffi::c_void` | 1.30.0 | | `repr(packed(N))` | 1.33.0 | +| `cfg(target_vendor)` | 1.33.0 | ## Platform support diff --git a/build.rs b/build.rs index f447c0ef9cd44d542449b7387aae7466f966f11b..27cfb0240123c408a6bdc552a6e7a91f156cacff 100644 --- a/build.rs +++ b/build.rs @@ -65,9 +65,10 @@ fn main() { println!("cargo:rustc-cfg=libc_core_cvoid"); } - // Rust >= 1.33 supports repr(packed(N)) + // Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor). if rustc_minor_ver >= 33 || rustc_dep_of_std { println!("cargo:rustc-cfg=libc_packedN"); + println!("cargo:rustc-cfg=libc_cfg_target_vendor"); } // #[thread_local] is currently unstable diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 237a0fb21a8e0311c702aaabbf472c90173a4368..7804f3e7bf957999dede7057ce558ea8a7b28662 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -596,9 +596,13 @@ extern "C" { pub fn getchar_unlocked() -> ::c_int; pub fn putchar_unlocked(c: ::c_int) -> ::c_int; + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] #[cfg_attr(target_os = "netbsd", link_name = "__socket30")] #[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")] pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int; + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "connect$UNIX2003" @@ -614,6 +618,8 @@ extern "C" { link_name = "listen$UNIX2003" )] pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "accept$UNIX2003" @@ -623,6 +629,8 @@ extern "C" { address: *mut sockaddr, address_len: *mut socklen_t, ) -> ::c_int; + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "getpeername$UNIX2003" @@ -632,6 +640,8 @@ extern "C" { address: *mut sockaddr, address_len: *mut socklen_t, ) -> ::c_int; + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "getsockname$UNIX2003" @@ -659,6 +669,8 @@ extern "C" { protocol: ::c_int, socket_vector: *mut ::c_int, ) -> ::c_int; + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "sendto$UNIX2003" @@ -1234,6 +1246,8 @@ extern "C" { pub fn dlclose(handle: *mut ::c_void) -> ::c_int; pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int; + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] #[cfg_attr(target_os = "illumos", link_name = "__xnet_getaddrinfo")] pub fn getaddrinfo( node: *const c_char, @@ -1241,6 +1255,8 @@ extern "C" { hints: *const addrinfo, res: *mut *mut addrinfo, ) -> ::c_int; + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] pub fn freeaddrinfo(res: *mut addrinfo); pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; #[cfg_attr( diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 55cb889aabe4243c4e1bfa1c160f0dcf92a2178e..defeda3aaaf368afc653edf0b93bb3bae7f03429 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -33,11 +33,15 @@ s! { pub ai_protocol: ::c_int, pub ai_addrlen: socklen_t, + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] #[cfg(target_arch = "xtensa")] pub ai_addr: *mut sockaddr, pub ai_canonname: *mut ::c_char, + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] #[cfg(not(target_arch = "xtensa"))] pub ai_addr: *mut sockaddr, @@ -598,6 +602,8 @@ extern "C" { pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) -> ::c_int; pub fn clock_settime( @@ -614,6 +620,8 @@ extern "C" { ) -> ::c_int; pub fn closesocket(sockfd: ::c_int) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] pub fn recvfrom( fd: ::c_int, buf: *mut ::c_void, @@ -622,6 +630,8 @@ extern "C" { addr: *mut sockaddr, addr_len: *mut socklen_t, ) -> isize; + #[cfg(not(all(libc_cfg_target_vendor, target_arch = "powerpc", + target_vendor = "nintendo")))] pub fn getnameinfo( sa: *const sockaddr, salen: socklen_t, @@ -700,6 +710,9 @@ cfg_if! { } else if #[cfg(target_arch = "xtensa")] { mod xtensa; pub use self::xtensa::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; } else { // Only tested on ARM so far. Other platforms might have different // definitions for types and constants. diff --git a/src/unix/newlib/powerpc/mod.rs b/src/unix/newlib/powerpc/mod.rs new file mode 100644 index 0000000000000000000000000000000000000000..4289658cd662380a0d392cd8213d341d7134c98d --- /dev/null +++ b/src/unix/newlib/powerpc/mod.rs @@ -0,0 +1,14 @@ +pub type clock_t = ::c_ulong; +pub type c_char = u8; +pub type wchar_t = ::c_int; + +pub type c_long = i32; +pub type c_ulong = u32; + +// the newlib shipped with devkitPPC does not support the following components: +// - sockaddr +// - AF_INET6 +// - FIONBIO +// - POLL* +// - SOL_SOCKET +// - MSG_*