diff options
author | Sebastian Wilhelmi <wilhelmi@ira.uka.de> | 1999-01-11 14:41:07 +0000 |
---|---|---|
committer | Sebastian Wilhelmi <wilhelmi@src.gnome.org> | 1999-01-11 14:41:07 +0000 |
commit | e5e86f8c6c8cfecab6e88934e804ea14b449f62d (patch) | |
tree | 226645b4627151722c05012b6131f7e178df4edf /gdate.c | |
parent | f4a2520f38468f975df4229d203b6bed03a8f95c (diff) | |
download | glib-e5e86f8c6c8cfecab6e88934e804ea14b449f62d.tar.gz |
Test for localtime_r only after including the right MT enabling CFLAGS
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Test for localtime_r only after including the
right MT enabling CFLAGS (i.e. -D_REENTRANT on most systems).
* gdate.c (g_date_set_time): Emit warning, if no localtime_r
function is available on thread enabled systems. Define ptm only,
if really needed, and assert on it.
Diffstat (limited to 'gdate.c')
-rw-r--r-- | gdate.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -790,15 +790,22 @@ g_date_set_time (GDate *d, GTime time) { time_t t = time; - struct tm tm, *ptm; + struct tm tm; g_return_if_fail (d != NULL); -#if HAVE_LOCALTIME_R +#ifdef HAVE_LOCALTIME_R localtime_r (&t, &tm); #else - ptm = localtime (&t); - memcpy((void *) &tm, (void *) ptm, sizeof(struct tm)); +# ifdef G_THREADS_ENABLED +# warning "the `g_date_set_time' function will not be MT-safe" +# warning "because there is no `localtime_r' on your system." +# endif + { + struct tm *ptm = localtime (&t); + g_assert (ptm); + memcpy ((void *) &tm, (void *) ptm, sizeof(struct tm)); + } #endif d->julian = FALSE; |