[Mesa-dev] [PATCH v2 1/3] gallium/util: add DEBUG_GET_ONCE_OPTION

Nicolai Hähnle nhaehnle at gmail.com
Mon Dec 21 13:18:20 PST 2015


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

This is analogous to the alreading existing macros for BOOL, NUM, and FLAGS.
---
(commit added in v2 of the series)

 src/gallium/auxiliary/util/u_debug.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index 5307072..34668f8 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -404,6 +404,19 @@ debug_get_flags_option(const char *name,
                        const struct debug_named_value *flags,
                        uint64_t dfault);
 
+#define DEBUG_GET_ONCE_OPTION(suffix, name, dfault) \
+static const char * \
+debug_get_option_ ## suffix (void) \
+{ \
+   static boolean first = TRUE; \
+   static const char * value; \
+   if (first) { \
+      first = FALSE; \
+      value = debug_get_option(name, dfault); \
+   } \
+   return value; \
+}
+
 #define DEBUG_GET_ONCE_BOOL_OPTION(sufix, name, dfault) \
 static boolean \
 debug_get_option_ ## sufix (void) \
-- 
2.5.0



More information about the mesa-dev mailing list