Reformat uuid
This commit is contained in:
@@ -16,7 +16,7 @@ struct uuid4 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
wapp_intern UUID4 generate_uuid4(void);
|
wapp_intern UUID4 generate_uuid4(void);
|
||||||
wapp_intern void uuid4_to_uuid(const UUID4* uuid4, WUUID *uuid);
|
wapp_intern void uuid4_to_uuid(const UUID4* uuid4, WUUID *uuid);
|
||||||
|
|
||||||
WUUID *wapp_uuid_init_uuid4(WUUID *uuid) {
|
WUUID *wapp_uuid_init_uuid4(WUUID *uuid) {
|
||||||
wapp_debug_assert(uuid != NULL, "`uuid` should not be NULL");
|
wapp_debug_assert(uuid != NULL, "`uuid` should not be NULL");
|
||||||
@@ -32,17 +32,17 @@ wapp_intern UUID4 generate_uuid4(void) {
|
|||||||
wapp_persist b8 initialised = false;
|
wapp_persist b8 initialised = false;
|
||||||
|
|
||||||
if (!initialised) {
|
if (!initialised) {
|
||||||
initialised = true;
|
initialised = true;
|
||||||
state = wapp_prng_xorshift_init_state();
|
state = wapp_prng_xorshift_init_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID4 uuid = (UUID4){
|
UUID4 uuid = (UUID4){
|
||||||
.high = wapp_prng_xorshift_256(&state),
|
.high = wapp_prng_xorshift_256(&state),
|
||||||
.low = wapp_prng_xorshift_256(&state),
|
.low = wapp_prng_xorshift_256(&state),
|
||||||
};
|
};
|
||||||
|
|
||||||
uuid.high = (uuid.high & 0xffffffffffff0fff) | 0x0000000000004000;
|
uuid.high = (uuid.high & 0xffffffffffff0fff) | 0x0000000000004000;
|
||||||
uuid.low = (uuid.low & 0x3fffffffffffffff) | 0x8000000000000000;
|
uuid.low = (uuid.low & 0x3fffffffffffffff) | 0x8000000000000000;
|
||||||
|
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user