[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:37 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: None (PiJoules)

<details>
<summary>Changes</summary>



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


2 Files Affected:

- (modified) libc/src/__support/CPP/cstddef.h (+4) 
- (modified) libc/src/__support/macros/attributes.h (+6) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/94065


More information about the libc-commits mailing list