diff --git a/build.rs b/build.rs index 4edad7f740077..78ed993441d53 100644 --- a/build.rs +++ b/build.rs @@ -14,15 +14,10 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "freebsd13", "freebsd14", "freebsd15", - "libc_cfg_target_vendor", "libc_const_extern_fn", "libc_const_extern_fn_unstable", - "libc_core_cvoid", "libc_deny_warnings", - "libc_int128", "libc_long_array", - "libc_non_exhaustive", - "libc_packedN", "libc_ptr_addr_of", "libc_thread_local", "libc_underscore_const_names", @@ -54,13 +49,6 @@ fn main() { let libc_ci = env::var("LIBC_CI").is_ok(); let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80; - if env::var("CARGO_FEATURE_USE_STD").is_ok() { - println!( - "cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \ - please consider using the `std` cargo feature instead\"" - ); - } - // The ABI of libc used by std is backward compatible with FreeBSD 12. // The ABI of libc from crates.io is backward compatible with FreeBSD 11. // @@ -94,29 +82,6 @@ fn main() { set_cfg("libc_deny_warnings"); } - // Rust >= 1.26 supports i128 and u128: - if rustc_minor_ver >= 26 || rustc_dep_of_std { - set_cfg("libc_int128"); - } - - // Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it. - // Otherwise, it defines an incompatible type to retaining - // backwards-compatibility. - if rustc_minor_ver >= 30 || rustc_dep_of_std { - set_cfg("libc_core_cvoid"); - } - - // Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor). - if rustc_minor_ver >= 33 || rustc_dep_of_std { - set_cfg("libc_packedN"); - set_cfg("libc_cfg_target_vendor"); - } - - // Rust >= 1.40 supports #[non_exhaustive]. - if rustc_minor_ver >= 40 || rustc_dep_of_std { - set_cfg("libc_non_exhaustive"); - } - // Rust >= 1.47 supports long array: if rustc_minor_ver >= 47 || rustc_dep_of_std { set_cfg("libc_long_array"); diff --git a/libc-test/build.rs b/libc-test/build.rs index 01907dff90652..0dec4bba362f5 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -67,7 +67,7 @@ fn do_ctest() { fn ctest_cfg() -> ctest::TestGenerator { let mut cfg = ctest::TestGenerator::new(); - let libc_cfgs = ["libc_core_cvoid", "libc_packedN", "libc_thread_local"]; + let libc_cfgs = ["libc_thread_local"]; for f in &libc_cfgs { cfg.cfg(f, None); } @@ -327,6 +327,9 @@ fn test_apple(target: &str) { // FIXME: Requires the macOS 14.4 SDK. "os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true, + // FIXME: "'__uint128' undeclared" in C + "__uint128" => true, + _ => false, } }); @@ -1858,6 +1861,10 @@ fn test_android(target: &str) { // These are intended to be opaque "posix_spawn_file_actions_t" => true, "posix_spawnattr_t" => true, + + // FIXME: "'__uint128' undeclared" in C + "__uint128" => true, + _ => false, } }); @@ -3702,6 +3709,9 @@ fn test_linux(target: &str) { "priority_t" if musl => true, "name_t" if musl => true, + // FIXME: "'__uint128' undeclared" in C + "__uint128" => true, + t => { if musl { // LFS64 types have been removed in musl 1.2.4+ diff --git a/src/fixed_width_ints.rs b/src/fixed_width_ints.rs index 999de8f54f194..980ff61ecdaf3 100644 --- a/src/fixed_width_ints.rs +++ b/src/fixed_width_ints.rs @@ -20,7 +20,7 @@ pub type uint32_t = u32; pub type uint64_t = u64; cfg_if! { - if #[cfg(all(libc_int128, target_arch = "aarch64", not(target_os = "windows")))] { + if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] { // This introduces partial support for FFI with __int128 and // equivalent types on platforms where Rust's definition is validated // to match the standard C ABI of that platform. diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 5495ce9549b10..9a0b8755c4659 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3,6 +3,8 @@ //! More functions and definitions can be found in the more specific modules //! according to the platform in question. +use c_void; + // PUB_TYPE pub type c_schar = i8; @@ -4490,23 +4492,3 @@ cfg_if! { // Unknown target_arch } } - -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} diff --git a/src/hermit.rs b/src/hermit.rs index 77df54ae12d8d..8e630c38f6b65 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -1,5 +1,7 @@ //! Hermit C type definitions +use c_void; + cfg_if! { if #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] { pub type c_char = u8; @@ -576,5 +578,3 @@ extern "C" { #[link_name = "sys_poll"] pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: i32) -> i32; } - -pub use ffi::c_void; diff --git a/src/lib.rs b/src/lib.rs index ffeda95e8d505..1dba4d8248fea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,9 +46,6 @@ cfg_if! { #[doc(hidden)] #[allow(unused_imports)] use core::clone::Clone; -#[cfg(libc_core_cvoid)] -#[allow(unused_imports)] -use core::ffi; #[allow(unused_imports)] use core::fmt; #[allow(unused_imports)] @@ -64,6 +61,8 @@ use core::num; #[allow(unused_imports)] use core::option::Option; +pub use core::ffi::c_void; + cfg_if! { if #[cfg(windows)] { mod fixed_width_ints; diff --git a/src/psp.rs b/src/psp.rs index a4ca029b6e0c1..3e1cdac2ceb82 100644 --- a/src/psp.rs +++ b/src/psp.rs @@ -4,6 +4,8 @@ //! by the linker. Crates that use these definitions must, somewhere in the //! crate graph, include a stub provider crate such as the `psp` crate. +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -27,26 +29,6 @@ pub type c_char = u8; pub type c_long = i64; pub type c_ulong = u64; -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} - pub type SceKernelVTimerHandler = unsafe extern "C" fn( uid: SceUid, arg1: *mut SceKernelSysClock, diff --git a/src/sgx.rs b/src/sgx.rs index 7da6269399d9e..e37ccd79c3a55 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -25,23 +25,3 @@ pub type c_ulong = u64; pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; - -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} diff --git a/src/solid/mod.rs b/src/solid/mod.rs index 2aca8d19abffd..da1ce150b0330 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -2,6 +2,8 @@ //! //! [SOLID]: https://solid.kmckk.com/ +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -871,26 +873,6 @@ extern "C" { pub fn lseek(arg1: c_int, arg2: __off_t, arg3: c_int) -> __off_t; } -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} - cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/src/switch.rs b/src/switch.rs index 030ab20d7bd8e..4a8b16e15f568 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -27,23 +27,3 @@ pub type wchar_t = u32; pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; - -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} diff --git a/src/unix/bsd/apple/b64/aarch64/mod.rs b/src/unix/bsd/apple/b64/aarch64/mod.rs index 1d4a5590fbf36..dd22fcb2507b1 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -37,16 +37,8 @@ s! { pub __pad: u32, } - // This type natively uses a uint128, but for a while we hacked - // it in with repr(align) and `[u64; 2]`. uint128 isn't available - // all the way back to our earliest supported versions so we - // preserver the old shim. - #[cfg_attr(not(libc_int128), repr(align(16)))] pub struct __darwin_arm_neon_state64 { - #[cfg(libc_int128)] pub __v: [::__uint128_t; 32], - #[cfg(not(libc_int128))] - pub __v: [[u64; 2]; 32], pub __fpsr: u32, pub __fpcr: u32, } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index efac489dcfc30..7ed887753c971 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1193,13 +1193,13 @@ s! { } s_no_extra_traits! { - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct ifconf { pub ifc_len: ::c_int, pub ifc_ifcu: __c_anonymous_ifc_ifcu, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct kevent { pub ident: ::uintptr_t, pub filter: i16, @@ -1209,7 +1209,7 @@ s_no_extra_traits! { pub udata: *mut ::c_void, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct semid_ds { // Note the manpage shows different types than the system header. pub sem_perm: ipc_perm, @@ -1222,7 +1222,7 @@ s_no_extra_traits! { pub sem_pad3: [i32; 4], } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct shmid_ds { pub shm_perm: ipc_perm, pub shm_segsz: ::size_t, @@ -1381,7 +1381,7 @@ s_no_extra_traits! { pub pth_name: [::c_char; MAXTHREADNAMESIZE], } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct if_data64 { pub ifi_type: ::c_uchar, pub ifi_typelen: ::c_uchar, @@ -1413,7 +1413,7 @@ s_no_extra_traits! { pub ifi_lastchange: timeval32, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct if_msghdr2 { pub ifm_msglen: ::c_ushort, pub ifm_version: ::c_uchar, @@ -1428,7 +1428,7 @@ s_no_extra_traits! { pub ifm_data: if_data64, } - #[cfg_attr(libc_packedN, repr(packed(8)))] + #[repr(packed(8))] pub struct vm_statistics64 { pub free_count: natural_t, pub active_count: natural_t, @@ -1456,7 +1456,7 @@ s_no_extra_traits! { pub total_uncompressed_pages_in_compressor: u64, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct mach_task_basic_info { pub virtual_size: mach_vm_size_t, pub resident_size: mach_vm_size_t, @@ -1467,7 +1467,7 @@ s_no_extra_traits! { pub suspend_count: integer_t, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct log2phys { pub l2p_flags: ::c_uint, pub l2p_contigbytes: ::off_t, @@ -1478,7 +1478,7 @@ s_no_extra_traits! { _os_unfair_lock_opaque: u32, } - #[cfg_attr(libc_packedN, repr(packed(1)))] + #[repr(packed(1))] pub struct sockaddr_vm { pub svm_len: ::c_uchar, pub svm_family: ::sa_family_t, @@ -1498,7 +1498,7 @@ s_no_extra_traits! { pub ifk_value: ::c_int, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct ifkpi { pub ifk_module_id: ::c_uint, pub ifk_type: ::c_uint, diff --git a/src/unix/linux_like/android/b64/aarch64/int128.rs b/src/unix/linux_like/android/b64/aarch64/int128.rs deleted file mode 100644 index 4535e73eeddf1..0000000000000 --- a/src/unix/linux_like/android/b64/aarch64/int128.rs +++ /dev/null @@ -1,7 +0,0 @@ -s! { - pub struct user_fpsimd_struct { - pub vregs: [::__uint128_t; 32], - pub fpsr: u32, - pub fpcr: u32, - } -} diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index d063c022bfb7e..49b990fd8f1ac 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -75,6 +75,12 @@ s! { // auto-derive traits like Debug __reserved: [[u64; 32]; 16], } + + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: u32, + pub fpcr: u32, + } } s_no_extra_traits! { @@ -448,10 +454,3 @@ pub const PROT_MTE: ::c_int = 0x20; // From NDK's asm/auxvec.h pub const AT_SYSINFO_EHDR: ::c_ulong = 33; pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 2; - -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } -} diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs deleted file mode 100644 index 398fbb53755c8..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs +++ /dev/null @@ -1,8 +0,0 @@ -s! { - #[repr(align(16))] - pub struct user_fpsimd_struct { - pub vregs: [[u64; 2]; 32], - pub fpsr: ::c_uint, - pub fpcr: ::c_uint, - } -} diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs deleted file mode 100644 index 4535e73eeddf1..0000000000000 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs +++ /dev/null @@ -1,7 +0,0 @@ -s! { - pub struct user_fpsimd_struct { - pub vregs: [::__uint128_t; 32], - pub fpsr: u32, - pub fpcr: u32, - } -} diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 783200a6d6e9c..5ee559190a8a2 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -217,6 +217,12 @@ s! { __reserved: [[u64; 32]; 16], } + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: ::c_uint, + pub fpcr: ::c_uint, + } + #[repr(align(8))] pub struct clone_args { pub flags: ::c_ulonglong, @@ -964,13 +970,3 @@ cfg_if! { pub use self::lp64::*; } } - -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } else { - mod fallback; - pub use self::fallback::*; - } -} diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 28d29251769ca..5629fe0d0a608 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -953,6 +953,14 @@ s! { pub pid: ::c_int, } + // linux/openat2.h + #[non_exhaustive] + pub struct open_how { + pub flags: ::__u64, + pub mode: ::__u64, + pub resolve: ::__u64, + } + #[repr(align(8))] pub struct tpacket_rollover_stats { pub tp_all: ::__u64, @@ -6183,10 +6191,3 @@ cfg_if! { mod arch; pub use self::arch::*; - -cfg_if! { - if #[cfg(libc_non_exhaustive)] { - mod non_exhaustive; - pub use self::non_exhaustive::*; - } -} diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs b/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs deleted file mode 100644 index 4535e73eeddf1..0000000000000 --- a/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs +++ /dev/null @@ -1,7 +0,0 @@ -s! { - pub struct user_fpsimd_struct { - pub vregs: [::__uint128_t; 32], - pub fpsr: u32, - pub fpcr: u32, - } -} diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 7582676c3bfa6..f71d47effe85c 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -101,6 +101,12 @@ s! { pub set_tid_size: ::c_ulonglong, pub cgroup: ::c_ulonglong, } + + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: u32, + pub fpcr: u32, + } } s_no_extra_traits! { @@ -684,10 +690,3 @@ pub const VMIN: usize = 6; pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; - -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } -} diff --git a/src/unix/linux_like/linux/non_exhaustive.rs b/src/unix/linux_like/linux/non_exhaustive.rs deleted file mode 100644 index e2e2cb847ac65..0000000000000 --- a/src/unix/linux_like/linux/non_exhaustive.rs +++ /dev/null @@ -1,9 +0,0 @@ -s! { - // linux/openat2.h - #[non_exhaustive] - pub struct open_how { - pub flags: ::__u64, - pub mode: ::__u64, - pub resolve: ::__u64, - } -} diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 1556c12726eb0..b3cc7424cd0d4 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -3,6 +3,8 @@ //! More functions and definitions can be found in the more specific modules //! according to the platform in question. +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -640,21 +642,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(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "netbsd", link_name = "__socket30")] #[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")] #[cfg_attr(target_os = "solaris", link_name = "__xnet7_socket")] #[cfg_attr(target_os = "espidf", link_name = "lwip_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(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "connect$UNIX2003" @@ -671,22 +665,14 @@ extern "C" { )] #[cfg_attr(target_os = "espidf", link_name = "lwip_listen")] 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(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "accept$UNIX2003" )] #[cfg_attr(target_os = "espidf", link_name = "lwip_accept")] pub fn accept(socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "getpeername$UNIX2003" @@ -697,11 +683,7 @@ 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(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "getsockname$UNIX2003" @@ -734,11 +716,7 @@ 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(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "sendto$UNIX2003" @@ -1248,11 +1226,7 @@ extern "C" { pub fn dlsym(handle: *mut ::c_void, symbol: *const ::c_char) -> *mut ::c_void; pub fn dlclose(handle: *mut ::c_void) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( any(target_os = "illumos", target_os = "solaris"), link_name = "__xnet_getaddrinfo" @@ -1264,11 +1238,7 @@ extern "C" { hints: *const addrinfo, res: *mut *mut addrinfo, ) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "espidf", link_name = "lwip_freeaddrinfo")] pub fn freeaddrinfo(res: *mut addrinfo); pub fn hstrerror(errcode: ::c_int) -> *const ::c_char; @@ -1703,23 +1673,3 @@ cfg_if! { // Unknown target_os } } - -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index e68da50aa3c0a..45d1b1a028fad 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -91,7 +91,7 @@ s! { #[cfg(not(any( target_os = "espidf", - all(libc_cfg_target_vendor, target_arch = "powerpc", target_vendor = "nintendo"))))] + all(target_arch = "powerpc", target_vendor = "nintendo"))))] pub ai_addr: *mut sockaddr, pub ai_next: *mut addrinfo, @@ -843,11 +843,7 @@ 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" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "espidf", link_name = "lwip_bind")] pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) -> ::c_int; pub fn clock_settime(clock_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; @@ -856,11 +852,7 @@ extern "C" { #[cfg_attr(target_os = "espidf", link_name = "lwip_close")] 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" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "espidf", link_name = "lwip_recvfrom")] pub fn recvfrom( fd: ::c_int, @@ -870,11 +862,7 @@ extern "C" { addr: *mut sockaddr, addr_len: *mut socklen_t, ) -> isize; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] pub fn getnameinfo( sa: *const sockaddr, salen: socklen_t, diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index 62a07f6279030..07cc583f43f3d 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -46,10 +46,7 @@ s! { } s_no_extra_traits! { - #[cfg_attr(any( - target_arch = "x86", target_arch = "x86_64"), - repr(packed(4)) - )] + #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed(4)))] pub struct epoll_event { pub events: u32, pub u64: u64, diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index daf3b013b48b3..18b102b906767 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1,5 +1,6 @@ //! Interface to VxWorks C library +use c_void; use core::mem::size_of; use core::ptr::null_mut; @@ -2003,26 +2004,6 @@ pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_ } } -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} - cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index 743f607379768..b157ab0d59b04 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -1,7 +1,7 @@ -use super::{Send, Sync}; use core::iter::Iterator; -pub use ffi::c_void; +use super::{Send, Sync}; +use c_void; pub type c_char = i8; pub type c_uchar = u8; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 63536a809a421..2270e7078c966 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -1,5 +1,7 @@ //! Windows CRT definitions +use c_void; + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -568,26 +570,6 @@ extern "system" { pub fn socket(af: ::c_int, socket_type: ::c_int, protocol: ::c_int) -> SOCKET; } -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -} - cfg_if! { if #[cfg(all(target_env = "gnu"))] { mod gnu; diff --git a/src/xous.rs b/src/xous.rs index e6c0c2573d07d..4073349306fb9 100644 --- a/src/xous.rs +++ b/src/xous.rs @@ -27,23 +27,3 @@ pub type wchar_t = u32; pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; - -cfg_if! { - if #[cfg(libc_core_cvoid)] { - pub use ::ffi::c_void; - } else { - // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help - // enable more optimization opportunities around it recognizing things - // like malloc/free. - #[repr(u8)] - #[allow(missing_copy_implementations)] - #[allow(missing_debug_implementations)] - pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used. - #[doc(hidden)] - __variant1, - #[doc(hidden)] - __variant2, - } - } -}