diff mbox

getentropy for <unistd.h>

Message ID e8272850-8c82-7ee9-c140-0ca587998b74@redhat.com
State Superseded
Headers show

Commit Message

Florian Weimer Dec. 23, 2016, 5:38 p.m. UTC
On 12/23/2016 05:45 PM, Paul Eggert wrote:
> Florian Weimer wrote:

>> Should I depend on _GNU_SOURCE instead?

>

> Sounds good to me. It would work well with Gnulib-using apps, which

> typically define _GNU_SOURCE at an early stage in 'configure'.


Good.  I plan to commit the attached patch.

Thanks,
Florian
diff mbox

Patch

Declare getentropy in <unistd.h>

2016-12-23  Florian Weimer  <fweimer@redhat.com>

	* posix/unistd.h (getentropy): Declare.

diff --git a/posix/unistd.h b/posix/unistd.h
index 392dc0e..70b10c6 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -1157,6 +1157,11 @@  extern int pthread_atfork (void (*__prepare) (void),
 			   void (*__child) (void)) __THROW;
 #endif
 
+#ifdef __USE_GNU
+/* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on
+   success or -1 on error.  */
+int getentropy (void *__buffer, size_t __length) __wur;
+#endif
 
 /* Define some macros helping to catch buffer overflows.  */
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function