]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/x86_64/multiarch/init-arch.h
* config.h.in (USE_MULTIARCH): Define.
[thirdparty/glibc.git] / sysdeps / x86_64 / multiarch / init-arch.h
CommitLineData
425ce2ed
UD
1/* This file is part of the GNU C Library.
2 Copyright (C) 2008 Free Software Foundation, Inc.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
18
19#include <sys/param.h>
20
21enum
22 {
23 INTEL_CPUID_INDEX_1 = 0,
24 /* Keep the following line at the end. */
25 INTEL_CPUID_INDEX_MAX
26 };
27
28enum
29 {
30 AMD_CPUID_INDEX_1 = 0,
31 /* Keep the following line at the end. */
32 AMD_CPUID_INDEX_MAX
33 };
34
35extern struct cpu_features
36{
37 enum
38 {
39 arch_kind_unknown = 0,
40 arch_kind_intel,
41 arch_kind_amd,
42 arch_kind_other
43 } kind;
44 int max_cpuid;
45 struct
46 {
47 unsigned int eax;
48 unsigned int ebx;
49 unsigned int ecx;
50 unsigned int edx;
51 } cpuid[MAX (INTEL_CPUID_INDEX_MAX, AMD_CPUID_INDEX_MAX)];
52} __cpu_features attribute_hidden;
53
54
55extern void __init_cpu_features (void) attribute_hidden;
56#define INIT_ARCH()\
57 do \
58 if (__cpu_features.kind == arch_kind_unknown) \
59 __init_cpu_features (); \
60 while (0)
61
62/* Following are the feature tests used throughout libc. */
63
64#define INTEL_HAS_POPCOUNT \
65 (__cpu_features.kind == arch_kind_intel \
66 && (__cpu_features.cpuid[INTEL_CPUID_INDEX_1].ecx & (1 << 23)) != 0)
67
68#define AMD_HAS_POPCOUNT \
69 (__cpu_features.kind == arch_kind_amd \
70 && (__cpu_features.cpuid[AMD_CPUID_INDEX_1].ecx & (1 << 23)) != 0)