| | 1 | /* |
| | 2 | $Header: d:/cvsroot/tads/TADS2/OS.H,v 1.2 1999/05/17 02:52:12 MJRoberts Exp $ |
| | 3 | */ |
| | 4 | |
| | 5 | /* |
| | 6 | * Copyright (c) 1991, 2002 Michael J. Roberts. All Rights Reserved. |
| | 7 | * |
| | 8 | * Please see the accompanying license file, LICENSE.TXT, for information |
| | 9 | * on using and copying this software. |
| | 10 | */ |
| | 11 | /* |
| | 12 | Name |
| | 13 | os.h - operating system definitions |
| | 14 | Function |
| | 15 | Definitions that vary by operating system |
| | 16 | Notes |
| | 17 | Do NOT put your system-specific definitions in this file, EXCEPT for |
| | 18 | your system-specific #include lines. |
| | 19 | |
| | 20 | We want to avoid piling up a huge tree of #ifdef's, since it's almost |
| | 21 | impossible to decipher such code. Instead, we want to isolate all of |
| | 22 | the code for each platform in its own header file -- this way, it |
| | 23 | should be easy to figure out what code is compiled on each system. |
| | 24 | |
| | 25 | So, when porting this code to a new platform, you should first |
| | 26 | create an osxxx.h file for your platform (for example, on Windows, |
| | 27 | the file is oswin.h), then add to this file an ifdef'd include for |
| | 28 | your file, something like this: |
| | 29 | |
| | 30 | #ifdef _FROBNIX |
| | 31 | #include "osfrobnix.h" |
| | 32 | #endif |
| | 33 | |
| | 34 | These should generally be the ONLY lines in this file that pertain |
| | 35 | to your system. Everything else for your system should be defined |
| | 36 | in your osxxx.h file. |
| | 37 | |
| | 38 | Also note that some definitions belong in your *hardware* file, |
| | 39 | rather than your operating system file. Since many types of hardware |
| | 40 | have several operating systems, and many operating systems run on |
| | 41 | more than one type of hardware, definitions that pertain to a |
| | 42 | particular type of hardware should be isolated in a separate file. |
| | 43 | So, if you're adding a new hardware platform as well as (or instead |
| | 44 | of) a new operating system, you should create a new h_xxx.h file |
| | 45 | (in the "hardware" source subdirectory), and add an include line |
| | 46 | like this: |
| | 47 | |
| | 48 | #ifdef _M_BANANA_3000 |
| | 49 | #include "h_b3000.h" |
| | 50 | #endif |
| | 51 | |
| | 52 | Note that you may have to adjust your makefile's CFLAGS so that |
| | 53 | the proper hardware and software configuration is selected via -D |
| | 54 | options (or your local equivalent). |
| | 55 | Modified |
| | 56 | 10/17/98 MJRoberts - creation (from TADS 2 os.h, los.h, etc) |
| | 57 | */ |
| | 58 | |
| | 59 | #ifndef OS_INCLUDED |
| | 60 | #define OS_INCLUDED |
| | 61 | |
| | 62 | /* |
| | 63 | * For C++ files, define externals with C linkage |
| | 64 | */ |
| | 65 | #ifdef __cplusplus |
| | 66 | extern "C" { |
| | 67 | #endif |
| | 68 | |
| | 69 | |
| | 70 | /* ------------------------------------------------------------------------ */ |
| | 71 | /* |
| | 72 | * Include the appropriate hardware-specific header. |
| | 73 | */ |
| | 74 | |
| | 75 | /* |
| | 76 | * Intel x86 processors - 32-bit |
| | 77 | */ |
| | 78 | #ifdef _M_IX86 |
| | 79 | #include "h_ix86.h" |
| | 80 | #endif |
| | 81 | |
| | 82 | /* |
| | 83 | * Intel x86 processors - 64-bit |
| | 84 | */ |
| | 85 | #ifdef _M_IX86_64 |
| | 86 | #include "h_ix86_64.h" |
| | 87 | #endif |
| | 88 | |
| | 89 | /* |
| | 90 | * PowerPC CPU's |
| | 91 | */ |
| | 92 | #ifdef _M_PPC |
| | 93 | #include "h_ppc.h" |
| | 94 | #endif |
| | 95 | |
| | 96 | /* |
| | 97 | * Qt. This isn't *truly* a hardware platform, but it looks like one to |
| | 98 | * us, because it provides its own hardware virtualization scheme. Rather |
| | 99 | * than trying to figure out what sort of physical hardware we're |
| | 100 | * targeting, we can simply define our hardware virtualization macros and |
| | 101 | * functions in terms of Qt's hardware virtualization APIs, and let Qt take |
| | 102 | * care of providing the target-specific implementation of those APIs. |
| | 103 | */ |
| | 104 | #ifdef _M_QT |
| | 105 | #include "h_qt.h" |
| | 106 | #endif |
| | 107 | |
| | 108 | /* add others here */ |
| | 109 | |
| | 110 | /* ------------------------------------------------------------------------ */ |
| | 111 | /* |
| | 112 | * Include the portable OS interface type definitions. These types can |
| | 113 | * be used within OS-specific headers, so this type definitions header |
| | 114 | * must be included before any of the OS-specific headers. |
| | 115 | */ |
| | 116 | #include "osifctyp.h" |
| | 117 | |
| | 118 | |
| | 119 | /* ------------------------------------------------------------------------ */ |
| | 120 | /* |
| | 121 | * Include the appropriate OS-specific header. We switch on system type |
| | 122 | * here to avoid a big pile of ifdef's for each system scattered among |
| | 123 | * all of the headers, and instead just select one big file for each |
| | 124 | * system-specific definitions. |
| | 125 | */ |
| | 126 | |
| | 127 | #ifdef _WIN32 |
| | 128 | # include "oswin.h" |
| | 129 | #endif |
| | 130 | #ifdef __MSDOS__ |
| | 131 | # ifdef __WIN32__ |
| | 132 | /* Windows-specific definitions are in oswin.h */ |
| | 133 | # include "oswin.h" |
| | 134 | # else |
| | 135 | # ifdef MSOS2 |
| | 136 | /* OS/2-specific definnitions are in osos2.h */ |
| | 137 | # include "osos2.h" |
| | 138 | # else |
| | 139 | /* DOS-specific definitions are in osdos.h */ |
| | 140 | # include "osdos.h" |
| | 141 | # endif |
| | 142 | # endif |
| | 143 | #endif |
| | 144 | |
| | 145 | #ifdef MAC_OS |
| | 146 | /* macintosh definitions (Mac OS <=9) are in osmac.h */ |
| | 147 | #include "osmac.h" |
| | 148 | #endif |
| | 149 | |
| | 150 | #ifdef MAC_OS_X |
| | 151 | /* macintosh OS X definitions are in osmacosx.h */ |
| | 152 | #include "osmacosx.h" |
| | 153 | #endif |
| | 154 | |
| | 155 | #ifdef UNIX |
| | 156 | /* unix definitions are in osunixt.h */ |
| | 157 | #include "osunixt.h" |
| | 158 | #endif |
| | 159 | |
| | 160 | #ifdef ATARI |
| | 161 | /* Atari ST definitions are in osatari.h */ |
| | 162 | #include "osatari.h" |
| | 163 | #endif |
| | 164 | |
| | 165 | #ifdef GLK |
| | 166 | /* glk definitions are in os_glk.h */ |
| | 167 | #include "os_glk.h" |
| | 168 | #endif |
| | 169 | |
| | 170 | #ifdef __BEOS__ |
| | 171 | #include "osbeos.h" |
| | 172 | #endif |
| | 173 | |
| | 174 | #ifdef TROLLTECH_QT |
| | 175 | /* Qt-specific definitions are in osqt.h */ |
| | 176 | #include "osqt.h" |
| | 177 | #endif |
| | 178 | |
| | 179 | #ifdef FROBTADS |
| | 180 | /* |
| | 181 | * FrobTADS definitions are in osfrobtads.h. (FrobTADS isn't really an OS, |
| | 182 | * but from our perspective it looks like one, since it implements the |
| | 183 | * various osifc entrypoints. FrobTADS further virtualizes access to |
| | 184 | * several Curses-style terminal i/o APIs, but we don't care about that; we |
| | 185 | * just care that it provides our osifc implementations.) |
| | 186 | */ |
| | 187 | #include "osfrobtads.h" |
| | 188 | #endif |
| | 189 | |
| | 190 | |
| | 191 | /* **************** add other systems here **************** */ |
| | 192 | |
| | 193 | |
| | 194 | /* |
| | 195 | * Done with C linkage section (osifc.h has its own) |
| | 196 | */ |
| | 197 | #ifdef __cplusplus |
| | 198 | } |
| | 199 | #endif |
| | 200 | |
| | 201 | |
| | 202 | /* ------------------------------------------------------------------------ */ |
| | 203 | /* |
| | 204 | * Include the generic interface definitions for routines that must be |
| | 205 | * implemented separately on each platform. |
| | 206 | * |
| | 207 | * Note that we include this file *after* including the system-specific |
| | 208 | * osxxx.h header -- this allows definitions in the osxxx.h header to |
| | 209 | * override certain defaults in osifc.h by #defining symbols to indicate |
| | 210 | * to osifc.h that it should not include the defaults. Refer to osifc.h |
| | 211 | * for details of such overridable definitions. |
| | 212 | */ |
| | 213 | #include "osifc.h" |
| | 214 | |
| | 215 | |
| | 216 | /* ------------------------------------------------------------------------ */ |
| | 217 | /* |
| | 218 | * If the system "long description" (for the banner) isn't defined, |
| | 219 | * make it the same as the platform ID string. |
| | 220 | */ |
| | 221 | #ifndef OS_SYSTEM_LDESC |
| | 222 | # define OS_SYSTEM_LDESC OS_SYSTEM_NAME |
| | 223 | #endif |
| | 224 | |
| | 225 | #endif /* OS_INCLUDED */ |
| | 226 | |