/[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 48 - (show annotations) (download) (as text)
Sat Apr 9 13:04:03 2005 UTC (15 years, 7 months ago) by jds
File MIME type: text/x-chdr
File size: 10448 byte(s)
Fix typo in utilities/ascConfig.h.  mea culpa.
Update WinVC7 project files.
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 * This header and tcl/tk headers are known to conflict. This header
35 * should be included AFTER tcl.h or tk.h, not before.
36 */
37
38 #ifndef _ASCCONFIG_H
39 #define _ASCCONFIG_H
40
41 /*
42 * If we are in a tcl-infested file, define
43 * CONST84 to be empty for back-compatibility with
44 * tcl8.3
45 */
46 #ifdef TCL_VERSION
47 #ifndef CONST84
48 #define CONST84
49 #define QUIET(x) x
50 #define QUIET2(x) x
51 #else
52 /** use this macro to shut up const when const
53 from tcl-land would be going into non-tcl C.
54 */
55 #define QUIET(x) ((char *)x)
56 #define QUIET2(v) ((char **)v)
57 #endif
58 #endif
59
60 /*
61 *
62 * Determine the Operating System we are building on
63 *
64 */
65 #ifndef __WIN32__
66 #if defined(_WIN32) || defined(WIN32)
67
68 /* Windows */
69 #define __WIN32__
70
71 #else /* _WIN32 || WIN32 */
72
73 /* Some flavor of Unix */
74
75 #ifdef __alpha
76 /* DEC Alpha running OSF */
77 #define __ALPHA_OSF__
78 #endif /* __alpha */
79
80 #ifdef __hpux
81 /* HP running HP-UX */
82 #define __HPUX__
83 #endif /* __hpux */
84
85 #ifdef _AIX
86 /* IBM RS6000 or PowerPC running AIX */
87 #define __IBM_AIX__
88 #endif /* _AIX */
89
90 #ifdef __sgi
91 /* SGI running IRIX */
92 #define __SGI_IRIX__
93 #endif /* __sgi */
94
95 #if defined(__sun) || defined(sun)
96 #ifdef __SVR4
97 /* Sparc running Solaris 2.x (SunOS 5.x) */
98 #define __SUN_SOLARIS__
99 #else /* __SVR4 */
100 /* Sparc running SunOS 4.x (Solaris 1.x) */
101 #define __SUN_SUNOS__
102 #endif /* __SVR4 */
103 #endif /* __sun || sun */
104
105 #endif /* _WIN32 || WIN32 */
106 #endif /* __WIN32__ */
107
108
109 /*
110 *
111 * Make certain we have proper limits defined
112 *
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 #define PATH_MAX 1023
134 /* POSIX values of PATH_MAX is 255, traditional is 1023 */
135 #endif
136
137 /* the following numbers should have come through limits.h */
138 #ifndef SHRT_MAX
139 #define SHRT_MAX 32767
140 #endif
141 #ifndef INT_MAX
142 #define INT_MAX 2147483647
143 /* 32 bit machines */
144 #endif
145 #ifndef LONG_MAX
146 #ifdef __alpha
147 #define LONG_MAX 9223372036854775807 /* 64 bit machines */
148 #else /* __alpha */
149 #define LONG_MAX 2147483647 /* 32 bit machines */
150 #endif /* __alpha */
151 #endif /* LONG_MAX */
152
153 #ifndef MAXDOUBLE
154 #define MAXDOUBLE DBL_MAX
155 #endif
156 #ifndef MAXINT
157 #define MAXINT INT_MAX
158 #endif
159 #ifndef MAXUINT
160 #define MAXUINT UINT_MAX
161 #endif
162 #ifndef MAXLONG
163 #define MAXLONG LONG_MAX
164 #endif
165 #ifndef MAXULONG
166 #define MAXULONG UILONG_MAX
167 #endif
168
169 /*
170 * the largest number of digits we'd ever expect to see in a single
171 * numeric value, * 3 or so for good measure.
172 */
173 #define MAXIMUM_NUMERIC_LENGTH 80
174
175 /*
176 *
177 * Useful Headers
178 *
179 */
180
181 /* for use by ascmalloc, which is also practically everywhere */
182 #include <assert.h>
183 #include <string.h>
184 /*
185 * #include <malloc.h>
186 *
187 * malloc() is defined in <stdlib.h> in ANSI-C
188 */
189
190
191 #define MAXTOKENLENGTH 1024 /* maximum token size most significant for */
192 /* identifiers and strings */
193 #ifndef FALSE
194 #define FALSE 0
195 #define TRUE 1
196 #endif
197
198 #ifndef MAX
199 #define MAX(a,b) ((a) > (b) ? (a) : (b))
200 #endif
201 #ifndef MIN
202 #define MIN(a,b) ((a) < (b) ? (a) : (b))
203 #endif
204 #ifndef ABS
205 #define ABS(x) ((x) > 0 ? (x) : -(x))
206 #endif
207
208
209 #ifndef CONST
210 #define CONST const
211 #endif
212
213 #define VOIDPTR void *
214
215
216 #define ASC_MILD_BUGMAIL "ascend+bugs@cs.cmu.edu"
217 #define ASC_BIG_BUGMAIL "ascend+developers@cs.cmu.edu"
218
219
220 extern FILE *g_ascend_errors;
221 extern FILE *g_ascend_warnings;
222 extern FILE *g_ascend_information;
223 #ifndef ASCERR
224 #define ASCERR g_ascend_errors
225 #define ASCWAR g_ascend_warnings
226 #define ASCINF g_ascend_information
227 #endif
228 /*
229 * file pointers for whine. they default to stderr. if you change
230 * them, be sure to change them to valid files.
231 */
232
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 REFCOUNT_T unsigned int
270 #define MAXREFCOUNT UINT_MAX
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 UNREFERENCED_PARAMETER
312 /** Standardize the treatment of unreferenced function parameters. */
313 # define UNREFERENCED_PARAMETER(p) (void)(p)
314 #endif
315
316 /*
317 *
318 * Platform specific fixes
319 *
320 */
321
322 /*
323 * The following definitions set up the proper options for Windows
324 * compilers. We use this method because there is no autoconf equivalent.
325 */
326 #ifdef __WIN32__
327
328 /*
329 * use the ASCEND printf substitutes
330 */
331 #ifndef USE_ASC_PRINTF
332 #define USE_ASC_PRINTF
333 #endif /* USE_ASC_PRINTF */
334
335 /*
336 * build the Tk Console
337 */
338 #ifndef ASC_USE_TK_CONSOLE
339 #define ASC_USE_TK_CONSOLE
340 #endif /* ASC_USE_TK_CONSOLE */
341
342 /*
343 * make macros so that DLLs can see nominated internal C functions.
344 * Unix programmers might also use the presence of these macros to figure
345 * out which APIs are to be regarded as more stable.
346 */
347 #define DLEXPORT __declspec(dllexport)
348 #define DLIMPORT __declspec(dllimport)
349
350 #else /* not __WIN32__ isms */
351
352 #define DLEXPORT
353 #define DLIMPORT
354
355 #endif /* __WIN32__ */
356
357 #ifdef ASC_NO_TRAPS
358 /* use signals by default, but disable with configure.
359 */
360 #define NO_SIGNAL_TRAPS 1
361 #else
362 #define NO_SIGNAL_TRAPS 0
363 #endif
364
365 #ifdef USE_ASC_PRINTF
366 #define PRINTF Asc_Printf
367 #define FPRINTF Asc_FPrintf
368 #define FFLUSH Asc_FFlush
369 #define PUTC Asc_FPutc
370 #define FPUTC Asc_FPutc
371 #define PUTCHAR Asc_Putchar
372 #include <stdarg.h>
373 #include "utilities/ascPrint.h"
374 #else /* USE_ASC_PRINTF */
375 #define PRINTF printf
376 #define FPRINTF fprintf
377 #define FFLUSH fflush
378 #define PUTC putc
379 #define FPUTC fputc
380 #define PUTCHAR putchar
381 #endif /* USE_ASC_PRINTF */
382
383
384
385 #ifndef __SUN_SUNOS__
386 /* do this for non-sun machines and for sun-solaris machines */
387 #ifndef roundup
388 #define rounddown(num,mod) ((num)-(num)%(mod))
389 #define roundup(num,mod) rounddown((num)+(mod)-1,(mod))
390 #define roundoff(num,mod) rounddown((num)+((mod)/2),(mod))
391 #endif /* roundup */
392 #endif /* __SUN_SUNOS__ */
393
394
395 /* These define integer divide and modulus mathematically correctly */
396 #define imod(num,den) ((num)%(den) + ((num)%(den)<0 ? (den) : 0))
397 #define idiv(num,den) ((num)/(den) + ((num)%(den)<0))
398 #define array_length(a) (sizeof(a)/sizeof((a)[0]))
399
400 /*
401 * the following patch up IEEE754isms that some systems can't seem to
402 * get right.
403 */
404 #define FPRESET (void)0
405 #ifdef __WIN32__
406 /* renamed in some __WIN32__ compiler systems */
407 # ifndef finite
408 # define finite(x) _finite(x)
409 # endif
410 # ifndef isnan
411 # define isnan(x) _isnan(x)
412 # endif
413 # ifndef isinf
414 # define isinf(x) _isinf(x)
415 # endif
416 # undef FPRESET
417 # define FPRESET _fpreset()
418 #endif /* __WIN32__ */
419
420 #ifdef __SUN_SUNOS__
421 /* not properly headered in math.h or ieee*.h */
422 extern int finite(double);
423 #endif
424
425
426 #endif /* _ASCCONFIG_H */
427

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