From: Jeff Garzik Date: Sat, 9 Jan 1999 19:14:16 +0000 (+0000) Subject: Add checks for vasprintf, localtime_r. X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=2a6789be13c4def678ae612d6cdf236d347374eb;p=dana%2Fcg-glib.git Add checks for vasprintf, localtime_r. * configure.in: Add checks for vasprintf, localtime_r. * gdate.c (g_date_set_time): Use localtime if localtime_r is not available. * gstrfuncs.c (g_strdup_vprintf): Use glibc vasprintf if possible; it's a bit faster than using GLib routines, and makes output code a bit smaller. * acconfig.h: Remove HAVE_VSNPRINTF and HAVE_VPRINTF. autoheader picks these up automatically and puts them in config.h.in. --- diff --git a/ChangeLog b/ChangeLog index 15866953..2e97a6f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Sat Jan 9 13:53:00 1999 Jeff Garzik + + * configure.in: + Add checks for vasprintf, localtime_r. + + * gdate.c (g_date_set_time): + Use localtime if localtime_r is not available. + + * gstrfuncs.c (g_strdup_vprintf): + Use glibc vasprintf if possible; it's a bit faster than using + GLib routines, and makes output code a bit smaller. + + * acconfig.h: + Remove HAVE_VSNPRINTF and HAVE_VPRINTF. autoheader picks these + up automatically and puts them in config.h.in. + Thu Jan 7 15:14:08 1999 Owen Taylor * gmain.c (g_source_free_func): Call the source-specific diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 15866953..2e97a6f4 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,19 @@ +Sat Jan 9 13:53:00 1999 Jeff Garzik + + * configure.in: + Add checks for vasprintf, localtime_r. + + * gdate.c (g_date_set_time): + Use localtime if localtime_r is not available. + + * gstrfuncs.c (g_strdup_vprintf): + Use glibc vasprintf if possible; it's a bit faster than using + GLib routines, and makes output code a bit smaller. + + * acconfig.h: + Remove HAVE_VSNPRINTF and HAVE_VPRINTF. autoheader picks these + up automatically and puts them in config.h.in. + Thu Jan 7 15:14:08 1999 Owen Taylor * gmain.c (g_source_free_func): Call the source-specific diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 15866953..2e97a6f4 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,19 @@ +Sat Jan 9 13:53:00 1999 Jeff Garzik + + * configure.in: + Add checks for vasprintf, localtime_r. + + * gdate.c (g_date_set_time): + Use localtime if localtime_r is not available. + + * gstrfuncs.c (g_strdup_vprintf): + Use glibc vasprintf if possible; it's a bit faster than using + GLib routines, and makes output code a bit smaller. + + * acconfig.h: + Remove HAVE_VSNPRINTF and HAVE_VPRINTF. autoheader picks these + up automatically and puts them in config.h.in. + Thu Jan 7 15:14:08 1999 Owen Taylor * gmain.c (g_source_free_func): Call the source-specific diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 15866953..2e97a6f4 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,19 @@ +Sat Jan 9 13:53:00 1999 Jeff Garzik + + * configure.in: + Add checks for vasprintf, localtime_r. + + * gdate.c (g_date_set_time): + Use localtime if localtime_r is not available. + + * gstrfuncs.c (g_strdup_vprintf): + Use glibc vasprintf if possible; it's a bit faster than using + GLib routines, and makes output code a bit smaller. + + * acconfig.h: + Remove HAVE_VSNPRINTF and HAVE_VPRINTF. autoheader picks these + up automatically and puts them in config.h.in. + Thu Jan 7 15:14:08 1999 Owen Taylor * gmain.c (g_source_free_func): Call the source-specific diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 15866953..2e97a6f4 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,19 @@ +Sat Jan 9 13:53:00 1999 Jeff Garzik + + * configure.in: + Add checks for vasprintf, localtime_r. + + * gdate.c (g_date_set_time): + Use localtime if localtime_r is not available. + + * gstrfuncs.c (g_strdup_vprintf): + Use glibc vasprintf if possible; it's a bit faster than using + GLib routines, and makes output code a bit smaller. + + * acconfig.h: + Remove HAVE_VSNPRINTF and HAVE_VPRINTF. autoheader picks these + up automatically and puts them in config.h.in. + Thu Jan 7 15:14:08 1999 Owen Taylor * gmain.c (g_source_free_func): Call the source-specific diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 15866953..2e97a6f4 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,19 @@ +Sat Jan 9 13:53:00 1999 Jeff Garzik + + * configure.in: + Add checks for vasprintf, localtime_r. + + * gdate.c (g_date_set_time): + Use localtime if localtime_r is not available. + + * gstrfuncs.c (g_strdup_vprintf): + Use glibc vasprintf if possible; it's a bit faster than using + GLib routines, and makes output code a bit smaller. + + * acconfig.h: + Remove HAVE_VSNPRINTF and HAVE_VPRINTF. autoheader picks these + up automatically and puts them in config.h.in. + Thu Jan 7 15:14:08 1999 Owen Taylor * gmain.c (g_source_free_func): Call the source-specific diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 15866953..2e97a6f4 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,19 @@ +Sat Jan 9 13:53:00 1999 Jeff Garzik + + * configure.in: + Add checks for vasprintf, localtime_r. + + * gdate.c (g_date_set_time): + Use localtime if localtime_r is not available. + + * gstrfuncs.c (g_strdup_vprintf): + Use glibc vasprintf if possible; it's a bit faster than using + GLib routines, and makes output code a bit smaller. + + * acconfig.h: + Remove HAVE_VSNPRINTF and HAVE_VPRINTF. autoheader picks these + up automatically and puts them in config.h.in. + Thu Jan 7 15:14:08 1999 Owen Taylor * gmain.c (g_source_free_func): Call the source-specific diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 15866953..2e97a6f4 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,19 @@ +Sat Jan 9 13:53:00 1999 Jeff Garzik + + * configure.in: + Add checks for vasprintf, localtime_r. + + * gdate.c (g_date_set_time): + Use localtime if localtime_r is not available. + + * gstrfuncs.c (g_strdup_vprintf): + Use glibc vasprintf if possible; it's a bit faster than using + GLib routines, and makes output code a bit smaller. + + * acconfig.h: + Remove HAVE_VSNPRINTF and HAVE_VPRINTF. autoheader picks these + up automatically and puts them in config.h.in. + Thu Jan 7 15:14:08 1999 Owen Taylor * gmain.c (g_source_free_func): Call the source-specific diff --git a/acconfig.h b/acconfig.h index 48582cda..ae08a75d 100644 --- a/acconfig.h +++ b/acconfig.h @@ -58,9 +58,7 @@ #undef HAVE_STRERROR #undef HAVE_STRSIGNAL #undef HAVE_UNISTD_H -#undef HAVE_VSNPRINTF #undef HAVE_VALUES_H -#undef HAVE_VPRINTF #undef HAVE_WCHAR_H #undef HAVE_WCTYPE_H diff --git a/configure.in b/configure.in index b6b0ba11..67c3adcc 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(lstat strerror strsignal memmove vsnprintf strcasecmp strncasecmp poll) +AC_CHECK_FUNCS(localtime_r lstat strerror strsignal memmove vsnprintf vasprintf strcasecmp strncasecmp poll) # Check for sys_errlist AC_MSG_CHECKING(for sys_errlist) diff --git a/gdate.c b/gdate.c index 08b3b0b0..04d0a9a8 100644 --- a/gdate.c +++ b/gdate.c @@ -790,11 +790,16 @@ g_date_set_time (GDate *d, GTime time) { time_t t = time; - struct tm tm; + struct tm tm, *ptm; g_return_if_fail (d != NULL); +#if HAVE_LOCALTIME_R localtime_r (&t, &tm); +#else + ptm = localtime (&t); + memcpy((void *) &tm, (void *) ptm, sizeof(struct tm)); +#endif d->julian = FALSE; diff --git a/glib/gdate.c b/glib/gdate.c index 08b3b0b0..04d0a9a8 100644 --- a/glib/gdate.c +++ b/glib/gdate.c @@ -790,11 +790,16 @@ g_date_set_time (GDate *d, GTime time) { time_t t = time; - struct tm tm; + struct tm tm, *ptm; g_return_if_fail (d != NULL); +#if HAVE_LOCALTIME_R localtime_r (&t, &tm); +#else + ptm = localtime (&t); + memcpy((void *) &tm, (void *) ptm, sizeof(struct tm)); +#endif d->julian = FALSE; diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c index e154c56d..6e58ad5e 100644 --- a/glib/gstrfuncs.c +++ b/glib/gstrfuncs.c @@ -108,6 +108,15 @@ g_strdup_vprintf (const gchar *format, va_list args1) { gchar *buffer; + +#if (HAVE_VASPRINTF) && !(ENABLE_MEM_CHECK) + /* if memory checking is disabled, that means we can call g_free() on + * memory obtained via malloc(). This allows us to use the + * glibc vasprintf() call where available. + */ + vasprintf (&buffer, format, args1); +#else + va_list args2; G_VA_COPY (args2, args1); @@ -117,6 +126,8 @@ g_strdup_vprintf (const gchar *format, vsprintf (buffer, format, args2); va_end (args2); +#endif /* (HAVE_VASPRINTF) && !(ENABLE_MEM_CHECK) */ + return buffer; } diff --git a/gstrfuncs.c b/gstrfuncs.c index e154c56d..6e58ad5e 100644 --- a/gstrfuncs.c +++ b/gstrfuncs.c @@ -108,6 +108,15 @@ g_strdup_vprintf (const gchar *format, va_list args1) { gchar *buffer; + +#if (HAVE_VASPRINTF) && !(ENABLE_MEM_CHECK) + /* if memory checking is disabled, that means we can call g_free() on + * memory obtained via malloc(). This allows us to use the + * glibc vasprintf() call where available. + */ + vasprintf (&buffer, format, args1); +#else + va_list args2; G_VA_COPY (args2, args1); @@ -117,6 +126,8 @@ g_strdup_vprintf (const gchar *format, vsprintf (buffer, format, args2); va_end (args2); +#endif /* (HAVE_VASPRINTF) && !(ENABLE_MEM_CHECK) */ + return buffer; }