mirror of
https://github.com/microsoft/mimalloc.git
synced 2024-12-26 21:04:27 +08:00
experiment with bcrypt api again
This commit is contained in:
parent
e740242978
commit
f7b94fe21c
@ -191,7 +191,7 @@ endif()
|
||||
|
||||
# extra needed libraries
|
||||
if(WIN32)
|
||||
list(APPEND mi_libraries psapi shell32 user32 advapi32)
|
||||
list(APPEND mi_libraries psapi shell32 user32 advapi32 bcrypt)
|
||||
else()
|
||||
if(NOT ${CMAKE_C_COMPILER} MATCHES "android")
|
||||
list(APPEND mi_libraries pthread)
|
||||
|
@ -162,14 +162,13 @@ If we cannot get good randomness, we fall back to weak randomness based on a tim
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
/*
|
||||
// We prefer BCryptGenRandom over RtlGenRandom but it leads to a crash a when using dynamic override combined with the C++ runtime :-(
|
||||
#pragma comment (lib,"bcrypt.lib")
|
||||
#include <bcrypt.h>
|
||||
static bool os_random_buf(void* buf, size_t buf_len) {
|
||||
return (BCryptGenRandom(NULL, (PUCHAR)buf, (ULONG)buf_len, BCRYPT_USE_SYSTEM_PREFERRED_RNG) >= 0);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
#pragma comment (lib,"advapi32.lib")
|
||||
#define RtlGenRandom SystemFunction036
|
||||
#ifdef __cplusplus
|
||||
@ -185,7 +184,7 @@ static bool os_random_buf(void* buf, size_t buf_len) {
|
||||
bool ok = (RtlGenRandom(buf, (ULONG)buf_len) != 0);
|
||||
return ok;
|
||||
}
|
||||
|
||||
*/
|
||||
#elif defined(ANDROID) || defined(XP_DARWIN) || defined(__APPLE__) || defined(__DragonFly__) || \
|
||||
defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
|
||||
defined(__sun) || defined(__wasi__)
|
||||
|
Loading…
x
Reference in New Issue
Block a user