ruby-changes:45234
From: normal <ko1@a...>
Date: Thu, 12 Jan 2017 07:38:57 +0900 (JST)
Subject: [ruby-changes:45234] normal:r57307 (trunk): random.c (fill_random_bytes_syscall): use "__NR_" prefix on Linux
normal 2017-01-12 07:38:50 +0900 (Thu, 12 Jan 2017) New Revision: 57307 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57307 Log: 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. Modified files: trunk/random.c Index: random.c =================================================================== --- random.c (revision 57306) +++ random.c (revision 57307) @@ -505,7 +505,7 @@ fill_random_bytes_syscall(void *seed, si https://github.com/ruby/ruby/blob/trunk/random.c#L505 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, si https://github.com/ruby/ruby/blob/trunk/random.c#L522 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; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/