Skip to content

Commit f074500

Browse files
authored
[libc][macros] Define LIBC_CONSTINIT (#95316)
1 parent 39f7846 commit f074500

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

libc/src/__support/macros/attributes.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
#include "properties/architectures.h"
2121

22+
#ifndef __has_attribute
23+
#define __has_attribute(x) 0
24+
#endif
25+
2226
#define LIBC_INLINE inline
2327
#define LIBC_INLINE_VAR inline
2428
#define LIBC_INLINE_ASM __asm__ __volatile__
@@ -30,4 +34,12 @@
3034
#define LIBC_THREAD_LOCAL thread_local
3135
#endif
3236

37+
#if __cplusplus >= 202002L
38+
#define LIBC_CONSTINIT constinit
39+
#elif __has_attribute(__require_constant_initialization__)
40+
#define LIBC_CONSTINIT __attribute__((__require_constant_initialization__))
41+
#else
42+
#define LIBC_CONSTINIT
43+
#endif
44+
3345
#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H

0 commit comments

Comments
 (0)