blob: cad21249637071cddf7385713da674d968b708db [file] [log] [blame]
From 391eeb744356353e96ce34f23b8b16b718a02d61 Mon Sep 17 00:00:00 2001
From: Rhys Perry <pendingchaos02@gmail.com>
Date: Thu, 6 Aug 2020 14:53:36 +0100
Subject: [PATCH] util: add a alignof() macro
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6206>
---
src/util/macros.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/util/macros.h b/src/util/macros.h
index 04aec96b546..f9aa478c994 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -351,4 +351,14 @@ enum pipe_debug_type
PIPE_DEBUG_TYPE_CONFORMANCE,
};
+#if !defined(alignof) && !defined(__cplusplus)
+#if __STDC_VERSION__ >= 201112L
+#define alignof(t) _Alignof(t)
+#elif defined(_MSC_VER)
+#define alignof(t) __alignof(t)
+#else
+#define alignof(t) __alignof__(t)
+#endif
+#endif
+
#endif /* UTIL_MACROS_H */
--
2.28.0.297.g1956fa8f8d-goog