non-linux regtest: update cmdline expecteds
[valgrind.git] / VEX / pub / libvex_basictypes.h
blobe3f1485d50aa14edeb38f40822cae3ff852094f8
2 /*---------------------------------------------------------------*/
3 /*--- begin libvex_basictypes.h ---*/
4 /*---------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2004-2017 OpenWorks LLP
11 info@open-works.net
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
28 Neither the names of the U.S. Department of Energy nor the
29 University of California nor the names of its contributors may be
30 used to endorse or promote products derived from this software
31 without prior written permission.
34 #ifndef __LIBVEX_BASICTYPES_H
35 #define __LIBVEX_BASICTYPES_H
37 /* It is important that the sizes of the following data types (on the
38 host) are as stated. LibVEX_Init therefore checks these at
39 startup. */
41 /* Always 8 bits. */
42 typedef unsigned char UChar;
43 typedef signed char Char;
44 typedef char HChar; /* signfulness depends on host */
45 /* Only to be used for printf etc
46 format strings */
48 /* Always 16 bits. */
49 typedef unsigned short UShort;
50 typedef signed short Short;
52 /* Always 32 bits. */
53 typedef unsigned int UInt;
54 typedef signed int Int;
56 /* Always 64 bits. */
57 typedef unsigned long long int ULong;
58 typedef signed long long int Long;
60 /* Equivalent of C's size_t type. The type is unsigned and has this
61 storage requirement:
62 32 bits on a 32-bit architecture
63 64 bits on a 64-bit architecture. */
64 typedef unsigned long SizeT;
66 /* Always 128 bits. */
67 typedef UInt U128[4];
69 /* Always 256 bits. */
70 typedef UInt U256[8];
72 /* A union for doing 128-bit vector primitives conveniently. */
73 typedef
74 union {
75 UChar w8[16];
76 UShort w16[8];
77 UInt w32[4];
78 ULong w64[2];
80 V128;
82 /* A union for doing 256-bit vector primitives conveniently. */
83 typedef
84 union {
85 UChar w8[32];
86 UShort w16[16];
87 UInt w32[8];
88 ULong w64[4];
90 V256;
92 /* Floating point. */
93 typedef float Float; /* IEEE754 single-precision (32-bit) value */
94 typedef double Double; /* IEEE754 double-precision (64-bit) value */
96 /* Bool is always 8 bits. */
97 typedef unsigned char Bool;
98 #define True ((Bool)1)
99 #define False ((Bool)0)
101 /* Use this to coerce the result of a C comparison to a Bool. This is
102 useful when compiling with Intel icc with ultra-paranoid
103 compilation flags (-Wall). */
104 static inline Bool toBool ( Int x ) {
105 Int r = (x == 0) ? False : True;
106 return (Bool)r;
108 static inline UChar toUChar ( Int x ) {
109 x &= 0xFF;
110 return (UChar)x;
112 static inline HChar toHChar ( Int x ) {
113 x &= 0xFF;
114 return (HChar)x;
116 static inline UShort toUShort ( Int x ) {
117 x &= 0xFFFF;
118 return (UShort)x;
120 static inline Short toShort ( Int x ) {
121 x &= 0xFFFF;
122 return (Short)x;
124 static inline UInt toUInt ( Long x ) {
125 x &= 0xFFFFFFFFLL;
126 return (UInt)x;
129 /* 32/64 bit addresses. */
130 typedef UInt Addr32;
131 typedef ULong Addr64;
133 /* An address: 32-bit or 64-bit wide depending on host architecture */
134 typedef unsigned long Addr;
137 /* Something which has the same size as void* on the host. That is,
138 it is 32 bits on a 32-bit host and 64 bits on a 64-bit host, and so
139 it can safely be coerced to and from a pointer type on the host
140 machine. */
141 typedef unsigned long HWord;
143 /* Size of GPRs */
144 #if defined(__mips__) && (__mips == 64) && (_MIPS_SIM == _ABIN32)
145 typedef ULong RegWord;
146 # define FMT_REGWORD "ll"
147 #else
148 typedef HWord RegWord;
149 # define FMT_REGWORD "l"
150 #endif
152 /* Set up VEX_HOST_WORDSIZE and VEX_REGPARM. */
153 #undef VEX_HOST_WORDSIZE
154 #undef VEX_REGPARM
156 /* The following 4 work OK for Linux. */
157 #if defined(__x86_64__)
158 # define VEX_HOST_WORDSIZE 8
159 # define VEX_REGPARM(_n) /* */
161 #elif defined(__i386__)
162 # define VEX_HOST_WORDSIZE 4
163 # define VEX_REGPARM(_n) __attribute__((regparm(_n)))
165 #elif defined(__powerpc__) && defined(__powerpc64__)
166 # define VEX_HOST_WORDSIZE 8
167 # define VEX_REGPARM(_n) /* */
169 #elif defined(__powerpc__) && !defined(__powerpc64__)
170 # define VEX_HOST_WORDSIZE 4
171 # define VEX_REGPARM(_n) /* */
173 #elif defined(__arm__) && !defined(__aarch64__)
174 # define VEX_HOST_WORDSIZE 4
175 # define VEX_REGPARM(_n) /* */
177 #elif defined(__aarch64__) && !defined(__arm__)
178 # define VEX_HOST_WORDSIZE 8
179 # define VEX_REGPARM(_n) /* */
181 #elif defined(__s390x__)
182 # define VEX_HOST_WORDSIZE 8
183 # define VEX_REGPARM(_n) /* */
185 #elif defined(__mips__) && (__mips == 64)
186 #if _MIPS_SIM == _ABIN32
187 # define VEX_HOST_WORDSIZE 4
188 #else
189 # define VEX_HOST_WORDSIZE 8
190 #endif
191 # define VEX_REGPARM(_n) /* */
193 #elif defined(__mips__) && (__mips != 64)
194 # define VEX_HOST_WORDSIZE 4
195 # define VEX_REGPARM(_n) /* */
197 #elif defined(__nanomips__) && (__nanomips != 64)
198 # define VEX_HOST_WORDSIZE 4
199 # define VEX_REGPARM(_n) /* */
201 #else
202 # error "Vex: Fatal: Can't establish the host architecture"
203 #endif
206 #endif /* ndef __LIBVEX_BASICTYPES_H */
208 /*---------------------------------------------------------------*/
209 /*--- libvex_basictypes.h ---*/
210 /*---------------------------------------------------------------*/