From fabe9c12f24617a1f4fc84d3dada942216622ba6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 9 Dec 2024 08:12:59 +0000 Subject: [PATCH 1/9] triagebot: Remove JohnTitor from the review rotation (backport ) (cherry picked from commit 65d0ffbd90fe8d79a16f4cb006db8ce985d28793) --- triagebot.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/triagebot.toml b/triagebot.toml index 6f8200cb14c25..7a103b8fb72a6 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -11,7 +11,6 @@ contributing_url = "https://github.com/rust-lang/libc/blob/HEAD/CONTRIBUTING.md" [assign.owners] "*" = [ - "@JohnTitor", "@tgross35", ] From 7fc5940d485e4d7dc5d115e9adbd67ce5e0f6165 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 10 Dec 2024 21:48:49 +0000 Subject: [PATCH 2/9] freebsd add more socket TCP stack constants. [ref](https://man.freebsd.org/cgi/man.cgi?query=tcp) (backport ) (cherry picked from commit abf49f6700de09c1a1801226f8e973a455e6eb43) --- libc-test/semver/freebsd.txt | 22 ++++++++++++++++++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 24 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 853e4c0043ddc..486d11e64a60a 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1504,6 +1504,17 @@ S_IWRITE TAB0 TAB3 TABDLY +TCP_BBR_ALGORITHM +TCP_BBR_DRAIN_PG +TCP_BBR_IWINTSO +TCP_BBR_MAX_RTO +TCP_BBR_MIN_RTO +TCP_BBR_PACE_OH +TCP_BBR_PROBE_RTT_INT +TCP_BBR_STARTUP_LOSS_EXIT +TCP_BBR_STARTUP_PG +TCP_BBR_TSLIMITS +TCP_BBR_USEDEL_RATE TCP_CCALGOOPT TCP_CONGESTION TCP_DELACK @@ -1530,7 +1541,18 @@ TCP_PCAP_IN TCP_PCAP_OUT TCP_PERF_INFO TCP_PROC_ACCOUNTING +TCP_RACK_EARLY_SEG +TCP_RACK_MBUF_QUEUE +TCP_RACK_MIN_TO +TCP_RACK_PACE_ALWAYS +TCP_RACK_PACE_MAX_SEG +TCP_RACK_PKT_DELAY +TCP_RACK_PRR_SENDALOT +TCP_RACK_REORD_FADE +TCP_RACK_REORD_THRESH +TCP_RACK_TLP_REDUCE TCP_REMOTE_UDP_ENCAPS_PORT +TCP_REUSPORT_LB_NUMA TCP_SHARED_CWND_ALLOWED TCP_USE_CMP_ACKS THOUSEP diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 72e5e7fdae553..ae4e366afdd48 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3764,6 +3764,30 @@ pub const TCP_FUNCTION_ALIAS: c_int = 8193; pub const TCP_FASTOPEN_PSK_LEN: c_int = 16; pub const TCP_FUNCTION_NAME_LEN_MAX: c_int = 32; +pub const TCP_REUSPORT_LB_NUMA: c_int = 1026; +pub const TCP_RACK_MBUF_QUEUE: c_int = 1050; +pub const TCP_RACK_TLP_REDUCE: c_int = 1052; +pub const TCP_RACK_PACE_MAX_SEG: c_int = 1054; +pub const TCP_RACK_PACE_ALWAYS: c_int = 1055; +pub const TCP_RACK_PRR_SENDALOT: c_int = 1057; +pub const TCP_RACK_MIN_TO: c_int = 1058; +pub const TCP_RACK_EARLY_SEG: c_int = 1060; +pub const TCP_RACK_REORD_THRESH: c_int = 1061; +pub const TCP_RACK_REORD_FADE: c_int = 1062; +pub const TCP_RACK_TLP_THRESH: c_int = 1063; +pub const TCP_RACK_PKT_DELAY: c_int = 1064; +pub const TCP_BBR_IWINTSO: c_int = 1067; +pub const TCP_BBR_STARTUP_PG: c_int = 1069; +pub const TCP_BBR_DRAIN_PG: c_int = 1070; +pub const TCP_BBR_PROBE_RTT_INT: c_int = 1072; +pub const TCP_BBR_STARTUP_LOSS_EXIT: c_int = 1074; +pub const TCP_BBR_TSLIMITS: c_int = 1076; +pub const TCP_BBR_PACE_OH: c_int = 1077; +pub const TCP_BBR_USEDEL_RATE: c_int = 1079; +pub const TCP_BBR_MIN_RTO: c_int = 1080; +pub const TCP_BBR_MAX_RTO: c_int = 1081; +pub const TCP_BBR_ALGORITHM: c_int = 1083; + pub const IP_BINDANY: c_int = 24; pub const IP_BINDMULTI: c_int = 25; pub const IP_RSS_LISTEN_BUCKET: c_int = 26; From eb4649d1bd29b13671df9451bcc95d3470e218d3 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Wed, 11 Dec 2024 21:11:47 +0000 Subject: [PATCH 3/9] Add sockaddr_vm definition for Fuchsia (backport ) (cherry picked from commit 816a236462f9d4031a63e890b0e046e2ce1c1af4) --- libc-test/semver/fuchsia.txt | 1 + src/fuchsia/mod.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/libc-test/semver/fuchsia.txt b/libc-test/semver/fuchsia.txt index f7bca9ab2e9cb..12f67d8b4c606 100644 --- a/libc-test/semver/fuchsia.txt +++ b/libc-test/semver/fuchsia.txt @@ -1446,6 +1446,7 @@ sigwait sigwaitinfo sockaddr_ll sockaddr_nl +sockaddr_vm splice spwd srand diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 71b88f579a394..8e56e3f62928d 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -357,6 +357,14 @@ s! { pub sin6_scope_id: u32, } + pub struct sockaddr_vm { + pub svm_family: sa_family_t, + pub svm_reserved1: c_ushort, + pub svm_port: crate::in_port_t, + pub svm_cid: c_uint, + pub svm_zero: [u8; 4], + } + pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, From 3eb9670cf3edd77e5688586347ebca20e37e1d30 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Fri, 13 Dec 2024 11:41:16 +0100 Subject: [PATCH 4/9] feat: Update c_char type (backport ) (cherry picked from commit c66faeba57869080a3fded445acdb5a42116f628) --- src/unix/newlib/espidf/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index 4e3898153357d..1ac5113c917b5 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -1,7 +1,7 @@ use crate::prelude::*; pub type clock_t = c_ulong; -pub type c_char = i8; +pub type c_char = u8; pub type wchar_t = u32; pub type c_long = i32; From 9fea17aad1b6d08a6598be82df9cfef91fa8744d Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 17 Dec 2024 09:57:41 +0000 Subject: [PATCH 5/9] Mirror `c_char` configuration from `rust-lang/rust` Create a module providing the same definitions of `c_char` as in `rust-lang/rust`, which in most cases are based on the architecture rather than the OS. This will allow individual platforms to reexport the definition rather than having configuration repeated in numerous modules. (backport ) (cherry picked from commit 28d406458efb715b5b1b37f57b27617f3b56110b) --- libc-test/build.rs | 35 ++++++++++++++++++++++++++++++++++- src/lib.rs | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 1af2c40afdf1b..1879334fb21a9 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -364,6 +364,9 @@ fn test_apple(target: &str) { // FIXME: "'__uint128' undeclared" in C "__uint128" => true, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, + _ => false, } }); @@ -758,6 +761,8 @@ fn test_windows(target: &str) { "ssize_t" if !gnu => true, // FIXME: The size and alignment of this type are incorrect "time_t" if gnu && i686 => true, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, _ => false, }); @@ -975,6 +980,8 @@ fn test_solarish(target: &str) { cfg.skip_type(move |ty| match ty { "sighandler_t" => true, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, _ => false, }); @@ -1278,6 +1285,8 @@ fn test_netbsd(target: &str) { match ty { // FIXME: sighandler_t is crazy across platforms "sighandler_t" => true, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, _ => false, } }); @@ -1497,7 +1506,8 @@ fn test_dragonflybsd(target: &str) { match ty { // sighandler_t is crazy across platforms "sighandler_t" => true, - + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, _ => false, } }); @@ -1659,6 +1669,8 @@ fn test_wasi(target: &str) { } }); + cfg.skip_type(|ty| ty == "c_char_def"); + // These have a different and internal type in header files and are only // used here to generate a pointer to them in bindings so skip these tests. cfg.skip_static(|c| c.starts_with("_CLOCK_")); @@ -1907,6 +1919,9 @@ fn test_android(target: &str) { // FIXME: "'__uint128' undeclared" in C "__uint128" => true, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, + _ => false, } }); @@ -2669,6 +2684,9 @@ fn test_freebsd(target: &str) { // `eventfd(2)` and things come with it are added in FreeBSD 13 "eventfd_t" if Some(13) > freebsd_ver => true, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, + _ => false, } }); @@ -2989,6 +3007,9 @@ fn test_emscripten(target: &str) { // https://github.com/emscripten-core/emscripten/issues/5033 ty if ty.starts_with("epoll") => true, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, + // LFS64 types have been removed in Emscripten 3.1.44 // https://github.com/emscripten-core/emscripten/pull/19812 t => t.ends_with("64") || t.ends_with("64_t"), @@ -3260,6 +3281,9 @@ fn test_neutrino(target: &str) { // Does not exist in Neutrino "locale_t" => true, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, + _ => false, } }); @@ -3426,6 +3450,8 @@ fn test_vxworks(target: &str) { // FIXME cfg.skip_type(move |ty| match ty { "stat64" | "sighandler_t" | "off64_t" => true, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, _ => false, }); @@ -3773,6 +3799,9 @@ fn test_linux(target: &str) { // FIXME: "'__uint128' undeclared" in C "__uint128" => true, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, + t => { if musl { // LFS64 types have been removed in musl 1.2.4+ @@ -4725,6 +4754,8 @@ fn test_linux_like_apis(target: &str) { }) .skip_type(move |ty| match ty { "Elf64_Phdr" | "Elf32_Phdr" => false, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, _ => true, }); cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_elf.rs"); @@ -4960,6 +4991,8 @@ fn test_haiku(target: &str) { "pthread_condattr_t" => true, "pthread_mutexattr_t" => true, "pthread_rwlockattr_t" => true, + // `c_char_def` is always public but not always reexported. + "c_char_def" => true, _ => false, } }); diff --git a/src/lib.rs b/src/lib.rs index 9ac6df16073ee..569775095fa8c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,6 +41,44 @@ cfg_if! { pub use core::ffi::c_void; +/// Type definitions that are coupled tighter to architecture than OS. +mod arch { + cfg_if! { + // This configuration comes from `rust-lang/rust` in `library/core/src/ffi/mod.rs`. + if #[cfg(all( + not(windows), + // FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it + not(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + )), + any( + target_arch = "aarch64", + target_arch = "arm", + target_arch = "csky", + target_arch = "hexagon", + target_arch = "msp430", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "riscv64", + target_arch = "riscv32", + target_arch = "s390x", + target_arch = "xtensa", + ) + ))] { + // To be reexported as `c_char` + // FIXME(ctest): just name these `c_char` once `ctest` learns that these don't get + // exported. + pub type c_char_def = u8; + } else { + pub type c_char_def = i8; + } + } +} + cfg_if! { if #[cfg(windows)] { mod fixed_width_ints; From 7e761a52d82bfa79fd6d872da6389e358e685e27 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 17 Dec 2024 20:06:16 +0900 Subject: [PATCH 6/9] Fix c_char on various targets - aarch64-kmc-solid_asp3 - armv7a-kmc-solid_asp3-eabi - armv7a-kmc-solid_asp3-eabihf - riscv64-linux-android - x86_64-unknown-l4re-uclibc - armv7-sony-vita-newlibeabihf - riscv32imac-unknown-nuttx-elf - riscv32imafc-unknown-nuttx-elf - riscv32imc-unknown-nuttx-elf - riscv64gc-unknown-nuttx-elf - riscv64imac-unknown-nuttx-elf - thumbv6m-nuttx-eabi - thumbv7em-nuttx-eabi - thumbv7em-nuttx-eabihf - thumbv7m-nuttx-eabi - thumbv8m.base-nuttx-eabi - thumbv8m.main-nuttx-eabi - thumbv8m.main-nuttx-eabihf - aarch64-unknown-redox - aarch64-unknown-illumos - riscv32-wrs-vxworks - riscv64-wrs-vxworks (backport ) (cherry picked from commit 0344a78d8ebfc3bf9c924df994541df6ac72280d) --- src/solid/aarch64.rs | 2 +- src/solid/arm.rs | 2 +- src/unix/linux_like/android/b64/riscv64/mod.rs | 2 +- src/unix/linux_like/linux/uclibc/x86_64/mod.rs | 2 +- src/unix/newlib/vita/mod.rs | 2 +- src/unix/nuttx/mod.rs | 12 +++++++++++- src/unix/redox/mod.rs | 8 +++++++- src/unix/solarish/mod.rs | 8 +++++++- src/vxworks/riscv32.rs | 2 +- src/vxworks/riscv64.rs | 2 +- 10 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/solid/aarch64.rs b/src/solid/aarch64.rs index ceabea397b804..4032488b6c0d5 100644 --- a/src/solid/aarch64.rs +++ b/src/solid/aarch64.rs @@ -1,4 +1,4 @@ -pub type c_char = i8; +pub type c_char = u8; pub type wchar_t = u32; pub type c_long = i64; pub type c_ulong = u64; diff --git a/src/solid/arm.rs b/src/solid/arm.rs index 04cc1542deaeb..55240068aa08e 100644 --- a/src/solid/arm.rs +++ b/src/solid/arm.rs @@ -1,4 +1,4 @@ -pub type c_char = i8; +pub type c_char = u8; pub type wchar_t = u32; pub type c_long = i32; pub type c_ulong = u32; diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index f214fe33702a4..d35c408955109 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -1,7 +1,7 @@ use crate::off64_t; use crate::prelude::*; -pub type c_char = i8; +pub type c_char = u8; pub type wchar_t = u32; pub type greg_t = i64; pub type __u64 = c_ulonglong; diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index ce91914765581..709b0d152444a 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -6,7 +6,7 @@ use crate::prelude::*; pub type blkcnt_t = i64; pub type blksize_t = i64; pub type clock_t = i64; -pub type c_char = u8; +pub type c_char = i8; pub type c_long = i64; pub type c_ulong = u64; pub type fsblkcnt_t = c_ulong; diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 120c4d54972f5..1a8c89319fa2d 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -3,7 +3,7 @@ use crate::prelude::*; pub type clock_t = c_long; -pub type c_char = i8; +pub type c_char = u8; pub type wchar_t = u32; pub type c_long = i32; diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 95d1156bfc48b..78ecf3f133505 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -5,7 +5,17 @@ pub type nlink_t = u16; pub type ino_t = u16; pub type blkcnt_t = u64; pub type blksize_t = i16; -pub type c_char = i8; +cfg_if! { + if #[cfg(any( + target_arch = "arm", + target_arch = "riscv32", + target_arch = "riscv64", + ))] { + pub type c_char = u8; + } else { + pub type c_char = i8; + } +} pub type c_long = isize; pub type c_ulong = usize; pub type cc_t = u8; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 3a8886e289a32..7c2e36f8bab98 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1,6 +1,12 @@ use crate::prelude::*; -pub type c_char = i8; +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + pub type c_char = u8; + } else { + pub type c_char = i8; + } +} pub type wchar_t = i32; cfg_if! { diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 6f35a1e712843..fa00988dceab6 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2,7 +2,13 @@ use core::mem::size_of; use crate::prelude::*; -pub type c_char = i8; +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + pub type c_char = u8; + } else { + pub type c_char = i8; + } +} pub type c_long = i64; pub type c_ulong = u64; pub type caddr_t = *mut c_char; diff --git a/src/vxworks/riscv32.rs b/src/vxworks/riscv32.rs index e617bb83c6ce3..40a8e338e83a2 100644 --- a/src/vxworks/riscv32.rs +++ b/src/vxworks/riscv32.rs @@ -1,4 +1,4 @@ -pub type c_char = i8; +pub type c_char = u8; pub type wchar_t = i32; pub type c_long = i32; pub type c_ulong = u32; diff --git a/src/vxworks/riscv64.rs b/src/vxworks/riscv64.rs index 5e95ea2567ddf..ccd68b0c64f82 100644 --- a/src/vxworks/riscv64.rs +++ b/src/vxworks/riscv64.rs @@ -1,4 +1,4 @@ -pub type c_char = i8; +pub type c_char = u8; pub type wchar_t = i32; pub type c_long = i64; pub type c_ulong = u64; From 3e09b7c0a08d5699de81d866263371f5fbd0c95f Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 17 Dec 2024 20:33:03 +0900 Subject: [PATCH 7/9] Do not re-export c_void in target-specific code (backport ) (cherry picked from commit c389c3059e782825c92159eadfc34c8806dede4b) --- src/teeos/mod.rs | 3 --- src/trusty.rs | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index b9a46f946a84d..40bc0c0549a08 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -5,9 +5,6 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] -// only supported on Rust > 1.59, so we can directly reexport c_void from core. -pub use core::ffi::c_void; - use crate::prelude::*; pub type c_schar = i8; diff --git a/src/trusty.rs b/src/trusty.rs index 2d2b78881a75f..60ca11d481613 100644 --- a/src/trusty.rs +++ b/src/trusty.rs @@ -1,4 +1,4 @@ -pub use core::ffi::c_void; +use crate::prelude::*; pub type size_t = usize; pub type ssize_t = isize; From 0567b59f0b9b2415d5a9d4845a09bdddd2d0a7d1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 17 Dec 2024 21:29:10 +0000 Subject: [PATCH 8/9] Ignore ordering style for `c_char` (backport ) (cherry picked from commit c33744ea5af50e876fb4ed954178a1f82d42308b) --- ci/style.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ci/style.rs b/ci/style.rs index f5aeabcc71b5a..cad08f2eecc88 100644 --- a/ci/style.rs +++ b/ci/style.rs @@ -28,10 +28,9 @@ //! * alignment //! * leading colons on paths -use std::env; -use std::fs; use std::io::prelude::*; use std::path::Path; +use std::{env, fs}; macro_rules! t { ($e:expr) => { @@ -130,7 +129,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) { let line = if is_pub { &line[4..] } else { line }; let line_state = if line.starts_with("use ") { - if line.contains("c_void") { + if line.contains("c_void") || line.contains("c_char") { continue; } if is_pub { From 2ade12cd84b3beccc287cb8bea475a7f08500af6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 17 Dec 2024 21:30:30 +0000 Subject: [PATCH 9/9] Replace arch-conditional `c_char` with a reexport For any platforms that have `c_char` within a `cfg_if` block, ensure they match the top-level `arch` definitions and reexport that to clean up code. (backport ) (cherry picked from commit fead383bf485cbed830b2686cf45ae5a12b74138) --- src/hermit.rs | 9 +-------- src/trusty.rs | 10 +--------- src/unix/nuttx/mod.rs | 12 +----------- src/unix/redox/mod.rs | 8 +------- src/unix/solarish/mod.rs | 8 +------- 5 files changed, 5 insertions(+), 42 deletions(-) diff --git a/src/hermit.rs b/src/hermit.rs index 2b470e78d3afe..9363fed788304 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -1,15 +1,8 @@ //! Hermit C type definitions +pub use crate::arch::c_char_def as c_char; use crate::prelude::*; -cfg_if! { - if #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] { - pub type c_char = u8; - } else { - pub type c_char = i8; - } -} - pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; diff --git a/src/trusty.rs b/src/trusty.rs index 60ca11d481613..676a456d892fe 100644 --- a/src/trusty.rs +++ b/src/trusty.rs @@ -1,18 +1,10 @@ +pub use crate::arch::c_char_def as c_char; use crate::prelude::*; - pub type size_t = usize; pub type ssize_t = isize; pub type off_t = i64; -cfg_if! { - if #[cfg(any(target_arch = "aarch64", target_arch = "arm"))] { - pub type c_char = u8; - } else if #[cfg(target_arch = "x86_64")] { - pub type c_char = i8; - } -} - pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 78ecf3f133505..ed3e1ed8bfa34 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -1,3 +1,4 @@ +pub use crate::arch::c_char_def as c_char; use crate::prelude::*; use crate::{in6_addr, in_addr_t, timespec, DIR}; @@ -5,17 +6,6 @@ pub type nlink_t = u16; pub type ino_t = u16; pub type blkcnt_t = u64; pub type blksize_t = i16; -cfg_if! { - if #[cfg(any( - target_arch = "arm", - target_arch = "riscv32", - target_arch = "riscv64", - ))] { - pub type c_char = u8; - } else { - pub type c_char = i8; - } -} pub type c_long = isize; pub type c_ulong = usize; pub type cc_t = u8; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 7c2e36f8bab98..c557509224437 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1,12 +1,6 @@ +pub use crate::arch::c_char_def as c_char; use crate::prelude::*; -cfg_if! { - if #[cfg(target_arch = "aarch64")] { - pub type c_char = u8; - } else { - pub type c_char = i8; - } -} pub type wchar_t = i32; cfg_if! { diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index fa00988dceab6..0f398ca448263 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1,14 +1,8 @@ use core::mem::size_of; +pub use crate::arch::c_char_def as c_char; use crate::prelude::*; -cfg_if! { - if #[cfg(target_arch = "aarch64")] { - pub type c_char = u8; - } else { - pub type c_char = i8; - } -} pub type c_long = i64; pub type c_ulong = u64; pub type caddr_t = *mut c_char;