xref: /llvm-project/llvm/lib/Support/Process.cpp (revision d5f82d92f3c5cb3785e4778e334cc42a8b5e1018)
1 //===-- Process.cpp - Implement OS Process Concept --------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  This header file implements the operating system Process concept.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/Support/Process.h"
15 #include "llvm/Config/config.h"
16 #include <cstdlib>
17 
18 namespace llvm {
19 using namespace sys;
20 
21 //===----------------------------------------------------------------------===//
22 //=== WARNING: Implementation here must contain only TRULY operating system
23 //===          independent code.
24 //===----------------------------------------------------------------------===//
25 
26 unsigned llvm::sys::Process::GetRandomNumber() {
27 #if defined(HAVE_ARC4RANDOM)
28   return arc4random();
29 #else
30   static int x = (::srand(::time(NULL)), 0);
31   return ::rand();
32 #endif
33 }
34 
35 }
36 
37 // Include the platform-specific parts of this class.
38 #ifdef LLVM_ON_UNIX
39 #include "Unix/Process.inc"
40 #endif
41 #ifdef LLVM_ON_WIN32
42 #include "Windows/Process.inc"
43 #endif
44