[virglrenderer-devel] [PATCH 2/5] utils: added some macros for future implems

Nathan Gauer nathan at gauer.org
Tue Jul 24 13:32:10 UTC 2018


This commit adds some macros designed for a future use:
ARRAY_SIZE: gives the size of an array
UNUSED_PARAMETER: cast a parameter to void. Only a bit more explicit.
TRACE_IN/TRACE_OUT: macros available in debug builds. Inspired from
virtio-gpu ones.

RETURN: encapsulates a return and a TRACE_OUT.

Signed-off-by: Nathan Gauer <nathan at gauer.org>
---
 src/util/macros.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 src/util/macros.h

diff --git a/src/util/macros.h b/src/util/macros.h
new file mode 100644
index 0000000..7931d7a
--- /dev/null
+++ b/src/util/macros.h
@@ -0,0 +1,26 @@
+#ifndef UTIL_MACRO_H
+#define UTIL_MACRO_H
+
+#define UNUSED_PARAMETER(Param) (void)(Param)
+#define ARRAY_SIZE(Array) (sizeof(Array) / sizeof((Array)[0]))
+
+#ifdef DEBUG
+
+#define TRACE_IN() fprintf(stderr, "server: --> %s\n", __func__)
+
+#define TRACE_OUT(Value)                                             \
+   do {                                                              \
+      fprintf(stderr, "%s: server: <-- (%d)\n", __func__, Value);    \
+   } while (0)
+#else
+
+#define TRACE_IN()
+#define TRACE_OUT(Value)
+
+#endif
+
+#define RETURN(Value)   \
+   TRACE_OUT(Value);    \
+   return Value;
+
+#endif
-- 
2.18.0



More information about the virglrenderer-devel mailing list