Skip to content

Commit 3c88cd5

Browse files
Remove GetSystemTime/GetSystemTimeAsFileTime from PAL (#119543)
* Implement GetSystemTimeAsFileTime in minipal * Cleanup FILETIME manipulation routines * Update unnecessary usages of GetSystemTime * Remove GetSystemTime * Simplify logging format Co-authored-by: Michał Petryka <[email protected]>
1 parent ce6fab1 commit 3c88cd5

File tree

28 files changed

+105
-755
lines changed

28 files changed

+105
-755
lines changed

src/coreclr/dlls/mscordac/mscordac_unixexports.src

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ nativeStringResourceTable_mscorrc
7979
#FormatMessageW
8080
#FreeEnvironmentStringsW
8181
#FreeLibrary
82-
#FileTimeToSystemTime
8382
#GetCurrentProcess
8483
#GetCurrentProcessId
8584
#GetCurrentThreadId
@@ -93,8 +92,6 @@ nativeStringResourceTable_mscorrc
9392
#GetProcAddress
9493
#GetStdHandle
9594
#GetSystemInfo
96-
#GetSystemTime
97-
#GetSystemTimeAsFileTime
9895
#GetTempPathA
9996
#GetTempPathW
10097
#LoadLibraryExA

src/coreclr/inc/stresslog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class StressLog {
227227
CRITSEC_COOKIE lock; // lock
228228
uint64_t tickFrequency; // number of ticks per second
229229
uint64_t startTimeStamp; // start time from when tick counter started
230-
FILETIME startTime; // time the application started
230+
uint64_t startTime; // time the application started in Windows FILETIME precision (100ns since 01 Jan 1601)
231231
SIZE_T moduleOffset; // Used to compute format strings.
232232
struct ModuleDesc
233233
{

src/coreclr/jit/compiler.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,6 @@ const BYTE genActualTypes[] = {
132132
};
133133

134134
#endif // FEATURE_JIT_METHOD_PERF
135-
/*****************************************************************************/
136-
inline unsigned getCurTime()
137-
{
138-
SYSTEMTIME tim;
139-
140-
GetSystemTime(&tim);
141-
142-
return (((tim.wHour * 60) + tim.wMinute) * 60 + tim.wSecond) * 1000 + tim.wMilliseconds;
143-
}
144135

145136
/*****************************************************************************/
146137
#ifdef DEBUG

src/coreclr/nativeaot/Runtime/Pal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,6 @@ UInt32_BOOL PalResetEvent(HANDLE arg1);
303303
UInt32_BOOL PalSetEvent(HANDLE arg1);
304304
uint32_t PalWaitForSingleObjectEx(HANDLE arg1, uint32_t arg2, UInt32_BOOL arg3);
305305

306-
void PalGetSystemTimeAsFileTime(FILETIME * arg1);
307-
308306
void RuntimeThreadShutdown(void* thread);
309307

310308
typedef void (*ThreadExitCallback)();

src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,7 @@ int64_t
519519
ep_rt_aot_system_timestamp_get (void)
520520
{
521521
STATIC_CONTRACT_NOTHROW;
522-
523-
FILETIME value;
524-
PalGetSystemTimeAsFileTime (&value);
525-
return static_cast<int64_t>(((static_cast<uint64_t>(value.dwHighDateTime)) << 32) | static_cast<uint64_t>(value.dwLowDateTime));
522+
return minipal_get_system_time();
526523
}
527524

528525
int32_t

src/coreclr/nativeaot/Runtime/inc/stressLog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class StressLog {
236236
CrstStatic *pLock; // lock
237237
uint64_t tickFrequency; // number of ticks per second
238238
uint64_t startTimeStamp; // start time from when tick counter started
239-
FILETIME startTime; // time the application started
239+
uint64_t startTime; // time the application started in Windows FILETIME precision (100ns since 01 Jan 1601)
240240
size_t moduleOffset; // Used to compute format strings.
241241

242242
#ifndef DACCESS_COMPILE

src/coreclr/nativeaot/Runtime/stressLog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void StressLog::Initialize(unsigned facilities, unsigned level, unsigned maxByt
118118

119119
theLog.tickFrequency = getTickFrequency();
120120

121-
PalGetSystemTimeAsFileTime (&theLog.startTime);
121+
theLog.startTime = minipal_get_system_time();
122122
theLog.startTimeStamp = getTimeStamp();
123123

124124
theLog.moduleOffset = (size_t)hMod; // HMODULES are base addresses.

src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,21 +1234,6 @@ int32_t PalGetModuleFileName(_Out_ const TCHAR** pModuleNameOut, HANDLE moduleBa
12341234
#endif // defined(HOST_WASM)
12351235
}
12361236

1237-
static const int64_t SECS_BETWEEN_1601_AND_1970_EPOCHS = 11644473600LL;
1238-
static const int64_t SECS_TO_100NS = 10000000; /* 10^7 */
1239-
1240-
void PalGetSystemTimeAsFileTime(FILETIME *lpSystemTimeAsFileTime)
1241-
{
1242-
struct timeval time = { 0 };
1243-
gettimeofday(&time, NULL);
1244-
1245-
int64_t result = ((int64_t)time.tv_sec + SECS_BETWEEN_1601_AND_1970_EPOCHS) * SECS_TO_100NS +
1246-
(time.tv_usec * 10);
1247-
1248-
lpSystemTimeAsFileTime->dwLowDateTime = (uint32_t)result;
1249-
lpSystemTimeAsFileTime->dwHighDateTime = (uint32_t)(result >> 32);
1250-
}
1251-
12521237
uint64_t PalGetCurrentOSThreadId()
12531238
{
12541239
return (uint64_t)minipal_get_current_thread_id();

src/coreclr/nativeaot/Runtime/windows/PalMinWin.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,3 @@ uint32_t PalWaitForSingleObjectEx(HANDLE arg1, uint32_t arg2, UInt32_BOOL arg3)
10631063
{
10641064
return ::WaitForSingleObjectEx(arg1, arg2, arg3);
10651065
}
1066-
1067-
void PalGetSystemTimeAsFileTime(FILETIME * arg1)
1068-
{
1069-
::GetSystemTimeAsFileTime(arg1);
1070-
}

src/coreclr/pal/inc/pal.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -548,38 +548,6 @@ PALAPI GetFileSizeEx(
548548
IN HANDLE hFile,
549549
OUT PLARGE_INTEGER lpFileSize);
550550

551-
PALIMPORT
552-
VOID
553-
PALAPI
554-
GetSystemTimeAsFileTime(
555-
OUT LPFILETIME lpSystemTimeAsFileTime);
556-
557-
typedef struct _SYSTEMTIME {
558-
WORD wYear;
559-
WORD wMonth;
560-
WORD wDayOfWeek;
561-
WORD wDay;
562-
WORD wHour;
563-
WORD wMinute;
564-
WORD wSecond;
565-
WORD wMilliseconds;
566-
} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
567-
568-
PALIMPORT
569-
VOID
570-
PALAPI
571-
GetSystemTime(
572-
OUT LPSYSTEMTIME lpSystemTime);
573-
574-
PALIMPORT
575-
BOOL
576-
PALAPI
577-
FileTimeToSystemTime(
578-
IN CONST FILETIME *lpFileTime,
579-
OUT LPSYSTEMTIME lpSystemTime);
580-
581-
582-
583551
PALIMPORT
584552
BOOL
585553
PALAPI

0 commit comments

Comments
 (0)