diff options
author | Riccardo Spagni <ric@spagni.net> | 2014-10-06 08:51:44 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2014-10-06 08:52:16 +0200 |
commit | 3463f0ab52a84b79977c3e67177637e62265c89c (patch) | |
tree | 1e2077aa15fa18fcc9b00fa23c9514d46df6ef95 /external/unbound/compat/ctime_r.c | |
parent | fix for miniupnpc static compile under Windows (diff) | |
parent | added aabramov's gpg key (diff) | |
download | monero-3463f0ab52a84b79977c3e67177637e62265c89c.tar.xz |
Merge pull request #171
32be6ae added aabramov's gpg key (Riccardo Spagni)
010bfcf minor English wordlist tweaks (Riccardo Spagni)
9ef094b added unbound to external deps (Riccardo Spagni)
732493c split mnemonic printout over 3 lines (Riccardo Spagni)
Diffstat (limited to 'external/unbound/compat/ctime_r.c')
-rw-r--r-- | external/unbound/compat/ctime_r.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/external/unbound/compat/ctime_r.c b/external/unbound/compat/ctime_r.c new file mode 100644 index 000000000..2594dc17e --- /dev/null +++ b/external/unbound/compat/ctime_r.c @@ -0,0 +1,42 @@ +/* taken from ldns 1.6.1 */ +#include "config.h" +#ifdef HAVE_TIME_H +#include <time.h> +#endif +#include "util/locks.h" + +/** the lock for ctime buffer */ +static lock_basic_t ctime_lock; +/** has it been inited */ +static int ctime_r_init = 0; + +/** cleanup ctime_r on exit */ +static void +ctime_r_cleanup(void) +{ + if(ctime_r_init) { + ctime_r_init = 0; + lock_basic_destroy(&ctime_lock); + } +} + +char *ctime_r(const time_t *timep, char *buf) +{ + char* result; + if(!ctime_r_init) { + /* still small race where this init can be done twice, + * which is mostly harmless */ + ctime_r_init = 1; + lock_basic_init(&ctime_lock); + atexit(&ctime_r_cleanup); + } + lock_basic_lock(&ctime_lock); + result = ctime(timep); + if(buf && result) { + if(strlen(result) > 10 && result[7]==' ' && result[8]=='0') + result[8]=' '; /* fix error in windows ctime */ + strcpy(buf, result); + } + lock_basic_unlock(&ctime_lock); + return result; +} |