lin
2025-07-30 fcd736bf35fd93b563e9bbf594f2aa7b62028cc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/******************************************************************************
 *
 *  Copyright 2014 The Android Open Source Project
 *  Copyright 2002 - 2004 Open Interface North America, Inc. All rights
 *                        reserved.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/
#ifndef _OI_CPU_DEP_H
#define _OI_CPU_DEP_H
 
#include <stdint.h>
 
/**
 * @file
 * This file contains definitions for characteristics of the target CPU and
 * compiler, including primitive data types and endianness.
 *
 * This file defines the byte order and primitive data types for various
 * CPU families. The preprocessor symbol 'CPU' must be defined to be an
 * appropriate value or this header will generate a compile-time error.
 *
 * @note The documentation for this header file uses the x86 family of
 * processors as an illustrative example for CPU/compiler-dependent data type
 * definitions. Go to the source code of this header file to see the details of
 * primitive type definitions for each platform.
 *
 * Additional information is available in the @ref data_types_docpage section.
 */
 
/*******************************************************************************
  $Revision: #1 $
 ******************************************************************************/
 
#ifdef __cplusplus
extern "C" {
#endif
 
/** \addtogroup Misc Miscellaneous APIs */
/**@{*/
 
/** @name Definitions indicating family of target OI_CPU_TYPE
 *  @{
 */
 
#define OI_CPU_X86 1 /**< x86 processor family */
#define OI_CPU_ARM                            \
  2 /**< ARM processor family.                \
         @deprecated Use #OI_CPU_ARM7_LEND or \
         #OI_CPU_ARM7_BEND. */
#define OI_CPU_ARC                                               \
  3                     /**< ARC processor family.               \
                             @deprecated Use #OI_CPU_ARC_LEND or \
                             #OI_CPU_ARC_BEND. */
#define OI_CPU_SH3 4    /**< Hitachi SH-3 processor family */
#define OI_CPU_H8 5     /**< Hitachi H8 processor family */
#define OI_CPU_MIPS 6   /**< MIPS processor family */
#define OI_CPU_SPARC 7  /**< SPARC processor family */
#define OI_CPU_M68000 8 /**< Motorola M68000 processor family */
#define OI_CPU_PPC 9    /**< PowerPC (PPC) processor family */
#define OI_CPU_SH4_7750 \
  10                  /**< Hitachi SH7750 series in SH-4 processor family */
#define OI_CPU_SH2 11 /**< Hitachi SH-2 processor family */
#define OI_CPU_ARM7_LEND 12 /**< ARM7, little-endian */
#define OI_CPU_ARM7_BEND 13 /**< ARM7, big-endian */
#define OI_CPU_GDM1202 14   /**< GCT GDM1202 */
#define OI_CPU_ARC_LEND 15  /**< ARC processor family, little-endian */
#define OI_CPU_ARC_BEND 16  /**< ARC processor family, big-endian */
#define OI_CPU_M30833F 17   /**< Mitsubishi M308 processor family */
#define OI_CPU_CR16C 18  /**< National Semiconductor 16 bit processor family */
#define OI_CPU_M64111 19 /**< Renesas M64111 processor (M32R family) */
#define OI_CPU_ARMV5_LEND 20  //*< ARM5, little-endian */
 
#define OI_CPU_TYPE 12
 
#ifndef OI_CPU_TYPE
#error "OI_CPU_TYPE type not defined"
#endif
 
/**@}*/
 
/** @name Definitions indicating byte-wise endianness of target CPU
 *  @{
 */
 
#define OI_BIG_ENDIAN_BYTE_ORDER                                           \
  0 /**< Multiple-byte values are stored in memory beginning with the most \
       significant byte at the lowest address.  */
#define OI_LITTLE_ENDIAN_BYTE_ORDER                                         \
  1 /**< Multiple-byte values are stored in memory beginning with the least \
       significant byte at the lowest address. */
 
/**@}*/
 
/** @name  CPU/compiler-independent primitive data type definitions
 *  @{
 */
 
typedef int
    OI_BOOL; /**< Boolean values use native integer data type for target CPU. */
typedef int
    OI_INT; /**< Integer values use native integer data type for target CPU. */
typedef unsigned int OI_UINT;  /**< Unsigned integer values use native unsigned
                                  integer data type for target CPU. */
typedef unsigned char OI_BYTE; /**< Raw bytes type uses native character data
                                  type for target CPU. */
typedef uint32_t OI_ELEMENT_UNION; /**< Type for first element of a union to
                                      support all data types up to pointer
                                      width. */
 
/**@}*/
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_X86
 
#define OI_CPU_BYTE_ORDER                                                      \
  OI_LITTLE_ENDIAN_BYTE_ORDER /**< x86 platform byte ordering is little-endian \
                                 */
 
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_ARM
/* This CPU type is deprecated (removed from use). Instead, use OI_CPU_ARM7_LEND
 * or OI_CPU_ARM7_BEND for little-endian or big-endian configurations of the
 * ARM7, respectively. */
#error OI_CPU_ARM is deprecated
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_ARC
/* This CPU type is deprecated (removed from use). Instead, use OI_CPU_ARC_LEND
 * or OI_CPU_ARC_BEND for little-endian or big-endian configurations of the
 * ARC, respectively. */
#error OI_CPU_ARC is deprecated
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_SH3
/* The Hitachi SH C compiler defines _LIT or _BIG, depending on the endianness
    specified to the compiler on the command line. */
#if defined(_LIT)
#define OI_CPU_BYTE_ORDER                                                 \
  OI_LITTLE_ENDIAN_BYTE_ORDER /**< If _LIT is defined, SH-3 platform byte \
                                 ordering is little-endian. */
#elif defined(_BIG)
#define OI_CPU_BYTE_ORDER                                              \
  OI_BIG_ENDIAN_BYTE_ORDER /**< If _BIG is defined, SH-3 platform byte \
                              ordering is big-endian. */
#else
#error SH compiler endianness undefined
#endif
 
#endif
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_SH2
 
#define OI_CPU_BYTE_ORDER \
  OI_BIG_ENDIAN_BYTE_ORDER /**< SH-2 platform byte ordering is big-endian. */
 
#endif
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_H8
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
#error basic types not defined
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_MIPS
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_SPARC
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
#error basic types not defined
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_M68000
#define OI_CPU_BYTE_ORDER                                                    \
  OI_BIG_ENDIAN_BYTE_ORDER /**< M68000 platform byte ordering is big-endian. \
                              */
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_PPC
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_SH4_7750
#define OI_CPU_BYTE_ORDER                                                    \
  OI_BIG_ENDIAN_BYTE_ORDER /**< SH7750 platform byte ordering is big-endian. \
                              */
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_ARM7_LEND
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_ARM7_BEND
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_GDM1202
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_ARC_LEND
 
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_ARC_BEND
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_M30833F
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_CR16C
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_M64111
#define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
#endif
 
/******************************************************************************/
 
#if OI_CPU_TYPE == OI_CPU_ARMV5_LEND
#define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
#endif
 
/******************************************************************************/
 
#ifndef OI_CPU_BYTE_ORDER
#error "Byte order (endian-ness) not defined"
#endif
 
/**@}*/
 
#ifdef __cplusplus
}
#endif
 
/******************************************************************************/
#endif /* _OI_CPU_DEP_H */