Mach7
Mach7 copied to clipboard
Add Visual C++ equivalent of RDTSC code
Windows headers are incompatible with /Za flag, which disables language extensions. Windows header right now seems to only be used for timing purposes, so we can include it conditionally when extensions are enabled only. Enabling them though makes us rely on the worst timer available.
Write equivalent of RDTSC access code we now have for GCC in Microsoft assembly.
Microsoft provides an intrinsic to access RDTSC, which is nice because they don't support inline assembly in amd64 code. However, it seems like the implementation of get_frequency would still "require" including <windows.h> in order to get Sleep() to pause execution for 1/10th of a second.
Given your statement "Enabling them though makes us rely on the worst timer available." Is the goal to use RDTSC always or to only use RDTSC if Microsoft extensions are disabled?
The main idea was to be able to build with /Za (disable Microsoft extensions), the actual task was what prevented us from doing this.
If you still need this, here you go. It is not attached because github says "We don't support that file type" when I drag and drop the file.
`.686P .XMM .model flat
;; ml /c rdtscget.asm ;; produces rdtscget.obj ;; link rdtscget.obj with the rest of your code ;; C function prototype ;; unsigned long long _stdcall rdtsc(void); PUBLIC _rdtsc@0 _TEXT SEGMENT
_rdtsc@0 PROC rdtsc ret _rdtsc@0 ENDP
_TEXT ENDS END `