The Build Engine
win32_compat.h
1 /*
2  * win32 compatibility header. Takes care of some legacy code issues
3  * and incompatibilities at the source level.
4  *
5  * Written by Ryan C. Gordon (icculus@clutteredmind.org)
6  *
7  * Please do NOT harrass Ken Silverman about any code modifications
8  * (including this file) to BUILD.
9  */
10 
11 /*
12  * "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
13  * Ken Silverman's official web site: "http://www.advsys.net/ken"
14  * See the included license file "BUILDLIC.TXT" for license info.
15  * This file IS NOT A PART OF Ken Silverman's original release
16  */
17 
18 #ifndef _INCLUDE_WIN32_COMPAT_H_
19 #define _INCLUDE_WIN32_COMPAT_H_
20 
21 #if (!defined PLATFORM_WIN32)
22 #error PLATFORM_WIN32 is not defined.
23 #endif
24 
25 #define PLATFORM_SUPPORTS_SDL
26 
27 #include <stdio.h>
28 
29 #if (!defined _MSC_VER)
30 #include <unistd.h>
31 #endif
32 
33 #include <stdlib.h>
34 #include <io.h>
35 #include <direct.h>
36 #include <conio.h>
37 #include <dos.h>
38 #include <assert.h>
39 
40 extern const int hbits[]; /* !!! what is this, and why is it here? */
41 
42 /*
43  Do some bitwise magic to approximate an algebraic (sign preserving)
44  right shift.
45  */
46 #define shift_algebraic_right(value,distance) \
47 (((value) >> (distance))| \
48  (hbits[(distance) + (((value) & 0x80000000) >> 26)]))
49 
50 /* !!! remove me later! */
51 /* !!! remove me later! */
52 /* !!! remove me later! */
53 #define outpw(x, y) printf("outpw(0x%X, 0x%X) call in %s, line %d.\n", \
54  (x), (y), __FILE__, __LINE__)
55 
56 #define koutpw(x, y) printf("koutpw(0x%X, 0x%X) call in %s, line %d.\n", \
57  (x), (y), __FILE__, __LINE__)
58 
59 #define outb(x, y) printf("outb(0x%X, 0x%X) call in %s, line %d.\n", \
60  (x), (y), __FILE__, __LINE__)
61 
62 #define koutb(x, y) printf("koutb(0x%X, 0x%X) call in %s, line %d.\n", \
63  (x), (y), __FILE__, __LINE__)
64 
65 #define outp(x, y) printf("outp(0x%X, 0x%X) call in %s, line %d.\n", \
66  (x), (y), __FILE__, __LINE__)
67 
68 #define koutp(x, y) printf("koutp(0x%X, 0x%X) call in %s, line %d.\n", \
69  (x), (y), __FILE__, __LINE__)
70 
71 #define kinp(x) _kinp_handler((x), __FILE__, __LINE__)
72 #define inp(x) _inp_handler((x), __FILE__, __LINE__)
73 
74 int _inp_handler(int port, char *source_file, int source_line);
75 int _kinp_handler(int port, char *source_file, int source_line);
76 /* !!! remove me later! */
77 /* !!! remove me later! */
78 /* !!! remove me later! */
79 
80 
81 #define __far
82 #define __interrupt
83 #define interrupt
84 #define far
85 #define kmalloc(x) malloc(x)
86 #define kkmalloc(x) malloc(x)
87 #define kfree(x) free(x)
88 #define kkfree(x) free(x)
89 
90 #ifdef FP_OFF
91 #undef FP_OFF
92 #endif
93 
94 #define FP_OFF(x) ((long) (x))
95 
96 /* !!! This might be temporary. */
97 #define printext16 printext256
98 #define printext16_noupdate printext256_noupdate
99 
100 #ifndef max
101 #define max(x, y) (((x) > (y)) ? (x) : (y))
102 #endif
103 
104 #ifndef min
105 #define min(x, y) (((x) < (y)) ? (x) : (y))
106 #endif
107 
108 #if (defined __WATCOMC__)
109 #define inline
110 #pragma intrinsic(min);
111 #pragma intrinsic(max);
112 #define __int64 long long
113 #endif
114 
115 #if (defined _MSC_VER)
116 #if ((!defined _INTEGRAL_MAX_BITS) || (_INTEGRAL_MAX_BITS < 64))
117 #error __int64 type not supported
118 #endif
119 
120 #define open _open
121 #define O_BINARY _O_BINARY
122 #define O_RDONLY _O_RDONLY
123 #define O_WRONLY _O_WRONLY
124 #define O_RDWR _O_RDWR
125 #define O_TRUNC _O_TRUNC
126 #define O_CREAT _O_CREAT
127 #define S_IREAD _S_IREAD
128 #define S_IWRITE _S_IWRITE
129 #define S_IRDWR _S_IRDWR
130 #endif /* defined _MSC_VER */
131 
132 #define snprintf _snprintf
133 #endif
134 
135 /* end of win32_compat.h ... */
136 
137 
138