[libc-commits] [libc] [libc][macros] Define LIBC_CONSTINIT (PR #95316)

via libc-commits libc-commits at lists.llvm.org
Wed Jun 12 14:30:59 PDT 2024


https://github.com/PiJoules created https://github.com/llvm/llvm-project/pull/95316

None

>From f8a0c53fc944d7de5b9508fb721bb3eedec78d82 Mon Sep 17 00:00:00 2001
From: Leonard Chan <leonardchan at google.com>
Date: Wed, 12 Jun 2024 14:29:57 -0700
Subject: [PATCH] [libc][macros] Define LIBC_CONSTINIT

---
 libc/src/__support/macros/attributes.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libc/src/__support/macros/attributes.h b/libc/src/__support/macros/attributes.h
index 8637e165fe3bc..73d5d777f6041 100644
--- a/libc/src/__support/macros/attributes.h
+++ b/libc/src/__support/macros/attributes.h
@@ -30,4 +30,10 @@
 #define LIBC_THREAD_LOCAL thread_local
 #endif
 
+#if __cplusplus >= 202002L
+#define LIBC_CONSTINIT constinit
+#else
+#define LIBC_CONSTINIT __attribute__((__require_constant_initialization__))
+#endif
+
 #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H



More information about the libc-commits mailing list