Skip to content

Commit 8ab8323

Browse files
committed
Define c_char at top-level and remove per-target c_char definitions
1 parent 5f41b7a commit 8ab8323

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+30
-173
lines changed

libc-test/build.rs

+1-35
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,6 @@ fn test_apple(target: &str) {
353353
// FIXME: "'__uint128' undeclared" in C
354354
"__uint128" => true,
355355

356-
// `c_char_def` is always public but not always reexported.
357-
"c_char_def" => true,
358-
359356
_ => false,
360357
}
361358
});
@@ -717,8 +714,6 @@ fn test_windows(target: &str) {
717714
"ssize_t" if !gnu => true,
718715
// FIXME: The size and alignment of this type are incorrect
719716
"time_t" if gnu && i686 => true,
720-
// `c_char_def` is always public but not always reexported.
721-
"c_char_def" => true,
722717
_ => false,
723718
});
724719

@@ -929,8 +924,6 @@ fn test_solarish(target: &str) {
929924

930925
cfg.skip_type(move |ty| match ty {
931926
"sighandler_t" => true,
932-
// `c_char_def` is always public but not always reexported.
933-
"c_char_def" => true,
934927
_ => false,
935928
});
936929

@@ -1231,8 +1224,6 @@ fn test_netbsd(target: &str) {
12311224
match ty {
12321225
// FIXME: sighandler_t is crazy across platforms
12331226
"sighandler_t" => true,
1234-
// `c_char_def` is always public but not always reexported.
1235-
"c_char_def" => true,
12361227
_ => false,
12371228
}
12381229
});
@@ -1450,8 +1441,6 @@ fn test_dragonflybsd(target: &str) {
14501441
match ty {
14511442
// sighandler_t is crazy across platforms
14521443
"sighandler_t" => true,
1453-
// `c_char_def` is always public but not always reexported.
1454-
"c_char_def" => true,
14551444
_ => false,
14561445
}
14571446
});
@@ -1610,8 +1599,6 @@ fn test_wasi(target: &str) {
16101599
}
16111600
});
16121601

