summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2014-02-11 03:40:14 +0000
committerAaron Ballman <aaron@aaronballman.com>2014-02-11 03:40:14 +0000
commitbec3b4865ecc540e332c806fe03190867d85b5b3 (patch)
tree3d98b0f5a9c1c728f5c22203dcc4bc81f2be9565 /lib
parent91b585bccc23fafe004024c47fa555a638547a2b (diff)
downloadllvm-bec3b4865ecc540e332c806fe03190867d85b5b3.tar.gz
llvm-bec3b4865ecc540e332c806fe03190867d85b5b3.tar.bz2
llvm-bec3b4865ecc540e332c806fe03190867d85b5b3.tar.xz
Using the helper API for random number generation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201125 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/Path.cpp1
-rw-r--r--lib/Support/Unix/Path.inc1
-rw-r--r--lib/Support/Windows/Path.inc14
3 files changed, 2 insertions, 14 deletions
diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp
index c2b3f1863e..1872af55ed 100644
--- a/lib/Support/Path.cpp
+++ b/lib/Support/Path.cpp
@@ -15,6 +15,7 @@
#include "llvm/Support/Endian.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Process.h"
#include <cctype>
#include <cstdio>
#include <cstring>
diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc
index d0b63b5ba5..cda976fdee 100644
--- a/lib/Support/Unix/Path.inc
+++ b/lib/Support/Unix/Path.inc
@@ -17,7 +17,6 @@
//===----------------------------------------------------------------------===//
#include "Unix.h"
-#include "llvm/Support/Process.h"
#include <limits.h>
#include <stdio.h>
#if HAVE_SYS_STAT_H
diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc
index 5a41e49e25..a431fa0480 100644
--- a/lib/Support/Windows/Path.inc
+++ b/lib/Support/Windows/Path.inc
@@ -112,25 +112,13 @@ static error_code createUniqueEntity(const Twine &model, int &result_fd,
// needed if the randomly chosen path already exists.
SmallVector<wchar_t, 128> random_path_utf16;
- // Get a Crypto Provider for CryptGenRandom.
- HCRYPTPROV HCPC;
- if (!::CryptAcquireContextW(&HCPC,
- NULL,
- NULL,
- PROV_RSA_FULL,
- CRYPT_VERIFYCONTEXT))
- return windows_error(::GetLastError());
- ScopedCryptContext CryptoProvider(HCPC);
-
retry_random_path:
random_path_utf16.set_size(0);
for (SmallVectorImpl<wchar_t>::const_iterator i = model_utf16.begin(),
e = model_utf16.end();
i != e; ++i) {
if (*i == L'%') {
- BYTE val = 0;
- if (!::CryptGenRandom(CryptoProvider, 1, &val))
- return windows_error(::GetLastError());
+ unsigned val = sys::Process::GetRandomNumber();
random_path_utf16.push_back(L"0123456789abcdef"[val & 15]);
}
else