-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
m4/ax_gcc_x86_cpuid.m4: update from autoconf-archive v2023.02.20
- Loading branch information
Showing
1 changed file
with
19 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
# =========================================================================== | ||
# http://www.nongnu.org/autoconf-archive/ax_gcc_x86_cpuid.html | ||
# https://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html | ||
# =========================================================================== | ||
# | ||
# 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 <[email protected]> | ||
# Copyright (c) 2008 Matteo Frigo | ||
# Copyright (c) 2015 Michael Petch <[email protected]> | ||
# | ||
# 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 | ||
|
@@ -40,7 +43,7 @@ | |
# Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
# As a special exception, the respective Autoconf Macro's copyright owner | ||
# gives unlimited permission to copy, distribute and modify the configure | ||
|
@@ -55,16 +58,25 @@ | |
# modified version of the Autoconf Macro, you may extend this special | ||
# exception to the GPL to apply to your modified version as well. | ||
|
||
#serial 10 | ||
|
||
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" | ||
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) | ||
: "a" (op)); | ||
__asm__ __volatile__ ("xchg %%ebx, %1\n" | ||
"cpuid\n" | ||
"xchg %%ebx, %1\n" | ||
: "=a" (eax), "=r" (ebx), "=c" (ecx), "=d" (edx) | ||
: "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); | ||
|