1
0

__randname.c 403 B

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