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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [sim/] [common/] [sim-n-endian.h] - Blame information for rev 280

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
/* The common simulator framework for GDB, the GNU Debugger.
2
 
3
   Copyright 2002, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4
 
5
   Contributed by Andrew Cagney and Red Hat.
6
 
7
   This file is part of GDB.
8
 
9
   This program is free software; you can redistribute it and/or modify
10
   it under the terms of the GNU General Public License as published by
11
   the Free Software Foundation; either version 3 of the License, or
12
   (at your option) any later version.
13
 
14
   This program is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
   GNU General Public License for more details.
18
 
19
   You should have received a copy of the GNU General Public License
20
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
21
 
22
 
23
#ifndef N
24
#error "N must be #defined"
25
#endif
26
 
27
#include "symcat.h"
28
 
29
/* NOTE: See end of file for #undef */
30
#define unsigned_N XCONCAT2(unsigned_,N)
31
#define endian_t2h_N XCONCAT2(endian_t2h_,N)
32
#define endian_h2t_N XCONCAT2(endian_h2t_,N)
33
#define _SWAP_N XCONCAT2(_SWAP_,N)
34
#define swap_N XCONCAT2(swap_,N)
35
#define endian_h2be_N XCONCAT2(endian_h2be_,N)
36
#define endian_be2h_N XCONCAT2(endian_be2h_,N)
37
#define endian_h2le_N XCONCAT2(endian_h2le_,N)
38
#define endian_le2h_N XCONCAT2(endian_le2h_,N)
39
#define offset_N XCONCAT2(offset_,N)
40
 
41
/* TAGS: endian_t2h_1 endian_t2h_2 endian_t2h_4 endian_t2h_8 endian_t2h_16 */
42
 
43
INLINE_SIM_ENDIAN\
44
(unsigned_N)
45
endian_t2h_N(unsigned_N raw_in)
46
{
47
  if (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER) {
48
    return raw_in;
49
  }
50
  else {
51
    _SWAP_N(return,raw_in);
52
  }
53
}
54
 
55
/* TAGS: endian_h2t_1 endian_h2t_2 endian_h2t_4 endian_h2t_8 endian_h2t_16 */
56
 
57
INLINE_SIM_ENDIAN\
58
(unsigned_N)
59
endian_h2t_N(unsigned_N raw_in)
60
{
61
  if (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER) {
62
    return raw_in;
63
  }
64
  else {
65
    _SWAP_N(return,raw_in);
66
  }
67
}
68
 
69
/* TAGS: swap_1 swap_2 swap_4 swap_8 swap_16 */
70
 
71
INLINE_SIM_ENDIAN\
72
(unsigned_N)
73
swap_N(unsigned_N raw_in)
74
{
75
  _SWAP_N(return,raw_in);
76
}
77
 
78
/* TAGS: endian_h2be_1 endian_h2be_2 endian_h2be_4 endian_h2be_8 endian_h2be_16 */
79
 
80
INLINE_SIM_ENDIAN\
81
(unsigned_N)
82
endian_h2be_N(unsigned_N raw_in)
83
{
84
  if (CURRENT_HOST_BYTE_ORDER == BIG_ENDIAN) {
85
    return raw_in;
86
  }
87
  else {
88
    _SWAP_N(return,raw_in);
89
  }
90
}
91
 
92
/* TAGS: endian_be2h_1 endian_be2h_2 endian_be2h_4 endian_be2h_8 endian_be2h_16 */
93
 
94
INLINE_SIM_ENDIAN\
95
(unsigned_N)
96
endian_be2h_N(unsigned_N raw_in)
97
{
98
  if (CURRENT_HOST_BYTE_ORDER == BIG_ENDIAN) {
99
    return raw_in;
100
  }
101
  else {
102
    _SWAP_N(return,raw_in);
103
  }
104
}
105
 
106
/* TAGS: endian_h2le_1 endian_h2le_2 endian_h2le_4 endian_h2le_8 endian_h2le_16 */
107
 
108
INLINE_SIM_ENDIAN\
109
(unsigned_N)
110
endian_h2le_N(unsigned_N raw_in)
111
{
112
  if (CURRENT_HOST_BYTE_ORDER == LITTLE_ENDIAN) {
113
    return raw_in;
114
  }
115
  else {
116
    _SWAP_N(return,raw_in);
117
  }
118
}
119
 
120
/* TAGS: endian_le2h_1 endian_le2h_2 endian_le2h_4 endian_le2h_8 endian_le2h_16 */
121
 
122
INLINE_SIM_ENDIAN\
123
(unsigned_N)
124
endian_le2h_N(unsigned_N raw_in)
125
{
126
  if (CURRENT_HOST_BYTE_ORDER == LITTLE_ENDIAN) {
127
    return raw_in;
128
  }
129
  else {
130
    _SWAP_N(return,raw_in);
131
  }
132
}
133
 
134
/* TAGS: offset_1 offset_2 offset_4 offset_8 offset_16 */
135
 
136
INLINE_SIM_ENDIAN\
137
(void*)
138
offset_N (unsigned_N *x,
139
          unsigned sizeof_word,
140
          unsigned word)
141
{
142
  char *in = (char*)x;
143
  char *out;
144
  unsigned offset = sizeof_word * word;
145
  ASSERT (offset + sizeof_word <= sizeof(unsigned_N));
146
  ASSERT (word < (sizeof (unsigned_N) / sizeof_word));
147
  ASSERT ((sizeof (unsigned_N) % sizeof_word) == 0);
148
  if (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN)
149
    {
150
      out = in + sizeof (unsigned_N) - offset - sizeof_word;
151
    }
152
  else
153
    {
154
      out = in + offset;
155
    }
156
  return out;
157
}
158
 
159
 
160
/* NOTE: See start of file for #define */
161
#undef unsigned_N
162
#undef endian_t2h_N
163
#undef endian_h2t_N
164
#undef _SWAP_N
165
#undef swap_N
166
#undef endian_h2be_N
167
#undef endian_be2h_N
168
#undef endian_h2le_N
169
#undef endian_le2h_N
170
#undef offset_N

powered by: WebSVN 2.1.0

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