From: Louis Dionne Date: Tue, 21 Dec 2021 21:50:34 +0000 (-0500) Subject: [libc++] Partially revert 346ef5e5879e X-Git-Tag: upstream/15.0.7~22439 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=beff71520b5be766ef06a0e0c1e67629fa39f429;p=platform%2Fupstream%2Fllvm.git [libc++] Partially revert 346ef5e5879e This moves the macro definitions back to __config, but keeps the improved documentation. 346ef5e5879e had broken the MinGW build. --- diff --git a/libcxx/include/__config b/libcxx/include/__config index 7d6cc16..720e12e 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -333,6 +333,50 @@ # 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 # if __BYTE_ORDER == __LITTLE_ENDIAN diff --git a/libcxx/include/__random/random_device.h b/libcxx/include/__random/random_device.h index 82dd1a1..835f726 100644 --- a/libcxx/include/__random/random_device.h +++ b/libcxx/include/__random/random_device.h @@ -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