progs/perftest.c: Use from Glibc syscall numbers.
[catacomb] / base / dispatch-x86ish.S
index 8a4c7b2..67ec05e 100644 (file)
@@ -44,30 +44,32 @@ FUNC(dispatch_x86ish_cpuid)
        // return zero if we can; otherwise fill with zero and return -1.
 
 #if CPUFAM_X86
+#  define OUT edi
        pushreg ebx
        pushreg edi
-       mov     edi, [SP + 12]
+       mov     OUT, [SP + 12]
        mov     eax, [SP + 16]
        mov     ecx, [SP + 20]
-#  define OUT edi
 #endif
 #if CPUFAM_AMD64 && ABI_SYSV
+#  define OUT rdi
        pushreg rbx
        mov     eax, esi
        mov     ecx, edx
-#  define OUT rdi
 #endif
 #if CPUFAM_AMD64 && ABI_WIN
+#  define OUT r9
        pushreg rbx
-       mov     r9, rcx
+       mov     OUT, rcx
        mov     eax, edx
        mov     ecx, r8d
-#  define OUT r9
 #endif
   endprologue
 
        // First, check that this is even a thing, using the complicated
-       // dance with the flags register.
+       // dance with the flags register.  This is unnecessary on AMD64,
+       // which postdates the introduction of `cpuid'.
+#if CPUFAM_X86
        pushf
        pop     DX                      // current flags in d
 
@@ -86,6 +88,7 @@ FUNC(dispatch_x86ish_cpuid)
        pop     DX
        test    edx, EFLAGS_ID
        jnz     8f
+#endif
 
        // OK, that seemed to work.
        cpuid
@@ -108,6 +111,7 @@ FUNC(dispatch_x86ish_cpuid)
        ret
 
        // Failed.
+#if CPUFAM_X86
 8:     xor     eax, eax
        mov     [OUT + 0], eax
        mov     [OUT + 4], eax
@@ -115,6 +119,9 @@ FUNC(dispatch_x86ish_cpuid)
        mov     [OUT + 12], eax
        mov     eax, -1
        jmp     9b
+#endif
+
+#undef OUT
 ENDFUNC
 
 ///--------------------------------------------------------------------------
@@ -165,7 +172,7 @@ FUNC(dispatch_x86ish_xgetbv)
 #if CPUFAM_X86
 #  define Z_OUT edi
        pushreg edi
-       mov     edi, [esp + 8]
+       mov     Z_OUT, [esp + 8]
        mov     ecx, [esp + 12]
 #endif
 #if CPUFAM_AMD64 && ABI_SYSV