]> Savannah Git Hosting - gnulib.git/commitdiff
tempname: use getrandom, not getentropy
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 Jun 2020 22:58:29 +0000 (15:58 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 Jun 2020 22:58:51 +0000 (15:58 -0700)
This removes a dependency, as getentropy depends on getrandom.
* lib/tempname.c: Include sys/random.h instead of unistd.h.
(RANDOM_BITS) [!_LIBC]: Use getrandom, not getentropy.
* modules/tempname (Depends-on): Depend on getrandom, not getentropy.

ChangeLog
lib/tempname.c
modules/tempname

index 381ca8814654d35c9810197212460a8dafc64925..5a07e5ae71bfa22575e4d9e9b0756ba6dfdd333a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-06-01  Paul Eggert  <eggert@cs.ucla.edu>
+
+       tempname: use getrandom, not getentropy
+       This removes a dependency, as getentropy depends on getrandom.
+       * lib/tempname.c: Include sys/random.h instead of unistd.h.
+       (RANDOM_BITS) [!_LIBC]: Use getrandom, not getentropy.
+       * modules/tempname (Depends-on): Depend on getrandom, not getentropy.
+
 2020-06-01  Bruno Haible  <bruno@clisp.org>
 
        doc: New chapter 'Multithreading'.
index ca7e8b1e78d180262250b86494102dea25545984..9219ee66af12d39613b2416e9cbc86903b4d59ac 100644 (file)
@@ -48,8 +48,7 @@
 
 #include <fcntl.h>
 #include <stdint.h>
-#include <unistd.h>
-
+#include <sys/random.h>
 #include <sys/stat.h>
 
 #if _LIBC
@@ -71,11 +70,11 @@ typedef uint32_t random_value;
 # define BASE_62_DIGITS 5 /* 62**5 < UINT32_MAX */
 # define BASE_62_POWER (62 * 62 * 62 * 62 * 62) /* 2**BASE_62_DIGITS */
 #else
-/* Use getentropy if it works, falling back on a 64-bit linear
+/* Use getrandom if it works, falling back on a 64-bit linear
    congruential generator that starts with whatever Var's value
    happens to be.  */
 # define RANDOM_BITS(Var) \
-    ((void) (getentropy (&(Var), sizeof (Var)) == 0 \
+    ((void) (getrandom (&(Var), sizeof (Var), 0) == sizeof (Var) \
              || ((Var) = 2862933555777941757 * (Var) + 3037000493)))
 typedef uint_fast64_t random_value;
 # define RANDOM_VALUE_MAX UINT_FAST64_MAX
index 6d6a034ebc0b9e67c98526da10ee537036e9b9ad..0f692d3d7c5566a3cf549ecc8f1bc4e2a77facff 100644 (file)
@@ -10,7 +10,7 @@ m4/tempname.m4
 Depends-on:
 extensions
 fcntl-h
-getentropy
+getrandom
 libc-config
 lstat
 mkdir