]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/ppc/sim-endian.c
sim: create a makefile fragment to pass common settings down
[thirdparty/binutils-gdb.git] / sim / ppc / sim-endian.c
CommitLineData
c906108c
SS
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
3fd725ef 7 the Free Software Foundation; either version 3 of the License, or
c906108c
SS
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
51b318de 16 along with this program; if not, see <http://www.gnu.org/licenses/>.
c906108c
SS
17
18 */
19
20
21#ifndef _SIM_ENDIAN_C_
22#define _SIM_ENDIAN_C_
23
6df01ab8
MF
24/* This must come before any other includes. */
25#include "defs.h"
26
c906108c 27#include "basics.h"
b778e6b0 28#include "symcat.h"
c906108c
SS
29
30
31#if !defined(_SWAP_1)
32#define _SWAP_1(SET,RAW) SET (RAW)
33#endif
34
956f0bab 35#if !defined(_SWAP_2) && (HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE) && defined(htons)
c906108c
SS
36#define _SWAP_2(SET,RAW) SET htons (RAW)
37#endif
38
39#ifndef _SWAP_2
40#define _SWAP_2(SET,RAW) SET (((RAW) >> 8) | ((RAW) << 8))
41#endif
42
956f0bab 43#if !defined(_SWAP_4) && (HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE) && defined(htonl)
c906108c
SS
44#define _SWAP_4(SET,RAW) SET htonl (RAW)
45#endif
46
47#ifndef _SWAP_4
48#define _SWAP_4(SET,RAW) SET (((RAW) << 24) | (((RAW) & 0xff00) << 8) | (((RAW) & 0xff0000) >> 8) | ((RAW) >> 24))
49#endif
50
51#ifndef _SWAP_8
52#define _SWAP_8(SET,RAW) \
53 union { unsigned_8 dword; unsigned_4 words[2]; } in, out; \
54 in.dword = RAW; \
55 _SWAP_4 (out.words[0] =, in.words[1]); \
56 _SWAP_4 (out.words[1] =, in.words[0]); \
57 SET out.dword;
58#endif
59
60#define N 1
61#include "sim-endian-n.h"
62#undef N
63
64#define N 2
65#include "sim-endian-n.h"
66#undef N
67
68#define N 4
69#include "sim-endian-n.h"
70#undef N
71
72#define N 8
73#include "sim-endian-n.h"
74#undef N
75
76#endif /* _SIM_ENDIAN_C_ */