Skip to content
Merged
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ standard, it's just a list shared among all OSs that declare `#[cfg(unix)]`.
We have two automated tests running on
[GitHub Actions](https://github.com/rust-lang/libc/actions):

1. [`libc-test`](https://github.com/gnzlbg/ctest)
1. `libc-test`
- `cd libc-test && cargo test`
- Use the `skip_*()` functions in `build.rs` if you really need a workaround.
2. Style checker
Expand Down
6 changes: 0 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ const ALLOWED_CFGS: &[&str] = &[
"gnu_file_offset_bits64",
// Corresponds to `_TIME_BITS=64` in glibc
"gnu_time_bits64",
// FIXME(ctest): this config shouldn't be needed but ctest can't parse `const extern fn`
"libc_const_extern_fn",
"libc_deny_warnings",
"libc_thread_local",
"libc_ctest",
// Corresponds to `__USE_TIME_BITS64` in UAPI
"linux_time_bits64",
"musl_v1_2_3",
Expand Down Expand Up @@ -151,9 +148,6 @@ fn main() {
set_cfg("libc_thread_local");
}

// Set unconditionally when ctest is not being invoked.
set_cfg("libc_const_extern_fn");

// Since Rust 1.80, configuration that isn't recognized by default needs to be provided to
// avoid warnings.
if rustc_minor_ver >= 80 {
Expand Down
7 changes: 0 additions & 7 deletions ci/style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ while IFS= read -r file; do
# wouldn't be correct for something like `all(any(...), ...)`).
perl -pi -0777 -e 's/if #\[cfg\((.*?)\)\]/if cfg_tmp!([$1])/gms' "$file"

# We have some instances of `{const}` that make macros happy but aren't
# valid syntax. Replace this with just the keyword, plus an indicator
# comment on the preceding line (which is where rustfmt puts it. Also
# rust-lang/rustfmt#5464).
perl -pi -e 's/^(\s*)(.*)\{const\}/$1\/\* FMT-CONST \*\/\n$1$2const/g' "$file"

# Format the file. We need to invoke `rustfmt` directly since `cargo fmt`
# can't figure out the module tree with the hacks in place.
failed=false
Expand All @@ -45,7 +39,6 @@ while IFS= read -r file; do
# Restore all changes to the files.
perl -pi -e 's/fn (\w+)_fmt_tmp\(\)/$1!/g' "$file"
perl -pi -0777 -e 's/cfg_tmp!\(\[(.*?)\]\)/#[cfg($1)]/gms' "$file"
perl -pi -0777 -e 's/\/\* FMT-CONST \*\/(?:\n\s*)?(.*?)const/$1\{const\}/gms' "$file"

# Defer emitting the failure until after the files get reset
if [ "$failed" != "false" ]; then
Expand Down
5 changes: 0 additions & 5 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1795,11 +1795,6 @@ fn test_wasi(target: &str) {
"wchar.h",
}

// Currently `ctest2` doesn't support macros-in-static-expressions and will
// panic on them. That affects `CLOCK_*` defines in wasi to set this here
// to omit them.
cfg.cfg("libc_ctest", None);

cfg.rename_struct_ty(move |ty| match ty {
"FILE" | "fd_set" | "DIR" => Some(ty.to_string()),
t if t.ends_with("_t") => Some(t.to_string()),
Expand Down
40 changes: 20 additions & 20 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ pub type rlim_t = c_ulonglong;

// FIXME(fuchsia): why are these uninhabited types? that seems... wrong?
// Presumably these should be `()` or an `extern type` (when that stabilizes).
#[cfg_attr(feature = "extra_traits", derive(Debug))]
#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
}
#[cfg_attr(feature = "extra_traits", derive(Debug))]
#[derive(Debug)]
pub enum DIR {}
impl Copy for DIR {}
impl Clone for DIR {
Expand All @@ -97,7 +97,7 @@ impl Clone for DIR {
}
}

#[cfg_attr(feature = "extra_traits", derive(Debug))]
#[derive(Debug)]
pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct
impl Copy for fpos64_t {}
impl Clone for fpos64_t {
Expand Down Expand Up @@ -3326,57 +3326,57 @@ f! {
}
}

pub {const} fn CMSG_ALIGN(len: size_t) -> size_t {
pub const fn CMSG_ALIGN(len: size_t) -> size_t {
(len + size_of::<size_t>() - 1) & !(size_of::<size_t>() - 1)
}

pub {const} fn CMSG_SPACE(len: c_uint) -> c_uint {
pub const fn CMSG_SPACE(len: c_uint) -> c_uint {
(CMSG_ALIGN(len as size_t) + CMSG_ALIGN(size_of::<cmsghdr>())) as c_uint
}

pub {const} fn CMSG_LEN(len: c_uint) -> c_uint {
pub const fn CMSG_LEN(len: c_uint) -> c_uint {
(CMSG_ALIGN(size_of::<cmsghdr>()) + len as size_t) as c_uint
}
}

safe_f! {
pub {const} fn WIFSTOPPED(status: c_int) -> bool {
pub const fn WIFSTOPPED(status: c_int) -> bool {
(status & 0xff) == 0x7f
}

pub {const} fn WSTOPSIG(status: c_int) -> c_int {
pub const fn WSTOPSIG(status: c_int) -> c_int {
(status >> 8) & 0xff
}

pub {const} fn WIFCONTINUED(status: c_int) -> bool {
pub const fn WIFCONTINUED(status: c_int) -> bool {
status == 0xffff
}

pub {const} fn WIFSIGNALED(status: c_int) -> bool {
pub const fn WIFSIGNALED(status: c_int) -> bool {
((status & 0x7f) + 1) as i8 >= 2
}

pub {const} fn WTERMSIG(status: c_int) -> c_int {
pub const fn WTERMSIG(status: c_int) -> c_int {
status & 0x7f
}

pub {const} fn WIFEXITED(status: c_int) -> bool {
pub const fn WIFEXITED(status: c_int) -> bool {
(status & 0x7f) == 0
}

pub {const} fn WEXITSTATUS(status: c_int) -> c_int {
pub const fn WEXITSTATUS(status: c_int) -> c_int {
(status >> 8) & 0xff
}

pub {const} fn WCOREDUMP(status: c_int) -> bool {
pub const fn WCOREDUMP(status: c_int) -> bool {
(status & 0x80) != 0
}

pub {const} fn QCMD(cmd: c_int, type_: c_int) -> c_int {
pub const fn QCMD(cmd: c_int, type_: c_int) -> c_int {
(cmd << 8) | (type_ & 0x00ff)
}

pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t {
pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t {
let major = major as crate::dev_t;
let minor = minor as crate::dev_t;
let mut dev = 0;
Expand All @@ -3387,14 +3387,14 @@ safe_f! {
dev
}

pub {const} fn major(dev: crate::dev_t) -> c_uint {
pub const fn major(dev: crate::dev_t) -> c_uint {
let mut major = 0;
major |= (dev & 0x00000000000fff00) >> 8;
major |= (dev & 0xfffff00000000000) >> 32;
major as c_uint
}

pub {const} fn minor(dev: crate::dev_t) -> c_uint {
pub const fn minor(dev: crate::dev_t) -> c_uint {
let mut minor = 0;
minor |= (dev & 0x00000000000000ff) >> 0;
minor |= (dev & 0x00000ffffff00000) >> 12;
Expand All @@ -3421,15 +3421,15 @@ fn __MHDR_END(mhdr: *const msghdr) -> *mut c_uchar {
#[link(name = "fdio")]
extern "C" {}

#[cfg_attr(feature = "extra_traits", derive(Debug))]
#[derive(Debug)]
pub enum FILE {}
impl Copy for FILE {}
impl Clone for FILE {
fn clone(&self) -> FILE {
*self
}
}
#[cfg_attr(feature = "extra_traits", derive(Debug))]
#[derive(Debug)]
pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct
impl Copy for fpos_t {}
impl Clone for fpos_t {
Expand Down
8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
unused_macros,
unused_macro_rules,
)]
#![warn(
missing_copy_implementations,
missing_debug_implementations,
safe_packed_borrows
)]
// Prepare for a future upgrade
#![warn(rust_2024_compatibility)]
// Things missing for 2024 that are blocked on MSRV or breakage
Expand All @@ -25,9 +30,6 @@
#![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))]
// DIFF(1.0): The thread local references that raise this lint were removed in 1.0
#![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))]
// Enable extra lints:
#![cfg_attr(feature = "extra_traits", warn(missing_debug_implementations))]
#![warn(missing_copy_implementations, safe_packed_borrows)]
#![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
#![cfg_attr(feature = "rustc-dep-of-std", no_core)]

Expand Down
Loading
Loading