path: root/src/corelib/configure.json
diff options
authorThiago Macieira <>2017-06-16 21:39:04 -0700
committerThiago Macieira <>2017-06-30 21:19:10 +0000
commit120ecc976fc3d5504d234702f68c2ad3898b77a4 (patch)
treebfd8b6248a3e1d1e1cd90ab5f29e2bf4012aca79 /src/corelib/configure.json
parent078f04254e1ab7e4e7cb4b7ff5f371ab22a020cc (diff)
QRandomGenerator: use getentropy on Linux & OpenBSD
The getentropy function, first found in OpenBSD, is present in glibc since version 2.25 and Bionic since Android 6.0 and NDK r11. It uses the Linux 3.17 getrandom system call. Unlike glibc's getrandom() wrapper, the glibc implementation of getentropy() function is not a POSIX thread cancellation point, so we prefer to use that even though we have to break the reading into 256-byte blocks. The big advantage is that these functions work even in the absence of a /dev/urandom device node, in addition to a few cycles shaved off by not having to open a file descriptor and close it at exit. What's more, the glibc implementation blocks until entropy is available on early boot, so we don't have to worry about a failure mode. The Bionic implementation will fall back by itself to /dev/urandom and, failing that, gathering entropy from elsewhere in the system in a way it cannot fail either. uClibc has a wrapper to getrandom(2) but no getentropy(3). MUSL has neither. Change-Id: Ia53158e207a94bf49489fffd14c8cee1b968a619 Reviewed-by: Lars Knoll <>
Diffstat (limited to 'src/corelib/configure.json')
1 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index 0da3bff713..5e2cb025d3 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -163,6 +163,11 @@
"type": "compile",
"test": "unix/futimesat"
+ "getentropy": {
+ "label": "getentropy()",
+ "type": "compile",
+ "test": "unix/getentropy"
+ },
"posix-iconv": {
"label": "POSIX iconv",
"type": "compile",
@@ -277,6 +282,11 @@
"condition": "!config.win32 && !features.futimens && !features.futimes && tests.futimesat",
"output": [ "privateFeature" ]
+ "getentropy": {
+ "label": "getentropy()",
+ "condition": "config.unix && tests.getentropy",
+ "output": [ "privateFeature" ]
+ },
"glib": {
"label": "GLib",
"autoDetect": "!config.win32",