From 2b0e2ff142de992d943a0df1aca605283f3449ab Mon Sep 17 00:00:00 2001
From: z30010524 <zhangyunbo7@huawei.com>
Date: Thu, 16 Mar 2023 11:06:12 +0800
Subject: [PATCH 09/15] Fix localtime_r() not defined on windows

DTS/AR: DTS2023031516597
Summary: <JDK> :Fix localtime_r() not defined on windows, get system time by os::localtime_pd()
LLT: NA
Patch Type: huawei
Bug url: NA
---
 hotspot/src/share/vm/services/memReporter.cpp | 2 +-
 hotspot/src/share/vm/services/nmtDCmd.cpp     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hotspot/src/share/vm/services/memReporter.cpp b/hotspot/src/share/vm/services/memReporter.cpp
index 8ea363805..9fc309c74 100644
--- a/hotspot/src/share/vm/services/memReporter.cpp
+++ b/hotspot/src/share/vm/services/memReporter.cpp
@@ -298,7 +298,7 @@ void MemSummaryDiffReporter::report_diff() {
   time_t startTime = NMTDCmd::get_start_time();
   time_t endTime = time(0);
   struct tm endTimeTm = {0};
-  if (localtime_r(&endTime, &endTimeTm) == NULL) {
+  if (os::localtime_pd(&endTime, &endTimeTm) == NULL) {
     out->print_cr("\nNative Memory Tracking:\n");
   } else {
     out->print_cr("\nNative Memory Tracking: end time is %d-%02d-%02d %02d:%02d:%02d, elapsed time is %d secs\n",
diff --git a/hotspot/src/share/vm/services/nmtDCmd.cpp b/hotspot/src/share/vm/services/nmtDCmd.cpp
index 417a58c59..5f6842a99 100644
--- a/hotspot/src/share/vm/services/nmtDCmd.cpp
+++ b/hotspot/src/share/vm/services/nmtDCmd.cpp
@@ -132,7 +132,7 @@ void NMTDCmd::execute(DCmdSource source, TRAPS) {
       NMTDCmd::set_start_time(time(0));
       time_t startTime = NMTDCmd::get_start_time();
       struct tm startTimeTm = {0};
-      if (localtime_r(&startTime, &startTimeTm) == NULL) {
+      if (os::localtime_pd(&startTime, &startTimeTm) == NULL) {
         output()->print_cr("Baseline succeeded");
       } else {
         output()->print_cr("Baseline succeeded, start time is %d-%02d-%02d %02d:%02d:%02d",
-- 
2.19.0

