diff --git a/ci/style.rs b/ci/style.rs index f5aeabcc71b5..cad08f2eecc8 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 { diff --git a/libc-test/build.rs b/libc-test/build.rs index 1af2c40afdf1..1879334fb21a 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/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 853e4c0043dd..486d11e64a60 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/libc-test/semver/fuchsia.txt b/libc-test/semver/fuchsia.txt index f7bca9ab2e9c..12f67d8b4c60 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 71b88f579a39..8e56e3f62928 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, diff --git a/src/hermit.rs b/src/hermit.rs index 2b470e78d3af..9363fed78830 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/lib.rs b/src/lib.rs index 9ac6df16073e..569775095fa8 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; diff --git a/src/solid/aarch64.rs b/src/solid/aarch64.rs index ceabea397b80..4032488b6c0d 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 04cc1542deae..55240068aa08 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/teeos/mod.rs b/src/teeos/mod.rs index b9a46f946a84..40bc0c0549a0 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 2d2b78881a75..676a456d892f 100644 --- a/src/trusty.rs +++ b/src/trusty.rs @@ -1,18 +1,10 @@ -pub use core::ffi::c_void; - +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/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 72e5e7fdae55..ae4e366afdd4 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; diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index f214fe33702a..d35c40895510 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 ce9191476558..709b0d152444 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/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index 4e3898153357..1ac5113c917b 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; diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 120c4d54972f..1a8c89319fa2 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 95d1156bfc48..ed3e1ed8bfa3 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,7 +6,6 @@ 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; 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 3a8886e289a3..c55750922443 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1,6 +1,6 @@ +pub use crate::arch::c_char_def as c_char; use crate::prelude::*; -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 6f35a1e71284..0f398ca44826 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1,8 +1,8 @@ use core::mem::size_of; +pub use crate::arch::c_char_def as c_char; use crate::prelude::*; -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 e617bb83c6ce..40a8e338e83a 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 5e95ea2567dd..ccd68b0c64f8 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; diff --git a/triagebot.toml b/triagebot.toml index 6f8200cb14c2..7a103b8fb72a 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", ]