summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2013-10-09 10:37:21 -0700
committerFrancisco Jerez <[email protected]>2013-10-29 12:40:55 -0700
commit98ab905af0e0eedf0cfbd9c466f6ae587f5b20c9 (patch)
treefbc09664c7d975b49f82d0a709fb851a5943471e /src/mesa
parentbe63803b0c1efab19d20be3274f92fb55ead7958 (diff)
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 <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/compiler.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
index 0f27d5a6643..d806d5b9d4c 100644
--- a/src/mesa/main/compiler.h
+++ b/src/mesa/main/compiler.h
@@ -444,7 +444,29 @@ 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
}