summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac3
-rw-r--r--src/cmsio0.c19
2 files changed, 21 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index eec188b..5e49b35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,9 @@ AX_APPEND_COMPILE_FLAGS(["-fvisibility=hidden"])
# Motorola and SPARC CPUs), define `WORDS_BIGENDIAN'.
AC_C_BIGENDIAN
+# Check for functions that some compilers lack (or name differently)
+AC_CHECK_FUNCS([gmtime_r _gmtime64_s])
+
# Point to JPEG installed in DIR or disable JPEG with --without-jpeg.
AC_ARG_WITH(jpeg,
AS_HELP_STRING([--with-jpeg=DIR],[use jpeg installed in DIR]),
diff --git a/src/cmsio0.c b/src/cmsio0.c
index 19ccbeb..8dafe57 100644
--- a/src/cmsio0.c
+++ b/src/cmsio0.c
@@ -488,6 +488,10 @@ cmsIOHANDLER* CMSEXPORT cmsGetProfileIOhandler(cmsHPROFILE hProfile)
// Creates an empty structure holding all required parameters
cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID)
{
+ struct tm *t;
+#if defined(HAVE_GMTIME_R) || defined(HAVE__GMTIME64_S)
+ struct tm tm;
+#endif
time_t now = time(NULL);
_cmsICCPROFILE* Icc = (_cmsICCPROFILE*) _cmsMallocZero(ContextID, sizeof(_cmsICCPROFILE));
if (Icc == NULL) return NULL;
@@ -500,14 +504,27 @@ cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID)
// Set default version
Icc ->Version = 0x02100000;
+#ifdef HAVE_GMTIME_R
+ t = gmtime_r(&now, &tm);
+#elif defined(HAVE__GMTIME64_S)
+ t = _gmtime64_s(&tm, &now) == 0 ? &tm : NULL;
+#else
+ t = gmtime(&now);
+#endif
+ if (t == NULL) goto Error;
+
// Set creation date/time
- memmove(&Icc ->Created, gmtime(&now), sizeof(Icc ->Created));
+ memmove(&Icc ->Created, t, sizeof(Icc ->Created));
// Create a mutex if the user provided proper plugin. NULL otherwise
Icc ->UsrMutex = _cmsCreateMutex(ContextID);
// Return the handle
return (cmsHPROFILE) Icc;
+
+Error:
+ _cmsFree(ContextID, Icc);
+ return NULL;
}
cmsContext CMSEXPORT cmsGetProfileContextID(cmsHPROFILE hProfile)