The Build Engine
unix_compat.h
1 /*
2  * Unix compatibility header. Takes care of some legacy code issues.
3  *
4  * Written by Ryan C. Gordon (icculus@clutteredmind.org)
5  *
6  * Please do NOT harrass Ken Silverman about any code modifications
7  * (including this file) to BUILD.
8  */
9 
10 /*
11  * "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
12  * Ken Silverman's official web site: "http://www.advsys.net/ken"
13  * See the included license file "BUILDLIC.TXT" for license info.
14  * This file IS NOT A PART OF Ken Silverman's original release
15  */
16 
17 #ifndef _INCLUDE_UNIX_COMPAT_H_
18 #define _INCLUDE_UNIX_COMPAT_H_
19 
20 #if (!defined PLATFORM_UNIX)
21 #error PLATFORM_UNIX is not defined.
22 #endif
23 
24 #define __int64 long long
25 
26 #define PLATFORM_SUPPORTS_SDL
27 
28 #include <stdio.h>
29 #include <unistd.h>
30 #include <stdlib.h>
31 #include <dirent.h>
32 #include <assert.h>
33 
34 extern const int hbits[];
35 
36 /*
37  Do some bitwise magic to approximate an algebraic (sign preserving)
38  right shift.
39  */
40 #define shift_algebraic_right(value,distance) \
41 (((value) >> (distance))| \
42  (hbits[(distance) + (((value) & 0x80000000) >> 26)]))
43 
44 /* !!! remove me later! */
45 /* !!! remove me later! */
46 /* !!! remove me later! */
47 #define outpw(x, y) printf("outpw(0x%X, 0x%X) call in %s, line %d.\n", \
48  (x), (y), __FILE__, __LINE__)
49 
50 #define koutpw(x, y) printf("koutpw(0x%X, 0x%X) call in %s, line %d.\n", \
51  (x), (y), __FILE__, __LINE__)
52 
53 #define outb(x, y) printf("outb(0x%X, 0x%X) call in %s, line %d.\n", \
54  (x), (y), __FILE__, __LINE__)
55 
56 #define koutb(x, y) printf("koutb(0x%X, 0x%X) call in %s, line %d.\n", \
57  (x), (y), __FILE__, __LINE__)
58 
59 #define outp(x, y) printf("outp(0x%X, 0x%X) call in %s, line %d.\n", \
60  (x), (y), __FILE__, __LINE__)
61 
62 #define koutp(x, y)
63 /* !!! */
64  /*printf("koutp(0x%X, 0x%X) call in %s, line %d.\n",
65  // (x), (y), __FILE__, __LINE__) */
66 
67 #define kinp(x) _kinp_handler((x), __FILE__, __LINE__)
68 #define inp(x) _inp_handler((x), __FILE__, __LINE__)
69 
70 int _inp_handler(int port, char *source_file, int source_line);
71 int _kinp_handler(int port, char *source_file, int source_line);
72 /* !!! remove me later! */
73 /* !!! remove me later! */
74 /* !!! remove me later! */
75 
76 
77 
78 
79 #define __far
80 #define __interrupt
81 #define interrupt
82 #define far
83 #define kmalloc(x) malloc(x)
84 #define kkmalloc(x) malloc(x)
85 #define kfree(x) free(x)
86 #define kkfree(x) free(x)
87 #define FP_OFF(x) ((long) (x))
88 
89 #ifndef O_BINARY
90 #define O_BINARY 0
91 #endif
92 
93 /* damned -ansi flag... :) */
94 int stricmp(const char *x, const char *y);
95 
96 #if (defined __STRICT_ANSI__)
97 #define inline __inline__
98 #endif
99 
100 #define printext16 printext256
101 #define printext16_noupdate printext256_noupdate
102 
103 /* Other DOSisms. See unix_compat.c for implementation. */
104 long filelength(int fhandle);
105 
106 /* !!! need an implementation of findfirst()/findnext()! */
107 /* Look for references to _dos_findfirst() in build.c! */
108 
109 #if (!defined S_IREAD)
110 #define S_IREAD S_IRUSR
111 #endif
112 
113 #ifdef DC //bero
114 #undef stdout
115 #undef stderr
116 #define stdout ((FILE*)2)
117 #define stderr ((FILE*)2)
118 #endif
119 
120 #ifndef max
121 #define max(x, y) (((x) > (y)) ? (x) : (y))
122 #endif
123 
124 #ifndef min
125 #define min(x, y) (((x) < (y)) ? (x) : (y))
126 #endif
127 
128 #endif
129 
130 /* end of unix_compat.h ... */
131 
132