LibreOffice
LibreOffice 5.3 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
32
#if defined _WIN32
33
# if defined _M_ALPHA || defined _M_AMD64 || defined _M_IX86 \
34
|| defined _M_MRX000 || defined _M_PPC
35
# define OSL_LITENDIAN
36
# endif
37
#elif defined ANDROID || defined LINUX
38
# include <
endian.h
>
39
# if __BYTE_ORDER == __LITTLE_ENDIAN
40
# define OSL_LITENDIAN
41
# elif __BYTE_ORDER == __BIG_ENDIAN
42
# define OSL_BIGENDIAN
43
# endif
44
#elif defined EMSCRIPTEN
45
# define OSL_LITENDIAN
46
#elif defined IOS || defined MACOSX || defined NETBSD
47
# include <machine/endian.h>
48
# if BYTE_ORDER == LITTLE_ENDIAN
49
# define OSL_LITENDIAN
50
# elif BYTE_ORDER == BIG_ENDIAN
51
# define OSL_BIGENDIAN
52
# endif
53
#elif defined FREEBSD
54
# include <sys/param.h>
55
# include <machine/endian.h>
56
# if defined _LITTLE_ENDIAN
57
# define OSL_LITENDIAN
58
# elif defined _BIG_ENDIAN
59
# define OSL_BIGENDIAN
60
# endif
61
#elif defined AIX
62
# include <sys/machine.h>
63
# if BYTE_ORDER == LITTLE_ENDIAN
64
# define OSL_LITENDIAN
65
# elif BYTE_ORDER == BIG_ENDIAN
66
# define OSL_BIGENDIAN
67
# endif
68
#elif defined SOLARIS
69
# include <sys/isa_defs.h>
70
# if defined _LITTLE_ENDIAN
71
# define OSL_LITENDIAN
72
# elif defined _BIG_ENDIAN
73
# define OSL_BIGENDIAN
74
# endif
75
#else
76
# error "Target platform not specified !"
77
#endif
78
#if defined OSL_LITENDIAN == defined OSL_BIGENDIAN
79
# error undetermined endianness
80
#endif
81
82
85
#ifndef OSL_MAKEBYTE
86
# define OSL_MAKEBYTE(nl, nh) ((sal_uInt8)(((nl) & 0x0F) | (((nh) & 0x0F) << 4)))
87
#endif
88
#ifndef OSL_LONIBBLE
89
# define OSL_LONIBBLE(b) ((sal_uInt8)((b) & 0x0F))
90
#endif
91
#ifndef OSL_HINIBBLE
92
# define OSL_HINIBBLE(b) ((sal_uInt8)(((b) >> 4) & 0x0F))
93
#endif
94
95
#ifndef OSL_MAKEWORD
96
# define OSL_MAKEWORD(bl, bh) ((sal_uInt16)((sal_uInt16)((bl) & 0xFF) | (((sal_uInt16)(bh) & 0xFF) << 8)))
97
#endif
98
#ifndef OSL_LOBYTE
99
# define OSL_LOBYTE(w) ((sal_uInt8)((sal_uInt16)(w) & 0xFF))
100
#endif
101
#ifndef OSL_HIBYTE
102
# define OSL_HIBYTE(w) ((sal_uInt8)(((sal_uInt16)(w) >> 8) & 0xFF))
103
#endif
104
105
#ifndef OSL_MAKEDWORD
106
# define OSL_MAKEDWORD(wl, wh) ((sal_uInt32)((wl) & 0xFFFF) | (((sal_uInt32)(wh) & 0xFFFF) << 16))
107
#endif
108
#ifndef OSL_LOWORD
109
# define OSL_LOWORD(d) ((sal_uInt16)((sal_uInt32)(d) & 0xFFFF))
110
#endif
111
#ifndef OSL_HIWORD
112
# define OSL_HIWORD(d) ((sal_uInt16)(((sal_uInt32)(d) >> 16) & 0xFFFF))
113
#endif
114
115
118
#ifdef OSL_BIGENDIAN
119
#ifndef OSL_NETWORD
120
# define OSL_NETWORD(w) (sal_uInt16)(w)
121
#endif
122
#ifndef OSL_NETDWORD
123
# define OSL_NETDWORD(d) (sal_uInt32)(d)
124
#endif
125
#else
/* OSL_LITENDIAN */
126
#ifndef OSL_NETWORD
127
# define OSL_NETWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
128
#endif
129
#ifndef OSL_NETDWORD
130
# define OSL_NETDWORD(d) OSL_MAKEDWORD(OSL_NETWORD(OSL_HIWORD(d)),OSL_NETWORD(OSL_LOWORD(d)))
131
#endif
132
#endif
/* OSL_BIGENDIAN */
133
134
137
#ifndef OSL_SWAPWORD
138
# define OSL_SWAPWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
139
#endif
140
#ifndef OSL_SWAPDWORD
141
# define OSL_SWAPDWORD(d) OSL_MAKEDWORD(OSL_SWAPWORD(OSL_HIWORD(d)),OSL_SWAPWORD(OSL_LOWORD(d)))
142
#endif
143
144
145
#ifdef __cplusplus
146
}
147
#endif
148
149
#endif // INCLUDED_OSL_ENDIAN_H
150
151
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
endian.h
types.h
Generated by
1.8.5