[Mesa-dev] [PATCH 1/2] mesa: Define introspection macro to determine whether a type is trivially destructible.
Ian Romanick
idr at freedesktop.org
Fri Oct 11 23:43:04 CEST 2013
The minor nit in both patches: The closing */ of a multiline comment
should go on its own line.
I'd like to hear some feedback from Paul and / or Ken before committing,
but this series is
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
On 10/09/2013 11:20 AM, Francisco Jerez wrote:
> 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.
> ---
> src/mesa/main/compiler.h | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
> index 0f27d5a..8853292 100644
> --- a/src/mesa/main/compiler.h
> +++ b/src/mesa/main/compiler.h
> @@ -444,7 +444,28 @@ do { \
> #define Elements(x) (sizeof(x)/sizeof(*(x)))
> #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
> }
>
More information about the mesa-dev
mailing list