[libcxx-commits] [libcxx] d13f502 - [libcxx] random_device, use arc4random() on FreeBSD, NetBSD and DragonFlyBSD

Brad Smith via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 24 18:49:37 PDT 2022


Author: Brad Smith
Date: 2022-04-24T21:45:49-04:00
New Revision: d13f5023891c92fc79818e02a838f913bf3e452b

URL: https://github.com/llvm/llvm-project/commit/d13f5023891c92fc79818e02a838f913bf3e452b
DIFF: https://github.com/llvm/llvm-project/commit/d13f5023891c92fc79818e02a838f913bf3e452b.diff

LOG: [libcxx] random_device, use arc4random() on FreeBSD, NetBSD and DragonFlyBSD

Reviewed By: ldionne, emaste, dim

Differential Revision: https://reviews.llvm.org/D122628

Added: 
    

Modified: 
    libcxx/docs/ReleaseNotes.rst
    libcxx/include/__config

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index ddb785b07ef40..0445b7bcfb9ab 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -97,6 +97,11 @@ ABI Changes
   ``_LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION`` will not be honoured anymore and there
   will be no way to opt back into the C++03 emulation of ``std::nullptr_t``.
 
+- On FreeBSD, NetBSD and DragonFlyBSD, ``std::random_device`` is now implemented on top of
+  ``arc4random()`` instead of reading from ``/dev/urandom``. Any implementation-defined
+  token used when constructing a ``std::random_device`` will now be ignored instead of
+  interpreted as a file to read entropy from.
+
 Build System Changes
 --------------------
 

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 660e98fd8b64f..050e8c82655c7 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -350,7 +350,8 @@
 //      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__) || defined(__APPLE__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
+    defined(__OpenBSD__) || defined(__DragonFly__)
 #  define _LIBCPP_USING_ARC4_RANDOM
 #elif defined(__wasi__)
 #  define _LIBCPP_USING_GETENTROPY


        


More information about the libcxx-commits mailing list