From e5e86f8c6c8cfecab6e88934e804ea14b449f62d Mon Sep 17 00:00:00 2001 From: Sebastian Wilhelmi Date: Mon, 11 Jan 1999 14:41:07 +0000 Subject: [PATCH] Test for localtime_r only after including the right MT enabling CFLAGS 1999-01-11 Sebastian Wilhelmi * 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. --- ChangeLog | 9 +++++++++ ChangeLog.pre-2-0 | 9 +++++++++ ChangeLog.pre-2-10 | 9 +++++++++ ChangeLog.pre-2-12 | 9 +++++++++ ChangeLog.pre-2-2 | 9 +++++++++ ChangeLog.pre-2-4 | 9 +++++++++ ChangeLog.pre-2-6 | 9 +++++++++ ChangeLog.pre-2-8 | 9 +++++++++ configure.in | 4 +++- gdate.c | 15 +++++++++++---- glib/gdate.c | 15 +++++++++++---- 11 files changed, 97 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17a91e0..a1f32ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +1999-01-11 Sebastian Wilhelmi + + * 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. + Sat Jan 9 15:08:44 1999 Jeff Garzik * testglib.c: diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 17a91e0..a1f32ce 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,12 @@ +1999-01-11 Sebastian Wilhelmi + + * 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. + Sat Jan 9 15:08:44 1999 Jeff Garzik * testglib.c: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 17a91e0..a1f32ce 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,12 @@ +1999-01-11 Sebastian Wilhelmi + + * 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. + Sat Jan 9 15:08:44 1999 Jeff Garzik * testglib.c: diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 17a91e0..a1f32ce 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,12 @@ +1999-01-11 Sebastian Wilhelmi + + * 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. + Sat Jan 9 15:08:44 1999 Jeff Garzik * testglib.c: diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 17a91e0..a1f32ce 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,12 @@ +1999-01-11 Sebastian Wilhelmi + + * 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. + Sat Jan 9 15:08:44 1999 Jeff Garzik * testglib.c: diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 17a91e0..a1f32ce 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,12 @@ +1999-01-11 Sebastian Wilhelmi + + * 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. + Sat Jan 9 15:08:44 1999 Jeff Garzik * testglib.c: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 17a91e0..a1f32ce 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,12 @@ +1999-01-11 Sebastian Wilhelmi + + * 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. + Sat Jan 9 15:08:44 1999 Jeff Garzik * testglib.c: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 17a91e0..a1f32ce 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,12 @@ +1999-01-11 Sebastian Wilhelmi + + * 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. + Sat Jan 9 15:08:44 1999 Jeff Garzik * testglib.c: diff --git a/configure.in b/configure.in index 327cb0a..2d22881 100644 --- a/configure.in +++ b/configure.in @@ -254,7 +254,7 @@ AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H)) AC_CHECK_HEADER(alloca.h, glib_have_alloca_h=yes, glib_have_alloca_h=no) # Check for some functions -AC_CHECK_FUNCS(localtime_r rand_r lstat strerror strsignal memmove vsnprintf vasprintf strcasecmp strncasecmp poll) +AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf vasprintf strcasecmp strncasecmp poll) # Check for sys_errlist AC_MSG_CHECKING(for sys_errlist) @@ -717,6 +717,8 @@ AC_SUBST(G_THREAD_LIBS) CFLAGS="$CFLAGS $G_THREAD_CFLAGS" +AC_CHECK_FUNCS(localtime_r rand_r) + dnl ********************************************** dnl *** GDefaultMutex setup and initialization *** dnl ********************************************** diff --git a/gdate.c b/gdate.c index 04d0a9a..f44d70b 100644 --- a/gdate.c +++ b/gdate.c @@ -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; diff --git a/glib/gdate.c b/glib/gdate.c index 04d0a9a..f44d70b 100644 --- a/glib/gdate.c +++ b/glib/gdate.c @@ -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; -- 2.7.4