/[ascend]/trunk/base/generic/utilities/ascConfig.h
ViewVC logotype

Contents of /trunk/base/generic/utilities/ascConfig.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 60 - (show annotations) (download) (as text)
Mon Oct 31 03:39:15 2005 UTC (18 years, 7 months ago) by jds
File MIME type: text/x-chdr
File size: 11371 byte(s)
- jam build up and limping on Linux (finally).
- fixes to CUnit test suite to compile on Linux (still not operable, though).
1 /*
2 * Basic Definitions for Ascend
3 * by Mark Thomas
4 * Version: $Revision: 1.12 $
5 * Version control file: $RCSfile: ascConfig.h,v $
6 * Date last modified: $Date: 2003/08/23 18:43:13 $
7 * Last modified by: $Author: ballan $
8 * Part of Ascend
9 *
10 * This file is part of the Ascend
11 *
12 * Copyright (C) 1997 Carnegie Mellon University
13 *
14 * The Ascend Language Interpreter is free software; you can redistribute
15 * it and/or modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * The Ascend Language Interpreter is distributed in hope that it will be
20 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with the program; if not, write to the Free Software Foundation,
26 * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
27 * COPYING.
28 *
29 * This module defines the fundamental constants used by the rest of
30 * Ascend and pulls in system headers.
31 * There is not corresponding compiler.c. The variables
32 * declared in this header are defined in ascParse.y.
33 */
34
35 /** @file
36 * Global configuration parameters.
37 * This header and tcl/tk headers are known to conflict. This header
38 * should be included AFTER tcl.h or tk.h, not before.
39 */
40
41 #ifndef _ASCCONFIG_H
42 #define _ASCCONFIG_H
43
44 /*
45 * If we are in a tcl-infested file, define
46 * CONST84 to be empty for back-compatibility with
47 * tcl8.3
48 */
49 #ifdef TCL_VERSION
50 #ifndef CONST84
51 #define CONST84
52 #define QUIET(x) x
53 #define QUIET2(x) x
54 #else
55 /** use this macro to shut up const when const
56 from tcl-land would be going into non-tcl C.
57 */
58 #define QUIET(x) ((char *)x)
59 #define QUIET2(v) ((char **)v)
60 #endif
61 #endif
62
63 /*
64 *
65 * Determine the Operating System we are building on
66 *
67 */
68 #ifndef __WIN32__
69 #if defined(_WIN32) || defined(WIN32)
70
71 /** Standard Windows define used in ASCEND. */
72 #define __WIN32__
73
74 #else /* _WIN32 || WIN32 */
75
76 /* Some flavor of Unix */
77
78 #ifdef __alpha
79 /** DEC Alpha running OSF */
80 #define __ALPHA_OSF__
81 #endif /* __alpha */
82
83 #ifdef __hpux
84 /** HP running HP-UX */
85 #define __HPUX__
86 #endif /* __hpux */
87
88 #ifdef _AIX
89 /** IBM RS6000 or PowerPC running AIX */
90 #define __IBM_AIX__
91 #endif /* _AIX */
92
93 #ifdef __sgi
94 /** SGI running IRIX */
95 #define __SGI_IRIX__
96 #endif /* __sgi */
97
98 #if defined(__sun) || defined(sun)
99 #ifdef __SVR4
100 /** Sparc running Solaris 2.x (SunOS 5.x) */
101 #define __SUN_SOLARIS__
102 #else /* __SVR4 */
103 /** Sparc running SunOS 4.x (Solaris 1.x) */
104 #define __SUN_SUNOS__
105 #endif /* __SVR4 */
106 #endif /* __sun || sun */
107
108 #endif /* _WIN32 || WIN32 */
109 #endif /* __WIN32__ */
110
111 /*
112 * Make certain we have proper limits defined
113 */
114 #include <stdlib.h>
115 #include <limits.h>
116 #include <float.h>
117 #include <sys/types.h>
118 #ifdef _OSF_SOURCE
119 #include <sys/syslimits.h>
120 #endif
121 /* for use practically everywhere */
122 #include<stdio.h>
123
124 #ifdef __WIN32__
125 #undef Status /* jds20041229 - #define in tcl include/X11/XLib.h conflicts. */
126 #define WIN32_LEAN_AND_MEAN
127 #include <windows.h> /* jds20041212 - some limits defined in winnt.h (MAXLONG). */
128 #undef WIN32_LEAN_AND_MEAN
129 #endif
130
131 #ifndef PATH_MAX
132 /** Normally will come from stdio.h or limits.h
133 * POSIX values of PATH_MAX is 255, traditional is 1023
134 */
135 #define PATH_MAX 1023
136 #endif
137
138 /* the following numbers should have come through limits.h */
139 #ifndef SHRT_MAX
140 #define SHRT_MAX 32767
141 #endif
142 #ifndef INT_MAX
143 #define INT_MAX 2147483647
144 /* 32 bit machines */
145 #endif
146 #ifndef LONG_MAX
147 #ifdef __alpha
148 #define LONG_MAX 9223372036854775807 /* 64 bit machines */
149 #else /* __alpha */
150 #define LONG_MAX 2147483647 /* 32 bit machines */
151 #endif /* __alpha */
152 #endif /* LONG_MAX */
153
154 #ifndef MAXDOUBLE
155 #define MAXDOUBLE DBL_MAX
156 #endif
157 #ifndef MAXINT
158 #define MAXINT INT_MAX
159 #endif
160 #ifndef MAXUINT
161 #define MAXUINT UINT_MAX
162 #endif
163 #ifndef MAXLONG
164 #define MAXLONG LONG_MAX
165 #endif
166 #ifndef MAXULONG
167 #define MAXULONG UILONG_MAX
168 #endif
169
170 /**
171 * The largest number of digits we'd ever expect to see in a single
172 * numeric value, * 3 or so for good measure.
173 */
174 #define MAXIMUM_NUMERIC_LENGTH 80
175
176 /*
177 * Useful Headers
178 */
179
180 /* for use by ascmalloc, which is also practically everywhere */
181 #include <assert.h>
182 #include <string.h>
183 /*
184 * #include <malloc.h>
185 *
186 * malloc() is defined in <stdlib.h> in ANSI-C
187 */
188
189 #define MAXTOKENLENGTH 1024 /**< Maximum token size.
190 Most significant for identifiers and strings */
191 #ifndef FALSE
192 #define FALSE 0
193 #define TRUE 1
194 #endif
195
196 #ifndef MAX
197 #define MAX(a,b) ((a) > (b) ? (a) : (b))
198 #endif
199 #ifndef MIN
200 #define MIN(a,b) ((a) < (b) ? (a) : (b))
201 #endif
202 #ifndef ABS
203 #define ABS(x) ((x) > 0 ? (x) : -(x))
204 #endif
205
206 #ifndef CONST
207 #define CONST const
208 #endif
209
210 #define VOIDPTR void *
211
212 #define ASC_MILD_BUGMAIL "ascend+bugs@cs.cmu.edu"
213 #define ASC_BIG_BUGMAIL "ascend+developers@cs.cmu.edu"
214
215
216 extern FILE *g_ascend_errors; /**< File stream to receive error messages. */
217 extern FILE *g_ascend_warnings; /**< File stream to receive warning messages. */
218 extern FILE *g_ascend_information; /**< File stream to receive general messages. */
219 #ifndef ASCERR
220 #define ASCERR g_ascend_errors
221 #define ASCWAR g_ascend_warnings
222 #define ASCINF g_ascend_information
223 #endif
224 /*
225 * file pointers for whine. they default to stderr. if you change
226 * them, be sure to change them to valid files.
227 */
228
229 #define BYTESIZE 8
230 #define WORDSIZE (sizeof(unsigned)*BYTESIZE)
231 #ifndef TRUE
232 #define TRUE 1
233 #endif
234 #ifndef FALSE
235 #define FALSE 0
236 #endif
237 typedef char *POINTER; /**< Generic pointer. */
238 typedef char boolean; /**< Boolean type. */
239 typedef int ALIGN; /**< Data alignment. */
240 /**
241 * real64:
242 * change this typedef and all the solver code should change
243 * precision automatically. The code is predicated on 64bit ieee math.
244 * change the typedef as needed to get 64bit numbers. In particular
245 * crays may change this to float.
246 * int32:
247 * uint32;
248 * a 32bit int. change this typedef and all the solver code changes
249 * with it. may be of use for compiler which default int to 16bits
250 * equivalent to -i4 on most f77 compilers.
251 */
252 typedef double real64; /* a value */
253 typedef int int32; /**< a row/col/var/rel index number */
254 typedef unsigned uint32;
255
256
257 /**
258 * MAXREFCOUNT should always be defined to be the maximum value
259 * that the reference count attribute of reference count objects
260 * can take. It is unreasonable that a refcount be 64 bits, so
261 * it is 32.
262 */
263 #define MAXREFCOUNT UINT_MAX
264 #define REFCOUNT_T unsigned int
265
266 /*
267 * A bit of header magic to address the question of NULL being implementation
268 * defined, though virtually all systems of interest define it as 0 or 0L,
269 * if we are to claim ANSI conformance.
270 *
271 * IEEE 754 arithmetic implies all 0 bits <--> 0.0, so there isn't
272 * a problem where this is concerned. We have assumed ieee math.
273 *
274 * Notes to myself:
275 * Put this in base.h and suggest its insertion in
276 * compiler.h and perhaps interface1.h.
277 * Any place that calloc is being used to allocate arrays of NULL pointers,
278 * put a proper #if to replace it with a call to malloc and an appropriate
279 * NULLing function.
280 *
281 * Ben Allan, Jan 6, 1994.
282 */
283
284 /*
285 * NOTE: The below if works for 0 or 0L, which is to say I assume it
286 * works for 0 and I have tested that it works for 0L. Next we define
287 * the cheap versions of null testing for machine with 0 == NULL
288 *
289 * These are the proper ANSI C tests for NULL on 0!=NULL machines, should
290 * we ever run into them.
291 */
292 #ifdef NULL
293 /* ok, so the machine has a NULL defined. */
294 #ifndef ISNULL
295 /* and we've not got an ISNULL function */
296 #define ISNULL(a) ((a) == NULL)
297 #define NOTNULL(a) ((a) != NULL)
298 #endif /* ISNULL */
299 #endif /* NULL */
300
301 #ifndef NULL
302 #error "Null not defined by the time ascConfig.h seen"
303 #endif
304
305 #ifndef UNUSED_PARAMETER
306 /** Standardize the treatment of unreferenced function parameters. */
307 # define UNUSED_PARAMETER(p) (void)(p)
308 #endif
309
310 /* ASCEND assertion defines */
311 /** Exit status code for failed assertion. */
312 #define ASCERR_ASSERTION_FAILED 100
313 /*
314 * For now, asc_assert tied to NDEBUG just like regular assert.
315 * Having a separate assertion deactivator (ASC_NO_ASSERTIONS)
316 * gives us the ability to decouple from NDEBUG and leave
317 * assertions active in release code if desired.
318 */
319 #ifdef NDEBUG
320 /** If defined, asc_assert() will be removed from code. */
321 #define ASC_NO_ASSERTIONS
322 #endif
323
324 /*
325 *
326 * Platform specific fixes
327 *
328 */
329
330 /*
331 * The following definitions set up the proper options for Windows
332 * compilers. We use this method because there is no autoconf equivalent.
333 */
334 #ifdef __WIN32__
335
336 /*
337 * use the ASCEND printf substitutes
338 */
339 #ifndef USE_ASC_PRINTF
340 #define USE_ASC_PRINTF
341 #endif /* USE_ASC_PRINTF */
342
343 /*
344 * build the Tk Console
345 */
346 #ifndef ASC_USE_TK_CONSOLE
347 #define ASC_USE_TK_CONSOLE
348 #endif /* ASC_USE_TK_CONSOLE */
349
350 /*
351 * make macros so that DLLs can see nominated internal C functions.
352 * Unix programmers might also use the presence of these macros to figure
353 * out which APIs are to be regarded as more stable.
354 */
355 #if defined(ASC_BUILD_DLL)
356 # define DLEXPORT __declspec(dllexport)
357 #elif defined(ASC_BUILD_LIB)
358 # define DLEXPORT
359 #else
360 # define DLEXPORT __declspec(dllimport)
361 #endif
362
363 #else /* not __WIN32__ isms */
364
365 #define DLEXPORT
366
367 #endif /* __WIN32__ */
368
369 /* use signals by default, but disable with configure. */
370 #ifdef ASC_NO_TRAPS
371 /** Don't use signals. */
372 #define NO_SIGNAL_TRAPS 1
373 #else
374 /** Use signals. */
375 #undef NO_SIGNAL_TRAPS
376 #endif
377
378 #ifdef USE_ASC_PRINTF
379 #define PRINTF Asc_Printf
380 #define FPRINTF Asc_FPrintf
381 #define FFLUSH Asc_FFlush
382 #define PUTC Asc_FPutc
383 #define FPUTC Asc_FPutc
384 #define PUTCHAR Asc_Putchar
385 #include <stdarg.h>
386 #include "utilities/ascPrint.h"
387 #else /* !USE_ASC_PRINTF */
388 #define PRINTF printf
389 #define FPRINTF fprintf
390 #define FFLUSH fflush
391 #define PUTC putc
392 #define FPUTC fputc
393 #define PUTCHAR putchar
394 #endif /* USE_ASC_PRINTF */
395
396
397
398 #ifndef __SUN_SUNOS__
399 /* do this for non-sun machines and for sun-solaris machines */
400 #ifndef roundup
401 #define rounddown(num,mod) ((num)-(num)%(mod))
402 #define roundup(num,mod) rounddown((num)+(mod)-1,(mod))
403 #define roundoff(num,mod) rounddown((num)+((mod)/2),(mod))
404 #endif /* roundup */
405 #endif /* __SUN_SUNOS__ */
406
407
408 /* These define integer divide and modulus mathematically correctly */
409 #define imod(num,den) ((num)%(den) + ((num)%(den)<0 ? (den) : 0))
410 #define idiv(num,den) ((num)/(den) + ((num)%(den)<0))
411 #define array_length(a) (sizeof(a)/sizeof((a)[0]))
412
413 /*
414 * the following patch up IEEE754isms that some systems can't seem to
415 * get right.
416 */
417 #define FPRESET (void)0
418 #ifdef __WIN32__
419 /* renamed in some __WIN32__ compiler systems */
420 # ifndef NO_RENAME_IEEE_FUNCTIONS
421 # undef finite
422 # define finite(x) _finite(x)
423 # undef isnan
424 # define isnan(x) _isnan(x)
425 # undef isinf
426 # define isinf(x) _isinf(x)
427 # endif
428 # undef FPRESET
429 # define FPRESET _fpreset()
430 #endif /* __WIN32__ */
431
432 #ifdef __SUN_SUNOS__
433 /** not properly headered in math.h or ieee*.h */
434 extern int finite(double);
435 #endif
436
437 #endif /* _ASCCONFIG_H */
438

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22