Vault  4.1
vtypes_platform.h
Go to the documentation of this file.
00001 /*
00002 Copyright c1997-2014 Trygve Isaacson. All rights reserved.
00003 This file is part of the Code Vault version 4.1
00004 http://www.bombaydigital.com/
00005 License: MIT. See LICENSE.md in the Vault top level directory.
00006 */
00007 
00008 #ifndef vtypes_platform_h
00009 #define vtypes_platform_h
00010 
00013 /*
00014 First, define the 2 fundamental properties:
00015 - platform
00016 - compiler
00017 */
00018 // Define the platform.
00019 #define VPLATFORM_MAC
00020 
00021 // We now make use of CF features in the Mac platform specific code all the time.
00022 #define VAULT_CORE_FOUNDATION_SUPPORT
00023 
00024 // Detect and define the compiler.
00025 // Note: we can also check for __GNUC__
00026 // We also need to detect the Metrowerks MSL library for some differences elsewhere
00027 //   (below and in vinstant_platform.cpp).
00028 #ifdef __MWERKS__
00029     #define VCOMPILER_CODEWARRIOR
00030     #define VLIBRARY_METROWERKS    /* might want to consider adding a check for using CW but not MSL */
00031 #endif
00032 
00033 /*
00034 Second, include the user-editable header file that configures
00035 the desired Vault features/behavior. It can decide based on
00036 the fundamental properties defined above.
00037 */
00038 #include "vconfigure.h"
00039 
00040 /*
00041 Finally, proceed with everything else.
00042 */
00043 
00044 // Boost seems to require being included first.
00045 // If using shared_ptr, must include before our vtypes.h redefines new.
00046 #ifdef VAULT_BOOST_STRING_FORMATTING_SUPPORT
00047     #include <boost/format.hpp>
00048 #endif
00049 #ifdef VAULT_BOOST_SHARED_PTR_INCLUDE
00050     #include <boost/shared_ptr.hpp>
00051     #include <boost/weak_ptr.hpp>
00052     #include <boost/enable_shared_from_this.hpp>
00053     #include <boost/scoped_ptr.hpp>
00054 #endif
00055 
00056 #include <unistd.h>
00057 
00058 #ifndef VLIBRARY_METROWERKS
00059     #define V_HAVE_REENTRANT_TIME // we can and should use the _r versions of time.h calls
00060 #endif
00061 
00062 // Minimal includes needed to compile against the Vault header files.
00063 
00064 #ifndef VCOMPILER_CODEWARRIOR
00065     #ifdef VAULT_CORE_FOUNDATION_SUPPORT
00066         #include <CoreFoundation/CFString.h>
00067     #endif
00068 #endif
00069 
00070 // Set our standard symbol indicating a 32/64-bit compile.
00071 // If you need to set it manually in vconfigure.h, that will be respected.
00072 // You really should write code that works in either mode, but if you need to check, use this.
00073 #if !defined(VCOMPILER_32BIT) && !defined(VCOMPILER_64BIT)
00074     #if __GNUC__
00075         #if __x86_64__ || __ppc64__
00076             #define VCOMPILER_64BIT
00077         #else
00078             #define VCOMPILER_32BIT
00079         #endif
00080     #else
00081         #define VCOMPILER_32BIT /* something to fall back on for unknown compilers, may need more */
00082     #endif
00083 #endif
00084 
00085 // Platform-specific definitions for types, byte order, min/max/abs/fabs, etc.
00086 
00087 /*
00088 The proprocessor macros __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are defined by GCC,
00089 which allows us to get the byte ordering right. In order to rely less on the
00090 existence of these on early versions of GCC, let's just check for the newer
00091 condition, __LITTLE_ENDIAN__ Mac on Intel.
00092 */
00093 #if __LITTLE_ENDIAN__
00094     #define VBYTESWAP_NEEDED // This means "host order" and "network order" differ.
00095 #endif
00096 
00097 /*
00098 The following conditional instructions are for compatibility when compiling using
00099 CodeWarrior 8.3 with the Mac OS X 10.4 (Tiger) developer tools. There are some symbol
00100 conflicts between the MSL headers and the BSD headers. This checks for the environment,
00101 and then does what's necessary to resolve the symbol conflicts. Basically, we pull in
00102 the BSD math.h header, and then undef a few symbols that MSL re-defines in a harmlessly
00103 compatible way.
00104 
00105 A separate issue with CW 8.3 and Tiger BSD headers is that the Tiger headers have added
00106 an extraneous token after four #endif directives, and CW 8.3 calls it a syntax error.
00107 This requires fixing the BSD headers in 4 places, by removing or commenting out the
00108 extraneous token following the #endif directive. Here are the lines of code to fix:
00109 /usr/include/netinet6/in6.h:307,338,347
00110 /usr/include/netinet/in.h:498
00111 
00112 Next fix required, if console_OS_X.c is part of the CW project, comment out:
00113 {CodeWarrior}MSL/MSL_C/MSL_MacOS/Src/console_OS_X.c:9
00114 The include of size_t.h causes a problem and removing it solves it.
00115 
00116 Note that when we check for MAC_OS_X_VERSION_10_4 below, we're really checking to see
00117 if we are building on 10.4 or later -- the 10.3 header only defines up to the 10.3
00118 symbol.
00119 */
00120 
00121 #include <AvailabilityMacros.h> /* so we can test MAC_OS_X_VERSION_xxxx values' presence */
00122 
00123 #ifdef VLIBRARY_METROWERKS
00124     #ifdef MAC_OS_X_VERSION_10_4
00125         #define __FP__
00126         #include <math.h>
00127         #undef FP_NAN
00128         #undef FP_INFINITE
00129         #undef FP_ZERO
00130         #undef FP_NORMAL
00131         #undef FP_SUBNORMAL
00132         #undef HUGE_VALF
00133         #undef HUGE_VALL
00134     #endif /* MAC_OS_X_VERSION_10_4 */
00135 #endif /* VLIBRARY_METROWERKS */
00136 
00137 /*
00138 The definition of V_ABS and V_FABS needs to vary quite a bit between CodeWarrior
00139 (using Metrowerks Standard Library), GCC 3.x (on Mac OS X 10.3), and GCC 4.0 (on
00140 Mac OS X 10.4), and even on CodeWarrior between Mac OS X 10.3 and 10.4, because
00141 of which headers dominate.
00142 */
00143 
00144 // min and max work the same everywhere
00145 #define V_MIN(a, b) std::min(a, b)  ///< Macro for getting min of compatible values using standard function template.
00146 #define V_MAX(a, b) std::max(a, b)  ///< Macro for getting max of compatible values using standard function template.
00147 
00148 #ifdef VLIBRARY_METROWERKS
00149 
00150     // Metrowerks cannot access abs under 10.4, and in any case does not put abs or fabs in std namespace.
00151 
00152     #ifdef MAC_OS_X_VERSION_10_4
00153         #define V_ABS(a) ((a) < 0 ? (-(a)) : (a))   ///< Macro for getting abs of an integer value when standard functions / templates are not available.
00154     #else
00155         #define V_ABS(a) abs(a)                     ///< Macro for getting abs of an integer value using standard function.
00156     #endif
00157 
00158     #define V_FABS(a) abs(a)                        ///< Macro for getting abs of a floating point value using standard function.
00159 
00160 #else
00161 
00162     // GCC can access std::abs under 10.3 and 10.4, but fabs is strangely inconsistent.
00163 
00164     #define V_ABS(a) std::abs(a)                    ///< Macro for getting abs of an integer value using standard function template.
00165 
00166     #ifdef MAC_OS_X_VERSION_10_4
00167         #include <math.h>
00168         #define V_FABS(a) fabs(a)                   ///< Macro for getting abs of a floating point value using standard function.
00169     #else
00170         #define V_FABS(a) std::fabs(a)              ///< Macro for getting abs of a floating point value using standard function template.
00171     #endif
00172 
00173 #endif /* VLIBRARY_METROWERKS */
00174 
00175 // vsnprintf(NULL, 0, . . .) behavior conforms to IEEE 1003.1 on CW and
00176 // for GCC/10.4; I have not verified this on GCC/10.3 yet.
00177 #define V_EFFICIENT_SPRINTF
00178 
00179 // We treat IOS as essentially a subset of Mac OS X. This test must come after including AvailabilityMacros.h above.
00180 #if defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE == 1)
00181     #define VPLATFORM_MAC_IOS
00182 #endif
00183 
00184 #ifdef MAC_OS_X_VERSION_10_6 // SPI not available in pthread.h prior to the 10.6 headers.
00185     #ifndef VPLATFORM_MAC_IOS // SPI not available in iOS dev kit as of iOS 4 SDK
00186         #define VTHREAD_PTHREAD_SETNAME_SUPPORTED
00187     #endif
00188 #endif
00189 
00190 #endif /* vtypes_platform_h */

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.