From 4333b1609002e26d53a5c3cd35309d0aa268f824 Mon Sep 17 00:00:00 2001 From: Abdelrahman Said Date: Mon, 29 Dec 2025 21:41:10 +0000 Subject: [PATCH] Reformat uuid --- src/uuid/uuid.c | 52 ++++++++++++++++++++++++------------------------- src/uuid/uuid.h | 2 +- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/uuid/uuid.c b/src/uuid/uuid.c index 65de857..accec5b 100644 --- a/src/uuid/uuid.c +++ b/src/uuid/uuid.c @@ -11,48 +11,48 @@ typedef struct uuid4 UUID4; struct uuid4 { - u64 high; - u64 low; + u64 high; + u64 low; }; 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) { - wapp_debug_assert(uuid != NULL, "`uuid` should not be NULL"); + wapp_debug_assert(uuid != NULL, "`uuid` should not be NULL"); - UUID4 uuid4 = generate_uuid4(); - uuid4_to_uuid(&uuid4, uuid); + UUID4 uuid4 = generate_uuid4(); + uuid4_to_uuid(&uuid4, uuid); - return uuid; + return uuid; } wapp_intern UUID4 generate_uuid4(void) { - wapp_persist XOR256State state = {0}; - wapp_persist b8 initialised = false; + wapp_persist XOR256State state = {0}; + wapp_persist b8 initialised = false; - if (!initialised) { - initialised = true; - state = wapp_prng_xorshift_init_state(); - } + if (!initialised) { + initialised = true; + state = wapp_prng_xorshift_init_state(); + } - UUID4 uuid = (UUID4){ - .high = wapp_prng_xorshift_256(&state), - .low = wapp_prng_xorshift_256(&state), - }; + UUID4 uuid = (UUID4){ + .high = wapp_prng_xorshift_256(&state), + .low = wapp_prng_xorshift_256(&state), + }; - uuid.high = (uuid.high & 0xffffffffffff0fff) | 0x0000000000004000; - uuid.low = (uuid.low & 0x3fffffffffffffff) | 0x8000000000000000; + uuid.high = (uuid.high & 0xffffffffffff0fff) | 0x0000000000004000; + uuid.low = (uuid.low & 0x3fffffffffffffff) | 0x8000000000000000; - return uuid; + return uuid; } wapp_intern void uuid4_to_uuid(const UUID4* uuid4, WUUID *uuid) { - u64 group1 = uuid4->high >> 32; - u64 group2 = (uuid4->high << 32) >> 48; - u64 group3 = (uuid4->high << 48) >> 48; - u64 group4 = uuid4->low >> 48; - u64 group5 = (uuid4->low << 16) >> 16; + u64 group1 = uuid4->high >> 32; + u64 group2 = (uuid4->high << 32) >> 48; + u64 group3 = (uuid4->high << 48) >> 48; + u64 group4 = uuid4->low >> 48; + u64 group5 = (uuid4->low << 16) >> 16; - wapp_str8_format(&(uuid->uuid), UUID_STR_FORMAT, group1, group2, group3, group4, group5); + wapp_str8_format(&(uuid->uuid), UUID_STR_FORMAT, group1, group2, group3, group4, group5); } diff --git a/src/uuid/uuid.h b/src/uuid/uuid.h index 0feedee..ed85fcd 100644 --- a/src/uuid/uuid.h +++ b/src/uuid/uuid.h @@ -17,7 +17,7 @@ BEGIN_C_LINKAGE typedef struct wapp_uuid WUUID; struct wapp_uuid { - Str8 uuid; + Str8 uuid; }; #define wapp_uuid_gen_uuid4() *(wapp_uuid_init_uuid4(&wapp_uuid_create()))