- 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
-//===- llvm/Support/Process.h ------------------------------------*- C++ -*-===//
+//===- llvm/Support/Process.h -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
/// Resets the terminals colors, or returns an escape sequence to do so.
static const char *ResetColor();
+
+ /// Get the result of a process wide random number generator. The
+ /// generator will be automatically seeded in non-deterministic fashion.
+ static unsigned GetRandomNumber();
/// @}
};
}
//=== 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.