Skip to content

[libc][macros] Define LIBC_CONSTINIT #95316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Conversation

PiJoules
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Jun 12, 2024

@llvm/pr-subscribers-libc

Author: None (PiJoules)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/95316.diff

1 Files Affected:

  • (modified) libc/src/__support/macros/attributes.h (+6)
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

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this need something like __has_attribute?

@PiJoules
Copy link
Contributor Author

Shouldn't this need something like __has_attribute?

Yup, lemme add that now

@PiJoules PiJoules requested review from lntue and jhuber6 June 12, 2024 22:30
@PiJoules PiJoules merged commit f074500 into llvm:main Jun 12, 2024
4 of 5 checks passed
@PiJoules PiJoules deleted the constinit-libc branch June 12, 2024 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants