mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-10 22:46:25 +00:00
Hopefully fixing the MinGW 32 build, which was broken by r200767. Not using rand_s() since MinGW does not have an implementation for it, but instead using the underlying CryptGenRandom APIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201124 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
921f0b1d66
commit
91b585bccc
@ -12,11 +12,6 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Config/config.h"
|
||||
#if LLVM_ON_WIN32
|
||||
// This define makes stdlib.h declare the rand_s function.
|
||||
#define _CRT_RAND_S
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/Process.h"
|
||||
|
||||
|
@ -362,8 +362,15 @@ const char *Process::ResetColor() {
|
||||
}
|
||||
|
||||
unsigned Process::GetRandomNumber() {
|
||||
unsigned int result;
|
||||
const int ec = rand_s(&result);
|
||||
assert(ec == 0 && "rand_s failed");
|
||||
return result;
|
||||
HCRYPTPROV HCPC;
|
||||
if (!::CryptAcquireContextW(&HCPC, NULL, NULL, PROV_RSA_FULL,
|
||||
CRYPT_VERIFYCONTEXT))
|
||||
assert(false && "Could not acquire a cryptographic context");
|
||||
|
||||
ScopedCryptContext CryptoProvider(HCPC);
|
||||
unsigned Ret;
|
||||
if (!::CryptGenRandom(CryptoProvider, sizeof(Ret),
|
||||
reinterpret_cast<BYTE *>(&Ret)))
|
||||
assert(false && "Could not generate a random number");
|
||||
return Ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user