mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-13 06:29:11 +00:00
Run formatter as per the Style Guide in CONTRIBUTING.md
This commit is contained in:
parent
7c75e3d709
commit
ed0c6c5757
3 changed files with 63 additions and 54 deletions
|
@ -863,9 +863,15 @@ int LuaUuidV7(lua_State *L) {
|
||||||
char bin[16], uuid_str[37];
|
char bin[16], uuid_str[37];
|
||||||
struct timespec ts = timespec_real();
|
struct timespec ts = timespec_real();
|
||||||
uint64_t unix_ts_ms = (uint64_t)((ts.tv_sec * 1000) + (ts.tv_nsec / 1000000));
|
uint64_t unix_ts_ms = (uint64_t)((ts.tv_sec * 1000) + (ts.tv_nsec / 1000000));
|
||||||
int fractional_ms = (int)floor((double)((double)(ts.tv_nsec - (ts.tv_nsec / 1000000) * 1000000)/1000000) * 4096) <<4;
|
int fractional_ms =
|
||||||
|
(int)floor(
|
||||||
|
(double)((double)(ts.tv_nsec - (ts.tv_nsec / 1000000) * 1000000) /
|
||||||
|
1000000) *
|
||||||
|
4096)
|
||||||
|
<< 4;
|
||||||
uint64_t rand_b = _rand64();
|
uint64_t rand_b = _rand64();
|
||||||
int rand_a = fractional_ms | (rand_b & 0x000000000000000f); //use the last 4 bits of rand_b
|
int rand_a = fractional_ms |
|
||||||
|
(rand_b & 0x000000000000000f); // use the last 4 bits of rand_b
|
||||||
|
|
||||||
bin[0] = unix_ts_ms >> 050;
|
bin[0] = unix_ts_ms >> 050;
|
||||||
bin[1] = unix_ts_ms >> 040;
|
bin[1] = unix_ts_ms >> 040;
|
||||||
|
@ -904,7 +910,10 @@ int LuaUuidV7(lua_State *L) {
|
||||||
uuid_str[17] = "0123456789abcdef"[(bin[7] & 0xf0) >> 4];
|
uuid_str[17] = "0123456789abcdef"[(bin[7] & 0xf0) >> 4];
|
||||||
uuid_str[18] = '-';
|
uuid_str[18] = '-';
|
||||||
uuid_str[19] = "0123456789abcdef"[(0x8 | ((bin[7] & 0x0f) >> 2))];
|
uuid_str[19] = "0123456789abcdef"[(0x8 | ((bin[7] & 0x0f) >> 2))];
|
||||||
uuid_str[20] = "0123456789abcdef"[(bin[7] & 0x03) | (bin[8] & 0xf0) >>6]; //See https://www.rfc-editor.org/rfc/rfc9562.html#version_field
|
uuid_str[20] = "0123456789abcdef"
|
||||||
|
[(bin[7] & 0x03) |
|
||||||
|
(bin[8] & 0xf0) >>
|
||||||
|
6]; // See https://www.rfc-editor.org/rfc/rfc9562.html#version_field
|
||||||
uuid_str[21] = "0123456789abcdef"[(bin[8] & 0x0f)];
|
uuid_str[21] = "0123456789abcdef"[(bin[8] & 0x0f)];
|
||||||
uuid_str[22] = "0123456789abcdef"[(bin[9] & 0xf0) >> 4];
|
uuid_str[22] = "0123456789abcdef"[(bin[9] & 0xf0) >> 4];
|
||||||
uuid_str[23] = '-';
|
uuid_str[23] = '-';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue