• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  **  Filename:       Host.h
3  **  Purpose:        This is the system independent typedefs and defines
4  **  Author:         MN, JG, MD
5  **  Version:        5.4.1
6  **  History:        11/7/94 MCD received the modification that Lennart made
7  **                  to port to 32 bit world and modify this file so that it
8  **                  will be shared between platform.
9  **                  11/9/94 MCD Make MSW32 subset of MSW. Now MSW means
10  **                  MicroSoft Window and MSW32 means the 32 bit worlds
11  **                  of MicroSoft Window. Therefore you want the environment
12  **                  to be MicroSoft Window and in the 32 bit world -
13  **                  __MSW__ and __MSW32__ must be uncommented out.
14  **                  11/30/94 MCD Incorporated comments received for more
15  **                  readability and the missing typedef for FLOAT.
16  **                  12/1/94 MCD Added PFVOID typedef
17  **                  5/1/95 MCD. Made many changes based on the inputs.
18  **                  Changes:
19  **                  1) Rearrange the #ifdef so that there're definitions for
20  **                  particular platforms.
21  **                  2) Took out the #define for computer and environment
22  **                  that developer can uncomment
23  **                  3) Added __OLDCODE__ where the defines will be
24  **                  obsoleted in the next version and advise not to use.
25  **                  4) Added the definitions for the following:
26  **                  FILE_HANDLE, MEMORY_HANDLE, BOOL8,
27  **                  MAX_INT8, MAX_INT16, MAX_INT32, MAX_UINT8
28  **                  MAX_UINT16, MAX_UINT32, MAX_FLOAT32
29  **                 06/19/96 MCD. Took out MAX_FLOAT32
30  **                 07/15/96 MCD. Fixed the comments error
31  **                 Add back BOOL8.
32  **
33  **  (c) Copyright Hewlett-Packard Company, 1988-1996.
34  ** Licensed under the Apache License, Version 2.0 (the "License");
35  ** you may not use this file except in compliance with the License.
36  ** You may obtain a copy of the License at
37  ** http://www.apache.org/licenses/LICENSE-2.0
38  ** Unless required by applicable law or agreed to in writing, software
39  ** distributed under the License is distributed on an "AS IS" BASIS,
40  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41  ** See the License for the specific language governing permissions and
42  ** limitations under the License.
43  */
44 
45 #ifndef   __HOST__
46 #define   __HOST__
47 
48 /******************************************************************************
49  **                                IMPORTANT!!!                                                                                                                 **
50  **                                                                                                                                                                              **
51  ** Defines either __MSW__, __MSW32__, __MAC__, __UNIX__, __OS2__, __PM__ to
52  ** use the specified definitions indicated below in the preprocessor settings.                                                        **
53  **                                                                                                                                                                              **
54  ** Also define either  __FarProc__ or  __FarData__  and __MOTO__ to use the
55  ** specified definitions indicated below in the preprocessor settings.                                                                        **
56  **                                                                                                                                                                             **
57  ** If a preprocessor settings is not allow in the compiler that is being use,
58  ** then it is recommended that a "platform.h" is created with the definition
59  ** of the computer and/or operating system.
60  ******************************************************************************/
61 
62 #include "platform.h"
63 /* __MSW32__ */
64 #ifdef __MSW32__
65 #include <windows.h>
66 #include <winbase.h>             // winbase.h contains windows.h
67 
68 #define DLLIMPORT __declspec( dllimport)
69 #define DLLEXPORT __declspec( dllexport)
70 
71 #else
72 /********************************************************/
73 /* __MSW__ */
74 #ifdef __MSW__
75 #include <windows.h>             // provides standard definitions (like HANDLE)
76 
77 #define DLLIMPORT __import
78 #define DLLEXPORT __export
79 #endif
80 #endif
81 
82 /********************************************************/
83 /* __MAC__ */
84 #ifdef __MAC__
85 #include <Types.h>
86 /*----------------------------*/
87 /*----------------------------*/
88 #define DLLIMPORT
89 #define DLLEXPORT
90 
91 #endif
92 /********************************************************/
93 #if defined(__UNIX__) || defined( __DOS__ ) || defined(__OS2__) || defined(__PM__)
94 /*----------------------------*/
95 /* FarProc and FarData */
96 /*----------------------------*/
97 #define DLLIMPORT
98 #define DLLEXPORT
99 /*----------------------------*/
100 #endif
101 /*****************************************************************************
102  **
103  **                      Standard GHC Definitions
104  **
105  *****************************************************************************/
106 
107 #ifdef __MOTO__
108 #define __NATIVE__   MOTO
109 #else
110 #define __NATIVE__   INTEL
111 #endif
112 
113 //typedef HANDLE FD*  PHANDLE;
114 
115 // definitions of portable data types (numbers and characters)
116 typedef SIGNED char inT8;
117 typedef unsigned char uinT8;
118 typedef short inT16;
119 typedef unsigned short uinT16;
120 typedef int inT32;
121 typedef unsigned int uinT32;
122 #if (_MSC_VER >= 1200)            //%%% vkr for VC 6.0
123 typedef INT64 inT64;
124 typedef UINT64 uinT64;
125 #else
126 typedef long long int inT64;
127 typedef unsigned long long int uinT64;
128 #endif                           //%%% vkr for VC 6.0
129 typedef float FLOAT32;
130 typedef double FLOAT64;
131 typedef unsigned char BOOL8;
132 
133 #define INT32FORMAT "%d"
134 #define INT64FORMAT "%lld"
135 
136 #define MAX_INT8  0x7f
137 #define MAX_INT16 0x7fff
138 #define MAX_INT32 0x7fffffff
139 #define MAX_UINT8 0xff
140 #define MAX_UINT16  0xffff
141 #define MAX_UINT32  0xffffffff
142 #define MAX_FLOAT32 ((float)3.40282347e+38)
143 
144 #define MIN_INT8  0x80
145 #define MIN_INT16 0x8000
146 #define MIN_INT32 0x80000000
147 #define MIN_UINT8 0x00
148 #define MIN_UINT16  0x0000
149 #define MIN_UINT32  0x00000000
150 #define MIN_FLOAT32 ((float)1.17549435e-38)
151 
152 // Defines
153 
154 #ifndef OKAY
155 #define OKAY            0
156 #endif
157 
158 #ifndef HPERR
159 #define HPERR           -1
160 #endif
161 
162 #ifndef TRUE
163 #define TRUE            1
164 #endif
165 
166 #ifndef FALSE
167 #define FALSE           0
168 #endif
169 
170 #ifndef NULL
171 #define NULL            0L
172 #endif
173 
174 // Return true if x is within tolerance of y
NearlyEqual(T x,T y,T tolerance)175 template<class T> bool NearlyEqual(T x, T y, T tolerance) {
176   T diff = x - y;
177   return diff <= tolerance && -diff <= tolerance;
178 }
179 
180 #endif
181