Merge #18364: random: remove getentropy() fallback for macOS < 10.12

f9f210d8de doc: fix GetTimeMicros() comment in random.cpp (fanquake)
a889711562 rand: remove getentropy() fallback for macOS < 10.12 (fanquake)

Pull request description:

  We [no longer support macOS < 10.12](https://github.com/bitcoin/bitcoin/pull/17550) (our binaries will not run), so remove the fallback for when `getentropy()` wasn't available. From the manpage:

  ```bash
  HISTORY
       The getentropy() function appeared in OSX 10.12
  ```

  Note that compiling on macOS you'll see a new unused function warning:
  ```bash
  random.cpp:256:13: warning: unused function 'GetDevURandom' [-Wunused-function]
  static void GetDevURandom(unsigned char *ent32)
              ^
  1 warning generated.
  ```

  This will likely be addressed as part of #17563.

ACKs for top commit:
  vasild:
    ACK f9f210d8 (code review, not tested)
  elichai:
    utACK f9f210d8de
  practicalswift:
    ACK f9f210d8de -- patch looks correct
  laanwj:
    ACK f9f210d8de
  hebasto:
    ACK f9f210d8de, tested on macOS 10.13.6: compiled

Tree-SHA512: 6bd2a721f23605a8bca0b7b51f42d628ebf92a18e74eb43194331ba745ee449223aff84119892781c40b188c70b75417447f4e390e3d9ac549292de2b1e8b308
pull/764/head
Wladimir J. van der Laan 5 years ago
commit 1d64dfe4fa
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D

@ -15,7 +15,7 @@
#endif
#include <logging.h> // for LogPrintf()
#include <sync.h> // for Mutex
#include <util/time.h> // for GetTime()
#include <util/time.h> // for GetTimeMicros()
#include <stdlib.h>
#include <thread>
@ -315,13 +315,10 @@ void GetOSRand(unsigned char *ent32)
RandFailure();
}
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
// We need a fallback for OSX < 10.12
if (&getentropy != nullptr) {
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
RandFailure();
}
} else {
GetDevURandom(ent32);
/* getentropy() is available on macOS 10.12 and later.
*/
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
RandFailure();
}
#elif defined(HAVE_SYSCTL_ARND)
/* FreeBSD and similar. It is possible for the call to return less

Loading…
Cancel
Save