Skip to content

Commit 105900c

Browse files
authored
[libc++] Always define _LIBCPP_GLIBC_PREREQ (#169405)
Always defining the macro allows us to simplify the few places where it's used.
1 parent 68c2a81 commit 105900c

File tree

4 files changed

+18
-43
lines changed

4 files changed

+18
-43
lines changed

libcxx/include/__config

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -657,18 +657,10 @@ typedef __char32_t char32_t;
657657
# endif // _LIBCPP_HAS_THREAD_API
658658
# endif // _LIBCPP_HAS_THREADS
659659

660-
# if _LIBCPP_HAS_THREAD_API_PTHREAD
661-
# if defined(__ANDROID__) && __ANDROID_API__ >= 30
662-
# define _LIBCPP_HAS_COND_CLOCKWAIT 1
663-
# elif defined(_LIBCPP_GLIBC_PREREQ)
664-
# if _LIBCPP_GLIBC_PREREQ(2, 30)
665-
# define _LIBCPP_HAS_COND_CLOCKWAIT 1
666-
# else
667-
# define _LIBCPP_HAS_COND_CLOCKWAIT 0
668-
# endif
669-
# else
670-
# define _LIBCPP_HAS_COND_CLOCKWAIT 0
671-
# endif
660+
# if !_LIBCPP_HAS_THREAD_API_PTHREAD
661+
# define _LIBCPP_HAS_COND_CLOCKWAIT 0
662+
# elif (defined(__ANDROID__) && __ANDROID_API__ >= 30) || _LIBCPP_GLIBC_PREREQ(2, 30)
663+
# define _LIBCPP_HAS_COND_CLOCKWAIT 1
672664
# else
673665
# define _LIBCPP_HAS_COND_CLOCKWAIT 0
674666
# endif
@@ -834,12 +826,8 @@ typedef __char32_t char32_t;
834826
// the latter depends on internal GNU libc details that are not appropriate
835827
// to depend on here, so any declarations present when __cpp_char8_t is not
836828
// defined are ignored.
837-
# if defined(_LIBCPP_GLIBC_PREREQ)
838-
# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
839-
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
840-
# else
841-
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
842-
# endif
829+
# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
830+
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
843831
# else
844832
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
845833
# endif

libcxx/include/__configuration/platform.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
#endif
3232

3333
// Need to detect which libc we're using if we're on Linux.
34-
#if defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)
35-
# if __has_include(<features.h>)
36-
# include <features.h>
37-
# if defined(__GLIBC_PREREQ)
38-
# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
39-
# else
40-
# define _LIBCPP_GLIBC_PREREQ(a, b) 0
41-
# endif // defined(__GLIBC_PREREQ)
42-
# endif
34+
#if (defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)) && __has_include(<features.h>)
35+
# include <features.h>
36+
# if defined(__GLIBC_PREREQ)
37+
# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
38+
# else
39+
# define _LIBCPP_GLIBC_PREREQ(a, b) 0
40+
# endif // defined(__GLIBC_PREREQ)
41+
#else
42+
# define _LIBCPP_GLIBC_PREREQ(a, b) 0
4343
#endif
4444

4545
// This is required in order for _NEWLIB_VERSION to be defined in places where we use it.

libcxx/include/__random/binomial_distribution.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,7 @@ class binomial_distribution {
9898
};
9999

100100
// Some libc declares the math functions to be `noexcept`.
101-
#if defined(_LIBCPP_GLIBC_PREREQ)
102-
# if _LIBCPP_GLIBC_PREREQ(2, 8)
103-
# define _LIBCPP_LGAMMA_R_NOEXCEPT _NOEXCEPT
104-
# else
105-
# define _LIBCPP_LGAMMA_R_NOEXCEPT
106-
# endif
107-
#elif defined(__LLVM_LIBC__)
101+
#if _LIBCPP_GLIBC_PREREQ(2, 8) || defined(__LLVM_LIBC__)
108102
# define _LIBCPP_LGAMMA_R_NOEXCEPT _NOEXCEPT
109103
#else
110104
# define _LIBCPP_LGAMMA_R_NOEXCEPT

libcxx/src/filesystem/operations.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,10 @@
4141
#include <time.h>
4242

4343
// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl
44-
#if defined(__linux__)
45-
# if defined(_LIBCPP_GLIBC_PREREQ)
46-
# if _LIBCPP_GLIBC_PREREQ(2, 27)
47-
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
48-
# endif
49-
# elif _LIBCPP_HAS_MUSL_LIBC
50-
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
51-
# endif
52-
#elif defined(__FreeBSD__)
44+
#if _LIBCPP_GLIBC_PREREQ(2, 27) || _LIBCPP_HAS_MUSL_LIBC || defined(__FreeBSD__)
5345
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
5446
#endif
47+
5548
#if __has_include(<sys/sendfile.h>)
5649
# include <sys/sendfile.h>
5750
# define _LIBCPP_FILESYSTEM_USE_SENDFILE

0 commit comments

Comments
 (0)