Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: fusl/src/temp/__randname.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/string/x86_64/memset.s ('k') | fusl/src/temp/mkdtemp.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/temp/__randname.c
diff --git a/fusl/src/temp/__randname.c b/fusl/src/temp/__randname.c
new file mode 100644
index 0000000000000000000000000000000000000000..464b83d5f95b09b23ecd3c91a1d12641187b2543
--- /dev/null
+++ b/fusl/src/temp/__randname.c
@@ -0,0 +1,20 @@
+#include <time.h>
+#include <stdint.h>
+
+int __clock_gettime(clockid_t, struct timespec *);
+
+/* 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_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;
+}
« no previous file with comments | « fusl/src/string/x86_64/memset.s ('k') | fusl/src/temp/mkdtemp.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698