forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxp_core.h
302 lines (257 loc) · 6.62 KB
/
xp_core.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*-----------------------------------------------------------------------------
xp_core.h
Cross-Platform Core Types
-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
Platform-specific defines
XP_WIN XP_IS_WIN XP_WIN_ARG(X)
XP_MAC XP_IS_MAC XP_MAC_ARG(X)
XP_UNIX XP_IS_UNIX XP_UNIX_ARG(X)
XP_CPLUSPLUS XP_IS_CPLUSPLUS
XP_OS2 XP_IS_OS2 XP_OS2_ARG(X) IBM-LTB added these
defined iff always defined defined to nothing
on that platform as 0 or 1 or X
Also Bool, Int32, Int16, Int, Uint32, Uint16, Uint, and nil
And TRUE, FALSE, ON, OFF, YES, NO
-----------------------------------------------------------------------------*/
#include "prtypes.h" /* for intn, etc. */
#include "prlog.h"
#ifndef _XP_Core_
#define _XP_Core_
/* which system are we on, get the base macro defined */
#if defined(macintosh) || defined(__MWERKS__) || defined(applec)
#ifndef macintosh
#define macintosh 1
#endif
#endif
#if defined(__unix) || defined(unix) || defined(UNIX) || defined(XP_UNIX)
#ifndef unix
#define unix 1
#endif
#endif
#if !defined(macintosh) && !defined(_WINDOWS) && !defined(unix)
/* #error xp library can't determine system type */
#endif
/* flush out all the system macros */
#ifdef macintosh
# ifndef XP_MAC
# define XP_MAC 1
# endif
# define XP_IS_MAC 1
# define XP_MAC_ARG(x) x
#else
# define XP_IS_MAC 0
# define XP_MAC_ARG(x)
#endif
#ifdef _WINDOWS
# ifndef XP_WIN
# define XP_WIN
# endif
# define XP_IS_WIN 1
# define XP_WIN_ARG(x) x
#if defined(_WIN32) || defined(WIN32)
# ifndef XP_WIN32
# define XP_WIN32
# endif
#else
# ifndef XP_WIN16
# define XP_WIN16
# endif
#endif
#else
# define XP_IS_WIN 0
# define XP_WIN_ARG(x)
#endif
#ifdef unix
# ifndef XP_UNIX
# define XP_UNIX
# endif
# define XP_IS_UNIX 1
# define XP_UNIX_ARG(x) x
#else
# define XP_IS_UNIX 0
# define XP_UNIX_ARG(x)
#endif
/* IBM-LTB Setup system macros for OS/2 */
#if defined (__OS2__)
# ifndef XP_OS2
# define XP_OS2
# endif
# define XP_IS_OS2 1
# define XP_OS2_ARG(x) x
#else
# define XP_IS_OS2 0
# define XP_OS2_ARG(x)
#endif
/* what language do we have? */
#if defined(__cplusplus)
# define XP_CPLUSPLUS
# define XP_IS_CPLUSPLUS 1
#else
# define XP_IS_CPLUSPLUS 0
#endif
#if defined(DEBUG) || !defined(XP_CPLUSPLUS)
#define XP_REQUIRES_FUNCTIONS
#endif
/*
language macros
If C++ code includes a prototype for a function *compiled* in C, it needs to be
wrapped in extern "C" for the linking to work properly. On the Mac, all code is
being compiled in C++ so this isn't necessary, and Unix compiles it all in C. So
only Windows actually will make use of the defined macros.
*/
#if defined(XP_CPLUSPLUS)
# define XP_BEGIN_PROTOS extern "C" {
# define XP_END_PROTOS }
#else
# define XP_BEGIN_PROTOS
# define XP_END_PROTOS
#endif
/* simple common types */
#ifdef XP_MAC
#include <Types.h>
#if __option(bool)
typedef bool BOOL;
typedef bool Bool;
typedef bool XP_Bool;
#else
typedef char BOOL;
typedef char Bool;
typedef char XP_Bool;
#endif
#elif defined(XP_WIN)
typedef int Bool;
typedef int XP_Bool;
#elif defined(XP_OS2) && !defined(RC_INVOKED)
typedef unsigned long Bool;
typedef unsigned long XP_Bool;
#else
/* XP_UNIX: X11/Xlib.h "define"s Bool to be int. This is really lame
* (that's what typedef is for losers). So.. in lieu of a #undef Bool
* here (Xlib still needs ints for Bool-typed parameters) people have
* been #undef-ing Bool before including this file.
* Can we just #undef Bool here? <mailto:mcafee> (help from djw, converse)
*/
#ifdef Bool
#undef Bool
#endif
typedef char Bool;
typedef char XP_Bool;
#endif
/* this should just go away, as nspr has it. */
#if !defined(XP_WIN) && !defined(XP_UNIX)
typedef int (*FARPROC)();
#endif
#if defined(XP_WIN)
#ifndef BOOL
#define BOOL Bool
#endif
#define MIN(a, b) min((a), (b))
#endif
#if defined(XP_OS2)
#ifndef MIN
#define MIN(a, b) min((a), (b))
#endif
#endif
#if defined(XP_UNIX) && !defined(MIN)
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE !FALSE
#endif
#define YES 1
#define NO 0
#define ON 1
#define OFF 0
#ifndef nil
#define nil 0
#endif
#ifndef NULL
#define NULL 0
#endif
#ifndef TRACEMSG
#ifdef DEBUG
#define TRACEMSG(msg) do { if(MKLib_trace_flag) XP_Trace msg; } while (0)
#else
#define TRACEMSG(msg)
#endif /* DEBUG */
#endif /* TRACEMSG */
#define _INT16
#define _UINT16
#define _INT32
#define _UINT32
/* function classifications */
#define PUBLIC
#define MODULE_PRIVATE
#if defined(XP_UNIX) && defined(MOZ_STRIP_NOT_EXPORTED)
#undef PUBLIC
#define PUBLIC __attribute__ ((dllexport))
#undef MODULE_PRIVATE
#define MODULE_PRIVATE __attribute__ ((dllexport))
#endif
#if defined(XP_UNIX) && defined(PRIVATE)
#undef PRIVATE
#endif
#define PRIVATE static
/* common typedefs */
typedef struct _XP_List XP_List;
/* standard system headers */
#if !defined(RC_INVOKED)
#include <assert.h>
#include <ctype.h>
#ifdef __sgi
# include <float.h>
# include <sys/bsd_types.h>
#endif
#ifdef XP_UNIX
#include <stdarg.h>
#endif
#include <limits.h>
#include <locale.h>
#if defined(XP_WIN) && defined(XP_CPLUSPLUS) && defined(_MSC_VER) && _MSC_VER >= 1020
/* math.h under MSVC 4.2 needs C++ linkage when C++. */
extern "C++" {
#include <math.h>
}
#elif (defined(__hpux) || defined(SCO)) && defined(__cplusplus)
extern "C++" {
#include <math.h>
}
#else
#include <math.h>
#endif
#ifdef XP_OS2
/*DSR021097 - on OS/2 we have conflicts over jmp_buf & HW_THREADS */
#ifdef SW_THREADS
#include <setjmp.h>
#endif
#else /*!XP_OS2*/
#include <setjmp.h>
#endif
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#endif
#endif /* _XP_Core_ */