diff options
author | unknown <dlenev@dlenev.mshome> | 2003-08-11 23:43:01 +0400 |
---|---|---|
committer | unknown <dlenev@dlenev.mshome> | 2003-08-11 23:43:01 +0400 |
commit | 2ad06dc68e3ca572d2abbe89b470f2a510466ad3 (patch) | |
tree | bec2ab17e0424dac363d21f954738ff68f4fede9 /mysys | |
parent | e8da290b099fe2cfcdcb16d5e7805c616a8b526e (diff) | |
download | mariadb-git-2ad06dc68e3ca572d2abbe89b470f2a510466ad3.tar.gz |
Implemented UTC_TIME, UTC_DATE and UTC_TIMESTAMP functions (WL#345)
configure.in:
./configure now tests if gmtime_r is present
include/config-os2.h:
Supposing that OS/2 have gmtime_r
include/my_pthread.h:
Use our imeplementation of gmtime_r if system lacks one
mysql-test/r/func_time.result:
Added UTC_* functions to test
mysql-test/t/func_time.test:
Added UTC_* functions to test
mysys/my_pthread.c:
Our implementation of gmtime_r
mysys/my_thr_init.c:
Now we also need LOCK_locktime_r if gmtime_r is absent
sql/item_timefunc.cc:
Generalized classes for CURDATE, CURTIME and NOW, abstracted them from
timezone. Added new children classes for implementing these and UTC_*
functions.
sql/item_timefunc.h:
Generalized classes for CURDATE, CURTIME and NOW, abstracted them from
timezone. Added new children classes for implementing these and UTC_*
functions.
sql/lex.h:
Added tokens for UTC_TIME, UTC_DATE and UTC_TIMESTAMP
sql/sql_yacc.yy:
Added UTC_* functions to grammar. Current functions are using
classes now.
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_pthread.c | 21 | ||||
-rw-r--r-- | mysys/my_thr_init.c | 6 |
2 files changed, 23 insertions, 4 deletions
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index 4f472f61593..32528707480 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -133,10 +133,13 @@ int my_sigwait(const sigset_t *set,int *sig) /* localtime_r for SCO 3.2V4.2 */ -#ifndef HAVE_LOCALTIME_R +#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) extern pthread_mutex_t LOCK_localtime_r; +#endif + +#if !defined(HAVE_LOCALTIME_R) struct tm *localtime_r(const time_t *clock, struct tm *res) { struct tm *tmp; @@ -148,6 +151,22 @@ struct tm *localtime_r(const time_t *clock, struct tm *res) } #endif +#if !defined(HAVE_GMTIME_R) +/* + Reentrant version of standard gmtime() function. + Needed on some systems which don't implement it. +*/ + +struct tm *gmtime_r(const time_t *clock, struct tm *res) +{ + struct tm *tmp; + pthread_mutex_lock(&LOCK_localtime_r); + tmp= gmtime(clock); + *res= *tmp; + pthread_mutex_unlock(&LOCK_localtime_r); + return res; +} +#endif /**************************************************************************** ** Replacement of sigwait if the system doesn't have one (like BSDI 3.0) diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 59466083b28..32bc8ea3724 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -31,7 +31,7 @@ pthread_key(struct st_my_thread_var, THR_KEY_mysys); pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache, THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap, THR_LOCK_net, THR_LOCK_charset; -#ifndef HAVE_LOCALTIME_R +#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) pthread_mutex_t LOCK_localtime_r; #endif #ifndef HAVE_GETHOSTBYNAME_R @@ -73,7 +73,7 @@ my_bool my_thread_global_init(void) #if defined( __WIN__) || defined(OS2) win_pthread_init(); #endif -#ifndef HAVE_LOCALTIME_R +#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) pthread_mutex_init(&LOCK_localtime_r,MY_MUTEX_INIT_SLOW); #endif #ifndef HAVE_GETHOSTBYNAME_R @@ -103,7 +103,7 @@ void my_thread_global_end(void) pthread_mutex_destroy(&THR_LOCK_heap); pthread_mutex_destroy(&THR_LOCK_net); pthread_mutex_destroy(&THR_LOCK_charset); -#ifndef HAVE_LOCALTIME_R +#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) pthread_mutex_destroy(&LOCK_localtime_r); #endif #ifndef HAVE_GETHOSTBYNAME_R |