|
Packit |
fb9d21 |
# ===========================================================================
|
|
Packit |
fb9d21 |
# http://www.nongnu.org/autoconf-archive/ax_gcc_x86_cpuid.html
|
|
Packit |
fb9d21 |
# ===========================================================================
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# SYNOPSIS
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# AX_GCC_X86_CPUID(OP)
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# DESCRIPTION
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# On Pentium and later x86 processors, with gcc or a compiler that has a
|
|
Packit |
fb9d21 |
# compatible syntax for inline assembly instructions, run a small program
|
|
Packit |
fb9d21 |
# that executes the cpuid instruction with input OP. This can be used to
|
|
Packit |
fb9d21 |
# detect the CPU type.
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# On output, the values of the eax, ebx, ecx, and edx registers are stored
|
|
Packit |
fb9d21 |
# as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable
|
|
Packit |
fb9d21 |
# ax_cv_gcc_x86_cpuid_OP.
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# If the cpuid instruction fails (because you are running a
|
|
Packit |
fb9d21 |
# cross-compiler, or because you are not using gcc, or because you are on
|
|
Packit |
fb9d21 |
# a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP
|
|
Packit |
fb9d21 |
# is set to the string "unknown".
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# This macro mainly exists to be used in AX_GCC_ARCHFLAG.
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# LICENSE
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
|
|
Packit |
fb9d21 |
# Copyright (c) 2008 Matteo Frigo
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# This program is free software: you can redistribute it and/or modify it
|
|
Packit |
fb9d21 |
# under the terms of the GNU General Public License as published by the
|
|
Packit |
fb9d21 |
# Free Software Foundation, either version 3 of the License, or (at your
|
|
Packit |
fb9d21 |
# option) any later version.
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# This program is distributed in the hope that it will be useful, but
|
|
Packit |
fb9d21 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
fb9d21 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
Packit |
fb9d21 |
# Public License for more details.
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# You should have received a copy of the GNU General Public License along
|
|
Packit |
fb9d21 |
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# As a special exception, the respective Autoconf Macro's copyright owner
|
|
Packit |
fb9d21 |
# gives unlimited permission to copy, distribute and modify the configure
|
|
Packit |
fb9d21 |
# scripts that are the output of Autoconf when processing the Macro. You
|
|
Packit |
fb9d21 |
# need not follow the terms of the GNU General Public License when using
|
|
Packit |
fb9d21 |
# or distributing such scripts, even though portions of the text of the
|
|
Packit |
fb9d21 |
# Macro appear in them. The GNU General Public License (GPL) does govern
|
|
Packit |
fb9d21 |
# all other use of the material that constitutes the Autoconf Macro.
|
|
Packit |
fb9d21 |
#
|
|
Packit |
fb9d21 |
# This special exception to the GPL applies to versions of the Autoconf
|
|
Packit |
fb9d21 |
# Macro released by the Autoconf Archive. When you make and distribute a
|
|
Packit |
fb9d21 |
# modified version of the Autoconf Macro, you may extend this special
|
|
Packit |
fb9d21 |
# exception to the GPL to apply to your modified version as well.
|
|
Packit |
fb9d21 |
|
|
Packit |
fb9d21 |
AC_DEFUN([AX_GCC_X86_CPUID],
|
|
Packit |
fb9d21 |
[AC_REQUIRE([AC_PROG_CC])
|
|
Packit |
fb9d21 |
AC_LANG_PUSH([C])
|
|
Packit |
fb9d21 |
AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
|
|
Packit |
fb9d21 |
[AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
|
|
Packit |
fb9d21 |
int op = $1, eax, ebx, ecx, edx;
|
|
Packit |
fb9d21 |
FILE *f;
|
|
Packit |
fb9d21 |
__asm__("cpuid"
|
|
Packit |
fb9d21 |
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
|
|
Packit |
fb9d21 |
: "a" (op));
|
|
Packit |
fb9d21 |
f = fopen("conftest_cpuid", "w"); if (!f) return 1;
|
|
Packit |
fb9d21 |
fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
|
|
Packit |
fb9d21 |
fclose(f);
|
|
Packit |
fb9d21 |
return 0;
|
|
Packit |
fb9d21 |
])],
|
|
Packit |
fb9d21 |
[ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid],
|
|
Packit |
fb9d21 |
[ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid],
|
|
Packit |
fb9d21 |
[ax_cv_gcc_x86_cpuid_$1=unknown])])
|
|
Packit |
fb9d21 |
AC_LANG_POP([C])
|
|
Packit |
fb9d21 |
])
|