Skip to content

Commit dcde5cd

Browse files
committed
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.
1 parent e860257 commit dcde5cd

File tree

11 files changed

+26
-60
lines changed

11 files changed

+26
-60
lines changed

src/macros.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -326,20 +326,6 @@ macro_rules! safe_f {
326326
)+};
327327
}
328328

329-
/// Define a nonpublic function.
330-
macro_rules! const_fn {
331-
($(
332-
$(#[$attr:meta])*
333-
const fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
334-
$body:block
335-
)*) => ($(
336-
#[inline]
337-
$(#[$attr])*
338-
const fn $i($($arg: $argty),*) -> $ret
339-
$body
340-
)*)
341-
}
342-
343329
macro_rules! __item {
344330
($i:item) => {
345331
$i

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,10 +1421,8 @@ pub const RTAX_MPLS2: c_int = 9;
14211421
pub const RTAX_MPLS3: c_int = 10;
14221422
pub const RTAX_MAX: c_int = 11;
14231423

1424-
const_fn! {
1425-
const fn _CMSG_ALIGN(n: usize) -> usize {
1426-
(n + (size_of::<c_long>() - 1)) & !(size_of::<c_long>() - 1)
1427-
}
1424+
const fn _CMSG_ALIGN(n: usize) -> usize {
1425+
(n + (size_of::<c_long>() - 1)) & !(size_of::<c_long>() - 1)
14281426
}
14291427

14301428
f! {

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4655,10 +4655,8 @@ pub const fn MAP_ALIGNED(a: c_int) -> c_int {
46554655
a << 24
46564656
}
46574657

4658-
const_fn! {
4659-
const fn _ALIGN(p: usize) -> usize {
4660-
(p + _ALIGNBYTES) & !_ALIGNBYTES
4661-
}
4658+
const fn _ALIGN(p: usize) -> usize {
4659+
(p + _ALIGNBYTES) & !_ALIGNBYTES
46624660
}
46634661

46644662
f! {

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,10 +2300,8 @@ pub const TFD_NONBLOCK: i32 = crate::O_NONBLOCK;
23002300
pub const TFD_TIMER_ABSTIME: i32 = crate::O_WRONLY;
23012301
pub const TFD_TIMER_CANCEL_ON_SET: i32 = crate::O_RDWR;
23022302

2303-
const_fn! {
2304-
const fn _ALIGN(p: usize) -> usize {
2305-
(p + _ALIGNBYTES) & !_ALIGNBYTES
2306-
}
2303+
const fn _ALIGN(p: usize) -> usize {
2304+
(p + _ALIGNBYTES) & !_ALIGNBYTES
23072305
}
23082306

23092307
f! {

src/unix/bsd/netbsdlike/openbsd/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,10 +1851,8 @@ pub const RTAX_STATIC: c_int = 13;
18511851
pub const RTAX_SEARCH: c_int = 14;
18521852
pub const RTAX_MAX: c_int = 15;
18531853

1854-
const_fn! {
1855-
const fn _ALIGN(p: usize) -> usize {
1856-
(p + _ALIGNBYTES) & !_ALIGNBYTES
1857-
}
1854+
const fn _ALIGN(p: usize) -> usize {
1855+
(p + _ALIGNBYTES) & !_ALIGNBYTES
18581856
}
18591857

18601858
f! {

src/unix/cygwin/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,10 +1928,8 @@ safe_f! {
19281928
}
19291929
}
19301930

1931-
const_fn! {
1932-
const fn CMSG_ALIGN(len: usize) -> usize {
1933-
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
1934-
}
1931+
const fn CMSG_ALIGN(len: usize) -> usize {
1932+
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
19351933
}
19361934

19371935
extern "C" {

src/unix/haiku/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,10 +1512,8 @@ pub const POSIX_SPAWN_SETSIGDEF: c_short = 0x10;
15121512
pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x20;
15131513
pub const POSIX_SPAWN_SETSID: c_short = 0x40;
15141514

1515-
const_fn! {
1516-
const fn CMSG_ALIGN(len: usize) -> usize {
1517-
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
1518-
}
1515+
const fn CMSG_ALIGN(len: usize) -> usize {
1516+
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
15191517
}
15201518

15211519
f! {

src/unix/hurd/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,10 +3414,8 @@ pub const PTHREAD_STACK_MIN: size_t = 0;
34143414
// Non-public helper constants
34153415
const _UTSNAME_LENGTH: usize = 1024;
34163416

3417-
const_fn! {
3418-
const fn CMSG_ALIGN(len: usize) -> usize {
3419-
(len + size_of::<usize>() - 1) & !(size_of::<usize>() - 1)
3420-
}
3417+
const fn CMSG_ALIGN(len: usize) -> usize {
3418+
(len + size_of::<usize>() - 1) & !(size_of::<usize>() - 1)
34213419
}
34223420

34233421
// functions

src/unix/linux_like/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,10 +1821,8 @@ cfg_if! {
18211821
}
18221822
}
18231823

1824-
const_fn! {
1825-
const fn CMSG_ALIGN(len: usize) -> usize {
1826-
(len + size_of::<usize>() - 1) & !(size_of::<usize>() - 1)
1827-
}
1824+
const fn CMSG_ALIGN(len: usize) -> usize {
1825+
(len + size_of::<usize>() - 1) & !(size_of::<usize>() - 1)
18281826
}
18291827

18301828
f! {

src/unix/nto/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,14 +2606,12 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
26062606
__spare: 0,
26072607
};
26082608

2609-
const_fn! {
2610-
const fn _CMSG_ALIGN(len: usize) -> usize {
2611-
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
2612-
}
2609+
const fn _CMSG_ALIGN(len: usize) -> usize {
2610+
len + size_of::<usize>() - 1 & !(size_of::<usize>() - 1)
2611+
}
26132612

2614-
const fn _ALIGN(p: usize, b: usize) -> usize {
2615-
(p + b - 1) & !(b - 1)
2616-
}
2613+
const fn _ALIGN(p: usize, b: usize) -> usize {
2614+
(p + b - 1) & !(b - 1)
26172615
}
26182616

26192617
f! {

0 commit comments

Comments
 (0)