About Social Code
aboutsummaryrefslogtreecommitdiff
path: root/src/util/detect_arch.h
blob: e32de8d50093fc44b2d582d02262220b51207e86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/**************************************************************************
 *
 * Copyright 2008 VMware, Inc.
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 **************************************************************************/

/**
 * @file
 * Gallium configuration defines.
 *
 * This header file sets several defines based on the compiler, processor
 * architecture, and operating system being used. These defines should be used
 * throughout the code to facilitate porting to new platforms. It is likely that
 * this file is auto-generated by an autoconf-like tool at some point, as some
 * things cannot be determined by pre-defined environment alone.
 *
 * See also:
 * - http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
 * - echo | gcc -dM -E - | sort
 * - http://msdn.microsoft.com/en-us/library/b0084kay.aspx
 *
 * @author José Fonseca <jfonseca@vmware.com>
 */

#ifndef UTIL_DETECT_ARCH_H_
#define UTIL_DETECT_ARCH_H_

#include <limits.h>

#include "util/detect_cc.h"

/*
 * Processor architecture
 */

#if defined(__i386__) /* gcc */ || defined(_M_IX86) /* msvc */ || defined(_X86_) || defined(__386__) || defined(i386) || defined(__i386) /* Sun cc */
#define DETECT_ARCH_X86 1
#endif

#if defined(__x86_64__) /* gcc */ || \
    ((defined(_M_X64) || defined(_M_AMD64)) && !defined(_M_ARM64EC)) /* msvc */ || \
    defined(__x86_64) /* Sun cc */
#define DETECT_ARCH_X86_64 1
#endif

#if DETECT_ARCH_X86 || DETECT_ARCH_X86_64
#if DETECT_CC_GCC && !defined(__SSE2__)
/* #warning SSE2 support requires -msse -msse2 compiler options */
#else
#define DETECT_ARCH_SSE 1
#endif
#endif

#if defined(__ppc__) || defined(__ppc64__) || defined(__PPC__) || defined(__PPC64__)
#define DETECT_ARCH_PPC 1
#if defined(__ppc64__) || defined(__PPC64__)
#define DETECT_ARCH_PPC_64 1
#endif
#endif

#if defined(__s390x__)
#define DETECT_ARCH_S390 1
#endif

#if defined(__arm__)
#define DETECT_ARCH_ARM 1
#endif

#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
#define DETECT_ARCH_AARCH64 1
#endif

#if defined(_M_ARM64EC)
#define DETECT_ARCH_ARM64EC 1
#endif

#if defined(__mips64) && defined(__LP64__)
#define DETECT_ARCH_MIPS64 1
#endif

#if defined(__mips__)
#define DETECT_ARCH_MIPS 1
#endif

#if defined(__hppa__)
#define DETECT_ARCH_HPPA 1
#endif

#if defined(__riscv)
#define DETECT_ARCH_RISCV 1
#if __riscv_xlen == 64
#define DETECT_ARCH_RISCV64 1
#elif __riscv_xlen == 32
#define DETECT_ARCH_RISCV32 1
#else
#error "detect_arch: unknown target riscv xlen"
#endif
#endif

#if defined(__loongarch__)
#ifdef __loongarch_lp64
#define DETECT_ARCH_LOONGARCH64 1
#else
#error "detect_arch: unknown target loongarch base ABI type"
#endif
#endif

#if defined(__sparc__) || defined(__sparc)
#define DETECT_ARCH_SPARC64 1
#endif

#ifndef DETECT_ARCH_X86
#define DETECT_ARCH_X86 0
#endif

#ifndef DETECT_ARCH_X86_64
#define DETECT_ARCH_X86_64 0
#endif

#ifndef DETECT_ARCH_SSE
#define DETECT_ARCH_SSE 0
#endif

#ifndef DETECT_ARCH_PPC
#define DETECT_ARCH_PPC 0
#endif

#ifndef DETECT_ARCH_PPC_64
#define DETECT_ARCH_PPC_64 0
#endif

#ifndef DETECT_ARCH_S390
#define DETECT_ARCH_S390 0
#endif

#ifndef DETECT_ARCH_ARM
#define DETECT_ARCH_ARM 0
#endif

#ifndef DETECT_ARCH_AARCH64
#define DETECT_ARCH_AARCH64 0
#endif

#ifndef DETECT_ARCH_ARM64EC
#define DETECT_ARCH_ARM64EC 0
#endif

#ifndef DETECT_ARCH_MIPS64
#define DETECT_ARCH_MIPS64 0
#endif

#ifndef DETECT_ARCH_MIPS
#define DETECT_ARCH_MIPS 0
#endif

#ifndef DETECT_ARCH_HPPA
#define DETECT_ARCH_HPPA 0
#endif

#ifndef DETECT_ARCH_RISCV
#define DETECT_ARCH_RISCV 0
#endif

#ifndef DETECT_ARCH_RISCV32
#define DETECT_ARCH_RISCV32 0
#endif

#ifndef DETECT_ARCH_RISCV64
#define DETECT_ARCH_RISCV64 0
#endif

#ifndef DETECT_ARCH_LOONGARCH64
#define DETECT_ARCH_LOONGARCH64 0
#endif

#ifndef DETECT_ARCH_SPARC64
#define DETECT_ARCH_SPARC64 0
#endif

#endif /* UTIL_DETECT_ARCH_H_ */