1
0

__randname.c 393 B

123456789101112131415161718
  1. #include <time.h>
  2. #include <stdint.h>
  3. /* This assumes that a check for the
  4. template size has already been made */
  5. char *__randname(char *template)
  6. {
  7. int i;
  8. struct timespec ts;
  9. unsigned long r;
  10. __clock_gettime(CLOCK_REALTIME, &ts);
  11. r = ts.tv_nsec*65537 ^ (uintptr_t)&ts / 16 + (uintptr_t)template;
  12. for (i=0; i<6; i++, r>>=5)
  13. template[i] = 'A'+(r&15)+(r&16)*2;
  14. return template;
  15. }