Skip to content

Commit 8448147

Browse files
taiki-etgross35
authored andcommitted
Define c_char at top-level and remove per-target c_char definitions
(backport <#4202>) (cherry picked from commit 0a02b94)
1 parent 0ead24f commit 8448147

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
@@ -364,9 +364,6 @@ fn test_apple(target: &str) {
364364
// FIXME: "'__uint128' undeclared" in C
365365
"__uint128" => true,
366366

367-
// `c_char_def` is always public but not always reexported.
368-
"c_char_def" => true,
369-
370367
_ => false,
371368
}
372369
});
@@ -766,8 +763,6 @@ fn test_windows(target: &str) {
766763
"ssize_t" if !gnu => true,
767764
// FIXME: The size and alignment of this type are incorrect
768765
"time_t" if gnu && i686 => true,
769-
// `c_char_def` is always public but not always reexported.
770-
"c_char_def" => true,
771766
_ => false,
772767
});
773768

@@ -985,8 +980,6 @@ fn test_solarish(target: &str) {
985980

986981
cfg.skip_type(move |ty| match ty {
987982
"sighandler_t" => true,
988-
// `c_char_def` is always public but not always reexported.
989-
"c_char_def" => true,
990983
_ => false,
991984
});
992985

@@ -1290,8 +1283,6 @@ fn test_netbsd(target: &str) {
12901283
match ty {
12911284
// FIXME: sighandler_t is crazy across platforms
12921285
"sighandler_t" => true,
1293-
// `c_char_def` is always public but not always reexported.
1294-
"c_char_def" => true,
12951286
_ => false,
12961287
}
12971288
});
@@ -1511,8 +1502,6 @@ fn test_dragonflybsd(target: &str) {
15111502
match ty {
15121503
// sighandler_t is crazy across platforms
15131504
"sighandler_t" => true,
1514-
// `c_char_def` is always public but not always reexported.
1515-
"c_char_def" => true,
15161505
_ => false,
15171506
}
15181507
});
@@ -1674,8 +1663,6 @@ fn test_wasi(target: &str) {
16741663
}
16751664
});
16761665

1677-
cfg.skip_type(|ty| ty == "c_char_def");
1678-
16791666
// These have a different and internal type in header files and are only
16801667
// used here to generate a pointer to them in bindings so skip these tests.
16811668
cfg.skip_static(|c| c.starts_with("_CLOCK_"));
@@ -1924,9 +1911,6 @@ fn test_android(target: &str) {
19241911
// FIXME: "'__uint128' undeclared" in C
19251912
"__uint128" => true,
19261913

1927-
// `c_char_def` is always public but not always reexported.
1928-
"c_char_def" => true,
1929-
19301914
_ => false,
19311915
}
19321916
});
@@ -2689,9 +2673,6 @@ fn test_freebsd(target: &str) {
26892673
// `eventfd(2)` and things come with it are added in FreeBSD 13
26902674
"eventfd_t" if Some(13) > freebsd_ver => true,
26912675

2692-
// `c_char_def` is always public but not always reexported.
2693-
"c_char_def" => true,
2694-
26952676
_ => false,
26962677
}
26972678
});
@@ -3012,9 +2993,6 @@ fn test_emscripten(target: &str) {
30122993
// https://github.com/emscripten-core/emscripten/issues/5033
30132994
ty if ty.starts_with("epoll") => true,
30142995

3015-
// `c_char_def` is always public but not always reexported.
3016-
"c_char_def" => true,
3017-
30182996
// LFS64 types have been removed in Emscripten 3.1.44
30192997
// https://github.com/emscripten-core/emscripten/pull/19812
30202998
t => t.ends_with("64") || t.ends_with("64_t"),
@@ -3286,9 +3264,6 @@ fn test_neutrino(target: &str) {
32863264
// Does not exist in Neutrino
32873265
"locale_t" => true,
32883266

3289-
// `c_char_def` is always public but not always reexported.
3290-
"c_char_def" => true,
3291-
32923267
_ => false,
32933268
}
32943269
});
@@ -3455,8 +3430,6 @@ fn test_vxworks(target: &str) {
34553430
// FIXME
34563431
cfg.skip_type(move |ty| match ty {
34573432
"stat64" | "sighandler_t" | "off64_t" => true,
3458-
// `c_char_def` is always public but not always reexported.
3459-
"c_char_def" => true,
34603433
_ => false,
34613434
});
34623435

@@ -3804,9 +3777,6 @@ fn test_linux(target: &str) {
38043777
// FIXME: "'__uint128' undeclared" in C
38053778
"__uint128" => true,
38063779

3807-
// `c_char_def` is always public but not always reexported.
3808-
"c_char_def" => true,
3809-
38103780
t => {
38113781
if musl {
38123782
// LFS64 types have been removed in musl 1.2.4+
@@ -4036,7 +4006,7 @@ fn test_linux(target: &str) {
40364006
}
40374007
// FIXME: Requires >= 5.4 kernel headers
40384008
if name == "PTP_CLOCK_GETCAPS2"
4039-
|| name == "PTP_ENABLE_PPS2"
4009+
|| name == "PTP_ENABLE_PPS2"
40404010
|| name == "PTP_EXTTS_REQUEST2"
40414011
|| name == "PTP_PEROUT_REQUEST2"
40424012
|| name == "PTP_PIN_GETFUNC2"
@@ -4759,8 +4729,6 @@ fn test_linux_like_apis(target: &str) {
47594729
})
47604730
.skip_type(move |ty| match ty {
47614731
"Elf64_Phdr" | "Elf32_Phdr" => false,
4762-
// `c_char_def` is always public but not always reexported.
4763-
"c_char_def" => true,
47644732
_ => true,
47654733
});
47664734
cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_elf.rs");
@@ -4996,8 +4964,6 @@ fn test_haiku(target: &str) {
49964964
"pthread_condattr_t" => true,
49974965
"pthread_mutexattr_t" => true,
49984966
"pthread_rwlockattr_t" => true,
4999-
// `c_char_def` is always public but not always reexported.
5000-
"c_char_def" => true,
50014967
_ => false,
50024968
}
50034969
});

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
@@ -41,41 +41,35 @@ cfg_if! {
4141

4242
pub use core::ffi::c_void;
4343

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

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)