Skip to content

checkasm: Include windows.h for the MSVC ARM64 readtime macro

Martin Storsjö requested to merge mstorsjo/dav1d:checkasm-msvc-arm64 into master

Including windows.h is a rather heavy thing to do though. Alternatively, instead of _InstructionSynchronizationBarrier(), we could use __isb(_ARM64_BARRIER_SY) and include arm64intr.h.

With that change, things do compile correctly as well. However, building other source files than checkasm.c won't see a definition of ReadTimeStampCounter, but an inline definition of it in checkasm.obj is enough for the other files referencing it. If we want a proper definition of it without including windows.h, we need to duplicate some amount of defines:

#include <arm64intr.h>
// In case windows.h already was included
#undef ARM64_SYSREG
#define ARM64_SYSREG(op0, op1, crn, crm, op2) \
        ( ((op0 & 1) << 14) | \
          ((op1 & 7) << 11) | \
          ((crn & 15) << 7) | \
          ((crm & 15) << 3) | \
          ((op2 & 7) << 0) )
#define ARM64_PMCCNTR_EL0       ARM64_SYSREG(3,3, 9,13,0)
#define readtime() (__isb(_ARM64_BARRIER_SY), _ReadStatusReg(ARM64_PMCCNTR_EL0)

I didn't notice this before as this isn't actually buildable properly with MSVC for ARM yet, due to https://github.com/mesonbuild/meson/issues/4366. I hacked up a manual makefile for testing it now though, and noticed this.

Edited by Martin Storsjö

Merge request reports

Loading