Skip to content

Commit 61bec0c

Browse files
joshtripletttgross35
authored andcommitted
Require rust >= 1.30 and drop libc_core_cvoid conditional
Move the `c_void` re-export to the top-level `lib.rs`.
1 parent 2943c03 commit 61bec0c

File tree

14 files changed

+16
-196
lines changed

14 files changed

+16
-196
lines changed

build.rs

-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
1717
"libc_cfg_target_vendor",
1818
"libc_const_extern_fn",
1919
"libc_const_extern_fn_unstable",
20-
"libc_core_cvoid",
2120
"libc_deny_warnings",
2221
"libc_long_array",
2322
"libc_non_exhaustive",
@@ -86,13 +85,6 @@ fn main() {
8685
set_cfg("libc_deny_warnings");
8786
}
8887

89-
// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
90-
// Otherwise, it defines an incompatible type to retaining
91-
// backwards-compatibility.
92-
if rustc_minor_ver >= 30 || rustc_dep_of_std {
93-
set_cfg("libc_core_cvoid");
94-
}
95-
9688
// Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor).
9789
if rustc_minor_ver >= 33 || rustc_dep_of_std {
9890
set_cfg("libc_packedN");

libc-test/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn do_ctest() {
6767

6868
fn ctest_cfg() -> ctest::TestGenerator {
6969
let mut cfg = ctest::TestGenerator::new();
70-
let libc_cfgs = ["libc_core_cvoid", "libc_packedN", "libc_thread_local"];
70+
let libc_cfgs = ["libc_packedN", "libc_thread_local"];
7171
for f in &libc_cfgs {
7272
cfg.cfg(f, None);
7373
}

src/fuchsia/mod.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//! More functions and definitions can be found in the more specific modules
44
//! according to the platform in question.
55
6+
use c_void;
7+
68
// PUB_TYPE
79

810
pub type c_schar = i8;
@@ -4490,23 +4492,3 @@ cfg_if! {
44904492
// Unknown target_arch
44914493
}
44924494
}
4493-
4494-
cfg_if! {
4495-
if #[cfg(libc_core_cvoid)] {
4496-
pub use ::ffi::c_void;
4497-
} else {
4498-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
4499-
// enable more optimization opportunities around it recognizing things
4500-
// like malloc/free.
4501-
#[repr(u8)]
4502-
#[allow(missing_copy_implementations)]
4503-
#[allow(missing_debug_implementations)]
4504-
pub enum c_void {
4505-
// Two dummy variants so the #[repr] attribute can be used.
4506-
#[doc(hidden)]
4507-
__variant1,
4508-
#[doc(hidden)]
4509-
__variant2,
4510-
}
4511-
}
4512-
}

src/hermit.rs

-2
Original file line numberDiff line numberDiff line change
@@ -576,5 +576,3 @@ extern "C" {
576576
#[link_name = "sys_poll"]
577577
pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: i32) -> i32;
578578
}
579-
580-
pub use ffi::c_void;

