aboutsummaryrefslogtreecommitdiffstats
path: root/random.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-11 22:38:50 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-11 22:38:50 +0000
commitd3ca6dc6321164f6937a2b58aa8afd8371c030b0 (patch)
tree98da85b85c08b9a31593362f6af59215208f9154 /random.c
parent661fea0c938a856e70a3baab4e806cf91e56ac32 (diff)
downloadruby-d3ca6dc6321164f6937a2b58aa8afd8371c030b0.tar.gz
random.c (fill_random_bytes_syscall): use "__NR_" prefix on Linux
glibc still does not define the SYS_getrandom alias for __NR_getrandom in the Linux kernel. However, installing up-to-date Linux kernel headers (linux-libc-dev >= 3.17 package on Debian) will get the __NR_getrandom syscall number defined properly without relying on glibc. This allows users with a modern kernel+headers to use the getrandom syscall without waiting on glibc support. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/random.c b/random.c
index 6ddf4d186e..6362055dac 100644
--- a/random.c
+++ b/random.c
@@ -505,7 +505,7 @@ fill_random_bytes_syscall(void *seed, size_t size, int unused)
CryptGenRandom(prov, size, seed);
return 0;
}
-#elif defined __linux__ && defined SYS_getrandom
+#elif defined __linux__ && defined __NR_getrandom
#include <linux/random.h>
# ifndef GRND_NONBLOCK
@@ -522,7 +522,7 @@ fill_random_bytes_syscall(void *seed, size_t size, int need_secure)
if (!need_secure)
flags = GRND_NONBLOCK;
errno = 0;
- ret = syscall(SYS_getrandom, seed, size, flags);
+ ret = syscall(__NR_getrandom, seed, size, flags);
if (errno == ENOSYS) {
ATOMIC_SET(try_syscall, 0);
return -1;