summaryrefslogtreecommitdiff
path: root/m4/ax_gcc_x86_cpuid.m4
diff options
context:
space:
mode:
authorMichael Petch <mpetch@capp-sysware.com>2015-09-03 23:05:01 +0200
committerPeter Simons <simons@cryp.to>2015-09-03 23:05:01 +0200
commite0bbac2cddd36ed8af80180841c05f3879a9a65c (patch)
treea2719cf01245106bb042166cdd5c701e5c0e89be /m4/ax_gcc_x86_cpuid.m4
parent08d9029ba984b8148216877e93796ec6b3c055be (diff)
downloadautoconf-archive-e0bbac2cddd36ed8af80180841c05f3879a9a65c.tar.gz
Fixes for AX_EXT / AX_GCC_X86_AVX_XGETBV / AX_GCC_X86_CPUID.
Submitted in https://savannah.gnu.org/patch/?8730.
Diffstat (limited to 'm4/ax_gcc_x86_cpuid.m4')
-rw-r--r--m4/ax_gcc_x86_cpuid.m418
1 files changed, 13 insertions, 5 deletions
diff --git a/m4/ax_gcc_x86_cpuid.m4 b/m4/ax_gcc_x86_cpuid.m4
index 7d46fee..370e6a7 100644
--- a/m4/ax_gcc_x86_cpuid.m4
+++ b/m4/ax_gcc_x86_cpuid.m4
@@ -5,13 +5,15 @@
# SYNOPSIS
#
# AX_GCC_X86_CPUID(OP)
+# AX_GCC_X86_CPUID_COUNT(OP, COUNT)
#
# DESCRIPTION
#
# On Pentium and later x86 processors, with gcc or a compiler that has a
# compatible syntax for inline assembly instructions, run a small program
# that executes the cpuid instruction with input OP. This can be used to
-# detect the CPU type.
+# detect the CPU type. AX_GCC_X86_CPUID_COUNT takes an additional COUNT
+# parameter that gets passed into register ECX before calling cpuid.
#
# On output, the values of the eax, ebx, ecx, and edx registers are stored
# as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable
@@ -28,6 +30,7 @@
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2008 Matteo Frigo
+# Copyright (c) 2015 Michael Petch <mpetch@capp-sysware.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
@@ -55,18 +58,23 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 7
+#serial 8
AC_DEFUN([AX_GCC_X86_CPUID],
+[AX_GCC_X86_CPUID_COUNT($1, 0)
+])
+
+AC_DEFUN([AX_GCC_X86_CPUID_COUNT],
[AC_REQUIRE([AC_PROG_CC])
AC_LANG_PUSH([C])
AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
[AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
- int op = $1, eax, ebx, ecx, edx;
+ int op = $1, level = $2, eax, ebx, ecx, edx;
FILE *f;
- __asm__("cpuid"
+ __asm__ __volatile__ ("cpuid"
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "a" (op));
+ : "a" (op), "2" (level));
+
f = fopen("conftest_cpuid", "w"); if (!f) return 1;
fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
fclose(f);