diff --git a/src/coreclr/dlls/mscordac/mscordac_unixexports.src b/src/coreclr/dlls/mscordac/mscordac_unixexports.src index 0b53a46fbb72a6..8e613dd0a3a05a 100644 --- a/src/coreclr/dlls/mscordac/mscordac_unixexports.src +++ b/src/coreclr/dlls/mscordac/mscordac_unixexports.src @@ -79,7 +79,6 @@ nativeStringResourceTable_mscorrc #FormatMessageW #FreeEnvironmentStringsW #FreeLibrary -#FileTimeToSystemTime #GetCurrentProcess #GetCurrentProcessId #GetCurrentThreadId @@ -93,8 +92,6 @@ nativeStringResourceTable_mscorrc #GetProcAddress #GetStdHandle #GetSystemInfo -#GetSystemTime -#GetSystemTimeAsFileTime #GetTempPathA #GetTempPathW #LoadLibraryExA diff --git a/src/coreclr/inc/stresslog.h b/src/coreclr/inc/stresslog.h index 0aa2f7a5238edb..f93a2cde304a7a 100644 --- a/src/coreclr/inc/stresslog.h +++ b/src/coreclr/inc/stresslog.h @@ -227,7 +227,7 @@ class StressLog { CRITSEC_COOKIE lock; // lock uint64_t tickFrequency; // number of ticks per second uint64_t startTimeStamp; // start time from when tick counter started - FILETIME startTime; // time the application started + uint64_t startTime; // time the application started in Windows FILETIME precision (100ns since 01 Jan 1601) SIZE_T moduleOffset; // Used to compute format strings. struct ModuleDesc { diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 494675bec694a8..56d527f3bbc00e 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -132,15 +132,6 @@ const BYTE genActualTypes[] = { }; #endif // FEATURE_JIT_METHOD_PERF -/*****************************************************************************/ -inline unsigned getCurTime() -{ - SYSTEMTIME tim; - - GetSystemTime(&tim); - - return (((tim.wHour * 60) + tim.wMinute) * 60 + tim.wSecond) * 1000 + tim.wMilliseconds; -} /*****************************************************************************/ #ifdef DEBUG diff --git a/src/coreclr/nativeaot/Runtime/Pal.h b/src/coreclr/nativeaot/Runtime/Pal.h index 0a9f9c2ea45599..b33da9157650d6 100644 --- a/src/coreclr/nativeaot/Runtime/Pal.h +++ b/src/coreclr/nativeaot/Runtime/Pal.h @@ -303,8 +303,6 @@ UInt32_BOOL PalResetEvent(HANDLE arg1); UInt32_BOOL PalSetEvent(HANDLE arg1); uint32_t PalWaitForSingleObjectEx(HANDLE arg1, uint32_t arg2, UInt32_BOOL arg3); -void PalGetSystemTimeAsFileTime(FILETIME * arg1); - void RuntimeThreadShutdown(void* thread); typedef void (*ThreadExitCallback)(); diff --git a/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.cpp b/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.cpp index 5d5e539e0c1b90..ec4c1031d4fe47 100644 --- a/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.cpp +++ b/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.cpp @@ -519,10 +519,7 @@ int64_t ep_rt_aot_system_timestamp_get (void) { STATIC_CONTRACT_NOTHROW; - - FILETIME value; - PalGetSystemTimeAsFileTime (&value); - return static_cast(((static_cast(value.dwHighDateTime)) << 32) | static_cast(value.dwLowDateTime)); + return minipal_get_system_time(); } int32_t diff --git a/src/coreclr/nativeaot/Runtime/inc/stressLog.h b/src/coreclr/nativeaot/Runtime/inc/stressLog.h index d3184d7056fb19..17bf5fbfee1b20 100644 --- a/src/coreclr/nativeaot/Runtime/inc/stressLog.h +++ b/src/coreclr/nativeaot/Runtime/inc/stressLog.h @@ -236,7 +236,7 @@ class StressLog { CrstStatic *pLock; // lock uint64_t tickFrequency; // number of ticks per second uint64_t startTimeStamp; // start time from when tick counter started - FILETIME startTime; // time the application started + uint64_t startTime; // time the application started in Windows FILETIME precision (100ns since 01 Jan 1601) size_t moduleOffset; // Used to compute format strings. #ifndef DACCESS_COMPILE diff --git a/src/coreclr/nativeaot/Runtime/stressLog.cpp b/src/coreclr/nativeaot/Runtime/stressLog.cpp index 9253a9eb0e8709..e3a5f8d8efe6f6 100644 --- a/src/coreclr/nativeaot/Runtime/stressLog.cpp +++ b/src/coreclr/nativeaot/Runtime/stressLog.cpp @@ -118,7 +118,7 @@ void StressLog::Initialize(unsigned facilities, unsigned level, unsigned maxByt theLog.tickFrequency = getTickFrequency(); - PalGetSystemTimeAsFileTime (&theLog.startTime); + theLog.startTime = minipal_get_system_time(); theLog.startTimeStamp = getTimeStamp(); theLog.moduleOffset = (size_t)hMod; // HMODULES are base addresses. diff --git a/src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp b/src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp index 8cb78884a37d0a..873ae69c28ddf5 100644 --- a/src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp +++ b/src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp @@ -1234,21 +1234,6 @@ int32_t PalGetModuleFileName(_Out_ const TCHAR** pModuleNameOut, HANDLE moduleBa #endif // defined(HOST_WASM) } -static const int64_t SECS_BETWEEN_1601_AND_1970_EPOCHS = 11644473600LL; -static const int64_t SECS_TO_100NS = 10000000; /* 10^7 */ - -void PalGetSystemTimeAsFileTime(FILETIME *lpSystemTimeAsFileTime) -{ - struct timeval time = { 0 }; - gettimeofday(&time, NULL); - - int64_t result = ((int64_t)time.tv_sec + SECS_BETWEEN_1601_AND_1970_EPOCHS) * SECS_TO_100NS + - (time.tv_usec * 10); - - lpSystemTimeAsFileTime->dwLowDateTime = (uint32_t)result; - lpSystemTimeAsFileTime->dwHighDateTime = (uint32_t)(result >> 32); -} - uint64_t PalGetCurrentOSThreadId() { return (uint64_t)minipal_get_current_thread_id(); diff --git a/src/coreclr/nativeaot/Runtime/windows/PalMinWin.cpp b/src/coreclr/nativeaot/Runtime/windows/PalMinWin.cpp index a8cad826d4c82e..e311a2bb02d1ec 100644 --- a/src/coreclr/nativeaot/Runtime/windows/PalMinWin.cpp +++ b/src/coreclr/nativeaot/Runtime/windows/PalMinWin.cpp @@ -1063,8 +1063,3 @@ uint32_t PalWaitForSingleObjectEx(HANDLE arg1, uint32_t arg2, UInt32_BOOL arg3) { return ::WaitForSingleObjectEx(arg1, arg2, arg3); } - -void PalGetSystemTimeAsFileTime(FILETIME * arg1) -{ - ::GetSystemTimeAsFileTime(arg1); -} diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 6276b907f2ddfc..c3355e4323f78e 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -548,38 +548,6 @@ PALAPI GetFileSizeEx( IN HANDLE hFile, OUT PLARGE_INTEGER lpFileSize); -PALIMPORT -VOID -PALAPI -GetSystemTimeAsFileTime( - OUT LPFILETIME lpSystemTimeAsFileTime); - -typedef struct _SYSTEMTIME { - WORD wYear; - WORD wMonth; - WORD wDayOfWeek; - WORD wDay; - WORD wHour; - WORD wMinute; - WORD wSecond; - WORD wMilliseconds; -} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME; - -PALIMPORT -VOID -PALAPI -GetSystemTime( - OUT LPSYSTEMTIME lpSystemTime); - -PALIMPORT -BOOL -PALAPI -FileTimeToSystemTime( - IN CONST FILETIME *lpFileTime, - OUT LPSYSTEMTIME lpSystemTime); - - - PALIMPORT BOOL PALAPI diff --git a/src/coreclr/pal/inc/palprivate.h b/src/coreclr/pal/inc/palprivate.h index 17c5a045eff6ce..0fe566b7cc17d8 100644 --- a/src/coreclr/pal/inc/palprivate.h +++ b/src/coreclr/pal/inc/palprivate.h @@ -113,13 +113,6 @@ PALAPI RemoveDirectoryW( IN LPCWSTR lpPathName); -PALIMPORT -LONG -PALAPI -CompareFileTime( - IN CONST FILETIME *lpFileTime1, - IN CONST FILETIME *lpFileTime2); - #ifdef __cplusplus } #endif diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 1395013eb59601..ac17e9a6c885e9 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -152,7 +152,6 @@ set(SOURCES exception/signal.cpp file/directory.cpp file/file.cpp - file/filetime.cpp file/path.cpp handlemgr/handleapi.cpp handlemgr/handlemgr.cpp diff --git a/src/coreclr/pal/src/file/file.cpp b/src/coreclr/pal/src/file/file.cpp index 8d0cfa99f789d3..fab78b1299467b 100644 --- a/src/coreclr/pal/src/file/file.cpp +++ b/src/coreclr/pal/src/file/file.cpp @@ -22,7 +22,6 @@ SET_DEFAULT_DEBUG_CHANNEL(FILE); // some headers have code with asserts, so do t #include "pal/palinternal.h" #include "pal/file.h" -#include "pal/filetime.h" #include "pal/utils.h" #include diff --git a/src/coreclr/pal/src/file/filetime.cpp b/src/coreclr/pal/src/file/filetime.cpp deleted file mode 100644 index edff44949d6af8..00000000000000 --- a/src/coreclr/pal/src/file/filetime.cpp +++ /dev/null @@ -1,293 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*++ - - - -Module Name: - - filetime.cpp - -Abstract: - - Implementation of the file WIN API related to file time. - -Notes: - -One very important thing to note is that on BSD systems, the stat structure -stores nanoseconds for the time-related fields. This is implemented by -replacing the time_t fields st_atime, st_mtime, and st_ctime by timespec -structures, instead named st_atimespec, st_mtimespec, and st_ctimespec. - -However, if _POSIX_SOURCE is defined, the fields are time_t values and use -their POSIX names. For compatibility purposes, when _POSIX_SOURCE is NOT -defined, the time-related fields are defined in sys/stat.h as: - -#ifndef _POSIX_SOURCE -#define st_atime st_atimespec.tv_sec -#define st_mtime st_mtimespec.tv_sec -#define st_ctime st_ctimespec.tv_sec -#endif - -Furthermore, if _POSIX_SOURCE is defined, the structure still has -additional fields for nanoseconds, named st_atimensec, st_mtimensec, and -st_ctimensec. - -In the PAL, there is a configure check to see if the system supports -nanoseconds for the time-related fields. This source file also sets macros -so that STAT_ATIME_NSEC etc. will always refer to the appropriate field -if it exists, and are defined as 0 otherwise. - --- - -Also note that there is no analog to "creation time" on Linux systems. -Instead, we use the inode change time, which is set to the current time -whenever mtime changes or when chmod, chown, etc. syscalls modify the -file status; or mtime if older. Ideally we would use birthtime when -available. - - ---*/ - -#include "pal/corunix.hpp" -#include "pal/dbgmsg.h" -#include "pal/filetime.h" -#include "pal/thread.hpp" -#include "pal/file.hpp" - -#include -#include -#include -#include - -#if HAVE_SYS_TIME_H -#include -#endif // HAVE_SYS_TIME_H - -using namespace CorUnix; - -SET_DEFAULT_DEBUG_CHANNEL(FILE); - -// In safemath.h, Template SafeInt uses macro _ASSERTE, which need to use variable -// defdbgchan defined by SET_DEFAULT_DEBUG_CHANNEL. Therefore, the include statement -// should be placed after the SET_DEFAULT_DEBUG_CHANNEL(FILE) -#include - -/* Magic number explanation: - - To 1970: - Both epochs are Gregorian. 1970 - 1601 = 369. Assuming a leap - year every four years, 369 / 4 = 92. However, 1700, 1800, and 1900 - were NOT leap years, so 89 leap years, 280 non-leap years. - 89 * 366 + 280 * 365 = 134774 days between epochs. Of course - 60 * 60 * 24 = 86400 seconds per day, so 134774 * 86400 = - 11644473600 = SECS_BETWEEN_1601_AND_1970_EPOCHS. - - To 2001: - Again, both epochs are Gregorian. 2001 - 1601 = 400. Assuming a leap - year every four years, 400 / 4 = 100. However, 1700, 1800, and 1900 - were NOT leap years (2000 was because it was divisible by 400), so - 97 leap years, 303 non-leap years. - 97 * 366 + 303 * 365 = 146097 days between epochs. 146097 * 86400 = - 12622780800 = SECS_BETWEEN_1601_AND_2001_EPOCHS. - - This result is also confirmed in the MSDN documentation on how - to convert a time_t value to a win32 FILETIME. -*/ -static const int64_t SECS_BETWEEN_1601_AND_1970_EPOCHS = 11644473600LL; -static const int64_t SECS_TO_100NS = 10000000; /* 10^7 */ - -#ifdef __APPLE__ -static const int64_t SECS_BETWEEN_1601_AND_2001_EPOCHS = 12622780800LL; -#endif // __APPLE__ - -/*++ -Function: - CompareFileTime - -See MSDN doc. ---*/ -LONG -PALAPI -CompareFileTime( - IN CONST FILETIME *lpFileTime1, - IN CONST FILETIME *lpFileTime2) -{ - int64_t First; - int64_t Second; - - long Ret; - - PERF_ENTRY(CompareFileTime); - ENTRY("CompareFileTime(lpFileTime1=%p lpFileTime2=%p)\n", - lpFileTime1, lpFileTime2); - - First = ((int64_t)lpFileTime1->dwHighDateTime << 32) + - lpFileTime1->dwLowDateTime; - Second = ((int64_t)lpFileTime2->dwHighDateTime << 32) + - lpFileTime2->dwLowDateTime; - - if ( First < Second ) - { - Ret = -1; - } - else if ( First > Second ) - { - Ret = 1; - } - else - { - Ret = 0; - } - - LOGEXIT("CompareFileTime returns LONG %ld\n", Ret); - PERF_EXIT(CompareFileTime); - return Ret; -} - - -/*++ -Function: - GetSystemTimeAsFileTime - -See MSDN doc. ---*/ -VOID -PALAPI -GetSystemTimeAsFileTime( - OUT LPFILETIME lpSystemTimeAsFileTime) -{ - PERF_ENTRY(GetSystemTimeAsFileTime); - ENTRY("GetSystemTimeAsFileTime(lpSystemTimeAsFileTime=%p)\n", - lpSystemTimeAsFileTime); - -#if HAVE_WORKING_CLOCK_GETTIME - struct timespec Time; - if (clock_gettime(CLOCK_REALTIME, &Time) == 0) - { - *lpSystemTimeAsFileTime = FILEUnixTimeToFileTime( Time.tv_sec, Time.tv_nsec ); - } -#else - struct timeval Time; - if (gettimeofday(&Time, NULL) == 0) - { - /* use (tv_usec * 1000) because 2nd arg is in nanoseconds */ - *lpSystemTimeAsFileTime = FILEUnixTimeToFileTime( Time.tv_sec, Time.tv_usec * 1000); - } -#endif - else - { - /* no way to indicate failure, so set time to zero */ - ASSERT("clock_gettime or gettimeofday failed"); - *lpSystemTimeAsFileTime = FILEUnixTimeToFileTime( 0, 0 ); - } - - LOGEXIT("GetSystemTimeAsFileTime returns.\n"); - PERF_EXIT(GetSystemTimeAsFileTime); -} - - -/*++ -Function: - FILEUnixTimeToFileTime - -Convert a time_t value to a win32 FILETIME structure, as described in -MSDN documentation. time_t is the number of seconds elapsed since -00:00 01 January 1970 UTC (Unix epoch), while FILETIME represents a -64-bit number of 100-nanosecond intervals that have passed since 00:00 -01 January 1601 UTC (win32 epoch). ---*/ -FILETIME FILEUnixTimeToFileTime( time_t sec, long nsec ) -{ - int64_t Result; - FILETIME Ret; - - Result = ((int64_t)sec + SECS_BETWEEN_1601_AND_1970_EPOCHS) * SECS_TO_100NS + - (nsec / 100); - - Ret.dwLowDateTime = (DWORD)Result; - Ret.dwHighDateTime = (DWORD)(Result >> 32); - - TRACE("Unix time = [%ld.%09ld] converts to Win32 FILETIME = [%#x:%#x]\n", - sec, nsec, Ret.dwHighDateTime, Ret.dwLowDateTime); - - return Ret; -} - - -/** -Function - - FileTimeToSystemTime() - - Helper function for FileTimeToDosTime. - Converts the necessary file time attributes to system time, for - easier manipulation in FileTimeToDosTime. - ---*/ -BOOL PALAPI FileTimeToSystemTime( CONST FILETIME * lpFileTime, - LPSYSTEMTIME lpSystemTime ) -{ - UINT64 FileTime = 0; - time_t UnixFileTime = 0; - struct tm * UnixSystemTime = 0; - - /* Combine the file time. */ - FileTime = lpFileTime->dwHighDateTime; - FileTime <<= 32; - FileTime |= (UINT)lpFileTime->dwLowDateTime; - bool isSafe = ClrSafeInt::subtraction( - FileTime, - SECS_BETWEEN_1601_AND_1970_EPOCHS * SECS_TO_100NS, - FileTime); - - if (isSafe == true) - { -#if HAVE_GMTIME_R - struct tm timeBuf; -#endif /* HAVE_GMTIME_R */ - /* Convert file time to unix time. */ - if (((INT64)FileTime) < 0) - { - UnixFileTime = -1 - ( ( -FileTime - 1 ) / 10000000 ); - } - else - { - UnixFileTime = FileTime / 10000000; - } - - /* Convert unix file time to Unix System time. */ -#if HAVE_GMTIME_R - UnixSystemTime = gmtime_r( &UnixFileTime, &timeBuf ); -#else /* HAVE_GMTIME_R */ - UnixSystemTime = gmtime( &UnixFileTime ); -#endif /* HAVE_GMTIME_R */ - if (!UnixSystemTime) - { - ERROR( "gmtime failed.\n" ); - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - /* Convert unix system time to Windows system time. */ - lpSystemTime->wDay = (WORD)UnixSystemTime->tm_mday; - - /* Unix time counts January as a 0, under Windows it is 1*/ - lpSystemTime->wMonth = (WORD)UnixSystemTime->tm_mon + 1; - /* Unix time returns the year - 1900, Windows returns the current year*/ - lpSystemTime->wYear = (WORD)UnixSystemTime->tm_year + 1900; - - lpSystemTime->wSecond = (WORD)UnixSystemTime->tm_sec; - lpSystemTime->wMinute = (WORD)UnixSystemTime->tm_min; - lpSystemTime->wHour = (WORD)UnixSystemTime->tm_hour; - return TRUE; - } - else - { - ERROR( "The file time is to large.\n" ); - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } -} - diff --git a/src/coreclr/pal/src/include/pal/filetime.h b/src/coreclr/pal/src/include/pal/filetime.h deleted file mode 100644 index efbe99828d2312..00000000000000 --- a/src/coreclr/pal/src/include/pal/filetime.h +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*++ - - - -Module Name: - - include/pal/filetime.h - -Abstract: - - Header file for utility functions having to do with file times. - -Revision History: - - - ---*/ - -#ifndef _PAL_FILETIME_H_ -#define _PAL_FILETIME_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif // __cplusplus - -FILETIME FILEUnixTimeToFileTime( time_t sec, long nsec ); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif /* _PAL_FILE_H_ */ - - - - - - - - - - - diff --git a/src/coreclr/pal/src/misc/time.cpp b/src/coreclr/pal/src/misc/time.cpp index 22f0c83871ebb1..92def38ccd565f 100644 --- a/src/coreclr/pal/src/misc/time.cpp +++ b/src/coreclr/pal/src/misc/time.cpp @@ -30,94 +30,6 @@ using namespace CorUnix; SET_DEFAULT_DEBUG_CHANNEL(MISC); -/*++ -Function: - GetSystemTime - -The GetSystemTime function retrieves the current system date and -time. The system time is expressed in Coordinated Universal Time -(UTC). - -Parameters - -lpSystemTime - [out] Pointer to a SYSTEMTIME structure to receive the current system date and time. - -Return Values - -This function does not return a value. - ---*/ -VOID -PALAPI -GetSystemTime( - OUT LPSYSTEMTIME lpSystemTime) -{ - time_t tt; -#if HAVE_GMTIME_R - struct tm ut; -#endif /* HAVE_GMTIME_R */ - struct tm *utPtr; - struct timeval timeval; - int timeofday_retval; - - PERF_ENTRY(GetSystemTime); - ENTRY("GetSystemTime (lpSystemTime=%p)\n", lpSystemTime); - - tt = time(NULL); - - /* We can't get millisecond resolution from time(), so we get it from - gettimeofday() */ - timeofday_retval = gettimeofday(&timeval,NULL); - -#if HAVE_GMTIME_R - utPtr = &ut; - if (gmtime_r(&tt, utPtr) == NULL) -#else /* HAVE_GMTIME_R */ - if ((utPtr = gmtime(&tt)) == NULL) -#endif /* HAVE_GMTIME_R */ - { - ASSERT("gmtime() failed; errno is %d (%s)\n", errno, strerror(errno)); - goto EXIT; - } - - lpSystemTime->wYear = (WORD)(1900 + utPtr->tm_year); - lpSystemTime->wMonth = (WORD)(utPtr->tm_mon + 1); - lpSystemTime->wDayOfWeek = (WORD)utPtr->tm_wday; - lpSystemTime->wDay = (WORD)utPtr->tm_mday; - lpSystemTime->wHour = (WORD)utPtr->tm_hour; - lpSystemTime->wMinute = (WORD)utPtr->tm_min; - lpSystemTime->wSecond = (WORD)utPtr->tm_sec; - - if(-1 == timeofday_retval) - { - ASSERT("gettimeofday() failed; errno is %d (%s)\n", - errno, strerror(errno)); - lpSystemTime->wMilliseconds = 0; - } - else - { - int old_seconds; - int new_seconds; - - lpSystemTime->wMilliseconds = (WORD)(timeval.tv_usec/tccMilliSecondsToMicroSeconds); - - old_seconds = utPtr->tm_sec; - new_seconds = timeval.tv_sec%60; - - /* just in case we reached the next second in the interval between - time() and gettimeofday() */ - if( old_seconds!=new_seconds ) - { - TRACE("crossed seconds boundary; setting milliseconds to 999\n"); - lpSystemTime->wMilliseconds = 999; - } - } -EXIT: - LOGEXIT("GetSystemTime returns void\n"); - PERF_EXIT(GetSystemTime); -} - /*++ Function: QueryThreadCycleTime diff --git a/src/coreclr/pal/tests/palsuite/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/CMakeLists.txt index a6338791711233..c61121186f831c 100644 --- a/src/coreclr/pal/tests/palsuite/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/CMakeLists.txt @@ -265,8 +265,6 @@ add_executable_clr(paltests file_io/GetFullPathNameW/test4/test4.cpp file_io/GetStdHandle/test1/GetStdHandle.cpp file_io/GetStdHandle/test2/GetStdHandle.cpp - file_io/GetSystemTime/test1/test.cpp - file_io/GetSystemTimeAsFileTime/test1/GetSystemTimeAsFileTime.cpp file_io/gettemppatha/test1/gettemppatha.cpp file_io/GetTempPathW/test1/GetTempPathW.cpp file_io/ReadFile/test1/ReadFile.cpp diff --git a/src/coreclr/pal/tests/palsuite/compilableTests.txt b/src/coreclr/pal/tests/palsuite/compilableTests.txt index ee5ba036ce7a31..c9de088fd78892 100644 --- a/src/coreclr/pal/tests/palsuite/compilableTests.txt +++ b/src/coreclr/pal/tests/palsuite/compilableTests.txt @@ -180,8 +180,6 @@ file_io/GetFullPathNameW/test3/paltest_getfullpathnamew_test3 file_io/GetFullPathNameW/test4/paltest_getfullpathnamew_test4 file_io/GetStdHandle/test1/paltest_getstdhandle_test1 file_io/GetStdHandle/test2/paltest_getstdhandle_test2 -file_io/GetSystemTime/test1/paltest_getsystemtime_test1 -file_io/GetSystemTimeAsFileTime/test1/paltest_getsystemtimeasfiletime_test1 file_io/gettemppatha/test1/paltest_gettemppatha_test1 file_io/GetTempPathW/test1/paltest_gettemppathw_test1 file_io/ReadFile/test1/paltest_readfile_test1 diff --git a/src/coreclr/pal/tests/palsuite/file_io/GetSystemTime/test1/test.cpp b/src/coreclr/pal/tests/palsuite/file_io/GetSystemTime/test1/test.cpp deleted file mode 100644 index b0a3b32ca2b93a..00000000000000 --- a/src/coreclr/pal/tests/palsuite/file_io/GetSystemTime/test1/test.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for GetSystemTime() function -** -** -**=========================================================*/ - -/* Note: Some of the range comparisons only check - * the high end of the range. Since the structure - * contains WORDs, negative values can never be included, - * so there is no reason to check and see if the lower - * end of the spectrum is <0 -*/ - -#include - - -PALTEST(file_io_GetSystemTime_test1_paltest_getsystemtime_test1, "file_io/GetSystemTime/test1/paltest_getsystemtime_test1") -{ - SYSTEMTIME TheTime; - SYSTEMTIME firstTime; - SYSTEMTIME secondTime; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - GetSystemTime(&TheTime); - - /* Go through each item in the structure and ensure it is a valid value. - We can't ensure they have the exact values of the current time, but - at least that they have been set to a valid range of values for that - item. - */ - - /* Year */ - if(TheTime.wYear < (WORD)2001) - { - Fail("ERROR: The year is %d, when it should be at least 2001.", - TheTime.wYear); - } - - /* Month */ - if(TheTime.wMonth > (WORD)12 || TheTime.wMonth < (WORD)1) - { - Fail("ERROR: The month should be between 1 and 12, and it is " - "showing up as %d.",TheTime.wMonth); - } - - /* Weekday */ - if(TheTime.wDayOfWeek > 6) - { - Fail("ERROR: The day of the week should be between 0 and 6, " - "and it is showing up as %d.",TheTime.wDayOfWeek); - } - - /* Day of the Month */ - if(TheTime.wDay > 31 || TheTime.wDay < 1) - { - Fail("ERROR: The day of the month should be between 1 and " - "31, and it is showing up as %d.",TheTime.wDay); - } - - /* Hour */ - if(TheTime.wHour > 23) - { - Fail("ERROR: The hour should be between 0 and 23, and it is " - "showing up as %d.",TheTime.wHour); - } - - /* Minute */ - if(TheTime.wMinute > 59) - { - Fail("ERROR: The minute should be between 0 and 59 and it is " - "showing up as %d.",TheTime.wMinute); - } - - /* Second */ - if(TheTime.wSecond > 59) - { - Fail("ERROR: The second should be between 0 and 59 and it is" - " showing up as %d.",TheTime.wSecond); - } - - /* Millisecond */ - if(TheTime.wMilliseconds > 999) - { - Fail("ERROR: The milliseconds should be between 0 and 999 " - "and it is currently showing %d.",TheTime.wMilliseconds); - } - - /* verify that two consecutive calls to system time return */ - /* different values of seconds across sleep() call. */ - /* do this 5 times in case we are super unlucky. */ - float avgDeltaFileTime = 0; - for (int i = 0; i < 5; i++) - { - GetSystemTime(&firstTime); - Sleep(1000); - GetSystemTime(&secondTime); - avgDeltaFileTime += abs(firstTime.wSecond - secondTime.wSecond); - } - - if( (avgDeltaFileTime / 5) == 0) - { - Fail("ERROR: GetSystemTime always returning same value of seconds Value[%f]", avgDeltaFileTime / 5); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/GetSystemTimeAsFileTime.cpp b/src/coreclr/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/GetSystemTimeAsFileTime.cpp deleted file mode 100644 index 7658abb4c9454e..00000000000000 --- a/src/coreclr/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/GetSystemTimeAsFileTime.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*===================================================================== -** -** Source: GetSystemTimeAsFileTime.c -** -** Purpose: Tests the PAL implementation of GetSystemTimeAsFileTime -** Take two times, three seconds apart, and ensure that the time is -** increasing, and that it has increased at least 3 seconds. -** -** -** -**===================================================================*/ - -#include - - -PALTEST(file_io_GetSystemTimeAsFileTime_test1_paltest_getsystemtimeasfiletime_test1, "file_io/GetSystemTimeAsFileTime/test1/paltest_getsystemtimeasfiletime_test1") -{ - - FILETIME TheFirstTime, TheSecondTime; - ULONG64 FullFirstTime, FullSecondTime; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Get two times, 3 seconds apart */ - - GetSystemTimeAsFileTime( &TheFirstTime ); - - Sleep( 3000 ); - - GetSystemTimeAsFileTime( &TheSecondTime ); - - /* Convert them to ULONG64 to work with */ - - FullFirstTime = ((( (ULONG64)TheFirstTime.dwHighDateTime )<<32) | - ( (ULONG64)TheFirstTime.dwLowDateTime )); - - FullSecondTime = ((( (ULONG64)TheSecondTime.dwHighDateTime )<<32) | - ( (ULONG64)TheSecondTime.dwLowDateTime )); - - /* Test to ensure the second value is larger than the first */ - - if( FullSecondTime <= FullFirstTime ) - { - Fail("ERROR: The system time didn't increase in the last " - "three seconds. The second time tested was less than " - "or equal to the first."); - } - - /* Note: The 30000000 magic number is 3 seconds in hundreds of nano - seconds. This test checks to ensure at least 3 seconds passed - between the readings. - */ - - if( ( (LONG64)( FullSecondTime - FullFirstTime ) - 30000000 ) < 0 ) - { - ULONG64 TimeError; - - /* Note: This test used to compare the difference between full times - in terms of hundreds of nanoseconds. But the x86 clock seems to be - precise only to the level of about 10000 nanoseconds, so we would - fail the comparison depending on when we took time slices. - - To fix this, we just check that we're within 10 milliseconds of - sleeping 3000 milliseconds. We're not currently ensuring that we - haven't slept much more than 3000 ms. We may want to do that. - */ - TimeError = 30000000 - ( FullSecondTime - FullFirstTime ); - if ( TimeError > 100000) - { - Fail("ERROR: Two system times were tested, with a sleep of 3 " - "seconds between. The time passed should have been at least " - "3 seconds. But, it was less according to the function. " - "Actual time difference: %llu hundred-nanoseconds, " - "Expected: 30000000, Tolerance: 100000", - (unsigned long long)(FullSecondTime - FullFirstTime)); - } - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/coreclr/pal/tests/palsuite/paltestlist.txt b/src/coreclr/pal/tests/palsuite/paltestlist.txt index b55a93735f16f2..035f8b33a14875 100644 --- a/src/coreclr/pal/tests/palsuite/paltestlist.txt +++ b/src/coreclr/pal/tests/palsuite/paltestlist.txt @@ -163,8 +163,6 @@ file_io/GetFullPathNameW/test1/paltest_getfullpathnamew_test1 file_io/GetFullPathNameW/test3/paltest_getfullpathnamew_test3 file_io/GetFullPathNameW/test4/paltest_getfullpathnamew_test4 file_io/GetStdHandle/test2/paltest_getstdhandle_test2 -file_io/GetSystemTime/test1/paltest_getsystemtime_test1 -file_io/GetSystemTimeAsFileTime/test1/paltest_getsystemtimeasfiletime_test1 file_io/gettemppatha/test1/paltest_gettemppatha_test1 file_io/GetTempPathW/test1/paltest_gettemppathw_test1 file_io/ReadFile/test2/paltest_readfile_test2 diff --git a/src/coreclr/pal/tests/palsuite/threading/Sleep/test1/Sleep.cpp b/src/coreclr/pal/tests/palsuite/threading/Sleep/test1/Sleep.cpp index e48d73c3d59c07..d7fb16d8b963b8 100644 --- a/src/coreclr/pal/tests/palsuite/threading/Sleep/test1/Sleep.cpp +++ b/src/coreclr/pal/tests/palsuite/threading/Sleep/test1/Sleep.cpp @@ -8,8 +8,7 @@ ** Purpose: Test to establish whether the Sleep function stops the thread from ** executing for the specified times. ** -** Dependencies: GetSystemTime -** Fail +** Dependencies: Fail ** Trace ** diff --git a/src/coreclr/pal/tests/palsuite/wasm/index.html b/src/coreclr/pal/tests/palsuite/wasm/index.html index a50c1ff3473f29..9ad519ad45c728 100644 --- a/src/coreclr/pal/tests/palsuite/wasm/index.html +++ b/src/coreclr/pal/tests/palsuite/wasm/index.html @@ -10,7 +10,6 @@

PAL Tests WASM