OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [sim/] [ppc/] [sim-endian.c] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 jlechner
/*  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
#include "config.h"
26
#include "basics.h"
27
 
28
 
29
#if !defined(_SWAP_1)
30
#define _SWAP_1(SET,RAW) SET (RAW)
31
#endif
32
 
33
#if !defined(_SWAP_2) && (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && defined(htons)
34
#define _SWAP_2(SET,RAW) SET htons (RAW)
35
#endif
36
 
37
#ifndef _SWAP_2
38
#define _SWAP_2(SET,RAW) SET (((RAW) >> 8) | ((RAW) << 8))
39
#endif
40
 
41
#if !defined(_SWAP_4) && (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && defined(htonl)
42
#define _SWAP_4(SET,RAW) SET htonl (RAW)
43
#endif
44
 
45
#ifndef _SWAP_4
46
#define _SWAP_4(SET,RAW) SET (((RAW) << 24) | (((RAW) & 0xff00) << 8) | (((RAW) & 0xff0000) >> 8) | ((RAW) >> 24))
47
#endif
48
 
49
#ifndef _SWAP_8
50
#define _SWAP_8(SET,RAW) \
51
  union { unsigned_8 dword; unsigned_4 words[2]; } in, out; \
52
  in.dword = RAW; \
53
  _SWAP_4 (out.words[0] =, in.words[1]); \
54
  _SWAP_4 (out.words[1] =, in.words[0]); \
55
  SET out.dword;
56
#endif
57
 
58
#define N 1
59
#include "sim-endian-n.h"
60
#undef N
61
 
62
#define N 2
63
#include "sim-endian-n.h"
64
#undef N
65
 
66
#define N 4
67
#include "sim-endian-n.h"
68
#undef N
69
 
70
#define N 8
71
#include "sim-endian-n.h"
72
#undef N
73
 
74
#endif /* _SIM_ENDIAN_C_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.