[libcxx-commits] [PATCH] D94571: [libcxx] random_device, for OpenBSD specify optimal entropy properties

Brad Smith via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 12 17:36:30 PST 2021

brad created this revision.
brad added reviewers: ldionne, libc++.
brad added a project: libc++.
Herald added a subscriber: krytarowski.
brad requested review of this revision.
Herald added 1 blocking reviewer(s): libc++.

Submitting upstream from OpenBSD tree:

The random_device is an abstraction to the underlying OS PRNG. In OpenBSD's case, we know it has optimal entropy properties so specify what that is.

  rG LLVM Github Monorepo



Index: libcxx/src/random.cpp
--- libcxx/src/random.cpp
+++ libcxx/src/random.cpp
@@ -33,6 +33,9 @@
 #include <nacl/nacl_random.h>
+#ifdef __OpenBSD__
+#include <limits>
@@ -172,7 +175,11 @@
 random_device::entropy() const _NOEXCEPT
+#ifdef __OpenBSD__
+    return std::numeric_limits<unsigned int>::digits;
     return 0;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94571.316283.patch
Type: text/x-patch
Size: 499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210113/ecf01259/attachment.bin>

More information about the libcxx-commits mailing list