aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Core/UUID.cpp
blob: 10350964f50e7a95e903d03d45d46a2fdd7af762 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <Core/UUID.h>
#include <Common/thread_local_rng.h>


namespace DB
{

namespace UUIDHelpers
{
    UUID generateV4()
    {
        UUID uuid;
        getHighBytes(uuid) = (thread_local_rng() & 0xffffffffffff0fffull) | 0x0000000000004000ull;
        getLowBytes(uuid) = (thread_local_rng() & 0x3fffffffffffffffull) | 0x8000000000000000ull;

        return uuid;
    }
}

}