31 lines
803 B
C++
31 lines
803 B
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright 2017 Google LLC.
|
|
//
|
|
// This software is licensed under the terms defined in the Widevine Master
|
|
// License Agreement. For a copy of this agreement, please contact
|
|
// widevine-licensing@google.com.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef UTIL_RANDOM_GLOBAL_ID_H_
|
|
#define UTIL_RANDOM_GLOBAL_ID_H_
|
|
|
|
#include "openssl/rand.h"
|
|
|
|
namespace widevine {
|
|
namespace util {
|
|
namespace random {
|
|
|
|
static uint64_t NewGlobalID() {
|
|
static __thread uint64_t val = 0;
|
|
if (val == 0) {
|
|
RAND_bytes(reinterpret_cast<uint8_t*>(&val), sizeof(val));
|
|
}
|
|
return val++;
|
|
}
|
|
|
|
} // namespace random
|
|
} // namespace util
|
|
} // namespace widevine
|
|
|
|
#endif // UTIL_RANDOM_GLOBAL_ID_H_
|