src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ cfg_if! {
4646
#[doc(hidden)]
4747
#[allow(unused_imports)]
4848
use core::clone::Clone;
49-
#[cfg(libc_core_cvoid)]
50-
#[allow(unused_imports)]
51-
use core::ffi;
5249
#[allow(unused_imports)]
5350
use core::fmt;
5451
#[allow(unused_imports)]
@@ -64,6 +61,8 @@ use core::num;
6461
#[allow(unused_imports)]
6562
use core::option::Option;
6663

64+
pub use core::ffi::c_void;
65+
6766
cfg_if! {
6867
if #[cfg(windows)] {
6968
mod fixed_width_ints;

src/psp.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//! by the linker. Crates that use these definitions must, somewhere in the
55
//! crate graph, include a stub provider crate such as the `psp` crate.
66
7+
use c_void;
8+
79
pub type c_schar = i8;
810
pub type c_uchar = u8;
911
pub type c_short = i16;
@@ -27,26 +29,6 @@ pub type c_char = u8;
2729
pub type c_long = i64;
2830
pub type c_ulong = u64;
2931

30-
cfg_if! {
31-
if #[cfg(libc_core_cvoid)] {
32-
pub use ::ffi::c_void;
33-
} else {
34-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
35-
// enable more optimization opportunities around it recognizing things
36-
// like malloc/free.
37-
#[repr(u8)]
38-
#[allow(missing_copy_implementations)]
39-
#[allow(missing_debug_implementations)]
40-
pub enum c_void {
41-
// Two dummy variants so the #[repr] attribute can be used.
42-
#[doc(hidden)]
43-
__variant1,
44-
#[doc(hidden)]
45-
__variant2,
46-
}
47-
}
48-
}
49-
5032
pub type SceKernelVTimerHandler = unsafe extern "C" fn(
5133
uid: SceUid,
5234
arg1: *mut SceKernelSysClock,

src/sgx.rs

-20
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,3 @@ pub type c_ulong = u64;
2525

2626
pub const INT_MIN: c_int = -2147483648;
2727
pub const INT_MAX: c_int = 2147483647;
28-
29-
cfg_if! {
30-
if #[cfg(libc_core_cvoid)] {
31-
pub use ::ffi::c_void;
32-
} else {
33-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
34-
// enable more optimization opportunities around it recognizing things
35-
// like malloc/free.
36-
#[repr(u8)]
37-
#[allow(missing_copy_implementations)]
38-
#[allow(missing_debug_implementations)]
39-
pub enum c_void {
40-
// Two dummy variants so the #[repr] attribute can be used.
41-
#[doc(hidden)]
42-
__variant1,
43-
#[doc(hidden)]
44-
__variant2,
45-
}
46-
}
47-
}

src/solid/mod.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//!
33
//! [SOLID]: https://solid.kmckk.com/
44
5+
use c_void;
6+
57
pub type c_schar = i8;
68
pub type c_uchar = u8;
79
pub type c_short = i16;
@@ -871,26 +873,6 @@ extern "C" {
871873
pub fn lseek(arg1: c_int, arg2: __off_t, arg3: c_int) -> __off_t;
872874
}
873875

874-
cfg_if! {
875-
if #[cfg(libc_core_cvoid)] {
876-
pub use ::ffi::c_void;
877-
} else {
878-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
879-
// enable more optimization opportunities around it recognizing things
880-
// like malloc/free.
881-
#[repr(u8)]
882-
#[allow(missing_copy_implementations)]
883-
#[allow(missing_debug_implementations)]
884-
pub enum c_void {
885-
// Two dummy variants so the #[repr] attribute can be used.
886-
#[doc(hidden)]
887-
__variant1,
888-
#[doc(hidden)]
889-
__variant2,
890-
}
891-
}
892-
}
893-
894876
cfg_if! {
895877
if #[cfg(target_arch = "aarch64")] {
896878
mod aarch64;

src/switch.rs

-20
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,3 @@ pub type wchar_t = u32;
2727

2828
pub const INT_MIN: c_int = -2147483648;
2929
pub const INT_MAX: c_int = 2147483647;
30-
31-
cfg_if! {
32-
if #[cfg(libc_core_cvoid)] {
33-
pub use ::ffi::c_void;
34-
} else {
35-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
36-
// enable more optimization opportunities around it recognizing things
37-
// like malloc/free.
38-
#[repr(u8)]
39-
#[allow(missing_copy_implementations)]
40-
#[allow(missing_debug_implementations)]
41-
pub enum c_void {
42-
// Two dummy variants so the #[repr] attribute can be used.
43-
#[doc(hidden)]
44-
__variant1,
45-
#[doc(hidden)]
46-
__variant2,
47-
}
48-
}
49-
}

