Remove path name from test case
[binutils-gdb.git] / sim / ppc / sim-endian.h
1 /* This file is part of the program psim.
2
3 Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>.
17
18 */
19
20
21 #ifndef _SIM_ENDIAN_H_
22 #define _SIM_ENDIAN_H_
23
24
25 /* C byte conversion functions */
26
27 INLINE_PSIM_ENDIAN(unsigned_1) endian_h2t_1(unsigned_1 x);
28 INLINE_PSIM_ENDIAN(unsigned_2) endian_h2t_2(unsigned_2 x);
29 INLINE_PSIM_ENDIAN(unsigned_4) endian_h2t_4(unsigned_4 x);
30 INLINE_PSIM_ENDIAN(unsigned_8) endian_h2t_8(unsigned_8 x);
31
32 INLINE_PSIM_ENDIAN(unsigned_1) endian_t2h_1(unsigned_1 x);
33 INLINE_PSIM_ENDIAN(unsigned_2) endian_t2h_2(unsigned_2 x);
34 INLINE_PSIM_ENDIAN(unsigned_4) endian_t2h_4(unsigned_4 x);
35 INLINE_PSIM_ENDIAN(unsigned_8) endian_t2h_8(unsigned_8 x);
36
37 INLINE_PSIM_ENDIAN(unsigned_1) swap_1(unsigned_1 x);
38 INLINE_PSIM_ENDIAN(unsigned_2) swap_2(unsigned_2 x);
39 INLINE_PSIM_ENDIAN(unsigned_4) swap_4(unsigned_4 x);
40 INLINE_PSIM_ENDIAN(unsigned_8) swap_8(unsigned_8 x);
41
42 INLINE_PSIM_ENDIAN(unsigned_1) endian_h2be_1(unsigned_1 x);
43 INLINE_PSIM_ENDIAN(unsigned_2) endian_h2be_2(unsigned_2 x);
44 INLINE_PSIM_ENDIAN(unsigned_4) endian_h2be_4(unsigned_4 x);
45 INLINE_PSIM_ENDIAN(unsigned_8) endian_h2be_8(unsigned_8 x);
46
47 INLINE_PSIM_ENDIAN(unsigned_1) endian_be2h_1(unsigned_1 x);
48 INLINE_PSIM_ENDIAN(unsigned_2) endian_be2h_2(unsigned_2 x);
49 INLINE_PSIM_ENDIAN(unsigned_4) endian_be2h_4(unsigned_4 x);
50 INLINE_PSIM_ENDIAN(unsigned_8) endian_be2h_8(unsigned_8 x);
51
52 INLINE_PSIM_ENDIAN(unsigned_1) endian_h2le_1(unsigned_1 x);
53 INLINE_PSIM_ENDIAN(unsigned_2) endian_h2le_2(unsigned_2 x);
54 INLINE_PSIM_ENDIAN(unsigned_4) endian_h2le_4(unsigned_4 x);
55 INLINE_PSIM_ENDIAN(unsigned_8) endian_h2le_8(unsigned_8 x);
56
57 INLINE_PSIM_ENDIAN(unsigned_1) endian_le2h_1(unsigned_1 x);
58 INLINE_PSIM_ENDIAN(unsigned_2) endian_le2h_2(unsigned_2 x);
59 INLINE_PSIM_ENDIAN(unsigned_4) endian_le2h_4(unsigned_4 x);
60 INLINE_PSIM_ENDIAN(unsigned_8) endian_le2h_8(unsigned_8 x);
61
62
63 /* SWAP */
64
65 #define SWAP_1 swap_1
66 #define SWAP_2 swap_2
67 #define SWAP_4 swap_4
68 #define SWAP_8 swap_8
69
70
71 /* HOST to BE */
72
73 #define H2BE_1 endian_h2be_1
74 #define H2BE_2 endian_h2be_2
75 #define H2BE_4 endian_h2be_4
76 #define H2BE_8 endian_h2be_8
77 #define BE2H_1 endian_be2h_1
78 #define BE2H_2 endian_be2h_2
79 #define BE2H_4 endian_be2h_4
80 #define BE2H_8 endian_be2h_8
81
82
83 /* HOST to LE */
84
85 #define H2LE_1 endian_h2le_1
86 #define H2LE_2 endian_h2le_2
87 #define H2LE_4 endian_h2le_4
88 #define H2LE_8 endian_h2le_8
89 #define LE2H_1 endian_le2h_1
90 #define LE2H_2 endian_le2h_2
91 #define LE2H_4 endian_le2h_4
92 #define LE2H_8 endian_le2h_8
93
94
95 /* HOST to TARGET */
96
97 #define H2T_1 endian_h2t_1
98 #define H2T_2 endian_h2t_2
99 #define H2T_4 endian_h2t_4
100 #define H2T_8 endian_h2t_8
101 #define T2H_1 endian_t2h_1
102 #define T2H_2 endian_t2h_2
103 #define T2H_4 endian_t2h_4
104 #define T2H_8 endian_t2h_8
105
106
107 /* CONVERT IN PLACE
108
109 These macros, given an argument of unknown size, swap its value in
110 place if a host/target conversion is required. */
111
112 #define H2T(VARIABLE) \
113 do { \
114 switch (sizeof(VARIABLE)) { \
115 case 1: VARIABLE = H2T_1(VARIABLE); break; \
116 case 2: VARIABLE = H2T_2(VARIABLE); break; \
117 case 4: VARIABLE = H2T_4(VARIABLE); break; \
118 case 8: VARIABLE = H2T_8(VARIABLE); break; \
119 } \
120 } while (0)
121
122 #define T2H(VARIABLE) \
123 do { \
124 switch (sizeof(VARIABLE)) { \
125 case 1: VARIABLE = T2H_1(VARIABLE); break; \
126 case 2: VARIABLE = T2H_2(VARIABLE); break; \
127 case 4: VARIABLE = T2H_4(VARIABLE); break; \
128 case 8: VARIABLE = T2H_8(VARIABLE); break; \
129 } \
130 } while (0)
131
132 #define SWAP(VARIABLE) \
133 do { \
134 switch (sizeof(VARIABLE)) { \
135 case 1: VARIABLE = SWAP_1(VARIABLE); break; \
136 case 2: VARIABLE = SWAP_2(VARIABLE); break; \
137 case 4: VARIABLE = SWAP_4(VARIABLE); break; \
138 case 8: VARIABLE = SWAP_8(VARIABLE); break; \
139 } \
140 } while (0)
141
142 #define H2BE(VARIABLE) \
143 do { \
144 switch (sizeof(VARIABLE)) { \
145 case 1: VARIABLE = H2BE_1(VARIABLE); break; \
146 case 2: VARIABLE = H2BE_2(VARIABLE); break; \
147 case 4: VARIABLE = H2BE_4(VARIABLE); break; \
148 case 8: VARIABLE = H2BE_8(VARIABLE); break; \
149 } \
150 } while (0)
151
152 #define BE2H(VARIABLE) \
153 do { \
154 switch (sizeof(VARIABLE)) { \
155 case 1: VARIABLE = BE2H_1(VARIABLE); break; \
156 case 2: VARIABLE = BE2H_2(VARIABLE); break; \
157 case 4: VARIABLE = BE2H_4(VARIABLE); break; \
158 case 8: VARIABLE = BE2H_8(VARIABLE); break; \
159 } \
160 } while (0)
161
162 #define H2LE(VARIABLE) \
163 do { \
164 switch (sizeof(VARIABLE)) { \
165 case 1: VARIABLE = H2LE_1(VARIABLE); break; \
166 case 2: VARIABLE = H2LE_2(VARIABLE); break; \
167 case 4: VARIABLE = H2LE_4(VARIABLE); break; \
168 case 8: VARIABLE = H2LE_8(VARIABLE); break; \
169 } \
170 } while (0)
171
172 #define LE2H(VARIABLE) \
173 do { \
174 switch (sizeof(VARIABLE)) { \
175 case 1: VARIABLE = LE2H_1(VARIABLE); break; \
176 case 2: VARIABLE = LE2H_2(VARIABLE); break; \
177 case 4: VARIABLE = LE2H_4(VARIABLE); break; \
178 case 8: VARIABLE = LE2H_8(VARIABLE); break; \
179 } \
180 } while (0)
181
182
183
184 /* TARGET WORD:
185
186 Byte swap a quantity the size of the targets word */
187
188 #if (WITH_TARGET_WORD_BITSIZE == 64)
189 #define H2T_word H2T_8
190 #define T2H_word T2H_8
191 #define H2BE_word H2BE_8
192 #define BE2H_word BE2H_8
193 #define H2LE_word H2LE_8
194 #define LE2H_word LE2H_8
195 #define SWAP_word SWAP_8
196 #endif
197 #if (WITH_TARGET_WORD_BITSIZE == 32)
198 #define H2T_word H2T_4
199 #define T2H_word T2H_4
200 #define H2BE_word H2BE_4
201 #define BE2H_word BE2H_4
202 #define H2LE_word H2LE_4
203 #define LE2H_word LE2H_4
204 #define SWAP_word SWAP_4
205 #endif
206
207
208 /* TARGET CELL:
209
210 Byte swap a quantity the size of the targets IEEE 1275 memory cell */
211
212 #define H2T_cell H2T_4
213 #define T2H_cell T2H_4
214 #define H2BE_cell H2BE_4
215 #define BE2H_cell BE2H_4
216 #define H2LE_cell H2LE_4
217 #define LE2H_cell LE2H_4
218 #define SWAP_cell SWAP_4
219
220
221 #if (SIM_ENDIAN_INLINE & INCLUDE_MODULE)
222 # include "sim-endian.c"
223 #endif
224
225 #endif /* _SIM_ENDIAN_H_ */