mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 05:32:52 +00:00
25 lines
456 B
C++
25 lines
456 B
C++
#include <time.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <DB/Common/Exception.h>
|
|
#include <DB/Common/randomSeed.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int CANNOT_CLOCK_GETTIME;
|
|
}
|
|
}
|
|
|
|
|
|
uint64_t randomSeed()
|
|
{
|
|
struct timespec times;
|
|
if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, ×))
|
|
DB::throwFromErrno("Cannot clock_gettime.", DB::ErrorCodes::CANNOT_CLOCK_GETTIME);
|
|
return times.tv_nsec + times.tv_sec + getpid();
|
|
}
|