|
reSIProcate/rutil
9694
|
00001 #if !defined(RESIP_COMPAT_HXX) 00002 #define RESIP_COMPAT_HXX 00003 00004 #ifdef HAVE_CONFIG_H 00005 #include "config.h" 00006 #endif 00007 00008 00015 #if defined(__INTEL_COMPILER ) && defined( __OPTIMIZE__ ) 00016 # undef __OPTIMIZE__ // weird intel bug with ntohs and htons macros 00017 #endif 00018 00019 //#if defined(HAVE_SYS_INT_TYPES_H) 00020 //#include <sys/int_types.h> 00021 //#endif 00022 00023 #include <cstring> 00024 00025 #ifndef WIN32 00026 # include <netdb.h> 00027 # include <sys/types.h> 00028 # include <sys/time.h> 00029 # include <sys/socket.h> 00030 # include <sys/select.h> 00031 # include <netinet/in.h> 00032 # include <arpa/inet.h> 00033 # include <unistd.h> 00034 # include <pthread.h> 00035 # include <limits.h> 00036 #endif 00037 00038 #ifdef WIN32 00039 // !cj! TODO would be nice to remove this 00040 # ifndef __GNUC__ 00041 # pragma warning(disable : 4996) 00042 # endif 00043 #define WIN32_LEAN_AND_MEAN 00044 # include <windows.h> 00045 # include <winsock2.h> 00046 #undef WIN32_LEAN_AND_MEAN 00047 # include <errno.h> 00048 # include <io.h> 00049 #ifdef UNDER_CE 00050 #include "wince/WceCompat.hxx" 00051 #endif // UNDER_CE 00052 #endif 00053 00054 #if defined(__APPLE__) 00055 // .amr. If you get linker or type conflicts around UInt32, then use this define 00056 # if defined(RESIP_APPLE_USE_SYSTEM_TYPES) 00057 # include <TargetConditionals.h> 00058 # include <CoreServices/CoreServices.h> 00059 # endif 00060 # if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_2 00061 // you don't include the SDK or you're running 10.3 or above 00062 // note: this will fail on 10.2 if you don't include the SDK 00063 # include <arpa/nameser_compat.h> 00064 # else 00065 // you include the SDK and you're running Mac OS 10.2 or below 00066 typedef int socklen_t; 00067 # endif 00068 # ifdef __MWERKS__ /* this is a <limits.h> bug filed with Apple, Radar# 3657629. */ 00069 # ifndef __SCHAR_MAX__ 00070 # define __SCHAR_MAX__ 127 00071 # endif 00072 # endif 00073 #endif 00074 00075 #if defined(__SUNPRO_CC) 00076 # if defined(_TIME_T) 00077 using std::time_t; 00078 # endif 00079 # include <time.h> 00080 # include <memory.h> 00081 # include <string.h> 00082 #endif 00083 00084 #if !defined(T_NAPTR) 00085 # define T_NAPTR 35 00086 #endif 00087 00088 #if !defined(T_SRV) 00089 # define T_SRV 33 00090 #endif 00091 00092 #if !defined(T_AAAA) 00093 # define T_AAAA 28 00094 #endif 00095 00096 #if !defined(T_A) 00097 # define T_A 1 00098 #endif 00099 00100 namespace resip 00101 { 00102 00103 #if defined(WIN32) || defined(__QNX__) 00104 #ifndef strcasecmp 00105 # define strcasecmp(a,b) stricmp(a,b) 00106 #endif 00107 #ifndef strncasecmp 00108 # define strncasecmp(a,b,c) strnicmp(a,b,c) 00109 #endif 00110 #endif 00111 00112 #if defined(__QNX__) || defined(__sun) || defined(WIN32) 00113 typedef unsigned int u_int32_t; 00114 #endif 00115 00116 template<typename _Tp> 00117 inline const _Tp& 00118 resipMin(const _Tp& __a, const _Tp& __b) 00119 { 00120 if (__b < __a) return __b; return __a; 00121 } 00122 00123 template<typename _Tp> 00124 inline const _Tp& 00125 resipMax(const _Tp& __a, const _Tp& __b) 00126 { 00127 if (__a < __b) return __b; return __a; 00128 } 00129 00130 template<typename _Tp1, typename _Tp2> 00131 inline const _Tp1 00132 resipIntDiv(const _Tp1& __a, const _Tp2& __b) 00133 { 00134 // .bwc. Divide-round-nearest without using any floating-point. 00135 if(__a%__b > __b/2) 00136 { 00137 return __a/__b+1; 00138 } 00139 00140 return __a/__b; 00141 } 00142 00143 } 00144 00145 // Mac OS X: UInt32 definition conflicts with the Mac OS or iPhone OS SDK. 00146 // If you've included either SDK then these will be defined. 00147 #if !defined(TARGET_OS_MAC) && !defined(TARGET_OS_IPHONE) 00148 typedef unsigned char UInt8; 00149 typedef unsigned short UInt16; 00150 typedef unsigned int UInt32; 00151 #endif 00152 00153 #if defined( WIN32 ) 00154 typedef unsigned __int64 UInt64; 00155 #else 00156 typedef unsigned long long UInt64; 00157 #endif 00158 //typedef struct { unsigned char octet[16]; } UInt128; 00159 00160 //template "levels; ie REASONABLE and COMPLETE 00161 //reasonable allows most things such as partial template specialization, 00162 //etc...like most compilers and VC++2003+. 00163 //COMPLETE would allow template metaprogramming, template< template< > > tricks, 00164 //etc...REASONABLE should always be defined when COMPLETE is defined. 00165 00166 //#if !defined(__SUNPRO_CC) && !defined(__INTEL_COMPILER) 00167 #if !defined(__INTEL_COMPILER) 00168 # define REASONABLE_TEMPLATES 00169 #endif 00170 00171 // .bwc. This is the only place we check for USE_IPV6 in a header file. This 00172 // code has no effect if USE_IPV6 is not set, so this should only kick in when 00173 // we're building the resip libs. If someone sets USE_IPV6 while building 00174 // against the resip libs, no resip header file will care. 00175 #ifdef USE_IPV6 00176 #ifndef IPPROTO_IPV6 00177 #if(_WIN32_WINNT >= 0x0501) // Some versions of the windows SDK define IPPROTO_IPV6 differently - always enable IP v6 if USE_IPV6 and _WIN32_WINNT >= 0x0501 00178 #define IPPROTO_IPV6 ::IPPROTO_IPV6 00179 #else 00180 #ifdef _MSC_VER 00181 #define __STR2__(x) #x 00182 #define __STR1__(x) __STR2__(x) 00183 #define __LOC__ __FILE__ "("__STR1__(__LINE__)"): " 00184 #pragma message (__LOC__ " IPv6 support requested, but IPPROTO_V6 undefined; this platform does not appear to support IPv6 ") 00185 #else 00186 #warning IPv6 support requested, but IPPROTO_IPV6 undefined; this platform does not appear to support IPv6 00187 #endif 00188 // .bwc. Don't do this; someone might have defined it for their own code. 00189 // #undef USE_IPV6 00190 #endif 00191 #endif 00192 #endif 00193 00194 // !bwc! Some poking around seems to indicate that icc supports gcc's function 00195 // attributes, at least as far back as version 8. I have no idea what support is 00196 // like prior to that. As for SUNPRO, it uses gcc's frontend, so I would expect 00197 // gnu-c function attributes to work, but does it define __GNUC__? 00198 #if defined(__GNUC__) || (__INTEL_COMPILER > 800) 00199 #define RESIP_DEPRECATED __attribute__ ((deprecated)) 00200 #elif defined(_MSC_VER) 00201 #define RESIP_DEPRECATED __declspec(deprecated) 00202 #else 00203 #define RESIP_DEPRECATED 00204 #endif 00205 00206 #endif 00207 00208 /* ==================================================================== 00209 * The Vovida Software License, Version 1.0 00210 * 00211 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00212 * 00213 * Redistribution and use in source and binary forms, with or without 00214 * modification, are permitted provided that the following conditions 00215 * are met: 00216 * 00217 * 1. Redistributions of source code must retain the above copyright 00218 * notice, this list of conditions and the following disclaimer. 00219 * 00220 * 2. Redistributions in binary form must reproduce the above copyright 00221 * notice, this list of conditions and the following disclaimer in 00222 * the documentation and/or other materials provided with the 00223 * distribution. 00224 * 00225 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00226 * and "Vovida Open Communication Application Library (VOCAL)" must 00227 * not be used to endorse or promote products derived from this 00228 * software without prior written permission. For written 00229 * permission, please contact vocal@vovida.org. 00230 * 00231 * 4. Products derived from this software may not be called "VOCAL", nor 00232 * may "VOCAL" appear in their name, without prior written 00233 * permission of Vovida Networks, Inc. 00234 * 00235 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00236 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00237 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00238 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00239 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00240 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00241 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00242 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00243 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00244 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00245 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00246 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00247 * DAMAGE. 00248 * 00249 * ==================================================================== 00250 */
1.7.5.1