From bacb1fe37333fd4e32310a9bd57e20d624e2f994 Mon Sep 17 00:00:00 2001 From: jb Date: Thu, 24 Feb 2011 21:51:39 +0000 Subject: PR 47802 Use strftime for CTIME and FDATE intrinsics git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170478 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/intrinsics/time_1.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libgfortran/intrinsics/time_1.h') diff --git a/libgfortran/intrinsics/time_1.h b/libgfortran/intrinsics/time_1.h index 073595a1442..12d79ebc12f 100644 --- a/libgfortran/intrinsics/time_1.h +++ b/libgfortran/intrinsics/time_1.h @@ -84,6 +84,26 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif /* !HAVE_GETRUSAGE || !HAVE_SYS_RESOURCE_H */ +/* If the re-entrant version of localtime is not available, provide a + fallback implementation. On some targets where the _r version is + not available, localtime uses thread-local storage so it's + threadsafe. */ + +#ifndef HAVE_LOCALTIME_R +/* If _POSIX is defined localtime_r gets defined by mingw-w64 headers. */ +#ifdef localtime_r +#undef localtime_r +#endif + +static inline struct tm * +localtime_r (const time_t * timep, struct tm * result) +{ + *result = *localtime (timep); + return result; +} +#endif + + #if defined (__GNUC__) && (__GNUC__ >= 3) # define ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) #else -- cgit v1.2.1