diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-05-05 17:14:19 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-05-05 17:14:19 +0800 |
commit | b31a0e3d53ce17d4626fe125dd1e1f654a0d192c (patch) | |
tree | 0413d8feb94f09c0a2ea157328b760bf1f80ed60 | |
parent | 1f0b3cd9795e2979fc3c4454d4fbcf74c65298e0 (diff) | |
download | pttbbs-b31a0e3d53ce17d4626fe125dd1e1f654a0d192c.tar pttbbs-b31a0e3d53ce17d4626fe125dd1e1f654a0d192c.tar.gz pttbbs-b31a0e3d53ce17d4626fe125dd1e1f654a0d192c.tar.bz2 pttbbs-b31a0e3d53ce17d4626fe125dd1e1f654a0d192c.tar.lz pttbbs-b31a0e3d53ce17d4626fe125dd1e1f654a0d192c.tar.xz pttbbs-b31a0e3d53ce17d4626fe125dd1e1f654a0d192c.tar.zst pttbbs-b31a0e3d53ce17d4626fe125dd1e1f654a0d192c.zip |
- (internal) add localtime4_r thread-safe API
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4271 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | common/sys/time.c | 14 | ||||
-rw-r--r-- | include/cmsys.h | 10 |
2 files changed, 21 insertions, 3 deletions
diff --git a/common/sys/time.c b/common/sys/time.c index 7cf963b3..7a3768c1 100644 --- a/common/sys/time.c +++ b/common/sys/time.c @@ -112,6 +112,20 @@ struct tm *localtime4(const time4_t *t) } } +struct tm* +localtime4_r(const time4_t *t, struct tm *pt) +{ + if (t) + { + time_t temp = (time_t)*t; + localtime_r(&temp, pt); + } + else + localtime_r(NULL, pt); + return pt; +} + + time4_t time4(time4_t *ptr) { if( ptr == NULL ) diff --git a/include/cmsys.h b/include/cmsys.h index abb66213..a50793fe 100644 --- a/include/cmsys.h +++ b/include/cmsys.h @@ -113,11 +113,15 @@ extern const char* Cdatelite(const time4_t *clock); extern const char* Cdatedate(const time4_t * clock); extern const char * Cdate_mdHM(const time4_t * clock); extern const char* my_ctime(const time4_t * t, char *ans, int len); +extern struct tm localtime4r(const time4_t *t); + #ifdef TIMET64 - struct tm *localtime4(const time4_t *); - time4_t time4(time4_t *); - char *ctime4(const time4_t *); + struct tm* localtime4(const time4_t *); + struct tm* localtime4_r(const time4_t *, struct tm *); + time4_t time4(time4_t *); + char* ctime4(const time4_t *); #else + #define localtime4_r(a,b) localtime_r(a,b) #define localtime4(a) localtime(a) #define time4(a) time(a) #define ctime4(a) ctime(a) |