[libcxx-commits] [libcxx] [libc++] Move threading and random device config into <__configuration/platform.h> (PR #206262)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jun 27 09:22:46 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions ,h -- libcxx/include/__config libcxx/include/__configuration/platform.h --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/__configuration/platform.h b/libcxx/include/__configuration/platform.h
index f24319fa2..03f692c18 100644
--- a/libcxx/include/__configuration/platform.h
+++ b/libcxx/include/__configuration/platform.h
@@ -88,18 +88,17 @@
 //      Use rand_s(), for use on Windows.
 //      When this option is used, the token passed to `std::random_device`'s
 //      constructor *must* be "/dev/urandom" -- anything else is an error.
-#  if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ||                     \
-      defined(__DragonFly__)
-#    define _LIBCPP_USING_ARC4_RANDOM
-#  elif defined(__wasi__) || defined(__EMSCRIPTEN__)
-#    define _LIBCPP_USING_GETENTROPY
-#  elif defined(__Fuchsia__)
-#    define _LIBCPP_USING_FUCHSIA_CPRNG
-#  elif defined(_LIBCPP_WIN32API)
-#    define _LIBCPP_USING_WIN32_RANDOM
-#  else
-#    define _LIBCPP_USING_DEV_RANDOM
-#  endif
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#  define _LIBCPP_USING_ARC4_RANDOM
+#elif defined(__wasi__) || defined(__EMSCRIPTEN__)
+#  define _LIBCPP_USING_GETENTROPY
+#elif defined(__Fuchsia__)
+#  define _LIBCPP_USING_FUCHSIA_CPRNG
+#elif defined(_LIBCPP_WIN32API)
+#  define _LIBCPP_USING_WIN32_RANDOM
+#else
+#  define _LIBCPP_USING_DEV_RANDOM
+#endif
 
 // Thread API
 // clang-format off
@@ -121,47 +120,47 @@
         defined(_AIX) ||                                                                                               \
         defined(__EMSCRIPTEN__)
 // clang-format on
-#      undef _LIBCPP_HAS_THREAD_API_PTHREAD
-#      define _LIBCPP_HAS_THREAD_API_PTHREAD 1
-#    elif defined(__Fuchsia__)
+#    undef _LIBCPP_HAS_THREAD_API_PTHREAD
+#    define _LIBCPP_HAS_THREAD_API_PTHREAD 1
+#  elif defined(__Fuchsia__)
 // TODO(44575): Switch to C11 thread API when possible.
-#      undef _LIBCPP_HAS_THREAD_API_PTHREAD
-#      define _LIBCPP_HAS_THREAD_API_PTHREAD 1
-#    elif defined(_LIBCPP_WIN32API)
-#      undef _LIBCPP_HAS_THREAD_API_WIN32
-#      define _LIBCPP_HAS_THREAD_API_WIN32 1
-#    else
-#      error "No thread API"
-#    endif // _LIBCPP_HAS_THREAD_API
-#  endif   // _LIBCPP_HAS_THREADS
-
-#  if !_LIBCPP_HAS_THREAD_API_PTHREAD
-#    define _LIBCPP_HAS_COND_CLOCKWAIT 0
-#  elif (defined(__ANDROID__) && __ANDROID_API__ >= 30) || _LIBCPP_GLIBC_PREREQ(2, 30)
-#    define _LIBCPP_HAS_COND_CLOCKWAIT 1
+#    undef _LIBCPP_HAS_THREAD_API_PTHREAD
+#    define _LIBCPP_HAS_THREAD_API_PTHREAD 1
+#  elif defined(_LIBCPP_WIN32API)
+#    undef _LIBCPP_HAS_THREAD_API_WIN32
+#    define _LIBCPP_HAS_THREAD_API_WIN32 1
 #  else
-#    define _LIBCPP_HAS_COND_CLOCKWAIT 0
-#  endif
+#    error "No thread API"
+#  endif // _LIBCPP_HAS_THREAD_API
+#endif   // _LIBCPP_HAS_THREADS
+
+#if !_LIBCPP_HAS_THREAD_API_PTHREAD
+#  define _LIBCPP_HAS_COND_CLOCKWAIT 0
+#elif (defined(__ANDROID__) && __ANDROID_API__ >= 30) || _LIBCPP_GLIBC_PREREQ(2, 30)
+#  define _LIBCPP_HAS_COND_CLOCKWAIT 1
+#else
+#  define _LIBCPP_HAS_COND_CLOCKWAIT 0
+#endif
 
-#  if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_PTHREAD
-#    error _LIBCPP_HAS_THREAD_API_PTHREAD may only be true when _LIBCPP_HAS_THREADS is true.
-#  endif
+#if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_PTHREAD
+#  error _LIBCPP_HAS_THREAD_API_PTHREAD may only be true when _LIBCPP_HAS_THREADS is true.
+#endif
 
-#  if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_EXTERNAL
-#    error _LIBCPP_HAS_THREAD_API_EXTERNAL may only be true when _LIBCPP_HAS_THREADS is true.
-#  endif
+#if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_EXTERNAL
+#  error _LIBCPP_HAS_THREAD_API_EXTERNAL may only be true when _LIBCPP_HAS_THREADS is true.
+#endif
 
-#  if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_C11
-#    error _LIBCPP_HAS_THREAD_API_C11 may only be true when _LIBCPP_HAS_THREADS is true.
-#  endif
+#if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_C11
+#  error _LIBCPP_HAS_THREAD_API_C11 may only be true when _LIBCPP_HAS_THREADS is true.
+#endif
 
-#  if !_LIBCPP_HAS_MONOTONIC_CLOCK && _LIBCPP_HAS_THREADS
-#    error _LIBCPP_HAS_MONOTONIC_CLOCK may only be false when _LIBCPP_HAS_THREADS is false.
-#  endif
+#if !_LIBCPP_HAS_MONOTONIC_CLOCK && _LIBCPP_HAS_THREADS
+#  error _LIBCPP_HAS_MONOTONIC_CLOCK may only be false when _LIBCPP_HAS_THREADS is false.
+#endif
 
-#  if _LIBCPP_HAS_THREADS && !defined(__STDCPP_THREADS__)
-#    define __STDCPP_THREADS__ 1
-#  endif
+#if _LIBCPP_HAS_THREADS && !defined(__STDCPP_THREADS__)
+#  define __STDCPP_THREADS__ 1
+#endif
 
 // The glibc and Bionic implementation of pthreads implements
 // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
@@ -178,10 +177,10 @@
       (_LIBCPP_HAS_THREAD_API_C11 && defined(__Fuchsia__)) ||                                                          \
        _LIBCPP_HAS_THREAD_API_WIN32
 // clang-format on
-#    define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 1
-#  else
-#    define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 0
-#  endif
+#  define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 1
+#else
+#  define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 0
+#endif
 
 // Destroying a condvar is a nop on Windows.
 //
@@ -191,15 +190,15 @@
 //
 // TODO(EricWF): This is potentially true for some pthread implementations
 // as well.
-#  if (_LIBCPP_HAS_THREAD_API_C11 && defined(__Fuchsia__)) || _LIBCPP_HAS_THREAD_API_WIN32
-#    define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 1
-#  else
-#    define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 0
-#  endif
+#if (_LIBCPP_HAS_THREAD_API_C11 && defined(__Fuchsia__)) || _LIBCPP_HAS_THREAD_API_WIN32
+#  define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 1
+#else
+#  define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 0
+#endif
 
-#  if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) ||                        \
-      _LIBCPP_HAS_MUSL_LIBC || defined(__OpenBSD__) || _LIBCPP_LIBC_LLVM_LIBC
-#    define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
-#  endif
+#if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || _LIBCPP_HAS_MUSL_LIBC || \
+    defined(__OpenBSD__) || _LIBCPP_LIBC_LLVM_LIBC
+#  define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
+#endif
 
 #endif // _LIBCPP___CONFIGURATION_PLATFORM_H

``````````

</details>


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


More information about the libcxx-commits mailing list