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