@@ -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
392343macro_rules! __item {
0 commit comments