summaryrefslogtreecommitdiff
path: root/src/temp/__randname.c
diff options
context:
space:
mode:
authorVladimir Azarov <avm@intermediate-node.net>2024-10-01 15:47:05 +0200
committerVladimir Azarov <avm@intermediate-node.net>2024-10-01 15:47:05 +0200
commit4abab5ad6c8465a7528ccdd5f49367da05f78bbd (patch)
treeebf009bf1376a5a223a915bc27cbbd791a1316bc /src/temp/__randname.c
Initial version
Diffstat (limited to 'src/temp/__randname.c')
-rw-r--r--src/temp/__randname.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/temp/__randname.c b/src/temp/__randname.c
new file mode 100644
index 0000000..e9b970f
--- /dev/null
+++ b/src/temp/__randname.c
@@ -0,0 +1,19 @@
+#include <time.h>
+#include <stdint.h>
+#include "pthread_impl.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_sec + ts.tv_nsec + __pthread_self()->tid * 65537UL;
+ for (i=0; i<6; i++, r>>=5)
+ template[i] = 'A'+(r&15)+(r&16)*2;
+
+ return template;
+}