/[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 414 - (show annotations) (download) (as text)
Mon Apr 3 04:55:35 2006 UTC (14 years, 6 months ago) by johnpye
File MIME type: text/x-chdr
File size: 13002 byte(s)
Some progress on getting a MSVC build to work with SCons. Issues with linking still.
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 If including the file, you should also include utilities/error.h
41 */
42
43 #ifndef ASC_ASCCONFIG_H
44 #define ASC_ASCCONFIG_H
45
46 /**
47 What kind of C compiler do we have?
48
49 Use compiler flag -DDISABLE_C99 to force older ISO C
50 This means no variadic macros, maybe other things too.
51 */
52 #if defined(__STDC__) && defined(__STDC_VERSION__)
53 # if __STDC_VERSION__>=199901L
54 # ifndef DISABLE_C99
55 # define HAVE_C99
56 # endif
57 # endif
58 #endif
59
60 /*
61 * If we are in a tcl-infested file, define
62 * CONST84 to be empty for back-compatibility with
63 * tcl8.3
64 */
65 #ifdef TCL_VERSION
66 # ifndef CONST84
67 # define CONST84
68 # define QUIET(x) x
69 # define QUIET2(x) x
70 # else
71 /** use this macro to shut up const when const
72 from tcl-land would be going into non-tcl C.
73 */
74 # define QUIET(x) ((char *)x)
75 # define QUIET2(v) ((char **)v)
76 # endif
77 #endif
78
79 /*
80 *
81 * Determine the Operating System we are building on
82 *
83 */
84
85 /* windows */
86 #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
87 # ifndef __WIN32__
88 # define __WIN32__
89 # endif
90 #endif
91
92 #ifdef __alpha
93 /** DEC Alpha running OSF */
94 # define __ALPHA_OSF__
95 #endif /* __alpha */
96
97 #ifdef __hpux
98 /** HP running HP-UX */
99 # define __HPUX__
100 #endif /* __hpux */
101
102 #ifdef _AIX
103 /** IBM RS6000 or PowerPC running AIX */
104 # define __IBM_AIX__
105 #endif /* _AIX */
106
107 #ifdef __sgi
108 /** SGI running IRIX */
109 # define __SGI_IRIX__
110 #endif /* __sgi */
111
112 #if defined(__sun) || defined(sun)
113 # ifdef __SVR4
114 /** Sparc running Solaris 2.x (SunOS 5.x) */
115 # define __SUN_SOLARIS__
116 # else /* __SVR4 */
117 /** Sparc running SunOS 4.x (Solaris 1.x) */
118 # define __SUN_SUNOS__
119 # endif /* __SVR4 */
120 #endif /* __sun || sun */
121
122
123 /*
124 * Make certain we have proper limits defined
125 */
126 #include <stdlib.h>
127 #include <limits.h>
128 #include <float.h>
129 #include <sys/types.h>
130 #ifdef _OSF_SOURCE
131 # include <sys/syslimits.h>
132 #endif
133 /* for use practically everywhere */
134 #include<stdio.h>
135
136
137 /* trying without this...
138 #if defined(__WIN32__) && !defined(__MINGW32__)
139 # undef Status /* jds20041229 - #define in tcl include/X11/XLib.h conflicts. *
140 # define WIN32_LEAN_AND_MEAN
141 # include <windows.h> /* jds20041212 - some limits defined in winnt.h (MAXLONG). *
142 # undef WIN32_LEAN_AND_MEAN
143 #endif
144 */
145 #ifndef PATH_MAX
146 /** Normally will come from stdio.h or limits.h
147 * POSIX values of PATH_MAX is 255, traditional is 1023
148 */
149 # define PATH_MAX 1023
150 #endif
151
152 /* the following numbers should have come through limits.h */
153 #ifndef SHRT_MAX
154 # define SHRT_MAX 32767
155 #endif
156 #ifndef INT_MAX
157 # define INT_MAX 2147483647
158 /* 32 bit machines */
159 #endif
160 #ifndef LONG_MAX
161 # ifdef __alpha
162 # define LONG_MAX 9223372036854775807 /* 64 bit machines */
163 # else /* __alpha */
164 # define LONG_MAX 2147483647 /* 32 bit machines */
165 # endif /* __alpha */
166 #endif /* LONG_MAX */
167
168 #ifndef MAXDOUBLE
169 # define MAXDOUBLE DBL_MAX
170 #endif
171 #ifndef MAXINT
172 # define MAXINT INT_MAX
173 #endif
174 #ifndef MAXUINT
175 # define MAXUINT UINT_MAX
176 #endif
177 #ifndef MAXLONG
178 # define MAXLONG LONG_MAX
179 #endif
180 #ifndef MAXULONG
181 # define MAXULONG UILONG_MAX
182 #endif
183
184 /**
185 * The largest number of digits we'd ever expect to see in a single
186 * numeric value, * 3 or so for good measure.
187 */
188 #define MAXIMUM_NUMERIC_LENGTH 80
189
190 /*
191 * Useful Headers
192 */
193
194 /* for use by ascmalloc, which is also practically everywhere */
195 #include <assert.h>
196 #include <string.h>
197 /*
198 * #include <malloc.h>
199 *
200 * malloc() is defined in <stdlib.h> in ANSI-C
201 */
202
203 #define MAXTOKENLENGTH 1024 /**< Maximum token size.
204 Most significant for identifiers and strings */
205 #ifndef FALSE
206 # define FALSE 0
207 # define TRUE 1
208 #endif
209
210 #ifndef CONST
211 # define CONST const
212 #endif
213
214 #define VOIDPTR void *
215
216 /* Updated the following to use new Wiki URLS */
217 #define ASC_MILD_BUGMAIL "https://pse.cheme.cmu.edu/wiki/view/Ascend/BugReport"
218 #define ASC_BIG_BUGMAIL "https://pse.cheme.cmu.edu/wiki/view/Ascend/BugReport"
219
220 extern FILE *g_ascend_errors; /**< File stream to receive error messages. */
221 extern FILE *g_ascend_warnings; /**< File stream to receive warning messages. */
222 extern FILE *g_ascend_information; /**< File stream to receive general messages. */
223
224 /* NB For error messages to be correctly captured, all output needs to go to stderr in error.h */
225 #ifndef ASCERR
226 # define ASCERR g_ascend_errors
227 # define ASCWAR g_ascend_warnings
228 # define ASCINF g_ascend_information
229 #endif
230 /*
231 * file pointers for whine. they default to stderr. if you change
232 * them, be sure to change them to valid files.
233 */
234
235 #define BYTESIZE 8
236 #define WORDSIZE (sizeof(unsigned)*BYTESIZE)
237 #ifndef TRUE
238 # define TRUE 1
239 #endif
240 #ifndef FALSE
241 # define FALSE 0
242 #endif
243 typedef char *POINTER; /**< Generic pointer. */
244 typedef char boolean; /**< Boolean type. */
245 typedef int ALIGN; /**< Data alignment. */
246 /**
247 * real64:
248 * change this typedef and all the solver code should change
249 * precision automatically. The code is predicated on 64bit ieee math.
250 * change the typedef as needed to get 64bit numbers. In particular
251 * crays may change this to float.
252 * int32:
253 * uint32;
254 * a 32bit int. change this typedef and all the solver code changes
255 * with it. may be of use for compiler which default int to 16bits
256 * equivalent to -i4 on most f77 compilers.
257 */
258 typedef double real64; /* a value */
259 typedef int int32; /**< a row/col/var/rel index number */
260 typedef unsigned uint32;
261
262
263 /**
264 * MAXREFCOUNT should always be defined to be the maximum value
265 * that the reference count attribute of reference count objects
266 * can take. It is unreasonable that a refcount be 64 bits, so
267 * it is 32.
268 */
269 #define MAXREFCOUNT UINT_MAX
270 #define REFCOUNT_T unsigned int
271
272 /*
273 * A bit of header magic to address the question of NULL being implementation
274 * defined, though virtually all systems of interest define it as 0 or 0L,
275 * if we are to claim ANSI conformance.
276 *
277 * IEEE 754 arithmetic implies all 0 bits <--> 0.0, so there isn't
278 * a problem where this is concerned. We have assumed ieee math.
279 *
280 * Notes to myself:
281 * Put this in base.h and suggest its insertion in
282 * compiler.h and perhaps interface1.h.
283 * Any place that calloc is being used to allocate arrays of NULL pointers,
284 * put a proper #if to replace it with a call to malloc and an appropriate
285 * NULLing function.
286 *
287 * Ben Allan, Jan 6, 1994.
288 */
289
290 /*
291 * NOTE: The below if works for 0 or 0L, which is to say I assume it
292 * works for 0 and I have tested that it works for 0L. Next we define
293 * the cheap versions of null testing for machine with 0 == NULL
294 *
295 * These are the proper ANSI C tests for NULL on 0!=NULL machines, should
296 * we ever run into them.
297 */
298 #ifdef NULL
299 /* ok, so the machine has a NULL defined. */
300 # ifndef ISNULL
301 /* and we've not got an ISNULL function */
302 # define ISNULL(a) ((a) == NULL)
303 # define NOTNULL(a) ((a) != NULL)
304 # endif /* ISNULL */
305 # endif /* NULL */
306
307 #ifndef NULL
308 # error "Null not defined by the time ascConfig.h seen"
309 #endif
310
311 #ifndef UNUSED_PARAMETER
312 /** Standardize the treatment of unreferenced function parameters. */
313 # define UNUSED_PARAMETER(p) (void)(p)
314 #endif
315
316 /* ASCEND assertion defines */
317 /** Exit status code for failed assertion. */
318 #define ASCERR_ASSERTION_FAILED 100
319 /*
320 * For now, asc_assert tied to NDEBUG just like regular assert.
321 * Having a separate assertion deactivator (ASC_NO_ASSERTIONS)
322 * gives us the ability to decouple from NDEBUG and leave
323 * assertions active in release code if desired.
324 */
325 #ifdef NDEBUG
326 /** If defined, asc_assert() will be removed from code. */
327 # define ASC_NO_ASSERTIONS
328 #endif
329
330 /*
331 *
332 * Platform specific fixes
333 *
334 */
335
336 #if defined(__WIN32__) && !defined(__MINGW32__)
337
338 /*
339 * use the ASCEND printf substitutes
340 */
341 # ifndef USE_ASC_PRINTF
342 # define USE_ASC_PRINTF
343 # endif /* USE_ASC_PRINTF */
344
345 /*
346 * build the Tk Console
347 */
348 # ifndef ASC_USE_TK_CONSOLE
349 # define ASC_USE_TK_CONSOLE
350 # endif /* ASC_USE_TK_CONSOLE */
351
352 /*
353 * make macros so that DLLs can see nominated internal C functions.
354 * Unix programmers might also use the presence of these macros to figure
355 * out which APIs are to be regarded as more stable.
356 */
357 # if defined(ASC_BUILD_DLL)
358 # define DLEXPORT __declspec(dllexport)
359 # elif defined(ASC_BUILD_LIB)
360 # define DLEXPORT
361 # else
362 /* changed this coz of errors with MSVC 2003 */
363 # define DLEXPORT
364 # endif
365
366 #else /* not __WIN32__ isms */
367
368 # ifdef HAVE_GCCVISIBILITYPATCH
369 # define DLEXPORT __attribute__ ((visibility("default")))
370 # else
371 # define DLEXPORT
372 # endif
373
374 #endif /* __WIN32__ */
375
376 #ifndef DLEXPORT
377 # error "NO DLEXPORT DEFINED"
378 #endif
379
380 /* use signals by default, but disable with configure. */
381 #ifdef ASC_NO_TRAPS
382 /** Don't use signals. */
383 # define NO_SIGNAL_TRAPS 1
384 #else
385 /** Use signals. */
386 # undef NO_SIGNAL_TRAPS
387 #endif
388
389 /*------------------------------------*
390 OUTPUT FILE* MAPPINGS
391
392 On Windows, we have to use these special Asc_Printf (etc)
393 routines in order that output can be captured correctly by the GUI.
394
395 On non-Windows platforms, allow error.h to
396 */
397 #ifdef USE_ASC_PRINTF
398 # define ASC_PRINTF Asc_Printf
399 # define ASC_FPRINTF Asc_FPrintf
400 # define ASC_VFPRINTF Asc_VFPrintf
401 # define ASC_FFLUSH Asc_FFlush
402 # define ASC_PUTC Asc_FPutc
403 # define ASC_FPUTC Asc_FPutc
404 # define ASC_PUTCHAR Asc_Putchar
405 # include <stdarg.h>
406 # include "utilities/ascPrint.h"
407 #else
408 # define ASC_PRINTF printf
409 # define ASC_FPRINTF fprintf
410 # define ASC_VFPRINTF vfprintf
411 # define ASC_FFLUSH fflush
412 # define ASC_PUTC putc
413 # define ASC_FPUTC fputc
414 # define ASC_PUTCHAR putchar
415 #endif
416
417 /* error.h will define handlers for
418 FPRINTF
419 FPUTC
420 FFLUSH
421 */
422 #ifdef IS_BINTOKEN_COMPILE
423 # define FPRINTF ASC_FPRINTF
424 # define FPUTC ASC_FPUTC
425 # define FFLUSH ASC_FFLUSH
426 #else
427 # include "utilities/error.h"
428 #endif
429
430 /* These are the remaining output macros that need to be mapped
431 */
432 #define PRINTF ASC_PRINTF
433 #define PUTCHAR ASC_PUTCHAR
434 /*------------------------------------*/
435
436
437 #ifndef __SUN_SUNOS__
438 /* do this for non-sun machines and for sun-solaris machines */
439 # ifndef roundup
440 # define rounddown(num,mod) ((num)-(num)%(mod))
441 # define roundup(num,mod) rounddown((num)+(mod)-1,(mod))
442 # define roundoff(num,mod) rounddown((num)+((mod)/2),(mod))
443 # endif /* roundup */
444 #endif /* __SUN_SUNOS__ */
445
446
447 /* These define integer divide and modulus mathematically correctly */
448 #define imod(num,den) ((num)%(den) + ((num)%(den)<0 ? (den) : 0))
449 #define idiv(num,den) ((num)/(den) + ((num)%(den)<0))
450 #define array_length(a) (sizeof(a)/sizeof((a)[0]))
451
452 /*
453 * the following patch up IEEE754isms that some systems can't seem to
454 * get right.
455 */
456 #define FPRESET (void)0
457 #ifdef __WIN32__
458 /* renamed in some __WIN32__ compiler systems */
459 # ifndef NO_RENAME_IEEE_FUNCTIONS
460 # undef finite
461 # define finite(x) _finite(x)
462 # undef isnan
463 # define isnan(x) _isnan(x)
464 # undef isinf
465 # define isinf(x) _isinf(x)
466 # endif
467 # undef FPRESET
468 # define FPRESET _fpreset()
469 /* MSVC peculiarities */
470 # ifdef _MSC_VER
471 # undef snprintf
472 # define snprintf _snprintf
473 # undef vsnprintf
474 # define vsnprintf _vsnprintf
475 # undef tempnam
476 # define tempnam _tempnam
477 # undef fdopen
478 # define fdopen _fdopen
479 # undef fileno
480 # define fileno _fileno
481 # undef getpid
482 # define getpid _getpid
483 # undef dup
484 # define dup _dup
485 # undef dup2
486 # define dup2 _dup2
487 # undef putenv
488 # define putenv _putenv
489 # endif
490 #endif /* __WIN32__ */
491
492 #ifdef __SUN_SUNOS__
493 /** not properly headered in math.h or ieee*.h */
494 extern int finite(double);
495 #endif
496
497 #endif /* ASC_ASCCONFIG_H */
498

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