1613-
cfg.skip_type(|ty| ty == "c_char_def");
1614-
16151602
// These have a different and internal type in header files and are only
16161603
// used here to generate a pointer to them in bindings so skip these tests.
16171604
cfg.skip_static(|c| c.starts_with("_CLOCK_"));
@@ -1860,9 +1847,6 @@ fn test_android(target: &str) {
18601847
// FIXME: "'__uint128' undeclared" in C
18611848
"__uint128" => true,
18621849

1863-
// `c_char_def` is always public but not always reexported.
1864-
"c_char_def" => true,
1865-
18661850
_ => false,
18671851
}
18681852
});
@@ -2614,9 +2598,6 @@ fn test_freebsd(target: &str) {
26142598
// `eventfd(2)` and things come with it are added in FreeBSD 13
26152599
"eventfd_t" if Some(13) > freebsd_ver => true,
26162600

2617-
// `c_char_def` is always public but not always reexported.
2618-
"c_char_def" => true,
2619-
26202601
_ => false,
26212602
}
26222603
});
@@ -2933,9 +2914,6 @@ fn test_emscripten(target: &str) {
29332914
// https://github.com/emscripten-core/emscripten/issues/5033
29342915
ty if ty.starts_with("epoll") => true,
29352916

2936-
// `c_char_def` is always public but not always reexported.
2937-
"c_char_def" => true,
2938-
29392917
// LFS64 types have been removed in Emscripten 3.1.44
29402918
// https://github.com/emscripten-core/emscripten/pull/19812
29412919
t => t.ends_with("64") || t.ends_with("64_t"),
@@ -3212,9 +3190,6 @@ fn test_neutrino(target: &str) {
32123190
// Does not exist in Neutrino
32133191
"locale_t" => true,
32143192

3215-
// `c_char_def` is always public but not always reexported.
3216-
"c_char_def" => true,
3217-
32183193
_ => false,
32193194
}
32203195
});
@@ -3378,8 +3353,6 @@ fn test_vxworks(target: &str) {
33783353
// FIXME
33793354
cfg.skip_type(move |ty| match ty {
33803355
"stat64" | "sighandler_t" | "off64_t" => true,
3381-
// `c_char_def` is always public but not always reexported.
3382-
"c_char_def" => true,
33833356
_ => false,
33843357
});
33853358

@@ -3727,9 +3700,6 @@ fn test_linux(target: &str) {
37273700
// FIXME: "'__uint128' undeclared" in C
37283701
"__uint128" => true,
37293702

3730-
// `c_char_def` is always public but not always reexported.
3731-
"c_char_def" => true,
3732-
37333703
t => {
37343704
if musl {
37353705
// LFS64 types have been removed in musl 1.2.4+
@@ -3959,7 +3929,7 @@ fn test_linux(target: &str) {
39593929
}
39603930
// FIXME: Requires >= 5.4 kernel headers
39613931
if name == "PTP_CLOCK_GETCAPS2"
3962-
|| name == "PTP_ENABLE_PPS2"
3932+
|| name == "PTP_ENABLE_PPS2"
39633933
|| name == "PTP_EXTTS_REQUEST2"
39643934
|| name == "PTP_PEROUT_REQUEST2"
39653935
|| name == "PTP_PIN_GETFUNC2"
@@ -4678,8 +4648,6 @@ fn test_linux_like_apis(target: &str) {
46784648
})
46794649
.skip_type(move |ty| match ty {
46804650
"Elf64_Phdr" | "Elf32_Phdr" => false,
4681-
// `c_char_def` is always public but not always reexported.
4682-
"c_char_def" => true,
46834651
_ => true,
46844652
});
46854653
cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_elf.rs");
@@ -4915,8 +4883,6 @@ fn test_haiku(target: &str) {
49154883
"pthread_condattr_t" => true,
49164884
"pthread_mutexattr_t" => true,
49174885
"pthread_rwlockattr_t" => true,
4918-
// `c_char_def` is always public but not always reexported.
4919-
"c_char_def" => true,
49204886
_ => false,
49214887
}
49224888
});

src/fuchsia/aarch64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::off_t;
22
use crate::prelude::*;
33

4-
pub type c_char = u8;
54
pub type __u64 = c_ulonglong;
65
pub type wchar_t = u32;
76
pub type nlink_t = c_ulong;

src/fuchsia/riscv64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::off_t;
22
use crate::prelude::*;
33

44
// From psABI Calling Convention for RV64
5-
pub type c_char = u8;
65
pub type __u64 = c_ulonglong;
76
pub type wchar_t = i32;
87

src/fuchsia/x86_64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::off_t;
22
use crate::prelude::*;
33

4-
pub type c_char = i8;
54
pub type wchar_t = i32;
65
pub type nlink_t = u64;
76
pub type blksize_t = c_long;

src/hermit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Hermit C type definitions
22
3-
pub use crate::arch::c_char_def as c_char;
43
use crate::prelude::*;
54

65
pub type c_schar = i8;

src/lib.rs

+29-35
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,35 @@ cfg_if! {
3838

3939
pub use core::ffi::c_void;
4040

41-
/// Type definitions that are coupled tighter to architecture than OS.
42-
mod arch {
43-
cfg_if! {
44-
// This configuration comes from `rust-lang/rust` in `library/core/src/ffi/mod.rs`.
45-
if #[cfg(all(
46-
not(windows),
47-
// FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it
48-
not(any(
49-
target_os = "macos",
50-
target_os = "ios",
51-
target_os = "tvos",
52-
target_os = "watchos",
53-
target_os = "visionos",
54-
)),
55-
any(
56-
target_arch = "aarch64",
57-
target_arch = "arm",
58-
target_arch = "csky",
59-
target_arch = "hexagon",
60-
target_arch = "msp430",
61-
target_arch = "powerpc",
62-
target_arch = "powerpc64",
63-
target_arch = "riscv64",
64-
target_arch = "riscv32",
65-
target_arch = "s390x",
66-
target_arch = "xtensa",
67-
)
68-
))] {
69-
// To be reexported as `c_char`
70-
// FIXME(ctest): just name these `c_char` once `ctest` learns that these don't get
71-
// exported.
72-
pub type c_char_def = u8;
73-
} else {
74-
pub type c_char_def = i8;
75-
}
41+
cfg_if! {
42+
// This configuration comes from `rust-lang/rust` in `library/core/src/ffi/mod.rs`.
43+
if #[cfg(all(
44+
not(windows),
45+
// FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it
46+
not(any(
47+
target_os = "macos",
48+
target_os = "ios",
49+
target_os = "tvos",
50+
target_os = "watchos",
51+
target_os = "visionos",
52+
)),
53+
any(
54+
target_arch = "aarch64",
55+
target_arch = "arm",
56+
target_arch = "csky",
57+
target_arch = "hexagon",
58+
target_arch = "msp430",
59+
target_arch = "powerpc",
60+
target_arch = "powerpc64",
61+
target_arch = "riscv64",
62+
target_arch = "riscv32",
63+
target_arch = "s390x",
64+
target_arch = "xtensa",
65+
)
66+
))] {
67+
pub type c_char = u8;
68+
} else {
69+
pub type c_char = i8;
7670
}
7771
}
7872

src/sgx.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub type intptr_t = isize;
1919
pub type uintptr_t = usize;
2020
pub type ssize_t = isize;
2121

22-
pub type c_char = i8;
2322
pub type c_long = i64;
2423
pub type c_ulong = u64;
2524

src/solid/aarch64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pub type c_char = u8;
21
pub type wchar_t = u32;
32
pub type c_long = i64;
43
pub type c_ulong = u64;

