meson: detect availability of attributes using cc.has_function_attribute()
Alternative to fabc22f599
As suggested in https://github.com/systemd/systemd/pull/41174#discussion_r2966411375
This commit is contained in:
@@ -80,10 +80,13 @@ endif
|
||||
efi_conf = configuration_data()
|
||||
|
||||
# import several configs from userspace
|
||||
foreach name : ['HAVE_ATTRIBUTE_RETAIN',
|
||||
'HAVE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT',
|
||||
'HAVE_WARNING_ZERO_LENGTH_BOUNDS',
|
||||
]
|
||||
foreach name : ['HAVE_WARNING_ZERO_LENGTH_BOUNDS',
|
||||
'HAVE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT']
|
||||
efi_conf.set(name, conf.get(name))
|
||||
endforeach
|
||||
|
||||
foreach attr : possible_c_attributes
|
||||
name = 'HAVE_ATTRIBUTE_' + attr.to_upper()
|
||||
efi_conf.set(name, conf.get(name))
|
||||
endforeach
|
||||
|
||||
|
||||
@@ -98,24 +98,24 @@
|
||||
#define _weak_ __attribute__((__weak__))
|
||||
#define _weakref_(x) __attribute__((__weakref__(#x)))
|
||||
|
||||
#if HAVE_ATTRIBUTE_ALLOC_SIZE
|
||||
# define _alloc_(...) __attribute__((__alloc_size__(__VA_ARGS__)))
|
||||
#else
|
||||
# define _alloc_(...)
|
||||
#endif
|
||||
|
||||
#if HAVE_ATTRIBUTE_FALLTHROUGH
|
||||
# define _fallthrough_ __attribute__((__fallthrough__))
|
||||
#else
|
||||
# define _fallthrough_
|
||||
#endif
|
||||
|
||||
#if HAVE_ATTRIBUTE_RETAIN
|
||||
# define _retain_ __attribute__((__retain__))
|
||||
#else
|
||||
# define _retain_
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
# define _alloc_(...)
|
||||
#else
|
||||
# define _alloc_(...) __attribute__((__alloc_size__(__VA_ARGS__)))
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && __clang_major__ < 10
|
||||
# define _fallthrough_
|
||||
#else
|
||||
# define _fallthrough_ __attribute__((__fallthrough__))
|
||||
#endif
|
||||
|
||||
#if __GNUC__ >= 15
|
||||
# define _nonnull_if_nonzero_(p, n) __attribute__((nonnull_if_nonzero(p, n)))
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user