1 #ifndef CONFIG2_H
2 #define CONFIG2_H 1
3 
4 #include <assert.h> /* NDEBUG==1 means: no assertions */
5 #if NDEBUG
6 #  define ASSERT_SIDE(x) x /* assert with side effect */
7 #  define ASSERT_SIDE2(x,y) x /* assert with side effect */
8 #else
9 #  define ASSERT_SIDE(x) assert(x)
10 #  define ASSERT_SIDE2(x,y) assert(x y)
11 #endif
12 
13 #if _MSC_VER > 1000
14 #  include "config-vc6.h"
15 #elif USE_CONFIG_MINGW_H
16 #  include "config-mingw.h"
17 #elif USE_CONFIG_UCLIBC_H
18 #  include "config-uclibc.h"
19 #else
20 #  include "config.h"
21 #endif
22 
23 #if 0
24 /* vvv i386 Debian slink gcc */
25 #define SIZEOF_SHORT 2
26 #define SIZEOF_INT 4
27 #define SIZEOF_LONG 4
28 #define SIZEOF_LONG_LONG 8
29 #endif
30 
31 #if SIZEOF_CHAR_P!=SIZEOF_LONG && SIZEOF_INT>=4
32   typedef unsigned slen_t;
33   typedef signed slendiff_t;
34 # define SIZEOF_SLEN_T SIZEOF_INT
35 # define SLEN_P ""
36 #else
37   typedef unsigned long slen_t;
38   typedef signed   long slendiff_t;
39 # define SIZEOF_SLEN_T SIZEOF_LONG
40 # define SLEN_P "l"
41 #endif
42 
43 #if SIZEOF___INT64>SIZEOF_LONG
44 #  define HAVE_LONG_LONG 1
45 #  define PTS_CFG_LONGEST __int64 /* may be used as signed CFG_LONGEST */
46 #  define SIZEOF_CFG_LONGEST SIZEOF___INT64
47 #elif SIZEOF_LONG_LONG>SIZEOF_LONG
48 #  define HAVE_LONG_LONG 1
49 #  define PTS_CFG_LONGEST long long /* may be used as signed CFG_LONGEST */
50 #  define SIZEOF_CFG_LONGEST SIZEOF_LONG_LONG
51 #elif SIZEOF_VERY_LONG>SIZEOF_LONG
52 #  define HAVE_LONG_LONG 1
53 #  define PTS_CFG_LONGEST very long /* may be used as signed CFG_LONGEST */
54 #  define SIZEOF_CFG_LONGEST SIZEOF_VERY_LONG
55 #else
56 #  undef HAVE_LONG_LONG
57 #  define PTS_CFG_LONGEST long
58 #  define SIZEOF_CFG_LONGEST SIZEOF_LONG
59 #endif
60 
61 #define NULLP ((void*)0)
62 
63 #define USE_IN_TIFF 1
64 #define USE_IN_JPEG 1
65 #define USE_IN_PNG 1
66 #define USE_IN_PCX 1
67 #define USE_IN_XPM 1
68 /* #define USE_IN_GIF 1 -- defined in */
69 #define USE_IN_PNM 1
70 #define USE_IN_BMP 1
71 #define USE_IN_PIP 1 /* simple paletted format defined by pts, but not implemented */
72 #define USE_IN_TGA 1
73 #define USE_IN_LBM 1
74 #define USE_IN_JAI 1
75 #define USE_IN_PDF 1
76 #define USE_IN_PS 1
77 /* #define USE_OUT_GIF 1 -- moved to config.h */
78 #define USE_IN_XPM_MAPPING 1
79 #define USE_BIG_MEMORY 1
80 #define USE_DICT_MAPPING 1
81 /* at Tue Jan 18 16:18:34 CET 2005 */
82 #define USE_ZLIB_MEM 1
83 
84 /** Quotes a filename to be displayed in error messages */
85 /* #define FNQ(str) (str) */
86 #define FNQ(filename) SimBuffer::B().appendFnq(SimBuffer::Static(filename))
87 #define FNQ2(beg,len) SimBuffer::B().appendFnq(SimBuffer::Static(beg,len),true)
88 #define FNQ2STDOK(beg,len) SimBuffer::B().appendFnq(SimBuffer::Static(beg,len),false)
89 
90 
91 #define param_assert assert
92 
93 #undef  __VA_START_STDC__
94 #ifdef __STDC__
95 # define __VA_START_STDC__ 1
96 #endif
97 #if _MSC_VER > 1000
98 # undef  __PROTOTYPES__
99 # define __PROTOTYPES__ 1
100 # undef  __VA_START_STDC__
101 # define __VA_START_STDC__ 1
102 # pragma warning(disable: 4127) /* conditional expression is constant */
103 # pragma warning(disable: 4244) /* =' : conversion from 'int ' to 'unsigned char ', possible loss of data */
104 # pragma warning(disable: 4250) /* 'SimBuffer::B' : inherits 'SimBuffer::Flat::getLength' via dominance */
105 # pragma warning(disable: 4514) /* 'each_char' : unreferenced inline function has been removed */
106 # pragma warning(disable: 4512) /* 'PipeE' : assignment operator could not be generated */
107 # pragma warning(disable: 4310) /* cast truncates constant value */
108 # pragma warning(disable: 4355) /* 'this' : used in base member initializer list */
109 #endif
110 
111 #if __VA_START_STDC__
112 # define PTS_va_start(ap, fmt) va_start(ap, fmt)
113 #else
114 # define PTS_va_start(ap, fmt) va_start(ap)
115 #endif
116 
117 #if HAVE_STATIC_CONST
118 # define BEGIN_STATIC_ENUM(basetype,type) typedef basetype type; static const type
119 # define BEGIN_STATIC_ENUM1(type) static const type
120 # define END_STATIC_ENUM() ;
121 #else /* VC6.0 */
122 # define BEGIN_STATIC_ENUM(basetype,type) enum type {
123 # define BEGIN_STATIC_ENUM1(type) enum {
124 # define END_STATIC_ENUM() };
125 #endif
126 
127 #if ((defined(__STDC__) || defined(__PROTOTYPES__)) && !defined(NO_PROTO)) || defined(__cplusplus)
128 # define _(args) args
129 # define OF(args) args
130 # define ___(arg2s,arg1s,argafter) arg2s /* Dat: no direct comma allowed in args :-( */
131 #else
132 # define _(args) ()
133 # define OF(args) ()
134 # define ___(arg2s,arg1s,argafter) arg1s argafter /* Dat: no direct comma allowed in args :-( */
135 #endif
136 
137 #if SIZEOF_BOOL!=1
138 #define bool PTS_bool
139 #define true 1
140 #define false 0
141 typedef unsigned char bool;
142 #endif
143 
144 #ifdef const
145 #  undef const
146 #  define PTS_const
147 #  undef HAVE_CONST
148 #else
149 #  define PTS_const const
150 #  define HAVE_CONST 1
151 #endif
152 
153 #ifdef volatile
154 #  undef volatile
155 #  define PTS_volatile
156 #  undef HAVE_VOLATILE
157 #else
158 #  define PTS_volatile volatile
159 #  define HAVE_VOLATILE 1
160 #endif
161 
162 #ifdef NEED_STRING_H
163 /* We use: memset(), memmove(), strncpy(), memcpy(), memcmp() */
164 #if HAVE_MEMCMPY_BUILTIN
165 #  undef memcpy
166 #  define memcpy dummy_memcpy
167 #  undef memcmp
168 #  define memcmp dummy_memcmp
169 #endif
170 #ifdef HAVE_strcpy_in_string
171 #  include <string.h>
172 #elif HAVE_strcpy_in_strings
173 #  include <strings.h>
174 #else
175 #  error no strcpy
176 #endif
177 #if HAVE_MEMCMPY_BUILTIN
178 #  undef memcmp
179 #  undef memcpy
180 #endif
181 #endif
182 
183 #ifdef NEED_MALLOC
184 #if HAVE_malloc_in_stdlib
185 #  include <stdlib.h>
186 #elif HAVE_PTS_STDC && HAVE_malloc_in_malloc
187 #  include <malloc.h>
188 #elif HAVE_PTS_STDC
189 #  error malloc() not found
190 #elif HAVE_PROTOTYPES
191   void *malloc(PTS_size_t size);
192   void *realloc(void *ptr, PTS_size_t size);
193   void free(void *ptr);
194 #else
195   void *malloc();
196   void *realloc();
197   void free();
198 #endif
199 #endif
200 
201 #ifdef NEED_ALLOCA
202 /* Make alloca work the best possible way.
203  * Imp: AIX requires this to be the 1st thing in the file??
204  */
205 #ifdef __GNUC__
206 # ifndef atarist
207 #  ifndef alloca
208 #   define alloca __builtin_alloca
209 #  endif
210 # endif /* atarist */
211 #elif defined(__BORLANDC__)
212 # include <malloc.h>
213 #elif HAVE_ALLOCA_H
214 # include <alloca.h>
215 #elif defined(_AIX)
216  #pragma alloca /* indented to avoid choking of pre-ANSI compilers */
217 #elif !defined alloca /* predefined by HP cc +Olibcalls */
218 char *alloca ();
219 #endif
220 #endif /* NEED_ALLOCA */
221 
222 #ifdef NEED_SIGN_EXTEND_CHAR
223 /* We remove any previous definition of `SIGN_EXTEND_CHAR',
224    since ours (we hope) works properly with all combinations of
225    machines, compilers, `char' and `unsigned char' argument types.
226    (Per Bothner suggested the basic approach.)  */
227 #undef SIGN_EXTEND_CHAR
228 #if HAVE_PTS_STDC
229 # define SIGN_EXTEND_CHAR(c) ((signed char)(c))
230 #else  /* not __STDC__ */
231 /* As in Harbison and Steele.  */
232 # define SIGN_EXTEND_CHAR(c) ((((unsigned char)(c)) ^ 128) - 128)
233 #endif
234 #endif
235 
236 /* by pts@fazekas.hu at Fri Mar 22 17:01:27 CET 2002 */
237 #if defined(HAVE_PTS_POPEN_)
238 #  define HAVE_PTS_POPEN 1
239 #  define CFG_PTS_POPEN_B ""
240 #elif defined(HAVE_PTS_POPEN_B)
241 #  define HAVE_PTS_POPEN 1
242 #  define CFG_PTS_POPEN_B "b"
243 #else
244 #  undef HAVE_PTS_POPEN
245 #endif
246 
247 #undef NEED_LONG_LONG
248 #undef NEED_LONG_DOUBLE
249 
250 /** Filename, directory and quoting conventions for the host OS.
251  * 0: UNIX
252  * 1: DOS/Win3.1
253  * 2: WinNT
254  * 3: Win9X
255  * 4: VMS
256  * 5: Mac
257  * 6...
258  *
259  * Imp: implement other than UNIX
260  */
261 #define COTY_UNIX  0
262 #define COTY_DOS   1
263 #define COTY_WINNT 2
264 #define COTY_WIN9X 3
265 #define COTY_VMS   4
266 #define COTY_MAC   5
267 #define COTY_OTHER 6
268 
269 #if HAVE_PTS_SYSTEMF_UNIX
270 #  define OS_COTY COTY_UNIX
271 #else
272 #  if HAVE_PTS_SYSTEMF_WIN32
273 #    define OS_COTY COTY_WIN9X
274 #  else
275 #    define OS_COTY COTY_OTHER
276 #  endif
277 #endif
278 
279 /* vvv Imp: autodetect this */
280 #if defined(__MSDOS__) || defined(__CYGWIN__) || defined(__MINGW32__) || _MSC_VER > 1000
281 #  define HAVE_DOS_BINARY 1
282 #else
283 #  undef  HAVE_DOS_BINARY
284 #endif
285 
286 /* #define PTS_dynamic_cast(ptrtype,ptr) dynamic_cast<ptrtype>(ptr) -- would include special G++ symbols into .o */
287 #define PTS_dynamic_cast(ptrtype,ptr) ((ptrtype)(ptr))
288 
289 /** Suppress effect of -Wcast-align warning */
290 #define PTS_align_cast(ptrtype,ptr) ((ptrtype)(void*)(ptr))
291 /** Suppress effect of -Wcast-align warning */
292 #define PTS_calign_cast(ptrtype,ptr) ((ptrtype)(void const*)(ptr))
293 
294 
295 #undef HAVE_LZW
296 #if USE_BUILTIN_LZW
297 #  define HAVE_LZW 1
298 #else
299 #  define HAVE_LZW 1 /* try to use external lzw_codec */
300 #endif
301 /* #define USE_BUILTIN_FAXE 1 */ /* in config.h */
302 #undef  USE_BUILTIN_FAXD /* sure */
303 /* #define USE_BUILTIN_FAXD 1 */ /* in config.h */
304 
305 #ifndef __cplusplus
306 #undef true
307 #undef false
308 #ifdef __BEOS__
309 typedef unsigned char bool;
310 #else
311 typedef int bool;
312 #endif
313 #define true ((bool)1)
314 #define false ((bool)0)
315 #endif
316 
317 /* by pts@fazekas.hu at Tue Sep  3 18:47:47 CEST 2002 */
318 #if OBJDEP && defined(__cplusplus) && HAVE_PTS_C_LGCC_CPP_REQUIRED
319 #  warning REQUIRES: c_lgcc.o
320 #endif
321 #if OBJDEP && defined(__cplusplus) && HAVE_PTS_C_LGCC3_CPP_REQUIRED
322 #  warning REQUIRES: c_lgcc3.o
323 #endif
324 
325 /* at Wed Aug 21 18:28:24 CEST 2002 */
326 #if HAVE_getc_in_stdio
327 #  define MACRO_GETC getc
328 #else
329 #  if HAVE_fgetc_in_stdio
330 #    define MACRO_GETC fgetc
331 #  else
332 #    error getc() or fgetc() is required
333 #  endif
334 #endif
335 #if HAVE_putc_in_stdio
336 #  define MACRO_PUTC putc
337 #else
338 #  if HAVE_fputc_in_stdio
339 #    define MACRO_PUTC fputc
340 #  else
341 #    error putc() or fputc() is required
342 #  endif
343 #endif
344 
345 #ifndef USE_ATTRIBUTE_ALIAS
346 #define USE_ATTRIBUTE_ALIAS 1
347 #endif
348 
349 #endif /* config2.h */
350