diff options
Diffstat (limited to '')
-rw-r--r-- | libc-top-half/musl/src/temp/__randname.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/temp/__randname.c b/libc-top-half/musl/src/temp/__randname.c new file mode 100644 index 0000000..2bce37a --- /dev/null +++ b/libc-top-half/musl/src/temp/__randname.c @@ -0,0 +1,18 @@ +#include <time.h> +#include <stdint.h> + +/* This assumes that a check for the + template size has already been made */ +char *__randname(char *template) +{ + int i; + struct timespec ts; + unsigned long r; + + __clock_gettime(CLOCK_REALTIME, &ts); + r = ts.tv_nsec*65537 ^ (uintptr_t)&ts / 16 + (uintptr_t)template; + for (i=0; i<6; i++, r>>=5) + template[i] = 'A'+(r&15)+(r&16)*2; + + return template; +} |