]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - sim/common/sim-types.h
sim: common: use standard intXX_t types for signedXX
[thirdparty/binutils-gdb.git] / sim / common / sim-types.h
1 /* The common simulator framework for GDB, the GNU Debugger.
2
3 Copyright 2002-2015 Free Software Foundation, Inc.
4
5 Contributed by Andrew Cagney and Red Hat.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22
23 #ifndef SIM_TYPES_H
24 #define SIM_TYPES_H
25
26 #include <stdint.h>
27
28 /* INTEGER QUANTITIES:
29
30 TYPES:
31
32 signed* signed type of the given size
33 unsigned* The corresponding insigned type
34
35 SIZES
36
37 *NN Size based on the number of bits
38 *_NN Size according to the number of bytes
39 *_word Size based on the target architecture's word
40 word size (32/64 bits)
41 *_cell Size based on the target architecture's
42 IEEE 1275 cell size (almost always 32 bits)
43
44 */
45
46
47 /* bit based */
48
49 #ifdef _MSC_VER
50 # define UNSIGNED32(X) (X##ui32)
51 # define UNSIGNED64(X) (X##ui64)
52 # define SIGNED32(X) (X##i32)
53 # define SIGNED64(X) (X##i64)
54 #else
55 # define UNSIGNED32(X) ((unsigned32) X##UL)
56 # define UNSIGNED64(X) ((unsigned64) X##ULL)
57 # define SIGNED32(X) ((signed32) X##L)
58 # define SIGNED64(X) ((signed64) X##LL)
59 #endif
60
61 typedef int8_t signed8;
62 typedef int16_t signed16;
63 typedef int32_t signed32;
64 typedef int64_t signed64;
65
66 typedef uint8_t unsigned8;
67 typedef uint16_t unsigned16;
68 typedef uint32_t unsigned32;
69 typedef uint64_t unsigned64;
70
71 typedef struct { unsigned64 a[2]; } unsigned128;
72 typedef struct { signed64 a[2]; } signed128;
73
74
75 /* byte based */
76
77 typedef signed8 signed_1;
78 typedef signed16 signed_2;
79 typedef signed32 signed_4;
80 typedef signed64 signed_8;
81 typedef signed128 signed_16;
82
83 typedef unsigned8 unsigned_1;
84 typedef unsigned16 unsigned_2;
85 typedef unsigned32 unsigned_4;
86 typedef unsigned64 unsigned_8;
87 typedef unsigned128 unsigned_16;
88
89
90 /* for general work, the following are defined */
91 /* unsigned: >= 32 bits */
92 /* signed: >= 32 bits */
93 /* long: >= 32 bits, sign undefined */
94 /* int: small indicator */
95
96 /* target architecture based */
97 #if (WITH_TARGET_WORD_BITSIZE == 64)
98 typedef unsigned64 unsigned_word;
99 typedef signed64 signed_word;
100 #endif
101 #if (WITH_TARGET_WORD_BITSIZE == 32)
102 typedef unsigned32 unsigned_word;
103 typedef signed32 signed_word;
104 #endif
105 #if (WITH_TARGET_WORD_BITSIZE == 16)
106 typedef unsigned16 unsigned_word;
107 typedef signed16 signed_word;
108 #endif
109
110
111 /* Other instructions */
112 #if (WITH_TARGET_ADDRESS_BITSIZE == 64)
113 typedef unsigned64 unsigned_address;
114 typedef signed64 signed_address;
115 #endif
116 #if (WITH_TARGET_ADDRESS_BITSIZE == 32)
117 typedef unsigned32 unsigned_address;
118 typedef signed32 signed_address;
119 #endif
120 #if (WITH_TARGET_ADDRESS_BITSIZE == 16)
121 typedef unsigned16 unsigned_address;
122 typedef signed16 signed_address;
123 #endif
124 typedef unsigned_address address_word;
125
126
127 /* IEEE 1275 cell size */
128 #if (WITH_TARGET_CELL_BITSIZE == 64)
129 typedef unsigned64 unsigned_cell;
130 typedef signed64 signed_cell;
131 #endif
132 #if (WITH_TARGET_CELL_BITSIZE == 32)
133 typedef unsigned32 unsigned_cell;
134 typedef signed32 signed_cell;
135 #endif
136 typedef signed_cell cell_word; /* cells are normally signed */
137
138
139 /* Floating point registers */
140 #if (WITH_TARGET_FLOATING_POINT_BITSIZE == 64)
141 typedef unsigned64 fp_word;
142 #endif
143 #if (WITH_TARGET_FLOATING_POINT_BITSIZE == 32)
144 typedef unsigned32 fp_word;
145 #endif
146
147 #endif