mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-21 12:38:45 +00:00
- 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
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
//===-- Process.cpp - Implement OS Process Concept --------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This header file implements the operating system Process concept.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Support/Process.h"
|
|
#include "llvm/Config/config.h"
|
|
|
|
namespace llvm {
|
|
using namespace sys;
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
//=== WARNING: Implementation here must contain only TRULY operating system
|
|
//=== 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.
|
|
#ifdef LLVM_ON_UNIX
|
|
#include "Unix/Process.inc"
|
|
#endif
|
|
#ifdef LLVM_ON_WIN32
|
|
#include "Windows/Process.inc"
|
|
#endif
|