summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWan-Teh Chang <wtc@google.com>2016-11-14 13:54:40 -0800
committerWan-Teh Chang <wtc@google.com>2016-11-14 13:54:40 -0800
commitf49e0a03447010e0d8d0374a8a628457e2e671d2 (patch)
tree963112e3b87e7679ea8d479b5e2168f49016f679
parent8df2829245601dbe20e4fcfbf67e419e1c5d4962 (diff)
downloadnspr-hg-f49e0a03447010e0d8d0374a8a628457e2e671d2.tar.gz
Modernize MT_safe_localtime. r=kaie.
Define HAVE_POINTER_LOCALTIME_R for Linux and Mac OS X. Add a definition of MT_safe_localtime() based on localtime_s() for Visual C++.
-rwxr-xr-xconfigure4
-rw-r--r--configure.in2
-rw-r--r--pr/src/misc/prtime.c14
3 files changed, 20 insertions, 0 deletions
diff --git a/configure b/configure
index fbd3b574..eba7da6e 100755
--- a/configure
+++ b/configure
@@ -6524,6 +6524,8 @@ fi
$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h
+ $as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
+
AS='$(CC) -x assembler-with-cpp'
CFLAGS="$CFLAGS -Wall -fno-common"
case "${target_cpu}" in
@@ -6975,6 +6977,8 @@ tools are selected during the Xcode/Developer Tools installation." "$LINENO" 5
$as_echo "#define HAVE_FCNTL_FILE_LOCKING 1" >>confdefs.h
+ $as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
+
case "${target}" in
*-android*|*-linuxandroid*)
OS_TARGET=Android
diff --git a/configure.in b/configure.in
index bc5cd3d9..4aa605ab 100644
--- a/configure.in
+++ b/configure.in
@@ -1349,6 +1349,7 @@ case "$target" in
AC_DEFINE(DARWIN)
AC_DEFINE(HAVE_BSD_FLOCK)
AC_DEFINE(HAVE_SOCKLEN_T)
+ AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
AS='$(CC) -x assembler-with-cpp'
CFLAGS="$CFLAGS -Wall -fno-common"
case "${target_cpu}" in
@@ -1789,6 +1790,7 @@ tools are selected during the Xcode/Developer Tools installation.])
AC_DEFINE(XP_UNIX)
AC_DEFINE(_GNU_SOURCE)
AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
+ AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
case "${target}" in
*-android*|*-linuxandroid*)
OS_TARGET=Android
diff --git a/pr/src/misc/prtime.c b/pr/src/misc/prtime.c
index 6735805d..39294114 100644
--- a/pr/src/misc/prtime.c
+++ b/pr/src/misc/prtime.c
@@ -495,6 +495,20 @@ PR_NormalizeTime(PRExplodedTime *time, PRTimeParamFn params)
#define MT_safe_localtime localtime_r
+#elif defined(_MSC_VER)
+
+/* Visual C++ has had localtime_s() since Visual C++ 2005. */
+
+static struct tm *MT_safe_localtime(const time_t *clock, struct tm *result)
+{
+ errno_t err = localtime_s(result, clock);
+ if (err != 0) {
+ errno = err;
+ return NULL;
+ }
+ return result;
+}
+
#else
#define HAVE_LOCALTIME_MONITOR 1 /* We use 'monitor' to serialize our calls