2 /*---------------------------------------------------------------*/
3 /*--- begin libvex_basictypes.h ---*/
4 /*---------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2004-2017 OpenWorks LLP
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
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
49 typedef unsigned short UShort
;
50 typedef signed short Short
;
53 typedef unsigned int UInt
;
54 typedef signed int Int
;
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
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. */
69 /* Always 256 bits. */
72 /* A union for doing 128-bit vector primitives conveniently. */
82 /* A union for doing 256-bit vector primitives conveniently. */
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
;
108 static inline UChar
toUChar ( Int x
) {
112 static inline HChar
toHChar ( Int x
) {
116 static inline UShort
toUShort ( Int x
) {
120 static inline Short
toShort ( Int x
) {
124 static inline UInt
toUInt ( Long x
) {
129 /* 32/64 bit addresses. */
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
141 typedef unsigned long HWord
;
144 #if defined(__mips__) && (__mips == 64) && (_MIPS_SIM == _ABIN32)
145 typedef ULong RegWord
;
146 # define FMT_REGWORD "ll"
148 typedef HWord RegWord
;
149 # define FMT_REGWORD "l"
152 /* Set up VEX_HOST_WORDSIZE and VEX_REGPARM. */
153 #undef VEX_HOST_WORDSIZE
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
189 # define VEX_HOST_WORDSIZE 8
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) /* */
202 # error "Vex: Fatal: Can't establish the host architecture"
206 #endif /* ndef __LIBVEX_BASICTYPES_H */
208 /*---------------------------------------------------------------*/
209 /*--- libvex_basictypes.h ---*/
210 /*---------------------------------------------------------------*/