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