about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--include/sys/random.h10
-rw-r--r--stdlib/getrandom.c6
-rw-r--r--sysdeps/mach/hurd/getentropy.c2
-rw-r--r--sysdeps/mach/hurd/getrandom.c5
-rw-r--r--sysdeps/unix/sysv/linux/getrandom.c6
5 files changed, 23 insertions, 6 deletions
diff --git a/include/sys/random.h b/include/sys/random.h
index b33d114b74..6aa313d35d 100644
--- a/include/sys/random.h
+++ b/include/sys/random.h
@@ -1 +1,11 @@
+#ifndef _SYS_RANDOM_H
 #include <stdlib/sys/random.h>
+
+# ifndef _ISOMAC
+
+extern ssize_t __getrandom (void *__buffer, size_t __length,
+                            unsigned int __flags) __wur;
+libc_hidden_proto (__getrandom)
+
+# endif /* !_ISOMAC */
+#endif
diff --git a/stdlib/getrandom.c b/stdlib/getrandom.c
index 3cfbd0c0dd..02b827c63c 100644
--- a/stdlib/getrandom.c
+++ b/stdlib/getrandom.c
@@ -22,10 +22,12 @@
 /* Write up to LENGTH bytes of randomness starting at BUFFER.
    Return the number of bytes written, or -1 on error.  */
 ssize_t
-getrandom (void *buffer, size_t length, unsigned int flags)
+__getrandom (void *buffer, size_t length, unsigned int flags)
 {
   __set_errno (ENOSYS);
   return -1;
 }
-
 stub_warning (getrandom)
+
+libc_hidden_def (__getrandom)
+weak_alias (__getrandom, getrandom)
diff --git a/sysdeps/mach/hurd/getentropy.c b/sysdeps/mach/hurd/getentropy.c
index d55eec8984..06175d90ce 100644
--- a/sysdeps/mach/hurd/getentropy.c
+++ b/sysdeps/mach/hurd/getentropy.c
@@ -41,7 +41,7 @@ getentropy (void *buffer, size_t length)
   while (buffer < end)
     {
       /* NB: No cancellation point.  */
-      ssize_t bytes = getrandom (buffer, end - buffer, 0);
+      ssize_t bytes = __getrandom (buffer, end - buffer, 0);
       if (bytes < 0)
         {
           if (errno == EINTR)
diff --git a/sysdeps/mach/hurd/getrandom.c b/sysdeps/mach/hurd/getrandom.c
index 0147aeef3a..8bf42aa40d 100644
--- a/sysdeps/mach/hurd/getrandom.c
+++ b/sysdeps/mach/hurd/getrandom.c
@@ -24,7 +24,7 @@
 /* Write up to LENGTH bytes of randomness starting at BUFFER.
    Return the number of bytes written, or -1 on error.  */
 ssize_t
-getrandom (void *buffer, size_t length, unsigned int flags)
+__getrandom (void *buffer, size_t length, unsigned int flags)
 {
   const char *random_source = "/dev/urandom";
   size_t amount_read;
@@ -41,3 +41,6 @@ getrandom (void *buffer, size_t length, unsigned int flags)
   __close_nocancel_nostatus(fd);
   return amount_read;
 }
+
+libc_hidden_def (__getrandom)
+weak_alias (__getrandom, getrandom)
diff --git a/sysdeps/unix/sysv/linux/getrandom.c b/sysdeps/unix/sysv/linux/getrandom.c
index 122c695a3e..83388b5319 100644
--- a/sysdeps/unix/sysv/linux/getrandom.c
+++ b/sysdeps/unix/sysv/linux/getrandom.c
@@ -25,7 +25,7 @@
 /* Write up to LENGTH bytes of randomness starting at BUFFER.
    Return the number of bytes written, or -1 on error.  */
 ssize_t
-getrandom (void *buffer, size_t length, unsigned int flags)
+__getrandom (void *buffer, size_t length, unsigned int flags)
 {
   return SYSCALL_CANCEL (getrandom, buffer, length, flags);
 }
@@ -33,7 +33,7 @@ getrandom (void *buffer, size_t length, unsigned int flags)
 /* 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)
+__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.  */
@@ -41,3 +41,5 @@ getrandom (void *buffer, size_t length, unsigned int flags)
   return -1;
 }
 #endif
+libc_hidden_def (__getrandom)
+weak_alias (__getrandom, getrandom)