From 490c23bd7e8e4112c0349c34aa212efe88391003 Mon Sep 17 00:00:00 2001 From: Ingo Albrecht Date: Sat, 5 Jan 2013 02:50:12 +0100 Subject: [PATCH] Use localtime_r instead of localtime localtime is not reentrant. --- sources/system/unix-date-interface.dylan | 2 +- sources/system/unix-portability.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sources/system/unix-date-interface.dylan b/sources/system/unix-date-interface.dylan index 6ecefeb146..b0ff367a7c 100644 --- a/sources/system/unix-date-interface.dylan +++ b/sources/system/unix-date-interface.dylan @@ -109,7 +109,7 @@ define method native-clock-to-tm (time :: ) => (tm :: ) => (tm :: ) (primitive-cast-raw-as-pointer(primitive-unwrap-machine-word(timeloc))) end)); diff --git a/sources/system/unix-portability.c b/sources/system/unix-portability.c index 9cfda12bb9..d423d8c1f8 100644 --- a/sources/system/unix-portability.c +++ b/sources/system/unix-portability.c @@ -2,6 +2,7 @@ #include #include #include +#include #ifdef __APPLE__ #include @@ -15,6 +16,12 @@ char **system_environ(void) return environ; } +struct tm *system_localtime(const time_t *timep) +{ + struct tm *res = GC_malloc(sizeof(struct tm)); + return localtime_r(timep, res); +} + /* Adapted from the SBCL run-time system, which in turn is derived * from the CMU CL system, which was written at Carnegie Mellon * University and released into the public domain.