1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#ifndef SHADOW_INCLUDE_LIB_ATTR_H_
#define SHADOW_INCLUDE_LIB_ATTR_H_
#include "config.h"
#if !defined(__has_c_attribute)
# define __has_c_attribute(x) 0
#endif
#if __has_c_attribute(maybe_unused)
# define MAYBE_UNUSED [[maybe_unused]]
#else
# define MAYBE_UNUSED
#endif
#if __has_c_attribute(noreturn)
# define NORETURN [[noreturn]]
#else
# define NORETURN
#endif
#if __has_c_attribute(gnu::format)
# define format_attr(type, fmt, va) [[gnu::format(type, fmt, va)]]
#else
# define format_attr(type, fmt, va)
#endif
#if __has_c_attribute(gnu::access)
# define ATTR_ACCESS(...) [[gnu::access(__VA_ARGS__)]]
#else
# define ATTR_ACCESS(...)
#endif
#if __has_c_attribute(gnu::alloc_size)
# define ATTR_ALLOC_SIZE(...) [[gnu::alloc_size(__VA_ARGS__)]]
#else
# define ATTR_ALLOC_SIZE(...)
#endif
#if (__GNUC__ >= 11) && !defined(__clang__)
# define ATTR_MALLOC(deallocator) [[gnu::malloc(deallocator)]]
#else
# define ATTR_MALLOC(deallocator)
#endif
#if __has_c_attribute(gnu::null_terminated_string_arg)
# define ATTR_STRING(i) [[gnu::null_terminated_string_arg(i)]]
#else
# define ATTR_STRING(i)
#endif
#if __has_c_attribute(gnu::nonstring)
# define ATTR_NONSTRING [[gnu::nonstring]]
#else
# define ATTR_NONSTRING
#endif
#endif // include guard
|