Move PhReadTimeStampCounter

This commit is contained in:
dmex
2025-09-22 18:55:57 +10:00
parent 0a7bfc787f
commit 1fa1bf1c2b
3 changed files with 26 additions and 38 deletions
-1
View File
@@ -468,7 +468,6 @@ EXPORTS
PhQueryTimeZoneBias
PhReAllocate
PhReAllocateSafe
PhReadTimeStampCounter
PhReferenceEmptyString
PhRegisterCallback
PhRegisterCallbackEx
-33
View File
@@ -493,39 +493,6 @@ NTSTATUS PhQueueUserWorkItem(
return status;
}
/**
* Reads the time stamp counter.
*
* This function reads the time stamp counter using the `__rdtscp` instruction,
* which is a serializing variant of the `rdtsc` instruction. It also includes
* a memory fence to ensure proper ordering of memory operations.
* \return The current value of the time stamp counter.
*/
ULONGLONG PhReadTimeStampCounter(
VOID
)
{
#if defined(PHNT_NATIVE_TIME)
ULONG64 value;
value = ReadTimeStampCounter();
#if !defined(NTDDI_WIN11_GE) || (NTDDI_VERSION < NTDDI_WIN11_GE)
MemoryBarrier();
#else
SpeculationFence();
#endif
#else
ULONG64 value;
ULONG index;
value = __rdtscp(&index);
#endif
return value;
}
// rev from QueryPerformanceCounter (dmex)
/**
* Retrieves the current value of the performance counter, which is a high resolution (<1us) time stamp that can be used for time-interval measurements.
+26 -4
View File
@@ -99,12 +99,34 @@ PhQueueUserWorkItem(
// Misc. system
//
PHLIBAPI
ULONGLONG
NTAPI
/**
* Reads the time stamp counter.
*
* This function reads the time stamp counter using the `__rdtscp` instruction,
* which is a serializing variant of the `rdtsc` instruction. It also includes
* a memory fence to ensure proper ordering of memory operations.
* \return The current value of the time stamp counter.
*/
FORCEINLINE
ULONG64
PhReadTimeStampCounter(
VOID
);
)
{
#if defined(PHNT_NATIVE_TIME)
ULONG64 value;
SpeculationFence();
value = ReadTimeStampCounter();
SpeculationFence();
return value;
#else
unsigned int aux;
return __rdtscp(&aux);
#endif
}
PHLIBAPI
BOOLEAN