OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

MoreSetup.h
1 /*
2 File: MoreSetup.h
3
4 Contains: Sets up conditions etc for MoreIsBetter.
5
6 Written by: Pete Gontier
7
8 Copyright: Copyright (c) 1998-2001 by Apple Computer, Inc., All Rights Reserved.
9
10 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
11 ("Apple") in consideration of your agreement to the following terms, and your
12 use, installation, modification or redistribution of this Apple software
13 constitutes acceptance of these terms. If you do not agree with these terms,
14 please do not use, install, modify or redistribute this Apple software.
15
16 In consideration of your agreement to abide by the following terms, and subject
17 to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
18 copyrights in this original Apple software (the "Apple Software"), to use,
19 reproduce, modify and redistribute the Apple Software, with or without
20 modifications, in source and/or binary forms; provided that if you redistribute
21 the Apple Software in its entirety and without modifications, you must retain
22 this notice and the following text and disclaimers in all such redistributions of
23 the Apple Software. Neither the name, trademarks, service marks or logos of
24 Apple Computer, Inc. may be used to endorse or promote products derived from the
25 Apple Software without specific prior written permission from Apple. Except as
26 expressly stated in this notice, no other rights or licenses, express or implied,
27 are granted by Apple herein, including but not limited to any patent rights that
28 may be infringed by your derivative works or by other works in which the Apple
29 Software may be incorporated.
30
31 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
32 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
33 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
35 COMBINATION WITH YOUR PRODUCTS.
36
37 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
38 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
39 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
41 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
42 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
43 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44
45 Change History (most recent first):
46
47 $Log: MoreSetup.h,v $
48 Revision 1.14 2002/11/08 22:43:02 eskimo1
49 A bunch of key changes. We no longer include <Carbon/Carbon.h> in the Mach-O builds, which means that individual MoreIsBetter modules can decide what frameworks they're dependent on. Also changed MoreIsBetter to use the standard C assert mechanism.
50
51 Revision 1.13 2001/11/07 15:55:15 eskimo1
52 Tidy up headers, add CVS logs, update copyright.
53
54
55 <12> 21/9/01 Quinn Fix CF framework includes workaround.
56 <11> 21/9/01 Quinn Changes for CWPro7 Mach-O build.
57 <10> 15/2/01 Quinn MoreIsBetter now requires UI 3.4 (pre-release) or later.
58 <9> 8/2/01 Quinn Modern versions of MIB require UI 3.3.2 or higher.
59 <8> 22/11/00 Quinn Switch to "MacErrors.h".
60 <7> 22/4/99 Quinn Add a check for the Universal Interfaces version. MoreIsBetter
61 requires Universal Interfaces 3.2 or higher (because many of its
62 component parts do).
63 <6> 2/11/99 PCG add comments because Andy rightfully pointed out my original
64 attempts sucked; also, remove some excessive TARGET_CARBON
65 gymnastics
66 <5> 1/22/99 PCG TARGET_CARBON
67 <4> 11/11/98 PCG fix header
68 <3> 11/10/98 PCG separate change histories
69 <2> 10/11/98 Quinn Convert "MorePrefix.h" to "MoreSetup.h".
70 <1> 10/11/98 Quinn Changed name from "MorePrefix.h" to "MoreSetup.h".
71
72 Start of "MorePrefix.h" change history (most recent first):
73
74 <3> 5/11/98 Quinn Use MoreAssertQ instead of MoreAssert.
75 <2> 7/24/98 PCG rid of triplet #includes
76 <2> 6/23/98 PCG add copyright disclaimer stuff
77 <1> 6/23/98 PCG initial checkin
78 */
79
80 #pragma once
81
82 //
83 // We never want to use old names or locations.
84 // Since these settings must be consistent all the way through
85 // a compilation unit, and since we don't want to silently
86 // change them out from under a developer who uses a prefix
87 // file (C/C++ panel of Target Settings), we simply complain
88 // if they are already set in a way we don't like.
89 //
90
91 #ifndef OLDROUTINELOCATIONS
92 #define OLDROUTINELOCATIONS 0
93 #elif OLDROUTINELOCATIONS
94 #error OLDROUTINELOCATIONS must be FALSE when compiling MoreIsBetter.
95 #endif
96
97 #ifndef OLDROUTINENAMES
98 #define OLDROUTINENAMES 0
99 #elif OLDROUTINENAMES
100 #error OLDROUTINENAMES must be FALSE when compiling MoreIsBetter.
101 #endif
102
103 //
104 // The next statement sets up the various TARGET_xxx
105 // variables needed later in this file.
106 //
107
108 #include <TargetConditionals.h>
109
110 //
111 // "TargetConditionals.h" on Mac OS X doesn't define
112 // TARGET_API_MAC_CARBON, which is kinda annoying. So,
113 // if we're building for Mach-O and it hasn't been set,
114 // set it. All Mach-O builds are inherently Carbon builds.
115 //
116 // Note that we *have* to set TARGET_API_MAC_CARBON because
117 // MoreIsBetter code tests it. However, we also want to set
118 // the other values because otherwise GCC won't use its
119 // precompiled header. I thought about fixing this by
120 // including <ConditionalMacros.h> via <CoreServices/CoreServices.h>,
121 // but the whole goal of using <TargetConditionals.h> was to
122 // allow MoreIsBetter projects to have no dependencies on
123 // frameworks beyond System.framework.
124 //
125
126 #if TARGET_RT_MAC_MACHO
127 #define TARGET_API_MAC_OS8 0
128 #define TARGET_API_MAC_CARBON 1
129 #define TARGET_API_MAC_OSX 1
130 #endif
131
132 //
133 // We need a master conditional to determine whether to use
134 // framework notation to reference include files. There is
135 // no good way to determine whether the source tree
136 // is using framework includes or not, so we make a guess and
137 // say that Mach-O implies framework includes. However,
138 // if you're building CFM with framework includes (which is
139 // possible, although somewhat tricky), you'll have to
140 // override this.
141 //
142
143 #if !defined(MORE_FRAMEWORK_INCLUDES)
144 #if TARGET_RT_MAC_MACHO
145 #define MORE_FRAMEWORK_INCLUDES 1
146 #else
147 #define MORE_FRAMEWORK_INCLUDES 0
148 #endif
149 #endif
150
151 //
152 // The following works around a problem in <CoreFoundation/CFBase.h>
153 // in Mac OS X. CF is assuming that the CW Mach-O compiler
154 // would not use framework includes, which is not the case for the
155 // CWPro7 and later compilers. We only do this for the CW build
156 // because otherwise the presence of the define prevents Project Builder
157 // from using Carbon's precompiled header.
158 //
159
160 #if MORE_FRAMEWORK_INCLUDES
161 #if defined(__MWERKS__)
162 #if !defined(__CF_USE_FRAMEWORK_INCLUDES__)
163 #define __CF_USE_FRAMEWORK_INCLUDES__ 1
164 #endif
165 #endif
166 #endif
167
168 //
169 // Previouly we would bring in <MacErrors.h> at this point.
170 // However, that's somewhat counter to the idea behind flat
171 // includes, so I've eliminated it.
172 //
173
174 //
175 // Now that we've included a Mac OS interface file,
176 // we know that the Universal Interfaces environment
177 // is set up. MoreIsBetter requires Universal Interfaces
178 // 3.4 or higher. Check for it. Of course, "TargetConditionals.h"
179 // on Mac OS X doesn't set UNIVERSAL_INTERFACES_VERSION, so
180 // we only check this if we're not using framework includes.
181 //
182
183 #if !MORE_FRAMEWORK_INCLUDES
184 #if !defined(UNIVERSAL_INTERFACES_VERSION) || UNIVERSAL_INTERFACES_VERSION < 0x0341
185 #error MoreIsBetter requires Universal Interfaces 3.4.1 or higher.
186 #endif
187 #endif
188
189 //
190 // We usually want assertions and other debugging code
191 // turned on, but you can turn it all off if you like
192 // by setting MORE_DEBUG to 0. Also, now that we use
193 // the standard C assertion mechanism, we default to
194 // have MORE_DEBUG off if NDEBUG is set.
195 //
196
197 #if !defined(MORE_DEBUG)
198 #if defined(NDEBUG)
199 #define MORE_DEBUG 0
200 #else
201 #define MORE_DEBUG 1
202 #endif
203 #endif
204
205 //
206 // We now use standard C assertions throughout MoreIsBetter.
207 // Previously we would declare two custom assertion macros,
208 // MoreAssert and MoreAssertQ.
209 //
210 // Our assertion macros compile down to nothing if
211 // MORE_DEBUG is not true. MoreAssert produces a
212 // value indicating whether the assertion succeeded
213 // or failed. MoreAssertQ is Quinn's flavor of
214 // MoreAssert which does not produce a value.
215 //
216
217 #include <assert.h>
218
219 //
220 // Chances are that if you're building CFM then you'd much
221 // rather have assert triggered DebugStr that abort. The
222 // following redefines assert that way. We don't do this
223 // for Mach-O because you might be building a Mach-O tool that
224 // doesn't have access to DebugStr.
225 //
226
227 #if TARGET_RT_MAC_CFM && !defined(NDEBUG)
228 #undef assert
229 #define assert(x) ((x) ? ((void) 0) : DebugStr("\pMoreIsBetter assertion failure: " #x))
230 #endif
231
232 //
233 // Finally, we define MoreAssertPCG, to accomodate some
234 // older MoreIsBetter code that tests the result of its
235 // assertions. This doesn't fit in with the standard C
236 // assert model, so I've deprecated the approach. However
237 // there's a bunch of existing code that works that way
238 // and reworking it would be likely to generate errors.
239 // Fortunately, all of the old code that uses this is
240 // Carbon based, so I don't have to worry about not having
241 // access to DebugStr.
242 //
243
244 #if MORE_DEBUG
245 #define MoreAssertPCG(x) \
246 ((x) ? true : (DebugStr ("\pMoreIsBetter assertion failure: " #x), false))
247 #else
248 #define MoreAssertPCG(x) (true)
249 #endif