Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Port to 2.1 - Fix performance regression in Guid.NewGuid on OSX #29457

Merged
merged 1 commit into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Native/Unix/Common/pal_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#cmakedefine01 HAVE_TIOCGWINSZ
#cmakedefine01 HAVE_SCHED_GETAFFINITY
#cmakedefine01 HAVE_SCHED_SETAFFINITY
#cmakedefine01 HAVE_ARC4RANDOM
#cmakedefine01 KEVENT_HAS_VOID_UDATA
#cmakedefine01 HAVE_FDS_BITS
#cmakedefine01 HAVE_PRIVATE_FDS_BITS
Expand Down
5 changes: 5 additions & 0 deletions src/Native/Unix/System.Native/pal_random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <time.h>
#include <errno.h>

#include "pal_config.h"
/*

Generate random bytes. The generated bytes are not cryptographically strong.
Expand All @@ -20,6 +21,9 @@ extern "C" void SystemNative_GetNonCryptographicallySecureRandomBytes(uint8_t* b
{
assert(buffer != NULL);

#if HAVE_ARC4RANDOM
arc4random_buf(buffer, (size_t)bufferLength);
#else
static volatile int rand_des = -1;
long num = 0;
static bool sMissingDevURandom;
Expand Down Expand Up @@ -93,4 +97,5 @@ extern "C" void SystemNative_GetNonCryptographicallySecureRandomBytes(uint8_t* b
*(buffer + i) ^= num;
num >>= 8;
}
#endif // HAS_ARC4RANDOM
}
4 changes: 4 additions & 0 deletions src/Native/Unix/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ check_function_exists(
sched_setaffinity
HAVE_SCHED_SETAFFINITY)

check_function_exists(
arc4random
HAVE_ARC4RANDOM)

check_symbol_exists(
TIOCGWINSZ
"sys/ioctl.h"
Expand Down