[libc-commits] [libc] f074500 - [libc][macros] Define LIBC_CONSTINIT (#95316)
via libc-commits
libc-commits at lists.llvm.org
Wed Jun 12 15:39:08 PDT 2024
Author: PiJoules
Date: 2024-06-12T15:39:04-07:00
New Revision: f074500b229837b482c4b88d4bdd0e53d1e24ed5
URL: https://github.com/llvm/llvm-project/commit/f074500b229837b482c4b88d4bdd0e53d1e24ed5
DIFF: https://github.com/llvm/llvm-project/commit/f074500b229837b482c4b88d4bdd0e53d1e24ed5.diff
LOG: [libc][macros] Define LIBC_CONSTINIT (#95316)
Added:
Modified:
libc/src/__support/macros/attributes.h
Removed:
################################################################################
diff --git a/libc/src/__support/macros/attributes.h b/libc/src/__support/macros/attributes.h
index 8637e165fe3bc..c489a288fbb11 100644
--- a/libc/src/__support/macros/attributes.h
+++ b/libc/src/__support/macros/attributes.h
@@ -19,6 +19,10 @@
#include "properties/architectures.h"
+#ifndef __has_attribute
+#define __has_attribute(x) 0
+#endif
+
#define LIBC_INLINE inline
#define LIBC_INLINE_VAR inline
#define LIBC_INLINE_ASM __asm__ __volatile__
@@ -30,4 +34,12 @@
#define LIBC_THREAD_LOCAL thread_local
#endif
+#if __cplusplus >= 202002L
+#define LIBC_CONSTINIT constinit
+#elif __has_attribute(__require_constant_initialization__)
+#define LIBC_CONSTINIT __attribute__((__require_constant_initialization__))
+#else
+#define LIBC_CONSTINIT
+#endif
+
#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H
More information about the libc-commits
mailing list