summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@nginx.com>2018-05-24 20:35:47 +0300
committerSergey Kandaurov <pluknet@nginx.com>2018-05-24 20:35:47 +0300
commita9ea218e7e119d7d7d050156835d4e16f41d0a6c (patch)
tree19d4a0d8b06181bef8ad6bec87a6cb7fda2b26c4 /src
parent3b7238996ad68f3c56a031e72e0b2f9aa0c8662c (diff)
downloadunit-a9ea218e7e119d7d7d050156835d4e16f41d0a6c.tar.gz
unit-a9ea218e7e119d7d7d050156835d4e16f41d0a6c.tar.bz2
Using getrandom() libc interface, SYS_getrandom fixes.
The interface is available since Glibc 2.25, and FreeBSD 12.0.
Diffstat (limited to 'src')
-rw-r--r--src/nxt_random.c8
-rw-r--r--src/nxt_unix.h10
2 files changed, 12 insertions, 6 deletions
diff --git a/src/nxt_random.c b/src/nxt_random.c
index 3dde1f15..27387b1f 100644
--- a/src/nxt_random.c
+++ b/src/nxt_random.c
@@ -62,9 +62,13 @@ nxt_random_stir(nxt_random_t *r)
#if (NXT_HAVE_GETRANDOM)
- /* Linux 3.17 getrandom(). */
+ n = getrandom(&key, NXT_RANDOM_KEY_SIZE, 0);
- n = getrandom(key, NXT_RANDOM_KEY_SIZE, 0);
+#elif (NXT_HAVE_LINUX_SYS_GETRANDOM)
+
+ /* Linux 3.17 SYS_getrandom. */
+
+ n = syscall(SYS_getrandom, &key, NXT_RANDOM_KEY_SIZE, 0);
#endif
diff --git a/src/nxt_unix.h b/src/nxt_unix.h
index d61f00bc..33e9f247 100644
--- a/src/nxt_unix.h
+++ b/src/nxt_unix.h
@@ -32,10 +32,6 @@
#include <malloc.h> /* malloc_usable_size(). */
#include <sys/syscall.h> /* syscall(SYS_gettid). */
-#if (NXT_GETRANDOM)
-#include <linux/random.h> /* getrandom(). */
-#endif
-
#if (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 4)
/*
* POSIX semaphores using NPTL atomic/futex operations
@@ -234,6 +230,12 @@
#include <sys/sendfile.h>
#endif
+#if (NXT_HAVE_GETRANDOM)
+#include <sys/random.h> /* getrandom(). */
+#elif (NXT_HAVE_LINUX_SYS_GETRANDOM)
+#include <linux/random.h> /* SYS_getrandom. */
+#endif
+
#if (NXT_TEST_BUILD)
#include <nxt_test_build.h>