diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2014-02-04 14:49:21 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2014-02-04 14:49:21 +0000 |
commit | 78440734029c40841904a05663c2c38e7b258214 (patch) | |
tree | d1109c52253e39116dff054cc278fc6daf85cf3c /llvm/lib | |
parent | 2da2cee706b0d02e8dc57ef662b1fe11f4617c43 (diff) | |
download | bcm5719-llvm-78440734029c40841904a05663c2c38e7b258214.tar.gz bcm5719-llvm-78440734029c40841904a05663c2c38e7b258214.zip |
Implemented support for Process::GetRandomNumber on Windows.
Patch thanks to Stephan Tolksdorf!
llvm-svn: 200767
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/Process.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/Support/Windows/Process.inc | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp index d5168f03a6d..1360842753d 100644 --- a/llvm/lib/Support/Process.cpp +++ b/llvm/lib/Support/Process.cpp @@ -12,6 +12,11 @@ //===----------------------------------------------------------------------===// #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" diff --git a/llvm/lib/Support/Windows/Process.inc b/llvm/lib/Support/Windows/Process.inc index 750097eecf4..16e4092e9fa 100644 --- a/llvm/lib/Support/Windows/Process.inc +++ b/llvm/lib/Support/Windows/Process.inc @@ -360,3 +360,10 @@ const char *Process::ResetColor() { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColors()); return 0; } + +unsigned Process::GetRandomNumber() { + unsigned int result; + const errno_t ec = rand_s(&result); + assert(ec == 0 && "rand_s failed"); + return result; +} |