1 /***************************************************************************** 2 ** 3 ** machine.h 4 ** 5 ** Copyright (c) Cambridge Electronic Design Limited 1991,1992,2010 6 ** 7 ** This program is free software; you can redistribute it and/or 8 ** modify it under the terms of the GNU General Public License 9 ** as published by the Free Software Foundation; either version 2 10 ** of the License, or (at your option) any later version. 11 ** 12 ** This program is distributed in the hope that it will be useful, 13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 ** GNU General Public License for more details. 16 ** 17 ** You should have received a copy of the GNU General Public License 18 ** along with this program; if not, write to the Free Software 19 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 ** 21 ** Contact CED: Cambridge Electronic Design Limited, Science Park, Milton Road 22 ** Cambridge, CB6 0FE. 23 ** www.ced.co.uk 24 ** greg@ced.co.uk 25 ** 26 ** This file is included at the start of 'C' or 'C++' source file to define 27 ** things for cross-platform/compiler interoperability. This used to deal with 28 ** MSDOS/16-bit stuff, but this was all removed in Decemeber 2010. There are 29 ** three things to consider: Windows, LINUX, mac OSX (BSD Unix) and 32 vs 64 30 ** bit. At the time of writing (DEC 2010) there is a consensus on the following 31 ** and their unsigned equivalents: 32 ** 33 ** type bits 34 ** char 8 35 ** short 16 36 ** int 32 37 ** long long 64 38 ** 39 ** long is a problem as it is always 64 bits on linux/unix and is always 32 bits 40 ** on windows. 41 ** On windows, we define _IS_WINDOWS_ and one of WIN32 or WIN64. 42 ** On linux we define LINUX 43 ** On Max OSX we define MACOSX 44 ** 45 */ 46 47 #ifndef __MACHINE_H__ 48 #define __MACHINE_H__ 49 #ifndef __KERNEL__ 50 #include <float.h> 51 #include <limits.h> 52 #endif 53 54 /* 55 ** The initial section is to identify the operating system 56 */ 57 #if (defined(__linux__) || defined(_linux) || defined(__linux)) && !defined(LINUX) 58 #define LINUX 1 59 #endif 60 61 #if (defined(__WIN32__) || defined(_WIN32)) && !defined(WIN32) 62 #define WIN32 1 63 #endif 64 65 #if defined(__APPLE__) 66 #define MACOSX 67 #endif 68 69 #if defined(_WIN64) 70 #undef WIN32 71 #undef WIN64 72 #define WIN64 1 73 #endif 74 75 #if defined(WIN32) || defined(WIN64) 76 #define _IS_WINDOWS_ 1 77 #endif 78 79 #if defined(LINUX) || defined(MAXOSX) 80 #define FAR 81 82 typedef int BOOL; // To match Windows 83 typedef char * LPSTR; 84 typedef const char * LPCSTR; 85 typedef unsigned short WORD; 86 typedef unsigned int DWORD; 87 typedef unsigned char BYTE; 88 typedef BYTE BOOLEAN; 89 typedef unsigned char UCHAR; 90 #define __packed __attribute__((packed)) 91 typedef BYTE * LPBYTE; 92 #define HIWORD(x) (WORD)(((x)>>16) & 0xffff) 93 #define LOWORD(x) (WORD)((x) & 0xffff) 94 #endif 95 96 #ifdef _IS_WINDOWS_ 97 #include <windows.h> 98 #define __packed 99 #endif 100 101 /* 102 ** Sort out the DllExport and DllImport macros. The GCC compiler has its own 103 ** syntax for this, though it also supports the MS specific __declspec() as 104 ** a synonym. 105 */ 106 #ifdef GNUC 107 #define DllExport __attribute__((dllexport)) 108 #define DllImport __attribute__((dllimport)) 109 #endif 110 111 #ifndef DllExport 112 #ifdef _IS_WINDOWS_ 113 #define DllExport __declspec(dllexport) 114 #define DllImport __declspec(dllimport) 115 #else 116 #define DllExport 117 #define DllImport 118 #endif 119 #endif /* _IS_WINDOWS_ */ 120 121 122 #ifndef TRUE 123 #define TRUE 1 124 #define FALSE 0 125 #endif 126 127 #endif 128