AlterOffice
AlterOffice 2026.2 SDK C/C++ API Reference
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
#ifndef INCLUDED_OSL_ENDIAN_H
5
#define INCLUDED_OSL_ENDIAN_H
6
7
#include "
sal/types.h
"
8
9
#ifdef __cplusplus
10
extern
"C"
{
11
#endif
12
16
#if defined _WIN32
17
# if defined _M_ALPHA || defined _M_AMD64 || defined _M_IX86 \
18
|| defined _M_MRX000 || defined _M_PPC || defined _M_ARM64
19
# define OSL_LITENDIAN
20
# endif
21
#elif defined ANDROID || defined LINUX || defined HAIKU
22
# include <
endian.h
>
23
# if __BYTE_ORDER == __LITTLE_ENDIAN
24
# define OSL_LITENDIAN
25
# elif __BYTE_ORDER == __BIG_ENDIAN
26
# define OSL_BIGENDIAN
27
# endif
28
#elif defined IOS || defined MACOSX || defined NETBSD
29
# include <machine/endian.h>
30
# if BYTE_ORDER == LITTLE_ENDIAN
31
# define OSL_LITENDIAN
32
# elif BYTE_ORDER == BIG_ENDIAN
33
# define OSL_BIGENDIAN
34
# endif
35
#elif defined FREEBSD
36
# include <sys/param.h>
37
# include <machine/endian.h>
38
# if defined _LITTLE_ENDIAN
39
# define OSL_LITENDIAN
40
# elif defined _BIG_ENDIAN
41
# define OSL_BIGENDIAN
42
# endif
43
#elif defined AIX
44
# include <sys/machine.h>
45
# if BYTE_ORDER == LITTLE_ENDIAN
46
# define OSL_LITENDIAN
47
# elif BYTE_ORDER == BIG_ENDIAN
48
# define OSL_BIGENDIAN
49
# endif
50
#elif defined __sun
51
# include <sys/isa_defs.h>
52
# if defined _LITTLE_ENDIAN
53
# define OSL_LITENDIAN
54
# elif defined _BIG_ENDIAN
55
# define OSL_BIGENDIAN
56
# endif
57
#elif defined EMSCRIPTEN
58
# define OSL_LITENDIAN
59
#else
60
# error "Target platform not specified !"
61
#endif
62
#if defined OSL_LITENDIAN == defined OSL_BIGENDIAN
63
# error undetermined endianness
64
#endif
65
66
69
#ifndef OSL_MAKEBYTE
70
# define OSL_MAKEBYTE(nl, nh) ((sal_uInt8)(((nl) & 0x0F) | (((nh) & 0x0F) << 4)))
71
#endif
72
#ifndef OSL_LONIBBLE
73
# define OSL_LONIBBLE(b) ((sal_uInt8)((b) & 0x0F))
74
#endif
75
#ifndef OSL_HINIBBLE
76
# define OSL_HINIBBLE(b) ((sal_uInt8)(((b) >> 4) & 0x0F))
77
#endif
78
79
#ifndef OSL_MAKEWORD
80
# define OSL_MAKEWORD(bl, bh) ((sal_uInt16)((sal_uInt16)((bl) & 0xFF) | (((sal_uInt16)(bh) & 0xFF) << 8)))
81
#endif
82
#ifndef OSL_LOBYTE
83
# define OSL_LOBYTE(w) ((sal_uInt8)((sal_uInt16)(w) & 0xFF))
84
#endif
85
#ifndef OSL_HIBYTE
86
# define OSL_HIBYTE(w) ((sal_uInt8)(((sal_uInt16)(w) >> 8) & 0xFF))
87
#endif
88
89
#ifndef OSL_MAKEDWORD
90
# define OSL_MAKEDWORD(wl, wh) ((sal_uInt32)((wl) & 0xFFFF) | (((sal_uInt32)(wh) & 0xFFFF) << 16))
91
#endif
92
#ifndef OSL_LOWORD
93
# define OSL_LOWORD(d) ((sal_uInt16)((sal_uInt32)(d) & 0xFFFF))
94
#endif
95
#ifndef OSL_HIWORD
96
# define OSL_HIWORD(d) ((sal_uInt16)(((sal_uInt32)(d) >> 16) & 0xFFFF))
97
#endif
98
99
102
#ifdef OSL_BIGENDIAN
103
#ifndef OSL_NETWORD
104
# define OSL_NETWORD(w) (sal_uInt16)(w)
105
#endif
106
#ifndef OSL_NETDWORD
107
# define OSL_NETDWORD(d) (sal_uInt32)(d)
108
#endif
109
#else
/* OSL_LITENDIAN */
110
#ifndef OSL_NETWORD
111
# define OSL_NETWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
112
#endif
113
#ifndef OSL_NETDWORD
114
# define OSL_NETDWORD(d) OSL_MAKEDWORD(OSL_NETWORD(OSL_HIWORD(d)),OSL_NETWORD(OSL_LOWORD(d)))
115
#endif
116
#endif
/* OSL_BIGENDIAN */
117
118
121
#ifndef OSL_SWAPWORD
122
# define OSL_SWAPWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w))
123
#endif
124
#ifndef OSL_SWAPDWORD
125
# define OSL_SWAPDWORD(d) OSL_MAKEDWORD(OSL_SWAPWORD(OSL_HIWORD(d)),OSL_SWAPWORD(OSL_LOWORD(d)))
126
#endif
127
128
129
#ifdef __cplusplus
130
}
131
#endif
132
133
#endif
// INCLUDED_OSL_ENDIAN_H
134
135
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
types.h
endian.h
Generated by
1.9.1