Skip to content

Commit e23890a

Browse files
committed
[libc++] Always define _LIBCPP_GLIBC_PREREQ
1 parent e3d0ac1 commit e23890a

File tree

4 files changed

+21
-42
lines changed

4 files changed

+21
-42
lines changed

libcxx/include/__config

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -678,18 +678,10 @@ typedef __char32_t char32_t;
678678
# endif // _LIBCPP_HAS_THREAD_API
679679
# endif // _LIBCPP_HAS_THREADS
680680

681-
# if _LIBCPP_HAS_THREAD_API_PTHREAD
682-
# if defined(__ANDROID__) && __ANDROID_API__ >= 30
683-
# define _LIBCPP_HAS_COND_CLOCKWAIT 1
684-
# elif defined(_LIBCPP_GLIBC_PREREQ)
685-
# if _LIBCPP_GLIBC_PREREQ(2, 30)
686-
# define _LIBCPP_HAS_COND_CLOCKWAIT 1
687-
# else
688-
# define _LIBCPP_HAS_COND_CLOCKWAIT 0
689-
# endif
690-
# else
691-
# define _LIBCPP_HAS_COND_CLOCKWAIT 0
692-
# endif
681+
# if !_LIBCPP_HAS_THREAD_API_PTHREAD
682+
# define _LIBCPP_HAS_COND_CLOCKWAIT 0
683+
# elif (defined(__ANDROID__) && __ANDROID_API__ >= 30) || _LIBCPP_GLIBC_PREREQ(2, 30)
684+
# define _LIBCPP_HAS_COND_CLOCKWAIT 1
693685
# else
694686
# define _LIBCPP_HAS_COND_CLOCKWAIT 0
695687
# endif
@@ -855,12 +847,8 @@ typedef __char32_t char32_t;
855847
// the latter depends on internal GNU libc details that are not appropriate
856848
// to depend on here, so any declarations present when __cpp_char8_t is not
857849
// defined are ignored.
858-
# if defined(_LIBCPP_GLIBC_PREREQ)
859-
# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
860-
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
861-
# else
862-
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
863-
# endif
850+
# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
851+
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
864852
# else
865853
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
866854
# 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: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,14 @@
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
44+
#if _LIBCPP_GLIBC_PREREQ(2, 27)
45+
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
46+
#elif _LIBCPP_HAS_MUSL_LIBC
47+
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
5248
#elif defined(__FreeBSD__)
5349
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
5450
#endif
51+
5552
#if __has_include(<sys/sendfile.h>)
5653
# include <sys/sendfile.h>
5754
# define _LIBCPP_FILESYSTEM_USE_SENDFILE

0 commit comments

Comments
 (0)