gallium/util: add DEBUG_GET_ONCE_OPTION
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 21 Dec 2015 21:11:37 +0000 (16:11 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 29 Dec 2015 14:06:57 +0000 (09:06 -0500)
This is analogous to the alreading existing macros for BOOL, NUM, and FLAGS.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/util/u_debug.h

index 5307072..34668f8 100644 (file)
@@ -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) \