File: headers\port.h
1 /**************************************
2 **
3 ** PORT.H : Miscellaneous definitions for portability. Please add
4 ** to this file for any new machines/compilers you may have.
5 **
6 ** XFRACT file "SHARED.H" merged into PORT.H on 3/14/92 by --CWM--
7 ** TW also merged in Wes Loewer's BIGPORT.H.
8 */
9
10 #ifndef PORT_H /* If this is defined, this file has been */
11 #define PORT_H /* included already in this module. */
12
13 #ifndef XFRACT
14 #include <dos.h>
15 #else
16 #include <unistd.h> 17 #endif
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <math.h>
21 #include <float.h>
22
23
24 #if (defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER) || defined(__TURBOC__)) && !defined(STDC)
25 # define STDC
26 #endif
27
28 #if (defined(LINUX)) && !defined(STDC)
30 #endif
31
32 #ifndef STDC
33 # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
34 # define const
35 # endif 36 #endif
37
38 #ifdef __TURBOC__
42 #endif
43
44 /* If endian.h is not present, it can be handled in the code below, */
45 /* but if you have this file, it can make it more fool proof. */
46 #if (defined(XFRACT) && !defined(__sun))
47 #if defined(sgi)
48 #include <sys/endian.h>
49 #else
50 #include <endian.h>
51 #endif 52 #endif
53 #ifndef BIG_ENDIAN
54 #define BIG_ENDIAN 4321 /* to show byte order (taken from gcc) */
55 #endif
56 #ifndef LITTLE_ENDIAN
57 #define LITTLE_ENDIAN 1234
58 #endif
59
60 #define MSDOS 1
61
62 #define overwrite fract_overwrite /* avoid name conflict with curses */
63
64 #ifdef XFRACT /* XFRACT forces unix configuration! --CWM-- */
103 #endif /* XFRACT */
104
105 #ifdef __TURBOC__
107 #endif
108
109 #ifdef MSDOS /* Microsoft C 5.1 for OS/2 and MSDOS */
110 /* NOTE: this is always true on DOS! */
111 /* (MSDOS is defined above) */
112 #define timebx timeb
113
114 #ifndef BYTE_ORDER
115 #define BYTE_ORDER LITTLE_ENDIAN
116 #endif
117
118 #ifdef _MSC_VER /* MSC assert does nothing under MSDOS */
119 #ifdef assert
122 #endif
123 #endif
124
125 typedef unsigned char U8;
126 typedef signed char S8;
127 typedef unsigned short U16;
128 typedef signed short S16;
129 typedef unsigned long U32;
130 typedef signed long S32;
131 typedef unsigned char BYTE;
132 typedef unsigned char CHAR;
133 typedef void *VOIDPTR;
134 typedef void far *VOIDFARPTR;
135 typedef const void *VOIDCONSTPTR;
136
137 #define CONST const
138 #define PRINTER "/dev/prn"
139 #define LOBYTEFIRST 1
140 #define SLASHC '\\'
141 #define SLASH "\\"
142 #define SLASHSLASH "\\\\"
143 #define SLASHDOT "\\."
144 #define DOTSLASH ".\\"
145 #define DOTDOTSLASH "..\\"
146 #define READMODE "rb" /* Correct DOS text-mode */
147 #define WRITEMODE "wb" /* file open "feature". */
148
149 #define write1(ptr,len,n,stream) fwrite(ptr,len,n,stream)
150 #define write2(ptr,len,n,stream) fwrite(ptr,len,n,stream)
151 #define rand15() rand()
152
153 #else /* Have to nest because #elif is not portable */
154 #ifdef AMIGA /* Lattice C 3.02 for Amiga */
155 typedef UBYTE U8;
156 typedef BYTE S8;
157 typedef UWORD U16;
158 typedef WORD S16;
159 typedef unsigned int U32;
160 typedef int S32;
161 typedef UBYTE BYTE;
162 typedef UBYTE CHAR;
163
164 typedef void *VOIDPTR;
165 typedef void *VOIDFARPTR;
166 typedef const void *VOIDCONSTPTR;
167
168 #define PRINTER "PRT:"
169 #define LOBYTEFIRST 0
170 #define SLASHC '/'
171 #define SLASH "/"
172 #define SLASHSLASH "//"
173 #define SLASHDOT "/."
174 #define DOTSLASH "./"
175 #define DOTDOTSLASH "../"
176 #define READMODE "rb"
177 #define WRITEMODE "wb"
178
179 #define write1(ptr,len,n,stream) (fputc(*(ptr),stream),1)
180 #define write2(ptr,len,n,stream) (fputc((*(ptr))&255,stream),fputc((*(ptr))>>8,stream),1)
181 #define rand15() (rand()&0x7FFF)
182
183 #define BYTE_ORDER BIG_ENDIAN
184 #define USE_BIGNUM_C_CODE
185 #define BIG_ANSI_C
186
187 #else
188 #ifdef unix /* Unix machine */
189 typedef unsigned char U8;
190 typedef signed char S8;
191 typedef unsigned short U16;
192 typedef short S16;
193 typedef unsigned long U32;
194 typedef long S32;
195 typedef unsigned char BYTE;
196 typedef char CHAR;
197
198 #ifndef __cdecl
199 #define __cdecl
200 #endif
201
202 #ifdef __SVR4
203 typedef void *VOIDPTR;
204 typedef void *VOIDFARPTR;
205 typedef const void *VOIDCONSTPTR;
206 #else
207 # ifdef BADVOID
208 typedef char *VOIDPTR;
209 typedef char *VOIDFARPTR;
210 typedef char *VOIDCONSTPTR;
211 # else
212 typedef void *VOIDPTR;
213 typedef void *VOIDFARPTR;
214 typedef const void *VOIDCONSTPTR;
215 # endif
216 #endif
217
218 #ifdef __SVR4
219 # include <fcntl.h>
220 typedef void sigfunc(int);
221 #else
222 typedef int sigfunc(int);
223 #endif
224
225 #ifndef BYTE_ORDER
226 /* change for little endians that don't have this defined elsewhere (endian.h) */
227 #ifdef LINUX
228 #define BYTE_ORDER LITTLE_ENDIAN
229 #else
230 #define BYTE_ORDER BIG_ENDIAN /* the usual case */
231 #endif
232 #endif
233
234 #ifndef USE_BIGNUM_C_CODE
235 #define USE_BIGNUM_C_CODE
236 #endif
237 #ifndef BIG_ANSI_C
238 #define BIG_ANSI_C
239 #endif
240
241 # define CONST const
242 # define PRINTER "/dev/lp"
243 # define SLASHC '/'
244 # define SLASH "/"
245 # define SLASHSLASH "//"
246 # define SLASHDOT "/."
247 # define DOTSLASH "./"
248 # define DOTDOTSLASH "../"
249 # define READMODE "r"
250 # define WRITEMODE "w"
251
252 # define write1(ptr,len,n,stream) (fputc(*(ptr),stream),1)
253 # define write2(ptr,len,n,stream) (fputc((*(ptr))&255,stream),fputc((*(ptr))>>8,stream),1)
254 # define rand15() (rand()&0x7FFF)
255
256 # include "unix.h"
257
258
259 #endif
260 #endif 261 #endif
262
263 /* Uses big_access32(), big_set32(),... functions instead of macros. */
264 /* Some little endian machines may require this as well. */
265 #if BYTE_ORDER == BIG_ENDIAN
267 #endif
268
269
270 #ifdef LOBYTEFIRST
271 #define GET16(c,i) (i) = *((U16*)(&(c)))
272 #else
273 #define GET16(c,i) (i) = (*(unsigned char *)&(c))+\
274 ((*((unsigned char*)&(c)+1))<<8) 275 #endif
276
277
278
279
280 /* Some compiler libraries don't correctly handle long double.*/
281 /* If you want to force the use of doubles, or */
282 /* if the compiler supports long doubles, but does not allow */
283 /* scanf("%Lf", &longdoublevar); */
284 /* to read in a long double, then uncomment this next line */
285 /* #define DO_NOT_USE_LONG_DOUBLE */
286 /* #define USE_BIGNUM_C_CODE */ /* ASM code requires using long double */
287
288
289 /* HP-UX support long doubles and allows them to be read in with */
290 /* scanf(), but does not support the functions sinl, cosl, fabsl, etc. */
291 /* CAE added this 26Jan95 so it would compile (altered by Wes to new macro) */
292 #ifdef _HPUX_SOURCE
294 #endif
295
296 /* Solaris itself does not provide long double arithmetics like sinl.
297 * However, the "sunmath" library that comes bundled with Sun C does
298 * provide them. */
299 #ifdef sun
305 #endif
306
307 /* This should not be neccessary, but below appears to not work */
308 #ifdef CYGWIN
310 #endif
311
312 #ifndef DO_NOT_USE_LONG_DOUBLE
313 #ifdef LDBL_DIG
314 /* this is what we're hoping for */
315 #define USE_LONG_DOUBLE
316 typedef long double LDBL;
319 #endif /* #ifdef LDBL_DIG */
320 #endif /* #ifndef DO_NOT_USE_LONG_DOUBLE */
321
322
323 #ifdef DO_NOT_USE_LONG_DOUBLE
374 #endif
375
376 #endif /* PORT_H */
377