Added getentropy() support.
Prodded by David Carlier.
This commit is contained in:
43
auto/unix
43
auto/unix
@@ -48,6 +48,49 @@ if [ $nxt_found = no ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ $nxt_found = no ]; then
|
||||||
|
|
||||||
|
# OpenBSD 5.6 lacks <sys/random.h>.
|
||||||
|
|
||||||
|
nxt_feature="getentropy()"
|
||||||
|
nxt_feature_name=NXT_HAVE_GETENTROPY
|
||||||
|
nxt_feature_test="#include <unistd.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
char buf[4];
|
||||||
|
|
||||||
|
if (getentropy(buf, 4) == -1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}"
|
||||||
|
. auto/feature
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ $nxt_found = no ]; then
|
||||||
|
|
||||||
|
# macOS 10.12.
|
||||||
|
|
||||||
|
nxt_feature="getentropy() in sys/random.h"
|
||||||
|
nxt_feature_name=NXT_HAVE_GETENTROPY_SYS_RANDOM
|
||||||
|
nxt_feature_test="#include <unistd.h>
|
||||||
|
#include <sys/random.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
char buf[4];
|
||||||
|
|
||||||
|
if (getentropy(buf, 4) == -1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}"
|
||||||
|
. auto/feature
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
nxt_feature="ucontext"
|
nxt_feature="ucontext"
|
||||||
nxt_feature_name=NXT_HAVE_UCONTEXT
|
nxt_feature_name=NXT_HAVE_UCONTEXT
|
||||||
nxt_feature_run=
|
nxt_feature_run=
|
||||||
|
|||||||
@@ -68,6 +68,14 @@ nxt_random_stir(nxt_random_t *r)
|
|||||||
|
|
||||||
n = syscall(SYS_getrandom, &key, NXT_RANDOM_KEY_SIZE, 0);
|
n = syscall(SYS_getrandom, &key, NXT_RANDOM_KEY_SIZE, 0);
|
||||||
|
|
||||||
|
#elif (NXT_HAVE_GETENTROPY || NXT_HAVE_GETENTROPY_SYS_RANDOM)
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
|
||||||
|
if (getentropy(&key, NXT_RANDOM_KEY_SIZE) == 0) {
|
||||||
|
n = NXT_RANDOM_KEY_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|||||||
@@ -234,6 +234,8 @@
|
|||||||
#include <sys/random.h> /* getrandom(). */
|
#include <sys/random.h> /* getrandom(). */
|
||||||
#elif (NXT_HAVE_LINUX_SYS_GETRANDOM)
|
#elif (NXT_HAVE_LINUX_SYS_GETRANDOM)
|
||||||
#include <linux/random.h> /* SYS_getrandom. */
|
#include <linux/random.h> /* SYS_getrandom. */
|
||||||
|
#elif (NXT_HAVE_GETENTROPY_SYS_RANDOM)
|
||||||
|
#include <sys/random.h> /* getentropy(). */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user