From 1483c7c7b97fd9a8033354cc0fb0fc35dcfa21a2 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 22 Sep 2025 22:32:31 -0500 Subject: [PATCH 1/2] cleanup: Simplify the syntax of `f!` and similar macros We no longer need to support gating `const` behind `libc_const_extern_fn`, so remove the awkward `{const}` syntax. --- ci/style.sh | 7 ---- src/fuchsia/mod.rs | 30 ++++++------- src/macros.rs | 26 +++++++----- src/unix/aix/mod.rs | 26 ++++++------ src/unix/bsd/apple/mod.rs | 22 +++++----- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 14 +++---- .../bsd/freebsdlike/freebsd/freebsd11/mod.rs | 6 +-- .../bsd/freebsdlike/freebsd/freebsd12/mod.rs | 6 +-- .../bsd/freebsdlike/freebsd/freebsd13/mod.rs | 6 +-- .../bsd/freebsdlike/freebsd/freebsd14/mod.rs | 6 +-- .../bsd/freebsdlike/freebsd/freebsd15/mod.rs | 6 +-- src/unix/bsd/freebsdlike/freebsd/mod.rs | 28 ++++++------- src/unix/bsd/freebsdlike/mod.rs | 6 +-- src/unix/bsd/mod.rs | 10 ++--- src/unix/bsd/netbsdlike/netbsd/mod.rs | 20 ++++----- src/unix/bsd/netbsdlike/openbsd/mod.rs | 20 ++++----- src/unix/cygwin/mod.rs | 26 ++++++------ src/unix/haiku/mod.rs | 22 +++++----- src/unix/hurd/mod.rs | 42 +++++++++---------- src/unix/linux_like/android/mod.rs | 6 +-- src/unix/linux_like/emscripten/mod.rs | 6 +-- src/unix/linux_like/linux/mod.rs | 12 +++--- src/unix/linux_like/mod.rs | 38 ++++++++--------- src/unix/mod.rs | 8 ++-- src/unix/newlib/horizon/mod.rs | 16 +++---- src/unix/newlib/rtems/mod.rs | 16 +++---- src/unix/nto/mod.rs | 32 +++++++------- src/unix/redox/mod.rs | 22 +++++----- src/unix/solarish/mod.rs | 26 ++++++------ src/vxworks/mod.rs | 18 ++++---- 30 files changed, 264 insertions(+), 265 deletions(-) diff --git a/ci/style.sh b/ci/style.sh index 2d3e874e38998..200cc15cfa16a 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -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 @@ -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 diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 35bac6169beae..2be025de53d36 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3374,57 +3374,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::() - 1) & !(size_of::() - 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::())) 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::()) + 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; @@ -3435,14 +3435,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; diff --git a/src/macros.rs b/src/macros.rs index 969a635018998..50d1663d9b2d4 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -296,40 +296,46 @@ macro_rules! c_enum { macro_rules! f { ($( $(#[$attr:meta])* - pub $({$constness:ident})? fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty + // Less than ideal hack to match either `fn` or `const fn`. + pub $(fn $i:ident)? $(const fn $const_i:ident)? + ($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty $body:block - )*) => ($( + )+) => {$( #[inline] $(#[$attr])* - pub $($constness)? unsafe extern "C" fn $i($($arg: $argty),*) -> $ret + pub $(unsafe extern "C" fn $i)? $(const unsafe extern "C" fn $const_i)? + ($($arg: $argty),*) -> $ret $body - )*) + )+}; } /// Define a safe function. macro_rules! safe_f { ($( $(#[$attr:meta])* - pub $({$constness:ident})? fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty + // Less than ideal hack to match either `fn` or `const fn`. + pub $(fn $i:ident)? $(const fn $const_i:ident)? + ($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty $body:block - )*) => ($( + )+) => {$( #[inline] $(#[$attr])* - pub $($constness)? extern "C" fn $i($($arg: $argty),*) -> $ret + pub $(extern "C" fn $i)? $(const extern "C" fn $const_i)? + ($($arg: $argty),*) -> $ret $body - )*) + )+}; } /// Define a nonpublic function. macro_rules! const_fn { ($( $(#[$attr:meta])* - $({$constness:ident})? fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty + const fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty $body:block )*) => ($( #[inline] $(#[$attr])* - $($constness)? fn $i($($arg: $argty),*) -> $ret + const fn $i($($arg: $argty),*) -> $ret $body )*) } diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 7ffd435798b45..7e3c8289c475a 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2457,11 +2457,11 @@ f! { (cmsg as *mut c_uchar).offset(size_of::() as isize) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { size_of::() as c_uint + length } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { size_of::() as c_uint + length } @@ -2493,11 +2493,11 @@ f! { } safe_f! { - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & _W_STOPPED) != 0 } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { if WIFSTOPPED(status) { (((status as c_uint) >> 8) & 0xff) as c_int } else { @@ -2505,11 +2505,11 @@ safe_f! { } } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0xFF) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { if WIFEXITED(status) { (((status as c_uint) >> 8) & 0xff) as c_int } else { @@ -2517,11 +2517,11 @@ safe_f! { } } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { !WIFEXITED(status) && !WIFSTOPPED(status) } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { if WIFSIGNALED(status) { (((status as c_uint) >> 16) & 0xff) as c_int } else { @@ -2529,26 +2529,26 @@ safe_f! { } } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { (status & WCONTINUED) != 0 } // AIX doesn't have native WCOREDUMP. - pub {const} fn WCOREDUMP(_status: c_int) -> bool { + pub const fn WCOREDUMP(_status: c_int) -> bool { false } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { let x = dev >> 16; x as c_uint } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { let y = dev & 0xFFFF; y as c_uint } - 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; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 93d9d52a9c60b..2c9fa9a7cddf8 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -5022,49 +5022,49 @@ f! { (cmsg as *mut c_uchar).add(__DARWIN_ALIGN32(size_of::())) } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { (__DARWIN_ALIGN32(size_of::()) + __DARWIN_ALIGN32(length as usize)) as c_uint } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { (__DARWIN_ALIGN32(size_of::()) + length as usize) as c_uint } - pub {const} fn VM_MAKE_TAG(id: u8) -> u32 { + pub const fn VM_MAKE_TAG(id: u8) -> u32 { (id as u32) << 24u32 } } safe_f! { - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { status >> 8 } - pub {const} fn _WSTATUS(status: c_int) -> c_int { + pub const fn _WSTATUS(status: c_int) -> c_int { status & 0x7f } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) == 0x13 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { _WSTATUS(status) != _WSTOPPED && _WSTATUS(status) != 0 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) != 0x13 } - pub {const} fn makedev(major: i32, minor: i32) -> dev_t { + pub const fn makedev(major: i32, minor: i32) -> dev_t { (major << 24) | minor } - pub {const} fn major(dev: dev_t) -> i32 { + pub const fn major(dev: dev_t) -> i32 { (dev >> 24) & 0xff } - pub {const} fn minor(dev: dev_t) -> i32 { + pub const fn minor(dev: dev_t) -> i32 { dev & 0xffffff } } diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index a87e0a3ffa4c4..6e5da73afc458 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1422,7 +1422,7 @@ pub const RTAX_MPLS3: c_int = 10; pub const RTAX_MAX: c_int = 11; const_fn! { - {const} fn _CMSG_ALIGN(n: usize) -> usize { + const fn _CMSG_ALIGN(n: usize) -> usize { (n + (size_of::() - 1)) & !(size_of::() - 1) } } @@ -1432,7 +1432,7 @@ f! { (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(size_of::()) as isize) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { (_CMSG_ALIGN(size_of::()) + length as usize) as c_uint } @@ -1448,7 +1448,7 @@ f! { } } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { (_CMSG_ALIGN(size_of::()) + _CMSG_ALIGN(length as usize)) as c_uint } @@ -1477,11 +1477,11 @@ f! { } safe_f! { - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 } - 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; @@ -1490,11 +1490,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { ((dev >> 8) & 0xff) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (dev & 0xffff00ff) as c_int } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index e66fc03545de1..83b058f8cec6f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -385,17 +385,17 @@ pub const MINCORE_SUPER: c_int = 0x20; pub const SPECNAMELEN: c_int = 63; safe_f! { - 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; (major << 8) | minor } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { ((dev >> 8) & 0xff) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (dev & 0xffff00ff) as c_int } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 073beb2dccb7c..8dcf4707749b3 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -434,7 +434,7 @@ pub const KI_NSPARE_PTR: usize = 6; pub const MINCORE_SUPER: c_int = 0x20; safe_f! { - 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; @@ -445,11 +445,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index b566c1a1632cf..06b4304fc5326 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -456,7 +456,7 @@ pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; pub const MINCORE_SUPER: c_int = 0x20; safe_f! { - 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; @@ -467,11 +467,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index a46d6b7a49fa9..1413ef7a8de4f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -458,7 +458,7 @@ pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; pub const MINCORE_SUPER: c_int = 0x60; safe_f! { - 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; @@ -469,11 +469,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index ef27418cc9af5..72af5f164df99 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -460,7 +460,7 @@ pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; pub const MINCORE_SUPER: c_int = 0x60; safe_f! { - 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; @@ -471,11 +471,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 1747f9f3c2d6c..c406a6b771631 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4656,7 +4656,7 @@ pub const fn MAP_ALIGNED(a: c_int) -> c_int { } const_fn! { - {const} fn _ALIGN(p: usize) -> usize { + const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } } @@ -4666,7 +4666,7 @@ f! { (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { _ALIGN(size_of::()) as c_uint + length } @@ -4683,7 +4683,7 @@ f! { } } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { (_ALIGN(size_of::()) + _ALIGN(length as usize)) as c_uint } @@ -4691,11 +4691,11 @@ f! { ffsl(lg as c_long - 1) } - pub {const} fn MALLOCX_TCACHE(tc: c_int) -> c_int { + pub const fn MALLOCX_TCACHE(tc: c_int) -> c_int { (tc + 2) << 8 as c_int } - pub {const} fn MALLOCX_ARENA(a: c_int) -> c_int { + pub const fn MALLOCX_ARENA(a: c_int) -> c_int { (a + 1) << 20 as c_int } @@ -4764,11 +4764,11 @@ f! { } safe_f! { - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 && status != 0x13 } - pub {const} fn INVALID_SINFO_FLAG(x: c_int) -> bool { + pub const fn INVALID_SINFO_FLAG(x: c_int) -> bool { (x) & 0xfffffff0 & !(SCTP_EOF | SCTP_ABORT @@ -4780,31 +4780,31 @@ safe_f! { != 0 } - pub {const} fn PR_SCTP_POLICY(x: c_int) -> c_int { + pub const fn PR_SCTP_POLICY(x: c_int) -> c_int { x & 0x0f } - pub {const} fn PR_SCTP_ENABLED(x: c_int) -> bool { + pub const fn PR_SCTP_ENABLED(x: c_int) -> bool { PR_SCTP_POLICY(x) != SCTP_PR_SCTP_NONE && PR_SCTP_POLICY(x) != SCTP_PR_SCTP_ALL } - pub {const} fn PR_SCTP_TTL_ENABLED(x: c_int) -> bool { + pub const fn PR_SCTP_TTL_ENABLED(x: c_int) -> bool { PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL } - pub {const} fn PR_SCTP_BUF_ENABLED(x: c_int) -> bool { + pub const fn PR_SCTP_BUF_ENABLED(x: c_int) -> bool { PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF } - pub {const} fn PR_SCTP_RTX_ENABLED(x: c_int) -> bool { + pub const fn PR_SCTP_RTX_ENABLED(x: c_int) -> bool { PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX } - pub {const} fn PR_SCTP_INVALID_POLICY(x: c_int) -> bool { + pub const fn PR_SCTP_INVALID_POLICY(x: c_int) -> bool { PR_SCTP_POLICY(x) > SCTP_PR_SCTP_MAX } - pub {const} fn PR_SCTP_VALID_POLICY(x: c_int) -> bool { + pub const fn PR_SCTP_VALID_POLICY(x: c_int) -> bool { PR_SCTP_POLICY(x) <= SCTP_PR_SCTP_MAX } } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index a3027a21abd6b..5dabe047633f0 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1479,15 +1479,15 @@ pub const POSIX_SPAWN_SETSIGDEF: c_short = 0x10; pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x20; safe_f! { - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { status == 0x13 } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { status >> 8 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0o177) == 0o177 } } diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 63897640635c1..7b18afa0842ca 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -608,23 +608,23 @@ f! { } safe_f! { - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0o177 } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0o177) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0x00ff } - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0o200) != 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) } } diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 611df0b9ec89c..f8eaf4b3be455 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2301,7 +2301,7 @@ pub const TFD_TIMER_ABSTIME: i32 = crate::O_WRONLY; pub const TFD_TIMER_CANCEL_ON_SET: i32 = crate::O_RDWR; const_fn! { - {const} fn _ALIGN(p: usize) -> usize { + const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } } @@ -2311,7 +2311,7 @@ f! { (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { _ALIGN(size_of::()) as c_uint + length } @@ -2328,7 +2328,7 @@ f! { } } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { (_ALIGN(size_of::()) + _ALIGN(length as usize)) as c_uint } @@ -2354,23 +2354,23 @@ f! { } safe_f! { - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { status >> 8 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0o177) == 0o177 } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { status == 0xffff } - 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; @@ -2380,11 +2380,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { (((dev as u32) & 0x000fff00) >> 8) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { let mut res = 0; res |= ((dev as u32) & 0xfff00000) >> 12; res |= (dev as u32) & 0x000000ff; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 7276bb54fe136..bb482f0b621f7 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1852,7 +1852,7 @@ pub const RTAX_SEARCH: c_int = 14; pub const RTAX_MAX: c_int = 15; const_fn! { - {const} fn _ALIGN(p: usize) -> usize { + const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } } @@ -1862,7 +1862,7 @@ f! { (cmsg as *mut c_uchar).offset(_ALIGN(size_of::()) as isize) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { _ALIGN(size_of::()) as c_uint + length } @@ -1879,29 +1879,29 @@ f! { } } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { (_ALIGN(size_of::()) + _ALIGN(length as usize)) as c_uint } } safe_f! { - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { status >> 8 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0o177 } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { (status & 0o177777) == 0o177777 } - 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; @@ -1911,11 +1911,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { ((dev as c_uint) >> 8) & 0xff } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { let dev = dev as c_uint; let mut res = 0; res |= (dev) & 0xff; diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index cadc2b062bf94..6d94a00ddb25a 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1853,7 +1853,7 @@ f! { CMSG_ALIGN(size_of::()) as c_uint + length } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint } @@ -1881,55 +1881,55 @@ f! { } safe_f! { - pub {const} fn makedev(ma: c_uint, mi: c_uint) -> dev_t { + pub const fn makedev(ma: c_uint, mi: c_uint) -> dev_t { let ma = ma as dev_t; let mi = mi as dev_t; (ma << 16) | (mi & 0xffff) } - pub {const} fn major(dev: dev_t) -> c_uint { + pub const fn major(dev: dev_t) -> c_uint { ((dev >> 16) & 0xffff) as c_uint } - pub {const} fn minor(dev: dev_t) -> c_uint { + pub const fn minor(dev: dev_t) -> c_uint { (dev & 0xffff) as c_uint } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0xff) == 0 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xff) == 0o177 } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { (status & 0o177777) == 0o177777 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0o177 } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { WIFSIGNALED(status) && (status & 0x80) != 0 } } const_fn! { - {const} fn CMSG_ALIGN(len: usize) -> usize { + const fn CMSG_ALIGN(len: usize) -> usize { len + size_of::() - 1 & !(size_of::() - 1) } } diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index bdfe0debc6a2d..ff0408037f66d 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1513,7 +1513,7 @@ pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x20; pub const POSIX_SPAWN_SETSID: c_short = 0x40; const_fn! { - {const} fn CMSG_ALIGN(len: usize) -> usize { + const fn CMSG_ALIGN(len: usize) -> usize { len + size_of::() - 1 & !(size_of::() - 1) } } @@ -1531,11 +1531,11 @@ f! { (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { CMSG_ALIGN(size_of::()) as c_uint + length } @@ -1582,36 +1582,36 @@ f! { } safe_f! { - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & !0xff) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { status & 0xff } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { ((status >> 8) & 0xff) != 0 } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { (status >> 8) & 0xff } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { ((status >> 16) & 0xff) != 0 } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status >> 16) & 0xff } // actually WIFCORED, but this is used everywhere else - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0x10000) != 0 } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { (status & 0x20000) != 0 } } diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 673877f4f01b9..e96799a57c8dc 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3415,7 +3415,7 @@ pub const PTHREAD_STACK_MIN: size_t = 0; const _UTSNAME_LENGTH: usize = 1024; const_fn! { - {const} fn CMSG_ALIGN(len: usize) -> usize { + const fn CMSG_ALIGN(len: usize) -> usize { (len + size_of::() - 1) & !(size_of::() - 1) } } @@ -3434,11 +3434,11 @@ f! { (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { CMSG_ALIGN(size_of::()) as c_uint + length } @@ -4526,7 +4526,7 @@ extern "C" { } safe_f! { - 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; @@ -4535,11 +4535,11 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { ((dev >> 8) & 0xff) as c_uint } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { (dev & 0xffff00ff) as c_uint } @@ -4551,63 +4551,63 @@ safe_f! { unsafe { __libc_current_sigrtmin() } } - 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 W_EXITCODE(ret: c_int, sig: c_int) -> c_int { + pub const fn W_EXITCODE(ret: c_int, sig: c_int) -> c_int { (ret << 8) | sig } - pub {const} fn W_STOPCODE(sig: c_int) -> c_int { + pub const fn W_STOPCODE(sig: c_int) -> c_int { (sig << 8) | 0x7f } - 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 IPOPT_COPIED(o: u8) -> u8 { + pub const fn IPOPT_COPIED(o: u8) -> u8 { o & IPOPT_COPY } - pub {const} fn IPOPT_CLASS(o: u8) -> u8 { + pub const fn IPOPT_CLASS(o: u8) -> u8 { o & IPOPT_CLASS_MASK } - pub {const} fn IPOPT_NUMBER(o: u8) -> u8 { + pub const fn IPOPT_NUMBER(o: u8) -> u8 { o & IPOPT_NUMBER_MASK } - pub {const} fn IPTOS_ECN(x: u8) -> u8 { + pub const fn IPTOS_ECN(x: u8) -> u8 { x & crate::IPTOS_ECN_MASK } } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index cd0a216d4f072..6643403572832 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3561,17 +3561,17 @@ f! { } safe_f! { - pub {const} fn makedev(ma: c_uint, mi: c_uint) -> crate::dev_t { + pub const fn makedev(ma: c_uint, mi: c_uint) -> crate::dev_t { let ma = ma as crate::dev_t; let mi = mi as crate::dev_t; ((ma & 0xfff) << 8) | (mi & 0xff) | ((mi & 0xfff00) << 12) } - pub {const} fn major(dev: crate::dev_t) -> c_int { + pub const fn major(dev: crate::dev_t) -> c_int { ((dev >> 8) & 0xfff) as c_int } - pub {const} fn minor(dev: crate::dev_t) -> c_int { + pub const fn minor(dev: crate::dev_t) -> c_int { ((dev & 0xff) | ((dev >> 12) & 0xfff00)) as c_int } } diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 811d6aad8519d..417e3e593bc5e 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1407,7 +1407,7 @@ f! { } safe_f! { - 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; @@ -1418,7 +1418,7 @@ safe_f! { dev } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { // see // https://github.com/emscripten-core/emscripten/blob/ // main/system/lib/libc/musl/include/sys/sysmacros.h @@ -1428,7 +1428,7 @@ safe_f! { major as c_uint } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { // see // https://github.com/emscripten-core/emscripten/blob/ // main/system/lib/libc/musl/include/sys/sysmacros.h diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index edb4900a8bcbc..f0b473230e500 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -5916,7 +5916,7 @@ f! { } safe_f! { - 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; @@ -5927,29 +5927,29 @@ 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; minor as c_uint } - pub {const} fn SCTP_PR_TTL_ENABLED(policy: c_int) -> bool { + pub const fn SCTP_PR_TTL_ENABLED(policy: c_int) -> bool { policy == SCTP_PR_SCTP_TTL } - pub {const} fn SCTP_PR_RTX_ENABLED(policy: c_int) -> bool { + pub const fn SCTP_PR_RTX_ENABLED(policy: c_int) -> bool { policy == SCTP_PR_SCTP_RTX } - pub {const} fn SCTP_PR_PRIO_ENABLED(policy: c_int) -> bool { + pub const fn SCTP_PR_PRIO_ENABLED(policy: c_int) -> bool { policy == SCTP_PR_SCTP_PRIO } } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 1f2719af3d1e3..0a1926da4794e 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1822,7 +1822,7 @@ cfg_if! { } const_fn! { - {const} fn CMSG_ALIGN(len: usize) -> usize { + const fn CMSG_ALIGN(len: usize) -> usize { (len + size_of::() - 1) & !(size_of::() - 1) } } @@ -1840,11 +1840,11 @@ f! { cmsg.offset(1) as *mut c_uchar } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { CMSG_ALIGN(size_of::()) as c_uint + length } @@ -1884,68 +1884,68 @@ safe_f! { unsafe { __libc_current_sigrtmin() } } - 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 W_EXITCODE(ret: c_int, sig: c_int) -> c_int { + pub const fn W_EXITCODE(ret: c_int, sig: c_int) -> c_int { (ret << 8) | sig } - pub {const} fn W_STOPCODE(sig: c_int) -> c_int { + pub const fn W_STOPCODE(sig: c_int) -> c_int { (sig << 8) | 0x7f } - 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 IPOPT_COPIED(o: u8) -> u8 { + pub const fn IPOPT_COPIED(o: u8) -> u8 { o & IPOPT_COPY } - pub {const} fn IPOPT_CLASS(o: u8) -> u8 { + pub const fn IPOPT_CLASS(o: u8) -> u8 { o & IPOPT_CLASS_MASK } - pub {const} fn IPOPT_NUMBER(o: u8) -> u8 { + pub const fn IPOPT_NUMBER(o: u8) -> u8 { o & IPOPT_NUMBER_MASK } - pub {const} fn IPTOS_ECN(x: u8) -> u8 { + pub const fn IPTOS_ECN(x: u8) -> u8 { x & crate::IPTOS_ECN_MASK } #[allow(ellipsis_inclusive_range_patterns)] - pub {const} fn KERNEL_VERSION(a: u32, b: u32, c: u32) -> u32 { + pub const fn KERNEL_VERSION(a: u32, b: u32, c: u32) -> u32 { ((a << 16) + (b << 8)) + if c > 255 { 255 } else { c } } } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index ddce11f66bf47..269c7aeba3cad 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1627,16 +1627,16 @@ extern "C" { safe_f! { // It seems htonl, etc are macros on macOS. So we have to reimplement them. So let's // reimplement them for all UNIX platforms - pub {const} fn htonl(hostlong: u32) -> u32 { + pub const fn htonl(hostlong: u32) -> u32 { u32::to_be(hostlong) } - pub {const} fn htons(hostshort: u16) -> u16 { + pub const fn htons(hostshort: u16) -> u16 { u16::to_be(hostshort) } - pub {const} fn ntohl(netlong: u32) -> u32 { + pub const fn ntohl(netlong: u32) -> u32 { u32::from_be(netlong) } - pub {const} fn ntohs(netshort: u16) -> u16 { + pub const fn ntohs(netshort: u16) -> u16 { u16::from_be(netshort) } } diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs index ee325a0247241..3958e02734ada 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -185,35 +185,35 @@ pub const GRND_RANDOM: c_uint = 0x2; // Horizon OS works doesn't or can't hold any of this information safe_f! { - pub {const} fn WIFSTOPPED(_status: c_int) -> bool { + pub const fn WIFSTOPPED(_status: c_int) -> bool { false } - pub {const} fn WSTOPSIG(_status: c_int) -> c_int { + pub const fn WSTOPSIG(_status: c_int) -> c_int { 0 } - pub {const} fn WIFCONTINUED(_status: c_int) -> bool { + pub const fn WIFCONTINUED(_status: c_int) -> bool { true } - pub {const} fn WIFSIGNALED(_status: c_int) -> bool { + pub const fn WIFSIGNALED(_status: c_int) -> bool { false } - pub {const} fn WTERMSIG(_status: c_int) -> c_int { + pub const fn WTERMSIG(_status: c_int) -> c_int { 0 } - pub {const} fn WIFEXITED(_status: c_int) -> bool { + pub const fn WIFEXITED(_status: c_int) -> bool { true } - pub {const} fn WEXITSTATUS(_status: c_int) -> c_int { + pub const fn WEXITSTATUS(_status: c_int) -> c_int { 0 } - pub {const} fn WCOREDUMP(_status: c_int) -> bool { + pub const fn WCOREDUMP(_status: c_int) -> bool { false } } diff --git a/src/unix/newlib/rtems/mod.rs b/src/unix/newlib/rtems/mod.rs index f14967da0aad1..0e23352744149 100644 --- a/src/unix/newlib/rtems/mod.rs +++ b/src/unix/newlib/rtems/mod.rs @@ -85,38 +85,38 @@ pub const WUNTRACED: c_int = 2; pub const SOMAXCONN: c_int = 128; 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 WEXITSTATUS(status) } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { ((status & 0x7f) > 0) && ((status & 0x7f) < 0x7f) } - 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 & 0xff) == 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { (status >> 8) & 0xff } // RTEMS doesn't have native WIFCONTINUED. - pub {const} fn WIFCONTINUED(_status: c_int) -> bool { + pub const fn WIFCONTINUED(_status: c_int) -> bool { true } // RTEMS doesn't have native WCOREDUMP. - pub {const} fn WCOREDUMP(_status: c_int) -> bool { + pub const fn WCOREDUMP(_status: c_int) -> bool { false } } diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 7b4b1ca62cc65..99cb1c181023a 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -2607,11 +2607,11 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { }; const_fn! { - {const} fn _CMSG_ALIGN(len: usize) -> usize { + const fn _CMSG_ALIGN(len: usize) -> usize { len + size_of::() - 1 & !(size_of::() - 1) } - {const} fn _ALIGN(p: usize, b: usize) -> usize { + const fn _ALIGN(p: usize, b: usize) -> usize { (p + b - 1) & !(b - 1) } } @@ -2639,11 +2639,11 @@ f! { (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(size_of::()) as isize) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { _CMSG_ALIGN(size_of::()) as c_uint + length } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { (_CMSG_ALIGN(size_of::()) + _CMSG_ALIGN(length as usize)) as c_uint } @@ -2705,51 +2705,51 @@ f! { } 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 IPTOS_ECN(x: u8) -> u8 { + pub const fn IPTOS_ECN(x: u8) -> u8 { x & crate::IPTOS_ECN_MASK } - 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 { ((major << 10) | (minor)) as crate::dev_t } - pub {const} fn major(dev: crate::dev_t) -> c_uint { + pub const fn major(dev: crate::dev_t) -> c_uint { ((dev as c_uint) >> 10) & 0x3f } - pub {const} fn minor(dev: crate::dev_t) -> c_uint { + pub const fn minor(dev: crate::dev_t) -> c_uint { (dev as c_uint) & 0x3ff } } diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 33990e9631480..bce1ee96d8844 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1094,13 +1094,13 @@ pub const PRIO_USER: c_int = 2; f! { //sys/socket.h - pub {const} fn CMSG_ALIGN(len: size_t) -> size_t { + pub const fn CMSG_ALIGN(len: size_t) -> size_t { (len + size_of::() - 1) & !(size_of::() - 1) } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { (CMSG_ALIGN(size_of::()) + length as usize) as c_uint } - 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::())) as c_uint } @@ -1133,35 +1133,35 @@ f! { } 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 } } diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 2694251a06c6a..8fb426a62830d 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2391,11 +2391,11 @@ const NEWDEV: c_int = 1; pub const SFV_FD_SELF: c_int = -2; const_fn! { - {const} fn _CMSG_HDR_ALIGN(p: usize) -> usize { + const fn _CMSG_HDR_ALIGN(p: usize) -> usize { (p + _CMSG_HDR_ALIGNMENT - 1) & !(_CMSG_HDR_ALIGNMENT - 1) } - {const} fn _CMSG_DATA_ALIGN(p: usize) -> usize { + const fn _CMSG_DATA_ALIGN(p: usize) -> usize { (p + _CMSG_DATA_ALIGNMENT - 1) & !(_CMSG_DATA_ALIGNMENT - 1) } } @@ -2405,7 +2405,7 @@ f! { _CMSG_DATA_ALIGN(cmsg.offset(1) as usize) as *mut c_uchar } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { _CMSG_DATA_ALIGN(size_of::()) as c_uint + length } @@ -2431,7 +2431,7 @@ f! { } } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { _CMSG_HDR_ALIGN(size_of::() as usize + length as usize) as c_uint } @@ -2471,39 +2471,39 @@ safe_f! { unsafe { crate::sysconf(_SC_SIGRT_MIN) as c_int } } - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0xFF) == 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 WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { status & 0x7F } - pub {const} fn WIFCONTINUED(status: c_int) -> bool { + pub const fn WIFCONTINUED(status: c_int) -> bool { (status & 0xffff) == 0xffff } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status & 0xff00) >> 8 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { ((status & 0xff) > 0) && (status & 0xff00 == 0) } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { ((status & 0xff) == 0x7f) && ((status & 0xff00) != 0) } - pub {const} fn WCOREDUMP(status: c_int) -> bool { + pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0x80) != 0 } - pub {const} fn MR_GET_TYPE(flags: c_uint) -> c_uint { + pub const fn MR_GET_TYPE(flags: c_uint) -> c_uint { flags & 0x0000ffff } } diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 23543f65eae0f..15bd1b482def2 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1083,7 +1083,7 @@ impl Clone for fpos_t { } f! { - pub {const} fn CMSG_ALIGN(len: usize) -> usize { + pub const fn CMSG_ALIGN(len: usize) -> usize { len + size_of::() - 1 & !(size_of::() - 1) } @@ -1111,11 +1111,11 @@ f! { (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) } - pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint } - pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + pub const fn CMSG_LEN(length: c_uint) -> c_uint { CMSG_ALIGN(size_of::()) as c_uint + length } } @@ -1948,22 +1948,22 @@ extern "C" { // wait.h macros safe_f! { - pub {const} fn WIFEXITED(status: c_int) -> bool { + pub const fn WIFEXITED(status: c_int) -> bool { (status & 0xFF00) == 0 } - pub {const} fn WIFSIGNALED(status: c_int) -> bool { + pub const fn WIFSIGNALED(status: c_int) -> bool { (status & 0xFF00) != 0 } - pub {const} fn WIFSTOPPED(status: c_int) -> bool { + pub const fn WIFSTOPPED(status: c_int) -> bool { (status & 0xFF0000) != 0 } - pub {const} fn WEXITSTATUS(status: c_int) -> c_int { + pub const fn WEXITSTATUS(status: c_int) -> c_int { status & 0xFF } - pub {const} fn WTERMSIG(status: c_int) -> c_int { + pub const fn WTERMSIG(status: c_int) -> c_int { (status >> 8) & 0xFF } - pub {const} fn WSTOPSIG(status: c_int) -> c_int { + pub const fn WSTOPSIG(status: c_int) -> c_int { (status >> 16) & 0xFF } } From a5348b37ad950a931fef56a3f0f81be5c5257d79 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 23 Sep 2025 01:30:01 -0500 Subject: [PATCH 2/2] cleanup: Remove the `const_fn!` macro Now that is okay for functions to be always `const`, this macro doesn't add anything other than the `#[inline]` attribute, which isn't useful for private functions anyway. Thus, remove the macro and leave its contents wherever it is used. --- src/macros.rs | 14 -------------- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 6 ++---- src/unix/bsd/freebsdlike/freebsd/mod.rs | 6 ++---- src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 ++---- src/unix/bsd/netbsdlike/openbsd/mod.rs | 6 ++---- src/unix/cygwin/mod.rs | 6 ++---- src/unix/haiku/mod.rs | 6 ++---- src/unix/hurd/mod.rs | 6 ++---- src/unix/linux_like/mod.rs | 6 ++---- src/unix/nto/mod.rs | 12 +++++------- src/unix/solarish/mod.rs | 12 +++++------- 11 files changed, 26 insertions(+), 60 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 50d1663d9b2d4..9cdabbd511b7b 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -326,20 +326,6 @@ macro_rules! safe_f { )+}; } -/// Define a nonpublic function. -macro_rules! const_fn { - ($( - $(#[$attr:meta])* - const fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty - $body:block - )*) => ($( - #[inline] - $(#[$attr])* - const fn $i($($arg: $argty),*) -> $ret - $body - )*) -} - macro_rules! __item { ($i:item) => { $i diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 6e5da73afc458..fb6b0fca02aeb 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1421,10 +1421,8 @@ pub const RTAX_MPLS2: c_int = 9; pub const RTAX_MPLS3: c_int = 10; pub const RTAX_MAX: c_int = 11; -const_fn! { - const fn _CMSG_ALIGN(n: usize) -> usize { - (n + (size_of::() - 1)) & !(size_of::() - 1) - } +const fn _CMSG_ALIGN(n: usize) -> usize { + (n + (size_of::() - 1)) & !(size_of::() - 1) } f! { diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index c406a6b771631..88eb12541ff94 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4655,10 +4655,8 @@ pub const fn MAP_ALIGNED(a: c_int) -> c_int { a << 24 } -const_fn! { - const fn _ALIGN(p: usize) -> usize { - (p + _ALIGNBYTES) & !_ALIGNBYTES - } +const fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES } f! { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index f8eaf4b3be455..07532c84dfbaf 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2300,10 +2300,8 @@ pub const TFD_NONBLOCK: i32 = crate::O_NONBLOCK; pub const TFD_TIMER_ABSTIME: i32 = crate::O_WRONLY; pub const TFD_TIMER_CANCEL_ON_SET: i32 = crate::O_RDWR; -const_fn! { - const fn _ALIGN(p: usize) -> usize { - (p + _ALIGNBYTES) & !_ALIGNBYTES - } +const fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES } f! { diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index bb482f0b621f7..df4eb22337810 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1851,10 +1851,8 @@ pub const RTAX_STATIC: c_int = 13; pub const RTAX_SEARCH: c_int = 14; pub const RTAX_MAX: c_int = 15; -const_fn! { - const fn _ALIGN(p: usize) -> usize { - (p + _ALIGNBYTES) & !_ALIGNBYTES - } +const fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES } f! { diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 6d94a00ddb25a..12e30f3f9016c 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1928,10 +1928,8 @@ safe_f! { } } -const_fn! { - const fn CMSG_ALIGN(len: usize) -> usize { - len + size_of::() - 1 & !(size_of::() - 1) - } +const fn CMSG_ALIGN(len: usize) -> usize { + len + size_of::() - 1 & !(size_of::() - 1) } extern "C" { diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index ff0408037f66d..259ad9f2db0f2 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1512,10 +1512,8 @@ pub const POSIX_SPAWN_SETSIGDEF: c_short = 0x10; pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x20; pub const POSIX_SPAWN_SETSID: c_short = 0x40; -const_fn! { - const fn CMSG_ALIGN(len: usize) -> usize { - len + size_of::() - 1 & !(size_of::() - 1) - } +const fn CMSG_ALIGN(len: usize) -> usize { + len + size_of::() - 1 & !(size_of::() - 1) } f! { diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index e96799a57c8dc..bb9bd87915b52 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3414,10 +3414,8 @@ pub const PTHREAD_STACK_MIN: size_t = 0; // Non-public helper constants const _UTSNAME_LENGTH: usize = 1024; -const_fn! { - const fn CMSG_ALIGN(len: usize) -> usize { - (len + size_of::() - 1) & !(size_of::() - 1) - } +const fn CMSG_ALIGN(len: usize) -> usize { + (len + size_of::() - 1) & !(size_of::() - 1) } // functions diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 0a1926da4794e..80fa9c176cb8c 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1821,10 +1821,8 @@ cfg_if! { } } -const_fn! { - const fn CMSG_ALIGN(len: usize) -> usize { - (len + size_of::() - 1) & !(size_of::() - 1) - } +const fn CMSG_ALIGN(len: usize) -> usize { + (len + size_of::() - 1) & !(size_of::() - 1) } f! { diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 99cb1c181023a..3c1f6394d4eae 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -2606,14 +2606,12 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __spare: 0, }; -const_fn! { - const fn _CMSG_ALIGN(len: usize) -> usize { - len + size_of::() - 1 & !(size_of::() - 1) - } +const fn _CMSG_ALIGN(len: usize) -> usize { + len + size_of::() - 1 & !(size_of::() - 1) +} - const fn _ALIGN(p: usize, b: usize) -> usize { - (p + b - 1) & !(b - 1) - } +const fn _ALIGN(p: usize, b: usize) -> usize { + (p + b - 1) & !(b - 1) } f! { diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 8fb426a62830d..5be6129222d00 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2390,14 +2390,12 @@ const NEWDEV: c_int = 1; // sys/sendfile.h pub const SFV_FD_SELF: c_int = -2; -const_fn! { - const fn _CMSG_HDR_ALIGN(p: usize) -> usize { - (p + _CMSG_HDR_ALIGNMENT - 1) & !(_CMSG_HDR_ALIGNMENT - 1) - } +const fn _CMSG_HDR_ALIGN(p: usize) -> usize { + (p + _CMSG_HDR_ALIGNMENT - 1) & !(_CMSG_HDR_ALIGNMENT - 1) +} - const fn _CMSG_DATA_ALIGN(p: usize) -> usize { - (p + _CMSG_DATA_ALIGNMENT - 1) & !(_CMSG_DATA_ALIGNMENT - 1) - } +const fn _CMSG_DATA_ALIGN(p: usize) -> usize { + (p + _CMSG_DATA_ALIGNMENT - 1) & !(_CMSG_DATA_ALIGNMENT - 1) } f! {