gallium/util: add one-time initialization helper
authorLuca Barbieri <luca@luca-barbieri.com>
Fri, 2 Apr 2010 00:01:25 +0000 (02:01 +0200)
committerLuca Barbieri <luca@luca-barbieri.com>
Fri, 2 Apr 2010 00:01:25 +0000 (02:01 +0200)
src/gallium/auxiliary/util/u_inline_init.h [new file with mode: 0644]

diff --git a/src/gallium/auxiliary/util/u_inline_init.h b/src/gallium/auxiliary/util/u_inline_init.h
new file mode 100644 (file)
index 0000000..7f2c591
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef U_INLINE_INIT_H_
+#define U_INLINE_INIT_H_
+
+#define UTIL_INLINE_INIT(m) \
+   extern boolean m##_inited; \
+   extern void m##_do_init(void); \
+   static inline void m##_init(void) \
+   { \
+      if(!m##_inited) { \
+         m##_do_init(); \
+         m##_inited = TRUE; \
+      } \
+   }
+
+#endif /* U_INLINE_INIT_H_ */