diff options
author | Daniel Dunbar <daniel@zuster.org> | 2012-05-05 16:36:20 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2012-05-05 16:36:20 +0000 |
commit | 9c69e6ae698f44703725eec8ff27630b6b81f0e3 (patch) | |
tree | 0410bec4b6aa9e2d68f436839fff332d018bdc46 /lib/Support/Process.cpp | |
parent | e0b0e7b2950d3c132004105bba5f36a8eaea7925 (diff) |
[Support] Add sys::Process::GetRandomNumber().
- Primitive API, but we rarely have need for random numbers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156237 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Process.cpp')
-rw-r--r-- | lib/Support/Process.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Support/Process.cpp b/lib/Support/Process.cpp index 88ca7c3f22..c65cb45404 100644 --- a/lib/Support/Process.cpp +++ b/lib/Support/Process.cpp @@ -22,6 +22,15 @@ using namespace sys; //=== independent code. //===----------------------------------------------------------------------===// +unsigned llvm::sys::Process::GetRandomNumber() { +#if defined(HAVE_ARC4RANDOM) + return arc4random(); +#else + static int x = (::srand(::time(NULL)), 0); + return rand(); +#endif +} + } // Include the platform-specific parts of this class. |