Scopira  20080306
platform.h
1 
2 /*
3  * Copyright (c) 2004 National Research Council
4  *
5  * All rights reserved.
6  *
7  * This material is confidential and proprietary information of
8  * National Research Council Canada ("Confidential Information").
9  * This Confidential Information may only be used and reproduced
10  * in accordance with the terms of the license agreement.
11  *
12  */
13 
14 #ifndef __INCLUDED__SCOPIRA_TOOL_PLATFORM_H__
15 #define __INCLUDED__SCOPIRA_TOOL_PLATFORM_H__
16 
17 //
18 // This header defines platform dependant macros
19 //
20 // PLATFORM_64 defined only if 64 bit arch (size(void*) == 8)
21 // PLATFORM_32 defined only if 32 bit arch (size(void*) == 4)
22 // PLATFORM_BYTESWAP defined only if byte order is opposite to that of x86
23 // PLATFORM_UNIX defined is OS family is UNIXy (all but windows)
24 // PLATFORM_DEBUG defined if building a debug set
25 //
26 // ONE of the following will always be defined
27 // PLATFORM_linux linux on x86 or x86_64 (64-bit)
28 // PLATFORM_irix SGI IRIX on MIPS
29 // PLATFORM_win32 Microsoft Windows (32 and 64-bit)
30 // PLATFORM_osx Apple Macintosh OS X (Intel only)
31 //
32 
33 #define SCOPIRA_VERSION "0.9.12"
34 #define SCOPIRA_VERSION_MAJOR 0
35 #define SCOPIRA_VERSION_MINOR 9
36 #define SCOPIRA_VERSION_SUBMINOR 12
37 
38 #if !defined(PLATFORM_win32) && defined(WIN32)
39 #define PLATFORM_win32
40 #endif
41 
42 #if !defined(PLATFORM_win32) && !defined(PLATFORM_UNIX)
43 #define PLATFORM_UNIX
44 #endif
45 
46 #ifdef PLATFORM_irix
47 #define PLATFORM_BYTESWAP
48 #endif
49 
50 #ifdef BUILDBOSS_32
51 #define PLATFORM_32
52 
53 #elif defined(BUILDBOSS_64)
54 #define PLATFORM_64
55 
56 #elif !defined(PLATFORM_32) && !defined(PLATFORM_64)
57 #define PLATFORM_32
58 #endif
59 
60 #ifndef NDEBUG
61 #define PLATFORM_DEBUG
62 #endif
63 
64 #ifndef PLATFORM_DESC
65 #ifdef PLATFORM_linux
66 #define PLATFORM_DESC "linux"
67 #elif defined(PLATFORM_win32)
68 #define PLATFORM_DESC "ms_win32"
69 #elif defined(PLATFORM_irix)
70 #define PLATFORM_DESC "irix"
71 #elif defined(PLATFORM_osx)
72 #define PLATFORM_DESC "mac_osx"
73 #else
74 #error You must define a valid PLATFORM_
75 #endif
76 #endif
77 
78 #ifdef PLATFORM_win32
79 #include <process.h>
80 #include <windows.h>
81 #else
82 // have to wait for studio 05 for this to work on win32 too
83 #include <stdint.h>
84 #endif
85 
86 // win32 crap that used to be in win_undef
87 #ifdef PLATFORM_win32
88 //comiple error of <limits>
89 #undef max
90 #undef min
91 #define random rand
92 #define srandom srand
93 #endif
94 
95 #ifdef PLATFORM_win32
96 // make this up until VC supports stdint.h
97 typedef signed __int8 int8_t;
98 typedef signed __int16 int16_t;
99 typedef signed __int32 int32_t;
100 typedef signed __int64 int64_t;
101 typedef unsigned __int8 uint8_t;
102 typedef unsigned __int16 uint16_t;
103 typedef unsigned __int32 uint32_t;
104 typedef unsigned __int64 uint64_t;
105 typedef float float32_t;
106 typedef double float64_t;
107 //change these for when we do 64-bit win32 builds
108 #ifdef PLATFORM_64
109 typedef signed __int64 intptr_t;
110 typedef unsigned __int64 uintptr_t;
111 #else
112 typedef signed __int32 intptr_t;
113 typedef unsigned __int32 uintptr_t;
114 #endif
115 typedef float float32_t;
116 typedef double float64_t;
117 #endif
118 
119 #ifdef PLATFORM_win32
120 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/msmod_6.asp
121 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/msmod_20.asp
122 #define PLATFORM_INDLL __declspec(dllexport)
123 #define PLATFORM_OUTDLL __declspec(dllimport)
124 #elif defined(PLATFORM_visibility) && defined(GCC_HASCLASSVISIBILITY)
125 //
126 // This Visibility Experiment
127 // This is too make the UNIX builds (under GCC 4) hide most of the symbols, like MS Windows
128 // does by default. To use, add the following to your BBCPP:
129 //
130 // BBCPP?=g++ -fvisibility=hidden -DPLATFORM_visibility
131 //
132 // GCC_HASCLASSVISIBILITY is defined if this facility is available under gcc/unix
133 //
134 // perhaps do -fvisibility=hidden and "__attribute__ ((visibility("default")))"
135 // see:
136 // http://gcc.gnu.org/wiki/Visibility
137 //
138 // Dont use this yet (well, you can try but you'll see why its not a nice
139 // drop in solution yet). In particular, the size gains for scopira seem to be
140 // "only" 10% off, and also, a techniqie to explicity mark whoe classes
141 // (to include their vtables and typeinfos) NEEDs to be implemented. This may be
142 // too much of a PITA aswell as reduce are already meager size savings.
143 //
144 #define PLATFORM_INDLL __attribute__ ((visibility("default")))
145 #define PLATFORM_OUTDLL __attribute__ ((visibility("default")))
146 #else
147 #define PLATFORM_INDLL
148 #define PLATFORM_OUTDLL
149 #endif
150 
151 
152 #endif
153