Skip to content

Commit 1d64dfe

Browse files
committed
Merge #18364: random: remove getentropy() fallback for macOS < 10.12
f9f210d doc: fix GetTimeMicros() comment in random.cpp (fanquake) a889711 rand: remove getentropy() fallback for macOS < 10.12 (fanquake) Pull request description: We [no longer support macOS < 10.12](bitcoin/bitcoin#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 f9f210d (code review, not tested) elichai: utACK f9f210d practicalswift: ACK f9f210d -- patch looks correct laanwj: ACK f9f210d hebasto: ACK f9f210d, tested on macOS 10.13.6: compiled Tree-SHA512: 6bd2a721f23605a8bca0b7b51f42d628ebf92a18e74eb43194331ba745ee449223aff84119892781c40b188c70b75417447f4e390e3d9ac549292de2b1e8b308
2 parents 8fc5f2b + f9f210d commit 1d64dfe

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/random.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#endif
1616
#include <logging.h> // for LogPrintf()
1717
#include <sync.h> // for Mutex
18-
#include <util/time.h> // for GetTime()
18+
#include <util/time.h> // for GetTimeMicros()
1919

2020
#include <stdlib.h>
2121
#include <thread>
@@ -315,13 +315,10 @@ void GetOSRand(unsigned char *ent32)
315315
RandFailure();
316316
}
317317
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
318-
// We need a fallback for OSX < 10.12
319-
if (&getentropy != nullptr) {
320-
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
321-
RandFailure();
322-
}
323-
} else {
324-
GetDevURandom(ent32);
318+
/* getentropy() is available on macOS 10.12 and later.
319+
*/
320+
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
321+
RandFailure();
325322
}
326323
#elif defined(HAVE_SYSCTL_ARND)
327324
/* FreeBSD and similar. It is possible for the call to return less

0 commit comments

Comments
 (0)