mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 06:50:11 +01:00
mesa: Define introspection macro to determine whether a type is trivially destructible.
Only implemented on GCC and Clang for now. Other compilers use a dummy implementation that always returns false, which should be a safe [but slightly inefficient] assumption in all cases. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
be63803b0c
commit
98ab905af0
1 changed files with 23 additions and 1 deletions
|
|
@ -444,7 +444,29 @@ do { \
|
||||||
#define Elements(x) (sizeof(x)/sizeof(*(x)))
|
#define Elements(x) (sizeof(x)/sizeof(*(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
/**
|
||||||
|
* Macro function that evaluates to true if T is a trivially
|
||||||
|
* destructible type -- that is, if its (non-virtual) destructor
|
||||||
|
* performs no action and all member variables and base classes are
|
||||||
|
* trivially destructible themselves.
|
||||||
|
*/
|
||||||
|
# if defined(__GNUC__)
|
||||||
|
# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
|
||||||
|
# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
|
||||||
|
# endif
|
||||||
|
# elif (defined(__clang__) && defined(__has_feature))
|
||||||
|
# if __has_feature(has_trivial_destructor)
|
||||||
|
# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# ifndef HAS_TRIVIAL_DESTRUCTOR
|
||||||
|
/* It's always safe (if inefficient) to assume that a
|
||||||
|
* destructor is non-trivial.
|
||||||
|
*/
|
||||||
|
# define HAS_TRIVIAL_DESTRUCTOR(T) (false)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue