aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/src
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-04-03 13:57:21 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-04-03 13:57:21 +0300
commit07ff7621c09ff6414a48ec1757c72af1e5e1dbc0 (patch)
tree6700f4b0c2e985ad9b95399a22a70676bd2b9195 /contrib/libs/cxxsupp/libcxx/src
parentbb0d582a3fa3ddfc775c44fe32f24b6806606b7b (diff)
downloadydb-07ff7621c09ff6414a48ec1757c72af1e5e1dbc0.tar.gz
intermediate changes
ref:8fcd56b3fe762902848ae3f9eabb01e1aa97432c
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src')
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/random.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/random.cpp b/contrib/libs/cxxsupp/libcxx/src/random.cpp
index c4bda825fbc..a5ac325bdf0 100644
--- a/contrib/libs/cxxsupp/libcxx/src/random.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/random.cpp
@@ -36,6 +36,8 @@
# endif
#elif defined(_LIBCPP_USING_NACL_RANDOM)
# include <nacl/nacl_random.h>
+#elif defined(_LIBCPP_USING_FUCHSIA_CPRNG)
+# include <zircon/syscalls.h>
#endif
@@ -170,6 +172,27 @@ random_device::operator()()
return r;
}
+#elif defined(_LIBCPP_USING_FUCHSIA_CPRNG)
+
+random_device::random_device(const string& __token) {
+ if (__token != "/dev/urandom")
+ __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
+}
+
+random_device::~random_device() {}
+
+unsigned random_device::operator()() {
+ // Implicitly link against the vDSO system call ABI without
+ // requiring the final link to specify -lzircon explicitly when
+ // statically linking libc++.
+# pragma comment(lib, "zircon")
+
+ // The system call cannot fail. It returns only when the bits are ready.
+ unsigned r;
+ _zx_cprng_draw(&r, sizeof(r));
+ return r;
+}
+
#else
#error "Random device not implemented for this architecture"
#endif
@@ -189,7 +212,7 @@ random_device::entropy() const noexcept
return std::numeric_limits<result_type>::digits;
return ent;
-#elif defined(__OpenBSD__)
+#elif defined(__OpenBSD__) || defined(_LIBCPP_USING_FUCHSIA_CPRNG)
return std::numeric_limits<result_type>::digits;
#else
return 0;