#include #include #include #include #include #include #include #include namespace DB { namespace ErrorCodes { extern const int CANNOT_CLOCK_GETTIME; } } DB::UInt64 randomSeed() { struct timespec times; if (clock_gettime(CLOCK_MONOTONIC, ×)) DB::throwFromErrno("Cannot clock_gettime.", DB::ErrorCodes::CANNOT_CLOCK_GETTIME); /// Not cryptographically secure as time, pid and stack address can be predictable. SipHash hash; hash.update(times.tv_nsec); hash.update(times.tv_sec); hash.update(getThreadId()); hash.update(×); return hash.get64(); }