Logo
Explore Help
Sign In
fluencelabs/musl
1
0
Fork 0
You've already forked musl
mirror of https://github.com/fluencelabs/musl synced 2025-06-02 17:41:37 +00:00
Code Issues Projects Releases Wiki Activity
musl/src/temp/__randname.c

21 lines
445 B
C
Raw Normal View History

add mkostemp, mkstemps, and mkostemps functions and reorganize temp internals based on patch contributed by Anthony G. Basile (blueness) some issues remain with the filename generation algorithm and other small bugs, but this patch has been sitting around long enough that I feel it's best to get it committed and then work out any remaining issues.
2013-02-20 22:43:23 -05:00
#include <time.h>
#include <stdint.h>
int __clock_gettime(clockid_t, struct timespec *);
/* This assumes that a check for the
fix typo in comment in __randname
2013-09-04 10:23:42 -04:00
template size has already been made */
add mkostemp, mkstemps, and mkostemps functions and reorganize temp internals based on patch contributed by Anthony G. Basile (blueness) some issues remain with the filename generation algorithm and other small bugs, but this patch has been sitting around long enough that I feel it's best to get it committed and then work out any remaining issues.
2013-02-20 22:43:23 -05:00
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;
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 100ms Template: 4ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API