[libc++] Partially revert 346ef5e5879e
authorLouis Dionne <ldionne.2@gmail.com>
Tue, 21 Dec 2021 21:50:34 +0000 (16:50 -0500)
committerMartin Storsjö <martin@martin.st>
Tue, 21 Dec 2021 21:58:17 +0000 (23:58 +0200)
This moves the macro definitions back to __config, but keeps the
improved documentation. 346ef5e5879e had broken the MinGW build.

libcxx/include/__config
libcxx/include/__random/random_device.h

index 7d6cc16..720e12e 100644 (file)
 #  define _LIBCPP_SHORT_WCHAR   1
 #endif
 
+// Libc++ supports various implementations of std::random_device.
+//
+// _LIBCPP_USING_DEV_RANDOM
+//      Read entropy from the given file, by default `/dev/urandom`.
+//      If a token is provided, it is assumed to be the path to a file
+//      to read entropy from. This is the default behavior if nothing
+//      else is specified. This implementation requires storing state
+//      inside `std::random_device`.
+//
+// _LIBCPP_USING_ARC4_RANDOM
+//      Use arc4random(). This allows obtaining random data even when
+//      using sandboxing mechanisms. On some platforms like Apple, this
+//      is the recommended source of entropy for user-space programs.
+//      When this option is used, the token passed to `std::random_device`'s
+//      constructor *must* be "/dev/urandom" -- anything else is an error.
+//
+// _LIBCPP_USING_GETENTROPY
+//      Use getentropy().
+//      When this option is used, the token passed to `std::random_device`'s
+//      constructor *must* be "/dev/urandom" -- anything else is an error.
+//
+// _LIBCPP_USING_NACL_RANDOM
+//      NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
+//      including accesses to the special files under `/dev`. This implementation
+//      uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
+//      When this option is used, the token passed to `std::random_device`'s
+//      constructor *must* be "/dev/urandom" -- anything else is an error.
+//
+// _LIBCPP_USING_WIN32_RANDOM
+//      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(__OpenBSD__)
+#  define _LIBCPP_USING_ARC4_RANDOM
+#elif defined(__Fuchsia__) || defined(__wasi__)
+#  define _LIBCPP_USING_GETENTROPY
+#elif defined(__native_client__)
+#  define _LIBCPP_USING_NACL_RANDOM
+#elif defined(_LIBCPP_WIN32API)
+#  define _LIBCPP_USING_WIN32_RANDOM
+#else
+#  define _LIBCPP_USING_DEV_RANDOM
+#endif
+
 #if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
 #  include <endian.h>
 #  if __BYTE_ORDER == __LITTLE_ENDIAN
index 82dd1a1..835f726 100644 (file)
@@ -23,50 +23,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if !defined(_LIBCPP_HAS_NO_RANDOM_DEVICE)
 
-// Libc++ supports various implementations of std::random_device.
-//
-// _LIBCPP_USING_DEV_RANDOM
-//      Read entropy from the given file, by default `/dev/urandom`.
-//      If a token is provided, it is assumed to be the path to a file
-//      to read entropy from. This is the default behavior if nothing
-//      else is specified. This implementation requires storing state
-//      inside `std::random_device`.
-//
-// _LIBCPP_USING_ARC4_RANDOM
-//      Use arc4random(). This allows obtaining random data even when
-//      using sandboxing mechanisms. On some platforms like Apple, this
-//      is the recommended source of entropy for user-space programs.
-//      When this option is used, the token passed to `std::random_device`'s
-//      constructor *must* be "/dev/urandom" -- anything else is an error.
-//
-// _LIBCPP_USING_GETENTROPY
-//      Use getentropy().
-//      When this option is used, the token passed to `std::random_device`'s
-//      constructor *must* be "/dev/urandom" -- anything else is an error.
-//
-// _LIBCPP_USING_NACL_RANDOM
-//      NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
-//      including accesses to the special files under `/dev`. This implementation
-//      uses the NaCL syscall `nacl_secure_random_init()` to get entropy.
-//      When this option is used, the token passed to `std::random_device`'s
-//      constructor *must* be "/dev/urandom" -- anything else is an error.
-//
-// _LIBCPP_USING_WIN32_RANDOM
-//      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(__OpenBSD__)
-#  define _LIBCPP_USING_ARC4_RANDOM
-#elif defined(__Fuchsia__) || defined(__wasi__)
-#  define _LIBCPP_USING_GETENTROPY
-#elif defined(__native_client__)
-#  define _LIBCPP_USING_NACL_RANDOM
-#elif defined(_LIBCPP_WIN32API)
-#  define _LIBCPP_USING_WIN32_RANDOM
-#else
-#  define _LIBCPP_USING_DEV_RANDOM
-#endif
-
 class _LIBCPP_TYPE_VIS random_device
 {
 #ifdef _LIBCPP_USING_DEV_RANDOM