Patchwork [13/26] Linux: getrandom syscall number is always available

login
register
mail settings
Submitter Florian Weimer
Date Feb. 9, 2020, 8:20 p.m.
Message ID <ac0ba6febb01f1f794d2067d80906539f9a10b9d.1581279333.git.fweimer@redhat.com>
Download mbox | patch
Permalink /patch/37817/
State New
Headers show

Comments

Florian Weimer - Feb. 9, 2020, 8:20 p.m.
Due to the built-in tables, __NR_getrandom is always defined.
---
 sysdeps/unix/sysv/linux/getentropy.c |  9 ---------
 sysdeps/unix/sysv/linux/getrandom.c  | 13 -------------
 2 files changed, 22 deletions(-)

Patch

diff --git a/sysdeps/unix/sysv/linux/getentropy.c b/sysdeps/unix/sysv/linux/getentropy.c
index 5d0b8d10c1..2f3a4e4692 100644
--- a/sysdeps/unix/sysv/linux/getentropy.c
+++ b/sysdeps/unix/sysv/linux/getentropy.c
@@ -21,7 +21,6 @@ 
 #include <errno.h>
 #include <unistd.h>
 
-#ifdef __NR_getrandom
 /* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on
    success and -1 on failure.  */
 int
@@ -63,11 +62,3 @@  getentropy (void *buffer, size_t length)
     }
   return 0;
 }
-#else
-int
-getentropy (void *buffer, size_t length)
-{
-  __set_errno (ENOSYS);
-  return -1;
-}
-#endif
diff --git a/sysdeps/unix/sysv/linux/getrandom.c b/sysdeps/unix/sysv/linux/getrandom.c
index 309beadf72..63b8d36bf4 100644
--- a/sysdeps/unix/sysv/linux/getrandom.c
+++ b/sysdeps/unix/sysv/linux/getrandom.c
@@ -21,7 +21,6 @@ 
 #include <unistd.h>
 #include <sysdep-cancel.h>
 
-#ifdef __NR_getrandom
 /* Write up to LENGTH bytes of randomness starting at BUFFER.
    Return the number of bytes written, or -1 on error.  */
 ssize_t
@@ -29,17 +28,5 @@  __getrandom (void *buffer, size_t length, unsigned int flags)
 {
   return SYSCALL_CANCEL (getrandom, buffer, length, flags);
 }
-#else
-/* Always provide a definition, even if the kernel headers lack the
-   system call number. */
-ssize_t
-__getrandom (void *buffer, size_t length, unsigned int flags)
-{
-  /* Ideally, we would add a cancellation point here, but we currently
-     cannot do so inside libc.  */
-  __set_errno (ENOSYS);
-  return -1;
-}
-#endif
 libc_hidden_def (__getrandom)
 weak_alias (__getrandom, getrandom)