]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/ppc/sim-endian.c
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / sim / ppc / sim-endian.c
CommitLineData
73c4941b
MM
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 2 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, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 */
20
21
22#ifndef _SIM_ENDIAN_C_
23#define _SIM_ENDIAN_C_
24
25#ifndef STATIC_INLINE_ENDIAN
26#define STATIC_INLINE_ENDIAN STATIC_INLINE
27#endif
28
29
30#include "config.h"
31#include "basics.h"
32
33
34#if !defined(_SWAP_1)
35#define _SWAP_1(SET,RAW) SET (RAW)
36#endif
37
38#if !defined(_SWAP_2) && (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && WITH_NTOH
39#define _SWAP_2(SET,RAW) SET htons (RAW)
40#endif
41
42#ifndef _SWAP_2
43#define _SWAP_2(SET,RAW) SET (((RAW) >> 8) | ((RAW) << 8))
44#endif
45
46#if !defined(_SWAP_4) && (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && WITH_NTOH
47#define _SWAP_4(SET,RAW) SET htonl (RAW)
48#endif
49
50#ifndef _SWAP_4
51#define _SWAP_4(SET,RAW) SET (((RAW) << 24) | (((RAW) & 0xff00) << 8) | (((RAW) & 0xff0000) >> 8) | ((RAW) >> 24))
52#endif
53
54#ifndef _SWAP_8
55#define _SWAP_8(SET,RAW) \
56 union { unsigned_8 dword; unsigned_4 words[2]; } in, out; \
57 in.dword = RAW; \
58 _SWAP_4 (out.words[0] =, in.words[1]); \
59 _SWAP_4 (out.words[1] =, in.words[0]); \
60 SET out.dword;
61#endif
62
63#undef N
64#define N 1
65#include "sim-endian-n.h"
66
67#undef N
68#define N 2
69#include "sim-endian-n.h"
70
71#undef N
72#define N 4
73#include "sim-endian-n.h"
74
75#undef N
76#define N 8
77#include "sim-endian-n.h"
78
79#endif /* _SIM_ENDIAN_C_ */