]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
sysdefs.h: Add alignas
authorLasse Collin <lasse.collin@tukaani.org>
Sat, 1 Jun 2024 11:44:04 +0000 (14:44 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Sun, 16 Jun 2024 09:59:20 +0000 (12:59 +0300)
src/common/sysdefs.h

index 5f3785b5137abf4a53eee02f7563cea31750c03c..2f9740367ae907ee881ef076da42970216dac51a 100644 (file)
@@ -156,6 +156,17 @@ typedef unsigned char _Bool;
 #      define __bool_true_false_are_defined 1
 #endif
 
+// We may need alignas from C11/C17/C23.
+#if __STDC_VERSION__ >= 202311
+       // alignas is a keyword in C23. Do nothing.
+#elif __STDC_VERSION__ >= 201112
+#      include <stdalign.h>
+#elif defined(__GNUC__) || defined(__clang__)
+#      define alignas(n) __attribute__((__aligned__(n)))
+#else
+#      define alignas(n)
+#endif
+
 #include <string.h>
 
 // Visual Studio 2013 update 2 supports only __inline, not inline.