X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Frandom.cpp;h=26f51d3a4a0a674e19c3721b69ee5ad23eefa2b0;hb=5a23e035fd978f4623b818d45a47ef89bc354579;hp=ec74688ec976df098f60ea330b3a7ae4eb4903e2;hpb=a99a847c47f9cdbc329b6e87cccfafe94d34091f;p=lttng-tools.git diff --git a/src/common/random.cpp b/src/common/random.cpp index ec74688ec..26f51d3a4 100644 --- a/src/common/random.cpp +++ b/src/common/random.cpp @@ -72,6 +72,17 @@ void getrandom_nonblock(char *out_data, std::size_t size) errno); } } +#elif defined(HAVE_ARC4RANDOM) + +#include + +/* + * According to the MacOS / FreeBSD manpage, this function never fails nor blocks. + */ +void getrandom_nonblock(char *out_data, std::size_t size) +{ + arc4random_buf(out_data, size); +} #else /* defined(__linux__) && defined(SYS_getrandom) && defined(HAVE_SYS_RANDOM_H) */ __attribute__((noreturn)) void getrandom_nonblock(char *out_data __attribute__((unused)), std::size_t size __attribute__((unused)))