From 391eeb744356353e96ce34f23b8b16b718a02d61 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 6 Aug 2020 14:53:36 +0100 Subject: [PATCH] util: add a alignof() macro Signed-off-by: Rhys Perry Reviewed-by: Eric Anholt Part-of: --- 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.30.2