home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / xp_core.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.2 KB  |  316 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*-----------------------------------------------------------------------------
  20.     xp_core.h
  21.     Cross-Platform Core Types
  22. -----------------------------------------------------------------------------*/
  23.  
  24. /*-----------------------------------------------------------------------------
  25.     Platform-specific defines
  26.  
  27.         XP_WIN              XP_IS_WIN       XP_WIN_ARG(X)
  28.         XP_MAC              XP_IS_MAC         XP_MAC_ARG(X)
  29.         XP_UNIX             XP_IS_UNIX        XP_UNIX_ARG(X)
  30.         XP_CPLUSPLUS        XP_IS_CPLUSPLUS
  31.         XP_OS2              XP_IS_OS2          XP_OS2_ARG(X)  IBM-LTB added these
  32.         defined iff         always defined    defined to nothing
  33.         on that platform    as 0 or 1         or X
  34.  
  35.         Also Bool, Int32, Int16, Int, Uint32, Uint16, Uint, and nil
  36.         And TRUE, FALSE, ON, OFF, YES, NO
  37. -----------------------------------------------------------------------------*/
  38.  
  39. #ifdef NSPR20
  40. #include "prtypes.h"    /* for intn, etc. */
  41. #ifdef XP_MAC
  42. #include "prosdep.h"
  43. #else
  44. #include "md/prosdep.h"
  45. #endif
  46. #include "prlog.h"
  47. #endif /* NSPR20 */
  48.  
  49. #ifndef _XP_Core_
  50. #define _XP_Core_
  51.  
  52. /* which system are we on, get the base macro defined */
  53.  
  54. #if defined(macintosh) || defined(__MWERKS__) || defined(applec)
  55. #ifndef macintosh
  56. #define macintosh 1
  57. #endif
  58. #endif
  59.  
  60. #if defined(__unix) || defined(unix) || defined(UNIX) || defined(XP_UNIX)
  61. #ifndef unix
  62. #define unix 1
  63. #endif
  64. #endif
  65.  
  66. #if !defined(macintosh) && !defined(_WINDOWS) && !defined(unix)
  67.   /* #error xp library can't determine system type */
  68. #endif
  69.  
  70. /* flush out all the system macros */
  71.  
  72. #ifdef macintosh
  73. # ifndef XP_MAC
  74. # define XP_MAC 1
  75. # endif
  76. # define XP_IS_MAC 1
  77. # define XP_MAC_ARG(x) x
  78. #else
  79. # define XP_IS_MAC 0
  80. # define XP_MAC_ARG(x)
  81. #endif
  82.  
  83. #ifdef _WINDOWS
  84. # ifndef XP_WIN
  85. # define XP_WIN
  86. # endif
  87. # define XP_IS_WIN 1
  88. # define XP_WIN_ARG(x) x
  89. #if defined(_WIN32) || defined(WIN32)
  90. # ifndef XP_WIN32
  91. # define XP_WIN32
  92. # endif
  93. #else
  94. # ifndef XP_WIN16
  95. # define XP_WIN16
  96. # endif
  97. #endif
  98. #else
  99. # define XP_IS_WIN 0
  100. # define XP_WIN_ARG(x)
  101. #endif
  102.  
  103. #ifdef unix
  104. # ifndef XP_UNIX
  105. # define XP_UNIX
  106. # endif
  107. # define XP_IS_UNIX 1
  108. # define XP_UNIX_ARG(x) x
  109. #else
  110. # define XP_IS_UNIX 0
  111. # define XP_UNIX_ARG(x)
  112. #endif
  113.  
  114. /*  IBM-LTB  Setup system macros for OS/2   */
  115. #if defined (__OS2__)
  116. # ifndef XP_OS2
  117. # define XP_OS2
  118. # endif
  119. # define XP_IS_OS2 1
  120. # define XP_OS2_ARG(x) x
  121. #else
  122. # define XP_IS_OS2 0
  123. # define XP_OS2_ARG(x)
  124. #endif
  125.  
  126. /* what language do we have? */
  127.  
  128. #if defined(__cplusplus)
  129. # define XP_CPLUSPLUS
  130. # define XP_IS_CPLUSPLUS 1
  131. #else
  132. # define XP_IS_CPLUSPLUS 0
  133. #endif
  134.  
  135. #if defined(DEBUG) || !defined(XP_CPLUSPLUS)
  136. #define XP_REQUIRES_FUNCTIONS
  137. #endif
  138.  
  139. /*
  140.     language macros
  141.     
  142.     If C++ code includes a prototype for a function *compiled* in C, it needs to be
  143.     wrapped in extern "C" for the linking to work properly. On the Mac, all code is
  144.     being compiled in C++ so this isn't necessary, and Unix compiles it all in C. So
  145.     only Windows actually will make use of the defined macros.
  146. */
  147.  
  148. #if defined(XP_CPLUSPLUS)
  149. # define XP_BEGIN_PROTOS extern "C" {
  150. # define XP_END_PROTOS }
  151. #else
  152. # define XP_BEGIN_PROTOS
  153. # define XP_END_PROTOS
  154. #endif
  155.  
  156. /* simple common types */
  157.  
  158. #if defined(XP_WIN) || defined(XP_OS2)
  159. #ifndef RESOURCE_STR
  160. #include "prtypes.h"
  161. #endif /* RESOURCE_STR */
  162. #else /* XP_WIN */
  163. #include "prtypes.h"
  164. #endif /* XP_WIN */
  165.  
  166. #ifdef XP_MAC
  167. #include <Types.h>
  168.  
  169.     #if __option(bool)
  170.         typedef bool BOOL;
  171.         typedef bool Bool;
  172.         typedef bool XP_Bool;
  173.     #else
  174.         typedef char BOOL;
  175.         typedef char Bool;
  176.         typedef char XP_Bool;
  177.     #endif
  178.  
  179. #elif defined(XP_WIN)
  180.     typedef int Bool;
  181.     typedef int XP_Bool;
  182. #elif defined(XP_OS2) && !defined(RC_INVOKED)
  183. #include "prosdep.h"
  184.     typedef unsigned long Bool;
  185.     typedef unsigned long XP_Bool;
  186. #else
  187.     /*  XP_UNIX: X11/Xlib.h "define"s Bool to be int. This is really lame
  188.      *  (that's what typedef is for losers). So.. in lieu of a #undef Bool
  189.      *  here (Xlib still needs ints for Bool-typed parameters) people have
  190.      *  been #undef-ing Bool before including this file.
  191.      *  Can we just #undef Bool here? <mailto:mcafee> (help from djw, converse)
  192.      */
  193.     typedef char Bool;
  194.     typedef char XP_Bool;
  195. #endif
  196.  
  197. #if defined(XP_WIN)
  198. #ifndef BOOL
  199. #define BOOL Bool
  200. #endif
  201. #define MIN(a, b)     min((a), (b))
  202. #endif
  203.  
  204. #if defined(XP_OS2)
  205. #ifndef MIN
  206. #define MIN(a, b)     min((a), (b))
  207. #endif
  208. #endif
  209.  
  210. #if defined(XP_UNIX) && !defined(MIN)
  211. #define MIN(a,b) (((a)<(b))?(a):(b))
  212. #endif
  213.  
  214. #ifndef FALSE
  215. #define FALSE 0
  216. #endif
  217.  
  218. /* disable the TRUE redefinition warning
  219.  * TRUE is defined by windows.h in the MSVC
  220.  * development environment, and creates a
  221.  * nasty warning for every file.  The only
  222.  * way to turn it off is to disable all
  223.  * macro redefinition warnings or to not
  224.  * define TRUE here
  225.  */
  226. #if !defined(TRUE) && !defined(XP_WIN)
  227. #define TRUE !FALSE
  228. #endif
  229.  
  230. #define YES 1
  231. #define NO 0
  232.  
  233. #define ON 1
  234. #define OFF 0
  235.  
  236. #ifndef nil
  237. #define nil 0
  238. #endif
  239.  
  240. #ifndef NULL
  241. #define NULL 0
  242. #endif
  243.  
  244. #ifndef TRACEMSG
  245. #ifdef DEBUG
  246. #define TRACEMSG(msg)  do { if(MKLib_trace_flag)  XP_Trace msg; } while (0)
  247. #else
  248. #define TRACEMSG(msg)
  249. #endif /* DEBUG */
  250. #endif /* TRACEMSG */
  251.  
  252. #define _INT16
  253. #define _UINT16
  254. #define _INT32
  255. #define _UINT32
  256.  
  257. #ifndef NSPR20
  258. typedef int             intn;
  259. #endif /* NSPR20 */
  260.  
  261. /* function classifications */
  262.  
  263. #define PUBLIC
  264. #define MODULE_PRIVATE
  265.  
  266. #if defined(XP_UNIX) && defined(PRIVATE)
  267. #undef PRIVATE
  268. #endif
  269. #define PRIVATE static
  270.  
  271. /* common typedefs */
  272. typedef struct _XP_List XP_List;
  273.  
  274. /* standard system headers */
  275.  
  276. #if !defined(RC_INVOKED)
  277. #include <assert.h>
  278. #include <ctype.h>
  279. #ifdef __sgi
  280. # include <float.h>
  281. # include <sys/bsd_types.h>
  282. #endif
  283. #ifdef XP_UNIX
  284. #include <stdarg.h>
  285. #endif
  286. #include <limits.h>
  287. #include <locale.h>
  288. #if defined(XP_WIN) && defined(XP_CPLUSPLUS) && defined(_MSC_VER) && _MSC_VER >= 1020
  289. /* math.h under MSVC 4.2 needs C++ linkage when C++. */
  290. extern "C++"    {
  291. #include <math.h>
  292. }
  293. #elif (defined(__hpux) || defined(SCO)) && defined(__cplusplus)
  294. extern "C++"    {
  295. #include <math.h>
  296. }
  297. #else
  298. #include <math.h>
  299. #endif
  300. #ifdef XP_OS2
  301. /*DSR021097 - on OS/2 we have conflicts over jmp_buf & HW_THREADS */
  302. #ifdef SW_THREADS
  303. #include <setjmp.h>
  304. #endif
  305. #else /*!XP_OS2*/
  306. #include <setjmp.h>
  307. #endif
  308. #include <stddef.h>
  309. #include <stdio.h>
  310. #include <stdlib.h>
  311. #include <string.h>
  312. #include <time.h>
  313. #endif
  314.  
  315. #endif /* _XP_Core_ */
  316.