diff options
author | 2023-06-30 10:23:39 -0700 | |
---|---|---|
committer | 2023-06-30 19:09:08 +0000 | |
commit | f323832d7e0dca7756fca88fab9608ed9aeb1fa8 (patch) | |
tree | b79b90de99b07bda1e4cc05482ca7fdc9a4f307a /libartbase/base/time_utils.cc | |
parent | acc70d3d37fdf314b6ad157aafd9f79cd8e0fb62 (diff) |
Use mingw localtime_r().
It's annoyingly opt-in, but I'd argue that's less annoying than #if...
Test: treehugger
Change-Id: Ic9b3f11a48193da725f15deee9e45285035961b8
Diffstat (limited to 'libartbase/base/time_utils.cc')
-rw-r--r-- | libartbase/base/time_utils.cc | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/libartbase/base/time_utils.cc b/libartbase/base/time_utils.cc index aeb7fa21a5..b26e0ef1b1 100644 --- a/libartbase/base/time_utils.cc +++ b/libartbase/base/time_utils.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#define _POSIX_THREAD_SAFE_FUNCTIONS // For mingw localtime_r(). + #include "time_utils.h" #include <inttypes.h> @@ -133,11 +135,6 @@ std::string FormatDuration(uint64_t nano_duration, TimeUnit time_unit, std::string GetIsoDate() { tm tmbuf; int ns; -#ifdef _WIN32 - time_t now = time(nullptr); - localtime_s(&tmbuf, &now); - ns = 0; -#else if (__builtin_available(macOS 10.12, *)) { timespec now; clock_gettime(CLOCK_REALTIME, &now); @@ -148,7 +145,6 @@ std::string GetIsoDate() { localtime_r(&now, &tmbuf); ns = 0; } -#endif char zone[16] = {}; strftime(zone, sizeof(zone), "%z", &tmbuf); return StringPrintf("%04d-%02d-%02d %02d:%02d:%02d.%09d%s", |