X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Ftemp%2F__randname.c;fp=src%2Ftemp%2F__randname.c;h=b097576d832baac9864f07fd339cc31f48fbfb2e;hp=0000000000000000000000000000000000000000;hb=2cc63358cdb0309ca996ffe56ccf402c2f2f16d5;hpb=f78cdbe8993d072bf60a65754544199016a1fe29 diff --git a/src/temp/__randname.c b/src/temp/__randname.c new file mode 100644 index 00000000..b097576d --- /dev/null +++ b/src/temp/__randname.c @@ -0,0 +1,21 @@ +#include +#include +#include + +int __clock_gettime(clockid_t, struct timespec *); + +/* This assumes that a check for the + template size has alrady 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; +}