src/solid/arm.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pub type c_char = u8;
21
pub type wchar_t = u32;
32
pub type c_long = i32;
43
pub type c_ulong = u32;

src/switch.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub type uintptr_t = usize;
2020
pub type ssize_t = isize;
2121

2222
pub type off_t = i64;
23-
pub type c_char = u8;
2423
pub type c_long = i64;
2524
pub type c_ulong = u64;
2625
pub type wchar_t = u32;

src/teeos/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ pub type ssize_t = isize;
4545

4646
pub type pid_t = c_int;
4747

48-
// aarch64 specific
49-
pub type c_char = u8;
50-
5148
pub type wchar_t = u32;
5249

5350
pub type c_long = i64;

src/trusty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pub use crate::arch::c_char_def as c_char;
21
use crate::prelude::*;
32
pub type size_t = usize;
43
pub type ssize_t = isize;

src/unix/aix/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::prelude::*;
22

3-
pub type c_char = u8;
43
pub type caddr_t = *mut c_char;
54
pub type clockid_t = c_longlong;
65
pub type blkcnt_t = c_long;

src/unix/bsd/apple/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use crate::prelude::*;
66
use crate::{cmsghdr, off_t};
77

8-
pub type c_char = i8;
98
pub type wchar_t = i32;
109
pub type clock_t = c_ulong;
1110
pub type time_t = c_long;

src/unix/bsd/freebsdlike/dragonfly/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::prelude::*;
22
use crate::{cmsghdr, off_t};
33

44
pub type dev_t = u32;
5-
pub type c_char = i8;
65
pub type wchar_t = i32;
76
pub type clock_t = u64;
87
pub type ino_t = u64;

src/unix/bsd/freebsdlike/freebsd/aarch64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::prelude::*;
22

3-
pub type c_char = u8;
43
pub type c_long = i64;
54
pub type c_ulong = u64;
65
pub type clock_t = i32;

src/unix/bsd/freebsdlike/freebsd/arm.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::prelude::*;
22

3-
pub type c_char = u8;
43
pub type c_long = i32;
54
pub type c_ulong = u32;
65
pub type clock_t = u32;

src/unix/bsd/freebsdlike/freebsd/powerpc.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::prelude::*;
22

3-
pub type c_char = u8;
43
pub type c_long = i32;
54
pub type c_ulong = u32;
65
pub type clock_t = u32;

src/unix/bsd/freebsdlike/freebsd/powerpc64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::prelude::*;
22

3-
pub type c_char = u8;
43
pub type c_long = i64;
54
pub type c_ulong = u64;
65
pub type clock_t = u32;

src/unix/bsd/freebsdlike/freebsd/riscv64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::prelude::*;
22

3-
pub type c_char = u8;
43
pub type c_long = i64;
54
pub type c_ulong = u64;
65
pub type clock_t = i32;

src/unix/bsd/freebsdlike/freebsd/x86.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::prelude::*;
22

3-
pub type c_char = i8;
43
pub type c_long = i32;
54
pub type c_ulong = u32;
65
pub type clock_t = c_ulong;

src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::prelude::*;
22

3-
pub type c_char = i8;
43
pub type c_long = i64;
54
pub type c_ulong = u64;
65
pub type clock_t = i32;

src/unix/bsd/netbsdlike/netbsd/aarch64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::PT_FIRSTMACH;
33

44
pub type c_long = i64;
55
pub type c_ulong = u64;
6-
pub type c_char = u8;
76
pub type greg_t = u64;
87
pub type __cpu_simple_lock_nv_t = c_uchar;
98

src/unix/bsd/netbsdlike/netbsd/arm.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::PT_FIRSTMACH;
33

44
pub type c_long = i32;
55
pub type c_ulong = u32;
6-
pub type c_char = u8;
76
pub type __cpu_simple_lock_nv_t = c_int;
87

98
pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_longlong>() - 1;

src/unix/bsd/netbsdlike/netbsd/mips.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::PT_FIRSTMACH;
33

44
pub type c_long = i32;
55
pub type c_ulong = u32;
6-
pub type c_char = i8;
76
pub type __cpu_simple_lock_nv_t = c_int;
87

98
pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_longlong>() - 1;

src/unix/bsd/netbsdlike/netbsd/powerpc.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::PT_FIRSTMACH;
33

44
pub type c_long = i32;
55
pub type c_ulong = u32;
6-
pub type c_char = u8;
76
pub type __cpu_simple_lock_nv_t = c_int;
87

98
pub(crate) const _ALIGNBYTES: usize = mem::size_of::<c_double>() - 1;

src/unix/bsd/netbsdlike/netbsd/riscv64.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::prelude::*;
44

55
pub type c_long = i64;
66
pub type c_ulong = u64;
7-
pub type c_char = u8;
87
pub type __greg_t = u64;
98
pub type __cpu_simple_lock_nv_t = c_int;
109
pub type __gregset = [__greg_t; _NGREG];

0 commit comments

Comments
 (0)