-
Notifications
You must be signed in to change notification settings - Fork 1
/
os.h
226 lines (187 loc) · 6.03 KB
/
os.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
$Header: d:/cvsroot/tads/TADS2/OS.H,v 1.2 1999/05/17 02:52:12 MJRoberts Exp $
*/
/*
* Copyright (c) 1991, 2002 Michael J. Roberts. All Rights Reserved.
*
* Please see the accompanying license file, LICENSE.TXT, for information
* on using and copying this software.
*/
/*
Name
os.h - operating system definitions
Function
Definitions that vary by operating system
Notes
Do NOT put your system-specific definitions in this file, EXCEPT for
your system-specific #include lines.
We want to avoid piling up a huge tree of #ifdef's, since it's almost
impossible to decipher such code. Instead, we want to isolate all of
the code for each platform in its own header file -- this way, it
should be easy to figure out what code is compiled on each system.
So, when porting this code to a new platform, you should first
create an osxxx.h file for your platform (for example, on Windows,
the file is oswin.h), then add to this file an ifdef'd include for
your file, something like this:
#ifdef _FROBNIX
#include "osfrobnix.h"
#endif
These should generally be the ONLY lines in this file that pertain
to your system. Everything else for your system should be defined
in your osxxx.h file.
Also note that some definitions belong in your *hardware* file,
rather than your operating system file. Since many types of hardware
have several operating systems, and many operating systems run on
more than one type of hardware, definitions that pertain to a
particular type of hardware should be isolated in a separate file.
So, if you're adding a new hardware platform as well as (or instead
of) a new operating system, you should create a new h_xxx.h file
(in the "hardware" source subdirectory), and add an include line
like this:
#ifdef _M_BANANA_3000
#include "h_b3000.h"
#endif
Note that you may have to adjust your makefile's CFLAGS so that
the proper hardware and software configuration is selected via -D
options (or your local equivalent).
Modified
10/17/98 MJRoberts - creation (from TADS 2 os.h, los.h, etc)
*/
#ifndef OS_INCLUDED
#define OS_INCLUDED
/*
* For C++ files, define externals with C linkage
*/
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------------------------------------------------------ */
/*
* Include the appropriate hardware-specific header.
*/
/*
* Intel x86 processors - 32-bit
*/
#ifdef _M_IX86
#include "h_ix86.h"
#endif
/*
* Intel x86 processors - 64-bit
*/
#ifdef _M_IX86_64
#include "h_ix86_64.h"
#endif
/*
* PowerPC CPU's
*/
#ifdef _M_PPC
#include "h_ppc.h"
#endif
/*
* Qt. This isn't *truly* a hardware platform, but it looks like one to
* us, because it provides its own hardware virtualization scheme. Rather
* than trying to figure out what sort of physical hardware we're
* targeting, we can simply define our hardware virtualization macros and
* functions in terms of Qt's hardware virtualization APIs, and let Qt take
* care of providing the target-specific implementation of those APIs.
*/
#ifdef _M_QT
#include "h_qt.h"
#endif
/* add others here */
/* ------------------------------------------------------------------------ */
/*
* Include the portable OS interface type definitions. These types can
* be used within OS-specific headers, so this type definitions header
* must be included before any of the OS-specific headers.
*/
#include "osifctyp.h"
/* ------------------------------------------------------------------------ */
/*
* Include the appropriate OS-specific header. We switch on system type
* here to avoid a big pile of ifdef's for each system scattered among
* all of the headers, and instead just select one big file for each
* system-specific definitions.
*/
#ifdef _WIN32
# include "oswin.h"
#endif
#ifdef __MSDOS__
# ifdef T_WIN32
/* Windows-specific definitions are in oswin.h */
# include "oswin.h"
# else
# ifdef MSOS2
/* OS/2-specific definnitions are in osos2.h */
# include "osos2.h"
# else
/* DOS-specific definitions are in osdos.h */
# include "osdos.h"
# endif
# endif
#endif
#ifdef MAC_OS
/* macintosh definitions (Mac OS <=9) are in osmac.h */
#include "osmac.h"
#endif
#ifdef MAC_OS_X
/* macintosh OS X definitions are in osmacosx.h */
#include "osmacosx.h"
#endif
#ifdef UNIX
/* unix definitions are in osunixt.h */
#include "osunixt.h"
#endif
#ifdef ATARI
/* Atari ST definitions are in osatari.h */
#include "osatari.h"
#endif
#ifdef GLK
/* glk definitions are in os_glk.h */
#include "os_glk.h"
#endif
#ifdef __BEOS__
#include "osbeos.h"
#endif
#ifdef TROLLTECH_QT
/* Qt-specific definitions are in osqt.h */
#include "osqt.h"
#endif
#ifdef FROBTADS
/*
* FrobTADS definitions are in osfrobtads.h. (FrobTADS isn't really an OS,
* but from our perspective it looks like one, since it implements the
* various osifc entrypoints. FrobTADS further virtualizes access to
* several Curses-style terminal i/o APIs, but we don't care about that; we
* just care that it provides our osifc implementations.)
*/
#include "osfrobtads.h"
#endif
/* **************** add other systems here **************** */
/*
* Done with C linkage section (osifc.h has its own)
*/
#ifdef __cplusplus
}
#endif
/* ------------------------------------------------------------------------ */
/*
* Include the generic interface definitions for routines that must be
* implemented separately on each platform.
*
* Note that we include this file *after* including the system-specific
* osxxx.h header -- this allows definitions in the osxxx.h header to
* override certain defaults in osifc.h by #defining symbols to indicate
* to osifc.h that it should not include the defaults. Refer to osifc.h
* for details of such overridable definitions.
*/
#include "osifc.h"
/* ------------------------------------------------------------------------ */
/*
* If the system "long description" (for the banner) isn't defined,
* make it the same as the platform ID string.
*/
#ifndef OS_SYSTEM_LDESC
# define OS_SYSTEM_LDESC OS_SYSTEM_NAME
#endif
#endif /* OS_INCLUDED */