[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in <new>
Joerg Sonnenberger via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 4 06:24:08 PST 2020
joerg updated this revision to Diff 242317.
joerg retitled this revision from "Don't define std::max_align_t if not used in C++03 mode" to "Depend stddef.h to provide max_align_t for C++11 and provide better fallback in <new>".
joerg edited the summary of this revision.
Herald added a subscriber: krytarowski.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73245/new/
https://reviews.llvm.org/D73245
Files:
libcxx/include/cstddef
libcxx/include/new
libcxx/include/stddef.h
Index: libcxx/include/stddef.h
===================================================================
--- libcxx/include/stddef.h
+++ libcxx/include/stddef.h
@@ -51,12 +51,6 @@
using std::nullptr_t;
}
-// Re-use the compiler's <stddef.h> max_align_t where possible.
-#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
- !defined(__DEFINED_max_align_t) && !defined(__NetBSD__)
-typedef long double max_align_t;
-#endif
-
#endif
#endif // _LIBCPP_STDDEF_H
Index: libcxx/include/new
===================================================================
--- libcxx/include/new
+++ libcxx/include/new
@@ -226,11 +226,21 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if !defined(_LIBCPP_CXX03_LANG)
+using __libcpp_max_align_t = max_align_t;
+#else
+union __libcpp_max_align_t {
+ void * __f1;
+ long long int __f2;
+ long double __f3;
+};
+#endif
+
_LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool __is_overaligned_for_new(size_t __align) _NOEXCEPT {
#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
#else
- return __align > alignment_of<max_align_t>::value;
+ return __align > alignment_of<__libcpp_max_align_t>::value;
#endif
}
Index: libcxx/include/cstddef
===================================================================
--- libcxx/include/cstddef
+++ libcxx/include/cstddef
@@ -25,7 +25,7 @@
ptrdiff_t
size_t
- max_align_t
+ max_align_t // C++11
nullptr_t
byte // C++17
@@ -49,12 +49,8 @@
using ::ptrdiff_t;
using ::size_t;
-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
- defined(__DEFINED_max_align_t) || defined(__NetBSD__)
-// Re-use the compiler's <stddef.h> max_align_t where possible.
+#if !defined(_LIBCPP_CXX03_LANG)
using ::max_align_t;
-#else
-typedef long double max_align_t;
#endif
_LIBCPP_END_NAMESPACE_STD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73245.242317.patch
Type: text/x-patch
Size: 1884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200204/51134fc5/attachment-0001.bin>
More information about the cfe-commits
mailing list