Skip to content

Commit 6e1e77e

Browse files
committed
Add support for declaring 'const fn' in the 'f!' macro
1 parent ff63cb5 commit 6e1e77e

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#![no_std]
3535
#![cfg_attr(feature = "rustc-dep-of-std", no_core)]
3636
#![cfg_attr(target_os = "redox", feature(static_nobundle))]
37+
#![feature(const_extern_fn)]
3738

3839
#[macro_use]
3940
mod macros;

src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ macro_rules! s_no_extra_traits {
123123

124124
#[allow(unused_macros)]
125125
macro_rules! f {
126-
($(pub fn $i:ident($($arg:ident: $argty:ty),*) -> $ret:ty {
126+
($(pub fn $i:ident($($arg:ident: $argty:ty),*) $($constness:ident)* -> $ret:ty {
127127
$($body:stmt);*
128128
})*) => ($(
129129
#[inline]
130-
pub unsafe extern fn $i($($arg: $argty),*) -> $ret {
130+
pub $($constness)* unsafe extern fn $i($($arg: $argty),*) -> $ret {
131131
$($body);*
132132
}
133133
)*)

src/unix/linux_like/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ pub const ARPHRD_IEEE802154: u16 = 804;
11651165
pub const ARPHRD_VOID: u16 = 0xFFFF;
11661166
pub const ARPHRD_NONE: u16 = 0xFFFE;
11671167

1168-
fn CMSG_ALIGN(len: usize) -> usize {
1168+
const fn CMSG_ALIGN(len: usize) -> usize {
11691169
len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
11701170
}
11711171

@@ -1182,7 +1182,7 @@ f! {
11821182
cmsg.offset(1) as *mut ::c_uchar
11831183
}
11841184

1185-
pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
1185+
pub fn CMSG_SPACE(length: ::c_uint) const -> ::c_uint {
11861186
(CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::<cmsghdr>()))
11871187
as ::c_uint
11881188
}

0 commit comments

Comments
 (0)