diff --git a/configure.ac b/configure.ac index ab5af3bd..138eb87e 100644 --- a/configure.ac +++ b/configure.ac @@ -208,8 +208,22 @@ GP_GETTEXT_FLAGS() dnl --------------------------------------------------------------------------- dnl Thread-safe functions dnl --------------------------------------------------------------------------- +AC_MSG_CHECKING([for localtime_s]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #include +]], [[ + localtime_s(NULL, NULL); +]])], [dnl + have_localtime_s="yes" + AC_DEFINE([HAVE_LOCALTIME_S], [1], [Define to 1 if you have localtime_s()]) +], [dnl + have_localtime_s="no" +]) +AC_MSG_RESULT([$have_localtime_s]) + AC_CHECK_FUNCS([localtime_r]) + dnl --------------------------------------------------------------------------- dnl Compiler/Linker Options and Warnings dnl --------------------------------------------------------------------------- diff --git a/libexif/exif-entry.c b/libexif/exif-entry.c index d08b2dbb..89744f34 100644 --- a/libexif/exif-entry.c +++ b/libexif/exif-entry.c @@ -1641,7 +1641,7 @@ exif_entry_initialize (ExifEntry *e, ExifTag tag) case EXIF_TAG_DATE_TIME_DIGITIZED: { time_t t; -#ifdef HAVE_LOCALTIME_R +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tms; #endif struct tm *tm; @@ -1649,6 +1649,9 @@ exif_entry_initialize (ExifEntry *e, ExifTag tag) t = time (NULL); #ifdef HAVE_LOCALTIME_R tm = localtime_r (&t, &tms); +#elif HAVE_LOCALTIME_S + localtime_s (&tms, &t); + tm = &tms; #else tm = localtime (&t); #endif