Mesa (main): util: use c11 alignof instead of our own

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 14 15:50:07 UTC 2022


Module: Mesa
Branch: main
Commit: 3a62badb2e1606274f7e36302c96b96f57e90b2d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a62badb2e1606274f7e36302c96b96f57e90b2d

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Tue Jun  7 16:33:02 2022 +0200

util: use c11 alignof instead of our own

...with an exception for MSVC, which doesn't have stdalign.h, so let's
add a definition for that.

Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16908>

---

 src/util/macros.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/util/macros.h b/src/util/macros.h
index 22b18303826..e0af384f7b9 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -410,13 +410,11 @@ u_uintN_max(unsigned bit_size)
    return UINT64_MAX >> (64 - bit_size);
 }
 
-#if !defined(alignof) && !defined(__cplusplus)
-#if __STDC_VERSION__ >= 201112L
-#define alignof(t) _Alignof(t)
-#elif defined(_MSC_VER)
-#define alignof(t) __alignof(t)
+#ifndef __cplusplus
+#ifdef _MSC_VER
+#define alignof _Alignof
 #else
-#define alignof(t) __alignof__(t)
+#include <stdalign.h>
 #endif
 #endif
 



More information about the mesa-commit mailing list