[libc-commits] [libc] [libc][CPP] Define max_align_t (PR #94065)
via libc-commits
libc-commits at lists.llvm.org
Fri May 31 15:29:05 PDT 2024
https://github.com/PiJoules created https://github.com/llvm/llvm-project/pull/94065
None
>From 000dccfffc19b0df0114ac3603c5fffd5ecf76fa Mon Sep 17 00:00:00 2001
From: Leonard Chan <leonardchan at google.com>
Date: Fri, 31 May 2024 15:27:41 -0700
Subject: [PATCH] [libc][CPP] Define max_align_t
---
libc/src/__support/CPP/cstddef.h | 4 ++++
libc/src/__support/macros/attributes.h | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/libc/src/__support/CPP/cstddef.h b/libc/src/__support/CPP/cstddef.h
index 1da51fd253fb5..111265d38cde7 100644
--- a/libc/src/__support/CPP/cstddef.h
+++ b/libc/src/__support/CPP/cstddef.h
@@ -16,6 +16,10 @@ namespace LIBC_NAMESPACE::cpp {
enum class byte : unsigned char {};
+// When built with clang, this will use the definition from the clang header
+// __stddef_max_align_t.h
+using ::max_align_t LIBC_USING_IF_EXISTS;
+
template <class IntegerType>
LIBC_INLINE constexpr enable_if_t<is_integral_v<IntegerType>, byte>
operator>>(byte b, IntegerType shift) noexcept {
diff --git a/libc/src/__support/macros/attributes.h b/libc/src/__support/macros/attributes.h
index 8637e165fe3bc..40b67281767f8 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 __has_attribute(__using_if_exists__)
+#define LIBC_USING_IF_EXISTS __attribute__((__using_if_exists__))
+#else
+#define LIBC_USING_IF_EXISTS
+#endif
+
#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H
More information about the libc-commits
mailing list