[SDK] Provide .const macro for gas
[reactos.git] / dll / opengl / mesa / main / cpuinfo.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.5
4 *
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 #include <precomp.h>
26
27 /**
28 * This function should be called before the various "cpu_has_foo" macros
29 * are used.
30 */
31 void
32 _mesa_get_cpu_features(void)
33 {
34 #ifdef USE_X86_ASM
35 _mesa_get_x86_features();
36 #endif
37 }
38
39
40 /**
41 * Return a string describing the CPU architexture and extensions that
42 * Mesa is using (such as SSE or Altivec).
43 * \return information string, free it with free()
44 */
45 char *
46 _mesa_get_cpu_string(void)
47 {
48 #define MAX_STRING 50
49 char *buffer;
50
51 buffer = (char *) malloc(MAX_STRING);
52 if (!buffer)
53 return NULL;
54
55 buffer[0] = 0;
56
57 #ifdef USE_X86_ASM
58
59 if (_mesa_x86_cpu_features) {
60 strcat(buffer, "x86");
61 }
62
63 # ifdef USE_MMX_ASM
64 if (cpu_has_mmx) {
65 strcat(buffer, (cpu_has_mmxext) ? "/MMX+" : "/MMX");
66 }
67 # endif
68 # ifdef USE_3DNOW_ASM
69 if (cpu_has_3dnow) {
70 strcat(buffer, (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!");
71 }
72 # endif
73 # ifdef USE_SSE_ASM
74 if (cpu_has_xmm) {
75 strcat(buffer, (cpu_has_xmm2) ? "/SSE2" : "/SSE");
76 }
77 # endif
78
79 #elif defined(USE_SPARC_ASM)
80
81 strcat(buffer, "SPARC");
82
83 #elif defined(USE_PPC_ASM)
84
85 if (_mesa_ppc_cpu_features) {
86 strcat(buffer, (cpu_has_64) ? "PowerPC 64" : "PowerPC");
87 }
88
89 # ifdef USE_VMX_ASM
90
91 if (cpu_has_vmx) {
92 strcat(buffer, "/Altivec");
93 }
94
95 # endif
96
97 if (! cpu_has_fpu) {
98 strcat(buffer, "/No FPU");
99 }
100
101 #endif
102
103 assert(strlen(buffer) < MAX_STRING);
104
105 return buffer;
106 }