Add deterministic QueryPerformanceCounter/Frequency mocks
Implemented Windows high-resolution timing mocks for deterministic simulation: **mock_QueryPerformanceCounter:** - Returns deterministic counter based on simulated_time - Uses fixed 10 MHz frequency (10,000,000 counts/second) - Calculation: count = (tv_sec * freq) + (tv_nsec * freq / 1e9) - Validates NULL pointer with ERROR_INVALID_PARAMETER - Provides consistent, reproducible timing across test runs **mock_QueryPerformanceFrequency:** - Returns fixed frequency of 10 MHz (10,000,000 Hz) - Common frequency on modern Windows systems - Ensures deterministic behavior (no variation between runs) - Validates NULL pointer with ERROR_INVALID_PARAMETER **Integration:** - Added function declarations to system.h - Macros already existed (sys_QueryPerformanceCounter/Frequency) - Complements existing mock_clock_gettime on Linux - Both platforms now have deterministic high-resolution timing This ensures Windows code using QueryPerformanceCounter for timing, benchmarking, or rate limiting behaves deterministically in tests. The fixed 10 MHz frequency provides nanosecond-level precision (100ns per tick) suitable for most timing needs.
This commit is contained in:
@@ -61,6 +61,8 @@ BOOL mock_FlushFileBuffers(HANDLE handle);
|
||||
BOOL mock_ReadFile(HANDLE handle, char *dst, DWORD len, DWORD *num, OVERLAPPED *ov);
|
||||
BOOL mock_WriteFile(HANDLE handle, char *src, DWORD len, DWORD *num, OVERLAPPED *ov);
|
||||
BOOL mock_GetFileSizeEx(HANDLE handle, LARGE_INTEGER *buf);
|
||||
BOOL mock_QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount);
|
||||
BOOL mock_QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency);
|
||||
char* mock__fullpath(char *path, char *dst, int cap);
|
||||
int mock__mkdir(char *path);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user