Created
January 5, 2018 03:35
-
-
Save serenitii/d51078ca7aa7bfdd5d508fbf2d15ec4b to your computer and use it in GitHub Desktop.
32bit GUID Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static u32 guid_32bit() { | |
static u32 s_guid_step_counter = 0; | |
struct timeval curr_time; | |
gettimeofday(&curr_time, nullptr); | |
//printf("%ld:%ld\n", curr_time.tv_sec, curr_time.tv_usec); | |
u32 secs = curr_time.tv_sec % 1000000; | |
u32 msecs = curr_time.tv_usec / 1000; | |
auto val = secs * 1000 + msecs + ++s_guid_step_counter; | |
return val; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment