[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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D94571
Files:
libcxx/src/random.cpp
Index: libcxx/src/random.cpp
===================================================================
--- libcxx/src/random.cpp
+++ libcxx/src/random.cpp
@@ -33,6 +33,9 @@
#include <nacl/nacl_random.h>
#endif
+#ifdef __OpenBSD__
+#include <limits>
+#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -172,7 +175,11 @@
double
random_device::entropy() const _NOEXCEPT
{
+#ifdef __OpenBSD__
+ return std::numeric_limits<unsigned int>::digits;
+#else
return 0;
+#endif
}
_LIBCPP_END_NAMESPACE_STD
-------------- 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