1*1be3ed10SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*1be3ed10SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1be3ed10SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1be3ed10SAndrew Rist * distributed with this work for additional information 6*1be3ed10SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1be3ed10SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1be3ed10SAndrew Rist * "License"); you may not use this file except in compliance 9*1be3ed10SAndrew Rist * with the License. You may obtain a copy of the License at 10*1be3ed10SAndrew Rist * 11*1be3ed10SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*1be3ed10SAndrew Rist * 13*1be3ed10SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1be3ed10SAndrew Rist * software distributed under the License is distributed on an 15*1be3ed10SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1be3ed10SAndrew Rist * KIND, either express or implied. See the License for the 17*1be3ed10SAndrew Rist * specific language governing permissions and limitations 18*1be3ed10SAndrew Rist * under the License. 19*1be3ed10SAndrew Rist * 20*1be3ed10SAndrew Rist *************************************************************/ 21*1be3ed10SAndrew Rist 22*1be3ed10SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir 25cdf0e10cSrcweir #ifndef _VOS_MACROS_HXX_ 26cdf0e10cSrcweir #define _VOS_MACROS_HXX_ 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <osl/endian.h> 30cdf0e10cSrcweir 31cdf0e10cSrcweir // ********************************************************************* 32cdf0e10cSrcweir // Macro definitions 33cdf0e10cSrcweir 34cdf0e10cSrcweir #ifndef VOS_CAST 35cdf0e10cSrcweir # define VOS_CAST(type,value) (*((type*)&(value))) 36cdf0e10cSrcweir #endif 37cdf0e10cSrcweir 38cdf0e10cSrcweir #ifndef VOS_UNUSED 39cdf0e10cSrcweir # define VOS_UNUSED(x) (x=x) 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir 42cdf0e10cSrcweir #ifndef VOS_FOREVER 43cdf0e10cSrcweir # define VOS_FOREVER for(;;) 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir 46cdf0e10cSrcweir #ifndef VOS_MAX 47cdf0e10cSrcweir # define VOS_MAX(a,b) (((a) > (b)) ? (a) : (b)) 48cdf0e10cSrcweir #endif 49cdf0e10cSrcweir #ifndef VOS_MIN 50cdf0e10cSrcweir # define VOS_MIN(a,b) (((a) < (b)) ? (a) : (b)) 51cdf0e10cSrcweir #endif 52cdf0e10cSrcweir 53cdf0e10cSrcweir #ifndef VOS_ABS 54cdf0e10cSrcweir # define VOS_ABS(a) (((a) < 0) ? (-(a)) : (a)) 55cdf0e10cSrcweir #endif 56cdf0e10cSrcweir #ifndef VOS_SIGN 57cdf0e10cSrcweir # define VOS_SIGN(a) ( ((a) < 0) ? (-1) : (((a) > 0) ? (1) : (0)) ) 58cdf0e10cSrcweir #endif 59cdf0e10cSrcweir 60cdf0e10cSrcweir #ifndef VOS_BOUND 61cdf0e10cSrcweir # define VOS_BOUND(x,l,h) ((x) <= (l) ? (l) : ((x) >= (h) ? (h) : (x))) 62cdf0e10cSrcweir #endif 63cdf0e10cSrcweir 64cdf0e10cSrcweir #ifndef VOS_SWAP 65cdf0e10cSrcweir # define VOS_SWAP(a,b) ((a) ^= (b) ^= (a) ^= (b)) 66cdf0e10cSrcweir #endif 67cdf0e10cSrcweir 68cdf0e10cSrcweir #ifndef VOS_BYTEBOUND 69cdf0e10cSrcweir # define VOS_BYTEBOUND(a) (((a) + 7) / 8) 70cdf0e10cSrcweir #endif 71cdf0e10cSrcweir 72cdf0e10cSrcweir #ifndef VOS_WORDBOUND 73cdf0e10cSrcweir # define VOS_WORDBOUND(a) ((((a) + 15) / 16) * 2) 74cdf0e10cSrcweir #endif 75cdf0e10cSrcweir 76cdf0e10cSrcweir #ifndef VOS_DWORDBOUND 77cdf0e10cSrcweir # define VOS_DWORDBOUND(a) ((((a) + 31) / 32) * 4) 78cdf0e10cSrcweir #endif 79cdf0e10cSrcweir 80cdf0e10cSrcweir #ifndef VOS_MAKEDWORD 81cdf0e10cSrcweir # define VOS_MAKEDWORD(wl, wh) ((sal_uInt32)((wl) & 0xFFFF) | (((sal_uInt32)(wh) & 0xFFFF) << 16)) 82cdf0e10cSrcweir #endif 83cdf0e10cSrcweir #ifndef VOS_LOWORD 84cdf0e10cSrcweir # define VOS_LOWORD(d) ((sal_uInt16)((sal_uInt32)(d) & 0xFFFF)) 85cdf0e10cSrcweir #endif 86cdf0e10cSrcweir #ifndef VOS_HIWORD 87cdf0e10cSrcweir # define VOS_HIWORD(d) ((sal_uInt16)(((sal_uInt32)(d) >> 16) & 0xFFFF)) 88cdf0e10cSrcweir #endif 89cdf0e10cSrcweir #ifndef VOS_MAKEWORD 90cdf0e10cSrcweir # define VOS_MAKEWORD(bl, bh) ((sal_uInt16)((bl) & 0xFF) | (((sal_uInt16)(bh) & 0xFF) << 8)) 91cdf0e10cSrcweir #endif 92cdf0e10cSrcweir #ifndef VOS_LOBYTE 93cdf0e10cSrcweir # define VOS_LOBYTE(w) ((sal_uInt8)((sal_uInt16)(w) & 0xFF)) 94cdf0e10cSrcweir #endif 95cdf0e10cSrcweir #ifndef VOS_HIBYTE 96cdf0e10cSrcweir # define VOS_HIBYTE(w) ((sal_uInt8)(((sal_uInt16)(w) >> 8) & 0xFF)) 97cdf0e10cSrcweir #endif 98cdf0e10cSrcweir #ifndef VOS_MAKEBYTE 99cdf0e10cSrcweir # define VOS_MAKEBYTE(nl, nh) ((sal_uInt8)(((nl) & 0x0F) | (((nh) & 0x0F) << 4))) 100cdf0e10cSrcweir #endif 101cdf0e10cSrcweir #ifndef VOS_LONIBBLE 102cdf0e10cSrcweir # define VOS_LONIBBLE(b) ((sal_uInt8)((b) & 0x0F)) 103cdf0e10cSrcweir #endif 104cdf0e10cSrcweir #ifndef VOS_HINIBBLE 105cdf0e10cSrcweir # define VOS_HINIBBLE(b) ((sal_uInt8)(((b) >> 4) & 0x0F)) 106cdf0e10cSrcweir #endif 107cdf0e10cSrcweir 108cdf0e10cSrcweir #ifndef VOS_SWAPWORD 109cdf0e10cSrcweir # define VOS_SWAPWORD(w) VOS_MAKEWORD(VOS_HIBYTE(w),VOS_LOBYTE(w)) 110cdf0e10cSrcweir #endif 111cdf0e10cSrcweir #ifndef VOS_SWAPDWORD 112cdf0e10cSrcweir # define VOS_SWAPDWORD(d) VOS_MAKEDWORD(VOS_SWAPWORD(VOS_HIWORD(d)),VOS_SWAPWORD(VOS_LOWORD(d))) 113cdf0e10cSrcweir #endif 114cdf0e10cSrcweir 115cdf0e10cSrcweir #ifdef OSL_BIGENDIAN 116cdf0e10cSrcweir #ifndef VOS_NETWORD 117cdf0e10cSrcweir # define VOS_NETWORD(w) (sal_uInt16)(w) 118cdf0e10cSrcweir #endif 119cdf0e10cSrcweir #ifndef VOS_NETDWORD 120cdf0e10cSrcweir # define VOS_NETDWORD(d) (sal_uInt32)(d) 121cdf0e10cSrcweir #endif 122cdf0e10cSrcweir #else // OSL_LITENDIAN 123cdf0e10cSrcweir #ifndef VOS_NETWORD 124cdf0e10cSrcweir # define VOS_NETWORD(w) VOS_MAKEWORD(VOS_HIBYTE(w),VOS_LOBYTE(w)) 125cdf0e10cSrcweir #endif 126cdf0e10cSrcweir #ifndef VOS_NETDWORD 127cdf0e10cSrcweir # define VOS_NETDWORD(d) VOS_MAKEDWORD(VOS_NETWORD(VOS_HIWORD(d)),VOS_NETWORD(VOS_LOWORD(d))) 128cdf0e10cSrcweir #endif 129cdf0e10cSrcweir #endif // OSL_BIGENDIAN 130cdf0e10cSrcweir 131cdf0e10cSrcweir #ifdef _OSL_MEMSEG 132cdf0e10cSrcweir # define VOS_MAKEPTR(base, off) ((void _far *)VOS_MAKEDWORD((off), (base))) 133cdf0e10cSrcweir # define VOS_BASEOF(ptr) VOS_HIWORD(ptr) 134cdf0e10cSrcweir # define VOS_OFSTOF(ptr) VOS_LOWORD(ptr) 135cdf0e10cSrcweir #else 136cdf0e10cSrcweir # define VOS_MAKEPTR(base, off) ((void *)((base) + (off))) 137cdf0e10cSrcweir # define VOS_BASEOF(ptr) (ptr) 138cdf0e10cSrcweir # define VOS_OFSTOF(ptr) 0 139cdf0e10cSrcweir #endif 140cdf0e10cSrcweir 141cdf0e10cSrcweir #ifndef VOS_FIELDOFFSET 142cdf0e10cSrcweir # define VOS_FIELDOFFSET(type, field) ((sal_Int32)(&((type *)1)->field) - 1) 143cdf0e10cSrcweir #endif 144cdf0e10cSrcweir 145cdf0e10cSrcweir // def. for arbitrary namespace 146cdf0e10cSrcweir #define VOS_NAMESPACE(class_name, name_space) name_space::class_name 147cdf0e10cSrcweir 148cdf0e10cSrcweir // sal_Int16 def. for namespace std 149cdf0e10cSrcweir #define NAMESPACE_STD(class_name) std::class_name 150cdf0e10cSrcweir 151cdf0e10cSrcweir #endif //_VOS_MACROS_HXX_ 152cdf0e10cSrcweir 153