My Project
UDK 3.2.7 C/C++ API Reference
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
osl
endian.h
Go to the documentation of this file.
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*************************************************************************
3
*
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* Copyright 2000, 2010 Oracle and/or its affiliates.
7
*
8
* OpenOffice.org - a multi-platform office productivity suite
9
*
10
* This file is part of OpenOffice.org.
11
*
12
* OpenOffice.org is free software: you can redistribute it and/or modify
13
* it under the terms of the GNU Lesser General Public License version 3
14
* only, as published by the Free Software Foundation.
15
*
16
* OpenOffice.org is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License version 3 for more details
20
* (a copy is included in the LICENSE file that accompanied this code).
21
*
22
* You should have received a copy of the GNU Lesser General Public License
23
* version 3 along with OpenOffice.org. If not, see
24
* <http://www.openoffice.org/license.html>
25
* for a copy of the LGPLv3 License.
26
*
27
************************************************************************/
28
29
#ifndef _OSL_ENDIAN_H_
30
#define _OSL_ENDIAN_H_
31
32
#include <
sal/types.h
>
33
34
#ifdef __cplusplus
35
extern
"C"
{
36
#endif
37
40
#ifdef _WIN32
41
# if defined(_M_IX86)
42
# define _LITTLE_ENDIAN
43
# elif defined(_M_AMD64)
44
# define _LITTLE_ENDIAN
45
# elif defined(_M_MRX000)
46
# define _LITTLE_ENDIAN
47
# elif defined(_M_ALPHA)
48
# define _LITTLE_ENDIAN
49
# elif defined(_M_PPC)
50
# define _LITTLE_ENDIAN
51
# endif
52
#endif
53
54
#ifdef LINUX
55
# include <
endian.h
>
56
# if __BYTE_ORDER == __LITTLE_ENDIAN
57
# ifndef _LITTLE_ENDIAN
58
# define _LITTLE_ENDIAN
59
# endif
60
# elif __BYTE_ORDER == __BIG_ENDIAN
61
# ifndef _BIG_ENDIAN
62
# define _BIG_ENDIAN
63
# endif
64
# endif
65
#endif
66
67
#ifdef ANDROID
68
# include <
endian.h
>
69
# if __BYTE_ORDER == __LITTLE_ENDIAN
70
# ifndef _LITTLE_ENDIAN
71
# define _LITTLE_ENDIAN
72
# endif
73
# elif __BYTE_ORDER == __BIG_ENDIAN
74
# ifndef _BIG_ENDIAN
75
# define _BIG_ENDIAN
76
# endif
77
# endif
78
#endif
79
80
#ifdef NETBSD
81
# include <machine/endian.h>
82
# if BYTE_ORDER == LITTLE_ENDIAN
83
# undef _BIG_ENDIAN
84
# elif BYTE_ORDER == BIG_ENDIAN
85
# undef _LITTLE_ENDIAN
86
# endif
87
#endif
88
89
#ifdef FREEBSD
90
# include <sys/param.h>
91
# include <machine/endian.h>
92
#if __FreeBSD_version < 500000
93
# if BYTE_ORDER == LITTLE_ENDIAN
94
# define _LITTLE_ENDIAN
95
# elif BYTE_ORDER == BIG_ENDIAN
96
# define _BIG_ENDIAN
97
# endif
98
#endif
99
#endif
100
101
#ifdef AIX
102
# include <sys/machine.h>
103
# if BYTE_ORDER == LITTLE_ENDIAN
104
# ifndef _LITTLE_ENDIAN
105
# define _LITTLE_ENDIAN
106
# endif
107
# elif BYTE_ORDER == BIG_ENDIAN
108
# ifndef _BIG_ENDIAN
109
# define _BIG_ENDIAN
110
# endif
111
# endif
112
#endif
113
114
#ifdef SOLARIS
115
# include <sys/isa_defs.h>
116
#endif
117
118
#ifdef MACOSX
119
# include <machine/endian.h>
120
# if BYTE_ORDER == LITTLE_ENDIAN
121
# ifndef _LITTLE_ENDIAN
122
# define _LITTLE_ENDIAN
123
# endif
124
# elif BYTE_ORDER == BIG_ENDIAN
125
# ifndef _BIG_ENDIAN
126
# define _BIG_ENDIAN
127
# endif
128
# endif
129
#endif
130
131
#ifdef IOS
132
# include <machine/endian.h>
133
# if BYTE_ORDER == LITTLE_ENDIAN
134
# ifndef _LITTLE_ENDIAN
135
# define _LITTLE_ENDIAN
136
# endif
137
# elif BYTE_ORDER == BIG_ENDIAN
138
# ifndef _BIG_ENDIAN
139
# define _BIG_ENDIAN
140
# endif
141
# endif
142
#endif
143
146
#if !defined(_WIN32) && \
147
!defined(LINUX) && !defined(NETBSD) && \
148
!defined(AIX) && !defined(OPENBSD) && \
149
!defined(SOLARIS) && !defined(MACOSX) && !defined(FREEBSD) && \
150
!defined(DRAGONFLY) && \
151
!defined(IOS) && !defined(ANDROID)
152
# error "Target platform not specified !"
153
#endif
154
155
158
#if defined _LITTLE_ENDIAN
159
# define OSL_LITENDIAN
160
#elif defined _BIG_ENDIAN
161
# define OSL_BIGENDIAN
162
#else
163
# error undetermined endianess
164
#endif
165
166
169
#ifndef OSL_MAKEBYTE
170
# define OSL_MAKEBYTE(nl, nh) ((sal_uInt8)(((nl) & 0x0F) | (((nh) & 0x0F) << 4)))
171
#endif
172
#ifndef OSL_LONIBBLE
173
# define OSL_LONIBBLE(b) ((sal_uInt8)((b) & 0x0F))
174
#endif
175
#ifndef OSL_HINIBBLE
176
# define OSL_HINIBBLE(b) ((sal_uInt8)(((b) >> 4) & 0x0F))
177
#endif
178
179
#ifndef OSL_MAKEWORD
180
# define OSL_MAKEWORD(bl, bh) ((sal_uInt16)((bl) & 0xFF) | (((sal_uInt16)(bh) & 0xFF) << 8))
181
#endif
182
#ifndef OSL_LOBYTE
183
# define OSL_LOBYTE(w) ((sal_uInt8)((sal_uInt16)(w) & 0xFF))
184
#endif
185
#ifndef OSL_HIBYTE
186
# define OSL_HIBYTE(w) ((sal_uInt8)(((sal_uInt16)(w) >> 8) & 0xFF))
187
#endif
188
189
#ifndef OSL_MAKEDWORD
190
# define OSL_MAKEDWORD(wl, wh) ((sal_uInt32)((wl) & 0xFFFF) | (((sal_uInt32)(wh) & 0xFFFF) << 16))
191
#endif
192
#ifndef OSL_LOWORD
193
# define OSL_LOWORD(d) ((sal_uInt16)((sal_uInt32)(d) & 0xFFFF))
194
#endif
195
#ifndef OSL_HIWORD
196
# define OSL_HIWORD(d) ((sal_uInt16)(((sal_uInt32)(d) >> 16) & 0xFFFF))
197
#endif
198
199
202
#ifdef OSL_BIGENDIAN
203
#ifndef OSL_NETWORD
204
# define OSL_NETWORD(w) (sal_uInt16)(w)
205
#endif
206
#ifndef OSL_NETDWORD
207
# define OSL_NETDWORD(d) (sal_uInt32)(d)
208
#endif
209
#else
/* OSL_LITENDIAN */
210
#ifndef OSL_NETWORD
211
# define OSL_NETWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
212
#endif
213
#ifndef OSL_NETDWORD
214
# define OSL_NETDWORD(d) OSL_MAKEDWORD(OSL_NETWORD(OSL_HIWORD(d)),OSL_NETWORD(OSL_LOWORD(d)))
215
#endif
216
#endif
/* OSL_BIGENDIAN */
217
218
221
#ifndef OSL_SWAPWORD
222
# define OSL_SWAPWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
223
#endif
224
#ifndef OSL_SWAPDWORD
225
# define OSL_SWAPDWORD(d) OSL_MAKEDWORD(OSL_SWAPWORD(OSL_HIWORD(d)),OSL_SWAPWORD(OSL_LOWORD(d)))
226
#endif
227
228
229
#ifdef __cplusplus
230
}
231
#endif
232
233
#endif
/*_OSL_ENDIAN_H_ */
234
235
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Generated on Mon Oct 8 2012 00:36:41 for My Project by
1.8.1.2