mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-23 17:53:37 +08:00
Linux: getrandom syscall number is always available
Due to the built-in tables, __NR_getrandom is always defined. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
parent
d241dee4dd
commit
658b5848a8
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user