From 800bd423e4e0e423249fcb0545edaf5f8c9b8a92 Mon Sep 17 00:00:00 2001 From: NeroBurner Date: Fri, 1 Jun 2018 10:14:20 +0200 Subject: [PATCH] port: split localtime_r definition and impl --- src/windows/port.cc | 6 ++++++ src/windows/port.h | 7 ++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/windows/port.cc b/src/windows/port.cc index d994325..aa8dcd8 100755 --- a/src/windows/port.cc +++ b/src/windows/port.cc @@ -55,6 +55,12 @@ int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) { return _vsnprintf(str, size-1, format, ap); } +#ifndef HAVE_LOCALTIME_R +struct tm* localtime_r(const time_t* timep, struct tm* result) { + localtime_s(result, timep); + return result; +} +#endif // not HAVE_LOCALTIME_R #ifndef HAVE_SNPRINTF int snprintf(char *str, size_t size, const char *format, ...) { va_list ap; diff --git a/src/windows/port.h b/src/windows/port.h index c7895dd..56b172b 100755 --- a/src/windows/port.h +++ b/src/windows/port.h @@ -148,11 +148,8 @@ enum { PTHREAD_ONCE_INIT = 0 }; // important that this be 0! for SpinLock #endif // HAVE_PTHREAD #ifndef HAVE_LOCALTIME_R -inline struct tm* localtime_r(const time_t* timep, struct tm* result) { - localtime_s(result, timep); - return result; -} -#endif +extern struct tm* GOOGLE_GLOG_DLL_DECL localtime_r(const time_t* timep, struct tm* result); +#endif // not HAVE_LOCALTIME_R inline char* strerror_r(int errnum, char* buf, size_t buflen) { strerror_s(buf, buflen, errnum);