[src/erc32] Use ncurses instead of termcap on Cygwin too
[binutils-gdb.git] / sim / ppc / sim-endian.c
blob1ffa2d7e4eb7de84d0dedb010580fb6cec644ac5
1 /* This file is part of the program psim.
3 Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
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.
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.
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/>.
21 #ifndef _SIM_ENDIAN_C_
22 #define _SIM_ENDIAN_C_
24 #include "config.h"
25 #include "basics.h"
28 #if !defined(_SWAP_1)
29 #define _SWAP_1(SET,RAW) SET (RAW)
30 #endif
32 #if !defined(_SWAP_2) && (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && defined(htons)
33 #define _SWAP_2(SET,RAW) SET htons (RAW)
34 #endif
36 #ifndef _SWAP_2
37 #define _SWAP_2(SET,RAW) SET (((RAW) >> 8) | ((RAW) << 8))
38 #endif
40 #if !defined(_SWAP_4) && (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && defined(htonl)
41 #define _SWAP_4(SET,RAW) SET htonl (RAW)
42 #endif
44 #ifndef _SWAP_4
45 #define _SWAP_4(SET,RAW) SET (((RAW) << 24) | (((RAW) & 0xff00) << 8) | (((RAW) & 0xff0000) >> 8) | ((RAW) >> 24))
46 #endif
48 #ifndef _SWAP_8
49 #define _SWAP_8(SET,RAW) \
50 union { unsigned_8 dword; unsigned_4 words[2]; } in, out; \
51 in.dword = RAW; \
52 _SWAP_4 (out.words[0] =, in.words[1]); \
53 _SWAP_4 (out.words[1] =, in.words[0]); \
54 SET out.dword;
55 #endif
57 #define N 1
58 #include "sim-endian-n.h"
59 #undef N
61 #define N 2
62 #include "sim-endian-n.h"
63 #undef N
65 #define N 4
66 #include "sim-endian-n.h"
67 #undef N
69 #define N 8
70 #include "sim-endian-n.h"
71 #undef N
73 #endif /* _SIM_ENDIAN_C_ */