| 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 | #ifdef __ppc__ |
| 76 | #define _M_PPC |
| 77 | #elif defined __x86_64__ |
| 78 | #define _M_IX86_64 |
| 79 | #elif defined __aarch64__ |
| 80 | #define _M_AARCH64 |
| 81 | #elif !defined _M_IX86 |
| 82 | #define _M_IX86 |
| 83 | #endif |
| 84 | |
| 85 | /* |
| 86 | * Intel x86 processors - 32-bit |
| 87 | */ |
| 88 | #ifdef _M_IX86 |
| 89 | #include "h_le_c11.h" |
| 90 | #endif |
| 91 | |
| 92 | /* |
| 93 | * Intel x86 processors - 64-bit |
| 94 | */ |
| 95 | #ifdef _M_IX86_64 |
| 96 | #include "h_le_c11.h" |
| 97 | #endif |
| 98 | |
| 99 | /* |
| 100 | * PowerPC CPU's |
| 101 | */ |
| 102 | #ifdef _M_PPC |
| 103 | #include "h_ppc.h" |
| 104 | #endif |
| 105 | |
| 106 | /* |
| 107 | * Qt. This isn't *truly* a hardware platform, but it looks like one to |
| 108 | * us, because it provides its own hardware virtualization scheme. Rather |
| 109 | * than trying to figure out what sort of physical hardware we're |
| 110 | * targeting, we can simply define our hardware virtualization macros and |
| 111 | * functions in terms of Qt's hardware virtualization APIs, and let Qt take |
| 112 | * care of providing the target-specific implementation of those APIs. |
| 113 | */ |
| 114 | #ifdef _M_QT |
| 115 | #include "h_qt.h" |
| 116 | #endif |
| 117 | |
| 118 | /* |
| 119 | * ARM 64-bit |
| 120 | */ |
| 121 | #ifdef _M_AARCH64 |
| 122 | #include "h_le_c11.h" |
| 123 | #endif |
| 124 | |
| 125 | /* add others here */ |
| 126 | |
| 127 | /* ------------------------------------------------------------------------ */ |
| 128 | /* |
| 129 | * Include the portable OS interface type definitions. These types can |
| 130 | * be used within OS-specific headers, so this type definitions header |
| 131 | * must be included before any of the OS-specific headers. |
| 132 | */ |
| 133 | #include "osifctyp.h" |
| 134 | |
| 135 | |
| 136 | /* ------------------------------------------------------------------------ */ |
| 137 | /* |
| 138 | * Include the appropriate OS-specific header. We switch on system type |
| 139 | * here to avoid a big pile of ifdef's for each system scattered among |
| 140 | * all of the headers, and instead just select one big file for each |
| 141 | * system-specific definitions. |
| 142 | */ |
| 143 | |
| 144 | #ifdef GLK |
| 145 | #include "osglk.h" |
| 146 | #else |
| 147 | |
| 148 | #ifdef _WIN32 |
| 149 | # include "oswin.h" |
| 150 | #endif |
| 151 | #ifdef __MSDOS__ |
| 152 | # ifdef T_WIN32 |
| 153 | /* Windows-specific definitions are in oswin.h */ |
| 154 | # include "oswin.h" |
| 155 | # else |
| 156 | # ifdef MSOS2 |
| 157 | /* OS/2-specific definnitions are in osos2.h */ |
| 158 | # include "osos2.h" |
| 159 | # else |
| 160 | /* DOS-specific definitions are in osdos.h */ |
| 161 | # include "osdos.h" |
| 162 | # endif |
| 163 | # endif |
| 164 | #endif |
| 165 | |
| 166 | #ifdef MAC_OS |
| 167 | /* macintosh definitions (Mac OS <=9) are in osmac.h */ |
| 168 | #include "osmac.h" |
| 169 | #endif |
| 170 | |
| 171 | #ifdef MAC_OS_X |
| 172 | /* macintosh OS X definitions are in osmacosx.h */ |
| 173 | #include "osmacosx.h" |
| 174 | #endif |
| 175 | |
| 176 | #ifdef UNIX |
| 177 | /* unix definitions are in osunixt.h */ |
| 178 | #include "osunixt.h" |
| 179 | #endif |
| 180 | |
| 181 | #ifdef ATARI |
| 182 | /* Atari ST definitions are in osatari.h */ |
| 183 | #include "osatari.h" |
| 184 | #endif |
| 185 | |
| 186 | #ifdef GLK |
| 187 | /* glk definitions are in os_glk.h */ |
| 188 | #include "os_glk.h" |
| 189 | #endif |
| 190 | |
| 191 | #ifdef __BEOS__ |
| 192 | #include "osbeos.h" |
| 193 | #endif |
| 194 | |
| 195 | #ifdef TROLLTECH_QT |
| 196 | /* Qt-specific definitions are in osqt.h */ |
| 197 | #include "osqt.h" |
| 198 | #endif |
| 199 | |
| 200 | #ifdef FROBTADS |
| 201 | /* |
| 202 | * FrobTADS definitions are in osfrobtads.h. (FrobTADS isn't really an OS, |
| 203 | * but from our perspective it looks like one, since it implements the |
| 204 | * various osifc entrypoints. FrobTADS further virtualizes access to |
| 205 | * several Curses-style terminal i/o APIs, but we don't care about that; we |
| 206 | * just care that it provides our osifc implementations.) |
| 207 | */ |
| 208 | #include "osfrobtads.h" |
| 209 | #endif |
| 210 | |
| 211 | #endif /* GLK */ |
| 212 | |
| 213 | /* **************** add other systems here **************** */ |
| 214 | |
| 215 | |
| 216 | /* |
| 217 | * Done with C linkage section (osifc.h has its own) |
| 218 | */ |
| 219 | #ifdef __cplusplus |
| 220 | } |
| 221 | #endif |
| 222 | |
| 223 | |
| 224 | /* ------------------------------------------------------------------------ */ |
| 225 | /* |
| 226 | * Include the generic interface definitions for routines that must be |
| 227 | * implemented separately on each platform. |
| 228 | * |
| 229 | * Note that we include this file *after* including the system-specific |
| 230 | * osxxx.h header -- this allows definitions in the osxxx.h header to |
| 231 | * override certain defaults in osifc.h by #defining symbols to indicate |
| 232 | * to osifc.h that it should not include the defaults. Refer to osifc.h |
| 233 | * for details of such overridable definitions. |
| 234 | */ |
| 235 | #include "osifc.h" |
| 236 | |
| 237 | |
| 238 | /* ------------------------------------------------------------------------ */ |
| 239 | /* |
| 240 | * If the system "long description" (for the banner) isn't defined, |
| 241 | * make it the same as the platform ID string. |
| 242 | */ |
| 243 | #ifndef OS_SYSTEM_LDESC |
| 244 | # define OS_SYSTEM_LDESC OS_SYSTEM_NAME |
| 245 | #endif |
| 246 | |
| 247 | #endif /* OS_INCLUDED */ |
| 248 |