From: Rhys Perry Date: Thu, 6 Aug 2020 13:53:36 +0000 (+0100) Subject: util: add a alignof() macro X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=commitdiff_plain;h=391eeb744356353e96ce34f23b8b16b718a02d61 util: add a alignof() macro Signed-off-by: Rhys Perry Reviewed-by: Eric Anholt Part-of: --- 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 */