src/unix/mod.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//! More functions and definitions can be found in the more specific modules
44
//! according to the platform in question.
55
6+
use c_void;
7+
68
pub type c_schar = i8;
79
pub type c_uchar = u8;
810
pub type c_short = i16;
@@ -1703,23 +1705,3 @@ cfg_if! {
17031705
// Unknown target_os
17041706
}
17051707
}
1706-
1707-
cfg_if! {
1708-
if #[cfg(libc_core_cvoid)] {
1709-
pub use ::ffi::c_void;
1710-
} else {
1711-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
1712-
// enable more optimization opportunities around it recognizing things
1713-
// like malloc/free.
1714-
#[repr(u8)]
1715-
#[allow(missing_copy_implementations)]
1716-
#[allow(missing_debug_implementations)]
1717-
pub enum c_void {
1718-
// Two dummy variants so the #[repr] attribute can be used.
1719-
#[doc(hidden)]
1720-
__variant1,
1721-
#[doc(hidden)]
1722-
__variant2,
1723-
}
1724-
}
1725-
}

src/vxworks/mod.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Interface to VxWorks C library
22
3+
use c_void;
34
use core::mem::size_of;
45
use core::ptr::null_mut;
56

@@ -2003,26 +2004,6 @@ pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_
20032004
}
20042005
}
20052006

2006-
cfg_if! {
2007-
if #[cfg(libc_core_cvoid)] {
2008-
pub use ::ffi::c_void;
2009-
} else {
2010-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
2011-
// enable more optimization opportunities around it recognizing things
2012-
// like malloc/free.
2013-
#[repr(u8)]
2014-
#[allow(missing_copy_implementations)]
2015-
#[allow(missing_debug_implementations)]
2016-
pub enum c_void {
2017-
// Two dummy variants so the #[repr] attribute can be used.
2018-
#[doc(hidden)]
2019-
__variant1,
2020-
#[doc(hidden)]
2021-
__variant2,
2022-
}
2023-
}
2024-
}
2025-
20262007
cfg_if! {
20272008
if #[cfg(target_arch = "aarch64")] {
20282009
mod aarch64;

src/wasi/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use super::{Send, Sync};
21
use core::iter::Iterator;
32

4-
pub use ffi::c_void;
3+
use super::{Send, Sync};
4+
use c_void;
55

66
pub type c_char = i8;
77
pub type c_uchar = u8;

src/windows/mod.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Windows CRT definitions
22
3+
use c_void;
4+
35
pub type c_schar = i8;
46
pub type c_uchar = u8;
57
pub type c_short = i16;
@@ -568,26 +570,6 @@ extern "system" {
568570
pub fn socket(af: ::c_int, socket_type: ::c_int, protocol: ::c_int) -> SOCKET;
569571
}
570572

571-
cfg_if! {
572-
if #[cfg(libc_core_cvoid)] {
573-
pub use ::ffi::c_void;
574-
} else {
575-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
576-
// enable more optimization opportunities around it recognizing things
577-
// like malloc/free.
578-
#[repr(u8)]
579-
#[allow(missing_copy_implementations)]
580-
#[allow(missing_debug_implementations)]
581-
pub enum c_void {
582-
// Two dummy variants so the #[repr] attribute can be used.
583-
#[doc(hidden)]
584-
__variant1,
585-
#[doc(hidden)]
586-
__variant2,
587-
}
588-
}
589-
}
590-
591573
cfg_if! {
592574
if #[cfg(all(target_env = "gnu"))] {
593575
mod gnu;

src/xous.rs

-20
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,3 @@ pub type wchar_t = u32;
2727

2828
pub const INT_MIN: c_int = -2147483648;
2929
pub const INT_MAX: c_int = 2147483647;
30-
31-
cfg_if! {
32-
if #[cfg(libc_core_cvoid)] {
33-
pub use ::ffi::c_void;
34-
} else {
35-
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
36-
// enable more optimization opportunities around it recognizing things
37-
// like malloc/free.
38-
#[repr(u8)]
39-
#[allow(missing_copy_implementations)]
40-
#[allow(missing_debug_implementations)]
41-
pub enum c_void {
42-
// Two dummy variants so the #[repr] attribute can be used.
43-
#[doc(hidden)]
44-
__variant1,
45-
#[doc(hidden)]
46-
__variant2,
47-
}
48-
}
49-
}

0 commit comments

Comments
 (0)