Scopira 20080306

platform.h

00001 
00002 /*
00003  *  Copyright (c) 2004    National Research Council
00004  *
00005  *  All rights reserved.
00006  *
00007  *  This material is confidential and proprietary information of
00008  *  National Research Council Canada ("Confidential Information").
00009  *  This Confidential Information may only be used and reproduced
00010  *  in accordance with the terms of the license agreement.
00011  *
00012  */
00013 
00014 #ifndef __INCLUDED__SCOPIRA_TOOL_PLATFORM_H__
00015 #define __INCLUDED__SCOPIRA_TOOL_PLATFORM_H__
00016 
00017 //
00018 // This header defines platform dependant macros
00019 //
00020 // PLATFORM_64       defined only if 64 bit arch (size(void*) == 8)
00021 // PLATFORM_32       defined only if 32 bit arch (size(void*) == 4)
00022 // PLATFORM_BYTESWAP defined only if byte order is opposite to that of x86
00023 // PLATFORM_UNIX     defined is OS family is UNIXy (all but windows)
00024 // PLATFORM_DEBUG    defined if building a debug set
00025 //
00026 // ONE of the following will always be defined
00027 // PLATFORM_linux    linux on x86 or x86_64 (64-bit)
00028 // PLATFORM_irix     SGI IRIX on MIPS
00029 // PLATFORM_win32    Microsoft Windows (32 and 64-bit)
00030 // PLATFORM_osx      Apple Macintosh OS X (Intel only)
00031 //
00032 
00033 #define SCOPIRA_VERSION "0.9.12"
00034 #define SCOPIRA_VERSION_MAJOR 0
00035 #define SCOPIRA_VERSION_MINOR 9
00036 #define SCOPIRA_VERSION_SUBMINOR 12
00037 
00038 #if !defined(PLATFORM_win32) && defined(WIN32)
00039 #define PLATFORM_win32
00040 #endif
00041 
00042 #if !defined(PLATFORM_win32) && !defined(PLATFORM_UNIX)
00043 #define PLATFORM_UNIX
00044 #endif
00045 
00046 #ifdef PLATFORM_irix
00047 #define PLATFORM_BYTESWAP
00048 #endif
00049 
00050 #ifdef BUILDBOSS_32
00051 #define PLATFORM_32
00052 
00053 #elif defined(BUILDBOSS_64)
00054 #define PLATFORM_64
00055 
00056 #elif !defined(PLATFORM_32) && !defined(PLATFORM_64)
00057 #define PLATFORM_32
00058 #endif
00059 
00060 #ifndef NDEBUG
00061 #define PLATFORM_DEBUG
00062 #endif
00063 
00064 #ifndef PLATFORM_DESC
00065 #ifdef PLATFORM_linux
00066 #define PLATFORM_DESC "linux"
00067 #elif defined(PLATFORM_win32)
00068 #define PLATFORM_DESC "ms_win32"
00069 #elif defined(PLATFORM_irix)
00070 #define PLATFORM_DESC "irix"
00071 #elif defined(PLATFORM_osx)
00072 #define PLATFORM_DESC "mac_osx"
00073 #else
00074 #error You must define a valid PLATFORM_
00075 #endif
00076 #endif
00077 
00078 #ifdef PLATFORM_win32
00079 #include <process.h>
00080 #include <windows.h>
00081 #else
00082 // have to wait for studio 05 for this to work on win32 too
00083 #include <stdint.h>
00084 #endif
00085 
00086 // win32 crap that used to be in win_undef
00087 #ifdef PLATFORM_win32
00088 //comiple error of <limits>
00089 #undef max
00090 #undef min
00091 #define random rand
00092 #define srandom srand
00093 #endif
00094 
00095     // related to http://www.opengroup.org/onlinepubs/009695399/basedefs/stdint.h.html
00096 #ifdef PLATFORM_win32
00097 // make this up until VC supports stdint.h
00098 typedef signed __int8 int8_t;
00099 typedef signed __int16 int16_t;
00100 typedef signed __int32 int32_t;
00101 typedef signed __int64 int64_t;
00102 typedef unsigned __int8 uint8_t;
00103 typedef unsigned __int16 uint16_t;
00104 typedef unsigned __int32 uint32_t;
00105 typedef unsigned __int64 uint64_t;
00106 typedef float float32_t;
00107 typedef double float64_t;
00108 //change these for when we do 64-bit win32 builds
00109 #ifdef PLATFORM_64
00110 typedef signed __int64 intptr_t;
00111 typedef unsigned __int64 uintptr_t;
00112 #else
00113 typedef signed __int32 intptr_t;
00114 typedef unsigned __int32 uintptr_t;
00115 #endif
00116 typedef float float32_t;
00117 typedef double float64_t;
00118 #endif
00119 
00120 #ifdef PLATFORM_win32
00121 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/msmod_6.asp
00122 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/msmod_20.asp
00123 #define PLATFORM_INDLL __declspec(dllexport)
00124 #define PLATFORM_OUTDLL __declspec(dllimport)
00125 #elif defined(PLATFORM_visibility) && defined(GCC_HASCLASSVISIBILITY)
00126 //
00127 // This Visibility Experiment
00128 // This is too make the UNIX builds (under GCC 4) hide most of the symbols, like MS Windows
00129 // does by default. To use, add the following to your BBCPP:
00130 //
00131 //   BBCPP?=g++ -fvisibility=hidden -DPLATFORM_visibility
00132 //
00133 // GCC_HASCLASSVISIBILITY is defined if this facility is available under gcc/unix
00134 //
00135 // perhaps do -fvisibility=hidden and "__attribute__ ((visibility("default")))"
00136 // see:
00137 //   http://www.nedprod.com/programs/gccvisibility.html
00138 //   http://gcc.gnu.org/wiki/Visibility
00139 //
00140 // Dont use this yet (well, you can try but you'll see why its not a nice
00141 // drop in solution yet). In particular, the size gains for scopira seem to be
00142 // "only" 10% off, and also, a techniqie to explicity mark whoe classes
00143 // (to include their vtables and typeinfos) NEEDs to be implemented. This may be
00144 // too much of a PITA aswell as reduce are already meager size savings.
00145 //
00146 #define PLATFORM_INDLL __attribute__ ((visibility("default")))
00147 #define PLATFORM_OUTDLL __attribute__ ((visibility("default")))
00148 #else
00149 #define PLATFORM_INDLL
00150 #define PLATFORM_OUTDLL
00151 #endif
00152 
00153 
00154 #endif
00155