|
UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /* 00003 * This file is part of the LibreOffice project. 00004 * 00005 * This Source Code Form is subject to the terms of the Mozilla Public 00006 * License, v. 2.0. If a copy of the MPL was not distributed with this 00007 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 00008 * 00009 * This file incorporates work covered by the following license notice: 00010 * 00011 * Licensed to the Apache Software Foundation (ASF) under one or more 00012 * contributor license agreements. See the NOTICE file distributed 00013 * with this work for additional information regarding copyright 00014 * ownership. The ASF licenses this file to you under the Apache 00015 * License, Version 2.0 (the "License"); you may not use this file 00016 * except in compliance with the License. You may obtain a copy of 00017 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 00018 */ 00019 00020 #ifndef _OSL_ENDIAN_H_ 00021 #define _OSL_ENDIAN_H_ 00022 00023 #include <sal/types.h> 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00031 #ifdef _WIN32 00032 # if defined(_M_IX86) 00033 # define _LITTLE_ENDIAN 00034 # elif defined(_M_AMD64) 00035 # define _LITTLE_ENDIAN 00036 # elif defined(_M_MRX000) 00037 # define _LITTLE_ENDIAN 00038 # elif defined(_M_ALPHA) 00039 # define _LITTLE_ENDIAN 00040 # elif defined(_M_PPC) 00041 # define _LITTLE_ENDIAN 00042 # endif 00043 #endif 00044 00045 #ifdef LINUX 00046 # include <endian.h> 00047 # if __BYTE_ORDER == __LITTLE_ENDIAN 00048 # ifndef _LITTLE_ENDIAN 00049 # define _LITTLE_ENDIAN 00050 # endif 00051 # elif __BYTE_ORDER == __BIG_ENDIAN 00052 # ifndef _BIG_ENDIAN 00053 # define _BIG_ENDIAN 00054 # endif 00055 # endif 00056 #endif 00057 00058 #ifdef ANDROID 00059 # include <endian.h> 00060 # if __BYTE_ORDER == __LITTLE_ENDIAN 00061 # ifndef _LITTLE_ENDIAN 00062 # define _LITTLE_ENDIAN 00063 # endif 00064 # elif __BYTE_ORDER == __BIG_ENDIAN 00065 # ifndef _BIG_ENDIAN 00066 # define _BIG_ENDIAN 00067 # endif 00068 # endif 00069 #endif 00070 00071 #ifdef NETBSD 00072 # include <machine/endian.h> 00073 # if BYTE_ORDER == LITTLE_ENDIAN 00074 # undef _BIG_ENDIAN 00075 # elif BYTE_ORDER == BIG_ENDIAN 00076 # undef _LITTLE_ENDIAN 00077 # endif 00078 #endif 00079 00080 #ifdef FREEBSD 00081 # include <sys/param.h> 00082 # include <machine/endian.h> 00083 #if __FreeBSD_version < 500000 00084 # if BYTE_ORDER == LITTLE_ENDIAN 00085 # define _LITTLE_ENDIAN 00086 # elif BYTE_ORDER == BIG_ENDIAN 00087 # define _BIG_ENDIAN 00088 # endif 00089 #endif 00090 #endif 00091 00092 #ifdef AIX 00093 # include <sys/machine.h> 00094 # if BYTE_ORDER == LITTLE_ENDIAN 00095 # ifndef _LITTLE_ENDIAN 00096 # define _LITTLE_ENDIAN 00097 # endif 00098 # elif BYTE_ORDER == BIG_ENDIAN 00099 # ifndef _BIG_ENDIAN 00100 # define _BIG_ENDIAN 00101 # endif 00102 # endif 00103 #endif 00104 00105 #ifdef SOLARIS 00106 # include <sys/isa_defs.h> 00107 #endif 00108 00109 #ifdef MACOSX 00110 # include <machine/endian.h> 00111 # if BYTE_ORDER == LITTLE_ENDIAN 00112 # ifndef _LITTLE_ENDIAN 00113 # define _LITTLE_ENDIAN 00114 # endif 00115 # elif BYTE_ORDER == BIG_ENDIAN 00116 # ifndef _BIG_ENDIAN 00117 # define _BIG_ENDIAN 00118 # endif 00119 # endif 00120 #endif 00121 00122 #ifdef IOS 00123 # include <machine/endian.h> 00124 # if BYTE_ORDER == LITTLE_ENDIAN 00125 # ifndef _LITTLE_ENDIAN 00126 # define _LITTLE_ENDIAN 00127 # endif 00128 # elif BYTE_ORDER == BIG_ENDIAN 00129 # ifndef _BIG_ENDIAN 00130 # define _BIG_ENDIAN 00131 # endif 00132 # endif 00133 #endif 00134 00137 #if !defined(_WIN32) && \ 00138 !defined(LINUX) && !defined(NETBSD) && \ 00139 !defined(AIX) && !defined(OPENBSD) && \ 00140 !defined(SOLARIS) && !defined(MACOSX) && !defined(FREEBSD) && \ 00141 !defined(DRAGONFLY) && \ 00142 !defined(IOS) && !defined(ANDROID) 00143 # error "Target platform not specified !" 00144 #endif 00145 00146 00149 #if defined _LITTLE_ENDIAN 00150 # define OSL_LITENDIAN 00151 #elif defined _BIG_ENDIAN 00152 # define OSL_BIGENDIAN 00153 #else 00154 # error undetermined endianess 00155 #endif 00156 00157 00160 #ifndef OSL_MAKEBYTE 00161 # define OSL_MAKEBYTE(nl, nh) ((sal_uInt8)(((nl) & 0x0F) | (((nh) & 0x0F) << 4))) 00162 #endif 00163 #ifndef OSL_LONIBBLE 00164 # define OSL_LONIBBLE(b) ((sal_uInt8)((b) & 0x0F)) 00165 #endif 00166 #ifndef OSL_HINIBBLE 00167 # define OSL_HINIBBLE(b) ((sal_uInt8)(((b) >> 4) & 0x0F)) 00168 #endif 00169 00170 #ifndef OSL_MAKEWORD 00171 # define OSL_MAKEWORD(bl, bh) ((sal_uInt16)((bl) & 0xFF) | (((sal_uInt16)(bh) & 0xFF) << 8)) 00172 #endif 00173 #ifndef OSL_LOBYTE 00174 # define OSL_LOBYTE(w) ((sal_uInt8)((sal_uInt16)(w) & 0xFF)) 00175 #endif 00176 #ifndef OSL_HIBYTE 00177 # define OSL_HIBYTE(w) ((sal_uInt8)(((sal_uInt16)(w) >> 8) & 0xFF)) 00178 #endif 00179 00180 #ifndef OSL_MAKEDWORD 00181 # define OSL_MAKEDWORD(wl, wh) ((sal_uInt32)((wl) & 0xFFFF) | (((sal_uInt32)(wh) & 0xFFFF) << 16)) 00182 #endif 00183 #ifndef OSL_LOWORD 00184 # define OSL_LOWORD(d) ((sal_uInt16)((sal_uInt32)(d) & 0xFFFF)) 00185 #endif 00186 #ifndef OSL_HIWORD 00187 # define OSL_HIWORD(d) ((sal_uInt16)(((sal_uInt32)(d) >> 16) & 0xFFFF)) 00188 #endif 00189 00190 00193 #ifdef OSL_BIGENDIAN 00194 #ifndef OSL_NETWORD 00195 # define OSL_NETWORD(w) (sal_uInt16)(w) 00196 #endif 00197 #ifndef OSL_NETDWORD 00198 # define OSL_NETDWORD(d) (sal_uInt32)(d) 00199 #endif 00200 #else /* OSL_LITENDIAN */ 00201 #ifndef OSL_NETWORD 00202 # define OSL_NETWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w)) 00203 #endif 00204 #ifndef OSL_NETDWORD 00205 # define OSL_NETDWORD(d) OSL_MAKEDWORD(OSL_NETWORD(OSL_HIWORD(d)),OSL_NETWORD(OSL_LOWORD(d))) 00206 #endif 00207 #endif /* OSL_BIGENDIAN */ 00208 00209 00212 #ifndef OSL_SWAPWORD 00213 # define OSL_SWAPWORD(w) OSL_MAKEWORD(OSL_HIBYTE(w),OSL_LOBYTE(w)) 00214 #endif 00215 #ifndef OSL_SWAPDWORD 00216 # define OSL_SWAPDWORD(d) OSL_MAKEDWORD(OSL_SWAPWORD(OSL_HIWORD(d)),OSL_SWAPWORD(OSL_LOWORD(d))) 00217 #endif 00218 00219 00220 #ifdef __cplusplus 00221 } 00222 #endif 00223 00224 #endif /*_OSL_ENDIAN_H_ */ 00225 00226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1.7.3