LibreOffice
LibreOffice 4.4 SDK 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
* 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
#endif
84
85
#ifdef AIX
86
# include <sys/machine.h>
87
# if BYTE_ORDER == LITTLE_ENDIAN
88
# ifndef _LITTLE_ENDIAN
89
# define _LITTLE_ENDIAN
90
# endif
91
# elif BYTE_ORDER == BIG_ENDIAN
92
# ifndef _BIG_ENDIAN
93
# define _BIG_ENDIAN
94
# endif
95
# endif
96
#endif
97
98
#ifdef SOLARIS
99
# include <sys/isa_defs.h>
100
#endif
101
102
#ifdef MACOSX
103
# include <machine/endian.h>
104
# if BYTE_ORDER == LITTLE_ENDIAN
105
# ifndef _LITTLE_ENDIAN
106
# define _LITTLE_ENDIAN
107
# endif
108
# elif BYTE_ORDER == BIG_ENDIAN
109
# ifndef _BIG_ENDIAN
110
# define _BIG_ENDIAN
111
# endif
112
# endif
113
#endif
114
115
#ifdef IOS
116
# include <machine/endian.h>
117
# if BYTE_ORDER == LITTLE_ENDIAN
118
# ifndef _LITTLE_ENDIAN
119
# define _LITTLE_ENDIAN
120
# endif
121
# elif BYTE_ORDER == BIG_ENDIAN
122
# ifndef _BIG_ENDIAN
123
# define _BIG_ENDIAN
124
# endif
125
# endif
126
#endif
127
130
#if !defined(_WIN32) && \
131
!defined(LINUX) && !defined(NETBSD) && \
132
!defined(AIX) && !defined(OPENBSD) && \
133
!defined(SOLARIS) && !defined(MACOSX) && !defined(FREEBSD) && \
134
!defined(DRAGONFLY) && \
135
!defined(IOS) && !defined(ANDROID)
136
# error "Target platform not specified !"
137
#endif
138
139
142
#if defined _LITTLE_ENDIAN
143
# define OSL_LITENDIAN
144
#elif defined _BIG_ENDIAN
145
# define OSL_BIGENDIAN
146
#else
147
# error undetermined endianness
148
#endif
149
150
153
#ifndef OSL_MAKEBYTE
154
# define OSL_MAKEBYTE(nl, nh) ((sal_uInt8)(((nl) & 0x0F) | (((nh) & 0x0F) << 4)))
155
#endif
156
#ifndef OSL_LONIBBLE
157
# define OSL_LONIBBLE(b) ((sal_uInt8)((b) & 0x0F))
158
#endif
159
#ifndef OSL_HINIBBLE
160
# define OSL_HINIBBLE(b) ((sal_uInt8)(((b) >> 4) & 0x0F))
161
#endif
162
163
#ifndef OSL_MAKEWORD
164
# define OSL_MAKEWORD(bl, bh) ((sal_uInt16)((bl) & 0xFF) | (((sal_uInt16)(bh) & 0xFF) << 8))
165
#endif
166
#ifndef OSL_LOBYTE
167
# define OSL_LOBYTE(w) ((sal_uInt8)((sal_uInt16)(w) & 0xFF))
168
#endif
169
#ifndef OSL_HIBYTE
170
# define OSL_HIBYTE(w) ((sal_uInt8)(((sal_uInt16)(w) >> 8) & 0xFF))
171
#endif
172
173
#ifndef OSL_MAKEDWORD
174
# define OSL_MAKEDWORD(wl, wh) ((sal_uInt32)((wl) & 0xFFFF) | (((sal_uInt32)(wh) & 0xFFFF) << 16))
175
#endif
176
#ifndef OSL_LOWORD
177
# define OSL_LOWORD(d) ((sal_uInt16)((sal_uInt32)(d) & 0xFFFF))
178
#endif
179
#ifndef OSL_HIWORD
180
# define OSL_HIWORD(d) ((sal_uInt16)(((sal_uInt32)(d) >> 16) & 0xFFFF))
181
#endif
182
183
186
#ifdef OSL_BIGENDIAN
187
#ifndef OSL_NETWORD
188
# define OSL_NETWORD(w) (sal_uInt16)(w)
189
#endif
190
#ifndef OSL_NETDWORD
191
# define OSL_NETDWORD(d) (sal_uInt32)(d)
192
#endif
193
#else
/* OSL_LITENDIAN */
194
#ifndef OSL_NETWORD
195
# define OSL_NETWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
196
#endif
197
#ifndef OSL_NETDWORD
198
# define OSL_NETDWORD(d) OSL_MAKEDWORD(OSL_NETWORD(OSL_HIWORD(d)),OSL_NETWORD(OSL_LOWORD(d)))
199
#endif
200
#endif
/* OSL_BIGENDIAN */
201
202
205
#ifndef OSL_SWAPWORD
206
# define OSL_SWAPWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
207
#endif
208
#ifndef OSL_SWAPDWORD
209
# define OSL_SWAPDWORD(d) OSL_MAKEDWORD(OSL_SWAPWORD(OSL_HIWORD(d)),OSL_SWAPWORD(OSL_LOWORD(d)))
210
#endif
211
212
213
#ifdef __cplusplus
214
}
215
#endif
216
217
#endif // INCLUDED_OSL_ENDIAN_H
218
219
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
endian.h
types.h
Generated on Wed Jul 1 2015 07:11:08 for LibreOffice by
1.8.8