Skip to content

Commit 49b1b89

Browse files
committed
Remove libc_const_extern_fn
This originally existed for MSRV support, then became a necessary hack to support the old ctest's inability to parse `const fn`. The new ctest doesn't have this limitation, so remove the config.
1 parent ab36ccb commit 49b1b89

File tree

2 files changed

+38
-92
lines changed

2 files changed

+38
-92
lines changed

build.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ const ALLOWED_CFGS: &[&str] = &[
1717
"gnu_file_offset_bits64",
1818
// Corresponds to `_TIME_BITS=64` in glibc
1919
"gnu_time_bits64",
20-
// FIXME(ctest): this config shouldn't be needed but ctest can't parse `const extern fn`
21-
"libc_const_extern_fn",
2220
"libc_deny_warnings",
2321
"libc_ctest",
2422
// Corresponds to `__USE_TIME_BITS64` in UAPI
@@ -144,9 +142,6 @@ fn main() {
144142
set_cfg("libc_deny_warnings");
145143
}
146144

147-
// Set unconditionally when ctest is not being invoked.
148-
set_cfg("libc_const_extern_fn");
149-
150145
// Since Rust 1.80, configuration that isn't recognized by default needs to be provided to
151146
// avoid warnings.
152147
if rustc_minor_ver >= 80 {

src/macros.rs

Lines changed: 38 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -298,95 +298,46 @@ macro_rules! c_enum {
298298
// from trying to parse the 'pub const unsafe extern fn', so users would get a compiler error even
299299
// when the 'libc_const_extern_fn' feature is disabled.
300300

301-
// FIXME(ctest): ctest can't handle `const extern` functions, we should be able to remove this
302-
// cfg completely.
303-
// FIXME(ctest): ctest can't handle `$(,)?` so we use `$(,)*` which isn't quite correct.
304-
cfg_if! {
305-
if #[cfg(libc_const_extern_fn)] {
306-
/// Define an `unsafe` function that is const as long as `libc_const_extern_fn` is enabled.
307-
macro_rules! f {
308-
($(
309-
$(#[$attr:meta])*
310-
pub $({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
311-
$body:block
312-
)*) => ($(
313-
#[inline]
314-
$(#[$attr])*
315-
pub $($constness)* unsafe extern "C" fn $i($($arg: $argty),*) -> $ret
316-
$body
317-
)*)
318-
}
319-
320-
/// Define a safe function that is const as long as `libc_const_extern_fn` is enabled.
321-
macro_rules! safe_f {
322-
($(
323-
$(#[$attr:meta])*
324-
pub $({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
325-
$body:block
326-
)*) => ($(
327-
#[inline]
328-
$(#[$attr])*
329-
pub $($constness)* extern "C" fn $i($($arg: $argty),*) -> $ret
330-
$body
331-
)*)
332-
}
333-
334-
/// A nonpublic function that is const as long as `libc_const_extern_fn` is enabled.
335-
macro_rules! const_fn {
336-
($(
337-
$(#[$attr:meta])*
338-
$({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
339-
$body:block
340-
)*) => ($(
341-
#[inline]
342-
$(#[$attr])*
343-
$($constness)* fn $i($($arg: $argty),*) -> $ret
344-
$body
345-
)*)
346-
}
347-
} else {
348-
/// Define an `unsafe` function that is const as long as `libc_const_extern_fn` is enabled.
349-
macro_rules! f {
350-
($(
351-
$(#[$attr:meta])*
352-
pub $({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
353-
$body:block
354-
)*) => ($(
355-
#[inline]
356-
$(#[$attr])*
357-
pub unsafe extern "C" fn $i($($arg: $argty),*) -> $ret
358-
$body
359-
)*)
360-
}
301+
/// Define a `unsafe` function.
302+
macro_rules! f {
303+
($(
304+
$(#[$attr:meta])*
305+
pub $({$constness:ident})? fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
306+
$body:block
307+
)*) => ($(
308+
#[inline]
309+
$(#[$attr])*
310+
pub $($constness)? unsafe extern "C" fn $i($($arg: $argty),*) -> $ret
311+
$body
312+
)*)
313+
}
361314

362-
/// Define a safe function that is const as long as `libc_const_extern_fn` is enabled.
363-
macro_rules! safe_f {
364-
($(
365-
$(#[$attr:meta])*
366-
pub $({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
367-
$body:block
368-
)*) => ($(
369-
#[inline]
370-
$(#[$attr])*
371-
pub extern "C" fn $i($($arg: $argty),*) -> $ret
372-
$body
373-
)*)
374-
}
315+
/// Define a safe function.
316+
macro_rules! safe_f {
317+
($(
318+
$(#[$attr:meta])*
319+
pub $({$constness:ident})? fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
320+
$body:block
321+
)*) => ($(
322+
#[inline]
323+
$(#[$attr])*
324+
pub $($constness)? extern "C" fn $i($($arg: $argty),*) -> $ret
325+
$body
326+
)*)
327+
}
375328

376-
/// A nonpublic function that is const as long as `libc_const_extern_fn` is enabled.
377-
macro_rules! const_fn {
378-
($(
379-
$(#[$attr:meta])*
380-
$({$constness:ident})* fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
381-
$body:block
382-
)*) => ($(
383-
#[inline]
384-
$(#[$attr])*
385-
fn $i($($arg: $argty),*) -> $ret
386-
$body
387-
)*)
388-
}
389-
}
329+
/// Define a nonpublic function.
330+
macro_rules! const_fn {
331+
($(
332+
$(#[$attr:meta])*
333+
$({$constness:ident})? fn $i:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty
334+
$body:block
335+
)*) => ($(
336+
#[inline]
337+
$(#[$attr])*
338+
$($constness)? fn $i($($arg: $argty),*) -> $ret
339+
$body
340+
)*)
390341
}
391342

392343
macro_rules! __item {

0 commit comments

Comments
 (0)