summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qconfig-bootstrapped.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-06-16 21:39:04 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-06-30 21:19:10 +0000
commit120ecc976fc3d5504d234702f68c2ad3898b77a4 (patch)
treebfd8b6248a3e1d1e1cd90ab5f29e2bf4012aca79 /src/corelib/global/qconfig-bootstrapped.h
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 <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/global/qconfig-bootstrapped.h')
-rw-r--r--src/corelib/global/qconfig-bootstrapped.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h
index a6a56b5d59..7dba4ae5da 100644
--- a/src/corelib/global/qconfig-bootstrapped.h
+++ b/src/corelib/global/qconfig-bootstrapped.h
@@ -76,6 +76,7 @@
# define QT_FEATURE_alloca_malloc_h -1
#endif
#define QT_FEATURE_cxx11_random (QT_HAS_INCLUDE(<random>) ? 1 : -1)
+#define QT_FEATURE_getentropy -1
#define QT_FEATURE_iconv -1
#define QT_FEATURE_icu -1
#define QT_FEATURE_journald -1