annotate acinclude/ax_gcc_x86_cpuid.m4.htm @ 5216:25ad4a50d34f

OpenGL ES 2.0 rendering LIVES!
author Sam Lantinga <slouken@libsdl.org>
date Sun, 06 Feb 2011 19:12:55 -0800
parents 5d7d48157be7
children
rev   line source
5029
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 # ===========================================================================
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 # http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 # ===========================================================================
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 # SYNOPSIS
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 # AX_GCC_X86_CPUID(OP)
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9 # DESCRIPTION
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 # On Pentium and later x86 processors, with gcc or a compiler that has a
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 # compatible syntax for inline assembly instructions, run a small program
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 # that executes the cpuid instruction with input OP. This can be used to
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 # detect the CPU type.
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 # On output, the values of the eax, ebx, ecx, and edx registers are stored
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 # as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 # ax_cv_gcc_x86_cpuid_OP.
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 # If the cpuid instruction fails (because you are running a
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 # cross-compiler, or because you are not using gcc, or because you are on
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 # a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 # is set to the string "unknown".
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 # This macro mainly exists to be used in AX_GCC_ARCHFLAG.
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 # LICENSE
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 # Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 # Copyright (c) 2008 Matteo Frigo
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 # This program is free software: you can redistribute it and/or modify it
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 # under the terms of the GNU General Public License as published by the
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 # Free Software Foundation, either version 3 of the License, or (at your
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 # option) any later version.
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 # This program is distributed in the hope that it will be useful, but
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 # WITHOUT ANY WARRANTY; without even the implied warranty of
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 # Public License for more details.
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 # You should have received a copy of the GNU General Public License along
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 # with this program. If not, see <http://www.gnu.org/licenses/>.
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 # As a special exception, the respective Autoconf Macro's copyright owner
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 # gives unlimited permission to copy, distribute and modify the configure
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 # scripts that are the output of Autoconf when processing the Macro. You
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 # need not follow the terms of the GNU General Public License when using
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 # or distributing such scripts, even though portions of the text of the
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 # Macro appear in them. The GNU General Public License (GPL) does govern
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 # all other use of the material that constitutes the Autoconf Macro.
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 #
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 # This special exception to the GPL applies to versions of the Autoconf
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 # Macro released by the Autoconf Archive. When you make and distribute a
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 # modified version of the Autoconf Macro, you may extend this special
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 # exception to the GPL to apply to your modified version as well.
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 #serial 7
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 AC_DEFUN([AX_GCC_X86_CPUID],
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 [AC_REQUIRE([AC_PROG_CC])
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 AC_LANG_PUSH([C])
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 int op = $1, eax, ebx, ecx, edx;
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 FILE *f;
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 __asm__("cpuid"
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 : "a" (op));
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 f = fopen("conftest_cpuid", "w"); if (!f) return 1;
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 fclose(f);
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 return 0;
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 ])],
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid],
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid],
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 [ax_cv_gcc_x86_cpuid_$1=unknown])])
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 AC_LANG_POP([C])
5d7d48157be7 Greg Jandl to SDL
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 ])