16 #if defined(__linux__)
17 #include <linux/limits.h>
37 return absl::uniform_int_distribution<uint32>(0,
kuint32max)(generator_);
43 return absl::uniform_int_distribution<uint64>(0,
kuint64max)(generator_);
47 return val_max == 0 ? 0 :
Next64() % val_max;
51 static inline uint32 Word32At(
const char* ptr) {
52 return ((
static_cast<uint32>(ptr[0])) + (
static_cast<uint32>(ptr[1]) << 8) +
53 (
static_cast<uint32>(ptr[2]) << 16) +
54 (
static_cast<uint32>(ptr[3]) << 24));
59 char name[PATH_MAX + 20];
60 assert(
sizeof(
name) - PATH_MAX >
sizeof(
uint32) * 3);
62 if (gethostname(
name, PATH_MAX) != 0) {
63 strcpy(
name,
"default-hostname");
65 const int namelen = strlen(
name);
66 for (
size_t i = 0; i <
sizeof(
uint32) * 3; ++i) {
67 name[namelen + i] =
'\0';
72 gettimeofday(&tv, NULL);
73 uint32 b =
static_cast<uint32>((tv.tv_sec + tv.tv_usec) & 0xffffffff);
74 #elif defined(_MSC_VER)
75 uint32 a = GetCurrentProcessId();
77 #else // Do not know what to do, returning 0.
81 for (
int i = 0; i < namelen; i +=
sizeof(
uint32) * 3) {
82 a += Word32At(
name + i);
89 return static_cast<int32>(c);