From c79d20855adf811611cb0499821318f6e043b50c Mon Sep 17 00:00:00 2001 From: Jason Erickson Date: Mon, 8 Nov 2010 10:23:38 -0700 Subject: [PATCH] Win32 *time_r fix Fixed the thread safetyness of the Windows *time_r functions. --- psycopg/config.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/psycopg/config.h b/psycopg/config.h index 274c0dbb..708f0a89 100644 --- a/psycopg/config.h +++ b/psycopg/config.h @@ -119,16 +119,9 @@ static int pthread_mutex_init(pthread_mutex_t *mutex, void* fake) /* to work around the fact that Windows does not have a gmtime_r function, or a proper gmtime function */ #ifdef _WIN32 -static struct tm *gmtime_r(time_t *t, struct tm *tm) -{ - tm = gmtime(t); - return tm; -} -static struct tm *localtime_r(time_t *t, struct tm *tm) -{ - tm = localtime(t); - return tm; -} +#define gmtime_r(t, tm) (gmtime(t)?memcpy((tm), gmtime(t), sizeof(*(tm))):NULL) +#define localtime_r(t, tm) (localtime(t)?memcpy((tm), localtime(t), sizeof(*(tm))):NULL) + /* remove the inline keyword, since it doesn't work unless C++ file */ #define inline