Skip to content

Commit ebc01bb

Browse files
committed
[libc++] Skip logic for detecting C11 features when using_if_exists is supported
In the future, we'll want to rely exclusively on using_if_exists for this job, but for now, only rely on it when the compiler supports that attribute. That removes the possibility for getting the logic wrong. Differential Revision: https://reviews.llvm.org/D108297
1 parent ec574f5 commit ebc01bb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

libcxx/include/__config

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,16 @@
354354
# define _LIBCPP_NO_CFI
355355
#endif
356356

357+
// If the compiler supports using_if_exists, pretend we have those functions and they'll
358+
// be picked up if the C library provides them.
359+
//
360+
// TODO: Once we drop support for Clang 12, we can assume the compiler supports using_if_exists
361+
// for platforms that don't have a conforming C11 library, so we can drop this whole thing.
362+
#if __has_attribute(using_if_exists)
363+
# define _LIBCPP_HAS_TIMESPEC_GET
364+
# define _LIBCPP_HAS_QUICK_EXIT
365+
# define _LIBCPP_HAS_ALIGNED_ALLOC
366+
#else
357367
#if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L
358368
# if defined(__FreeBSD__)
359369
# define _LIBCPP_HAS_ALIGNED_ALLOC
@@ -408,6 +418,7 @@
408418
# endif
409419
# endif // __APPLE__
410420
#endif
421+
#endif // __has_attribute(using_if_exists)
411422

412423
#ifndef _LIBCPP_CXX03_LANG
413424
# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)

libcxx/include/ctime

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int timespec_get( struct timespec *ts, int base); // C++17
5959
// we're detecting this here instead of in <__config> because we can't include
6060
// system headers from <__config>, since it leads to circular module dependencies.
6161
// This is also meant to be a very temporary workaround until the SDKs are fixed.
62-
#if defined(__APPLE__)
62+
#if defined(__APPLE__) && !__has_attribute(using_if_exists)
6363
# include <sys/cdefs.h>
6464
# if defined(_LIBCPP_HAS_TIMESPEC_GET) && (__DARWIN_C_LEVEL < __DARWIN_C_FULL)
6565
# define _LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED

0 commit comments

Comments
 (0)