[libc-commits] [libc] [libc][macros] Define LIBC_CONSTINIT (PR #95316)
via libc-commits
libc-commits at lists.llvm.org
Wed Jun 12 15:29:48 PDT 2024
https://github.com/PiJoules updated https://github.com/llvm/llvm-project/pull/95316
>From c521cfeadfc319bb4be5a50644c772aea7139aff 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 | 12 ++++++++++++
1 file changed, 12 insertions(+)
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