LibreOffice
LibreOffice 4.3 SDK C/C++ API Reference
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
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
* This file is part of the LibreOffice project.
4
*
5
* This Source Code Form is subject to the terms of the Mozilla Public
6
* License, v. 2.0. If a copy of the MPL was not distributed with this
7
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
*
9
* This file incorporates work covered by the following license notice:
10
*
11
* Licensed to the Apache Software Foundation (ASF) under one or more
12
* contributor license agreements. See the NOTICE file distributed
13
* with this work for additional information regarding copyright
14
* ownership. The ASF licenses this file to you under the Apache
15
* License, Version 2.0 (the "License"); you may not use this file
16
* except in compliance with the License. You may obtain a copy of
17
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
*/
19
20
#ifndef INCLUDED_OSL_ENDIAN_H
21
#define INCLUDED_OSL_ENDIAN_H
22
23
#include <
sal/types.h
>
24
25
#ifdef __cplusplus
26
extern
"C"
{
27
#endif
28
31
#ifdef _WIN32
32
# if defined(_M_IX86)
33
# define _LITTLE_ENDIAN
34
# elif defined(_M_AMD64)
35
# define _LITTLE_ENDIAN
36
# elif defined(_M_MRX000)
37
# define _LITTLE_ENDIAN
38
# elif defined(_M_ALPHA)
39
# define _LITTLE_ENDIAN
40
# elif defined(_M_PPC)
41
# define _LITTLE_ENDIAN
42
# endif
43
#endif
44
45
#ifdef LINUX
46
# include <
endian.h
>
47
# if __BYTE_ORDER == __LITTLE_ENDIAN
48
# ifndef _LITTLE_ENDIAN
49
# define _LITTLE_ENDIAN
50
# endif
51
# elif __BYTE_ORDER == __BIG_ENDIAN
52
# ifndef _BIG_ENDIAN
53
# define _BIG_ENDIAN
54
# endif
55
# endif
56
#endif
57
58
#ifdef ANDROID
59
# include <
endian.h
>
60
# if __BYTE_ORDER == __LITTLE_ENDIAN
61
# ifndef _LITTLE_ENDIAN
62
# define _LITTLE_ENDIAN
63
# endif
64
# elif __BYTE_ORDER == __BIG_ENDIAN
65
# ifndef _BIG_ENDIAN
66
# define _BIG_ENDIAN
67
# endif
68
# endif
69
#endif
70
71
#ifdef NETBSD
72
# include <machine/endian.h>
73
# if BYTE_ORDER == LITTLE_ENDIAN
74
# undef _BIG_ENDIAN
75
# elif BYTE_ORDER == BIG_ENDIAN
76
# undef _LITTLE_ENDIAN
77
# endif
78
#endif
79
80
#ifdef FREEBSD
81
# include <sys/param.h>
82
# include <machine/endian.h>
83
#if __FreeBSD_version < 500000
84
# if BYTE_ORDER == LITTLE_ENDIAN
85
# define _LITTLE_ENDIAN
86
# elif BYTE_ORDER == BIG_ENDIAN
87
# define _BIG_ENDIAN
88
# endif
89
#endif
90
#endif
91
92
#ifdef AIX
93
# include <sys/machine.h>
94
# if BYTE_ORDER == LITTLE_ENDIAN
95
# ifndef _LITTLE_ENDIAN
96
# define _LITTLE_ENDIAN
97
# endif
98
# elif BYTE_ORDER == BIG_ENDIAN
99
# ifndef _BIG_ENDIAN
100
# define _BIG_ENDIAN
101
# endif
102
# endif
103
#endif
104
105
#ifdef SOLARIS
106
# include <sys/isa_defs.h>
107
#endif
108
109
#ifdef MACOSX
110
# include <machine/endian.h>
111
# if BYTE_ORDER == LITTLE_ENDIAN
112
# ifndef _LITTLE_ENDIAN
113
# define _LITTLE_ENDIAN
114
# endif
115
# elif BYTE_ORDER == BIG_ENDIAN
116
# ifndef _BIG_ENDIAN
117
# define _BIG_ENDIAN
118
# endif
119
# endif
120
#endif
121
122
#ifdef IOS
123
# include <machine/endian.h>
124
# if BYTE_ORDER == LITTLE_ENDIAN
125
# ifndef _LITTLE_ENDIAN
126
# define _LITTLE_ENDIAN
127
# endif
128
# elif BYTE_ORDER == BIG_ENDIAN
129
# ifndef _BIG_ENDIAN
130
# define _BIG_ENDIAN
131
# endif
132
# endif
133
#endif
134
137
#if !defined(_WIN32) && \
138
!defined(LINUX) && !defined(NETBSD) && \
139
!defined(AIX) && !defined(OPENBSD) && \
140
!defined(SOLARIS) && !defined(MACOSX) && !defined(FREEBSD) && \
141
!defined(DRAGONFLY) && \
142
!defined(IOS) && !defined(ANDROID)
143
# error "Target platform not specified !"
144
#endif
145
146
149
#if defined _LITTLE_ENDIAN
150
# define OSL_LITENDIAN
151
#elif defined _BIG_ENDIAN
152
# define OSL_BIGENDIAN
153
#else
154
# error undetermined endianness
155
#endif
156
157
160
#ifndef OSL_MAKEBYTE
161
# define OSL_MAKEBYTE(nl, nh) ((sal_uInt8)(((nl) & 0x0F) | (((nh) & 0x0F) << 4)))
162
#endif
163
#ifndef OSL_LONIBBLE
164
# define OSL_LONIBBLE(b) ((sal_uInt8)((b) & 0x0F))
165
#endif
166
#ifndef OSL_HINIBBLE
167
# define OSL_HINIBBLE(b) ((sal_uInt8)(((b) >> 4) & 0x0F))
168
#endif
169
170
#ifndef OSL_MAKEWORD
171
# define OSL_MAKEWORD(bl, bh) ((sal_uInt16)((bl) & 0xFF) | (((sal_uInt16)(bh) & 0xFF) << 8))
172
#endif
173
#ifndef OSL_LOBYTE
174
# define OSL_LOBYTE(w) ((sal_uInt8)((sal_uInt16)(w) & 0xFF))
175
#endif
176
#ifndef OSL_HIBYTE
177
# define OSL_HIBYTE(w) ((sal_uInt8)(((sal_uInt16)(w) >> 8) & 0xFF))
178
#endif
179
180
#ifndef OSL_MAKEDWORD
181
# define OSL_MAKEDWORD(wl, wh) ((sal_uInt32)((wl) & 0xFFFF) | (((sal_uInt32)(wh) & 0xFFFF) << 16))
182
#endif
183
#ifndef OSL_LOWORD
184
# define OSL_LOWORD(d) ((sal_uInt16)((sal_uInt32)(d) & 0xFFFF))
185
#endif
186
#ifndef OSL_HIWORD
187
# define OSL_HIWORD(d) ((sal_uInt16)(((sal_uInt32)(d) >> 16) & 0xFFFF))
188
#endif
189
190
193
#ifdef OSL_BIGENDIAN
194
#ifndef OSL_NETWORD
195
# define OSL_NETWORD(w) (sal_uInt16)(w)
196
#endif
197
#ifndef OSL_NETDWORD
198
# define OSL_NETDWORD(d) (sal_uInt32)(d)
199
#endif
200
#else
/* OSL_LITENDIAN */
201
#ifndef OSL_NETWORD
202
# define OSL_NETWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
203
#endif
204
#ifndef OSL_NETDWORD
205
# define OSL_NETDWORD(d) OSL_MAKEDWORD(OSL_NETWORD(OSL_HIWORD(d)),OSL_NETWORD(OSL_LOWORD(d)))
206
#endif
207
#endif
/* OSL_BIGENDIAN */
208
209
212
#ifndef OSL_SWAPWORD
213
# define OSL_SWAPWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
214
#endif
215
#ifndef OSL_SWAPDWORD
216
# define OSL_SWAPDWORD(d) OSL_MAKEDWORD(OSL_SWAPWORD(OSL_HIWORD(d)),OSL_SWAPWORD(OSL_LOWORD(d)))
217
#endif
218
219
220
#ifdef __cplusplus
221
}
222
#endif
223
224
#endif // INCLUDED_OSL_ENDIAN_H
225
226
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
endian.h
types.h
Generated by
1.8.9.1