Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 * The contents of this file are subject to the Mozilla Public
4 * License Version 1.1 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of
6 * the License at http://www.mozilla.org/MPL/
8 * Software distributed under the License is distributed on an "AS
9 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 * implied. See the License for the specific language governing
11 * rights and limitations under the License.
13 * The Original Code is the Netscape Portable Runtime (NSPR).
15 * The Initial Developer of the Original Code is Netscape
16 * Communications Corporation. Portions created by Netscape are
17 * Copyright (C) 1998-2000 Netscape Communications Corporation. All
21 * Portions Copyright (c) 2004-2006, Nokia Corporation
24 * Alternatively, the contents of this file may be used under the
25 * terms of the GNU General Public License Version 2 or later (the
26 * "GPL"), in which case the provisions of the GPL are applicable
27 * instead of those above. If you wish to allow use of your
28 * version of this file only under the terms of the GPL and not to
29 * allow others to use your version of this file under the MPL,
30 * indicate your decision by deleting the provisions above and
31 * replace them with the notice and other provisions required by
32 * the GPL. If you do not delete the provisions above, a recipient
33 * may use your version of this file under either the MPL or the
38 * Nokia modified this file, by changing certain variables for the purpose of
39 * porting the file to the Symbian platform on May 1st, 2004.
45 ** Description: Definitions of NSPR's basic types
47 ** Prototypes and macros used to make up for deficiencies in ANSI environments
48 ** that we have found.
50 ** Since we do not wrap <stdlib.h> and all the other standard headers, authors
51 ** of portable code will not know in general that they need these definitions.
52 ** Instead of requiring these authors to find the dependent uses in their code
53 ** and take the following steps only in those C files, we take steps once here
68 /***********************************************************************
72 ** These are only for externally visible routines and globals. For
73 ** internal routines, just use "extern" for type checking and that
74 ** will not export internal cross-file or forward-declared symbols.
75 ** Define a macro for declaring procedures return types. We use this to
76 ** deal with windoze specific type hackery for DLL definitions. Use
77 ** PR_EXTERN when the prototype for the method is declared. Use
78 ** PR_IMPLEMENT for the implementation of the method.
82 ** PR_EXTERN( void ) DoWhatIMean( void );
84 ** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
87 ***********************************************************************/
92 #define _declspec(x) __declspec(x)
95 #define PR_EXPORT(__type) extern _declspec(dllexport) __type
96 #define PR_EXPORT_DATA(__type) extern _declspec(dllexport) __type
97 #define PR_IMPORT(__type) _declspec(dllimport) __type
98 #define PR_IMPORT_DATA(__type) _declspec(dllimport) __type
100 #define PR_EXTERN(__type) extern _declspec(dllexport) __type
101 #define PR_IMPLEMENT(__type) _declspec(dllexport) __type
102 #define PR_EXTERN_DATA(__type) extern _declspec(dllexport) __type
103 #define PR_IMPLEMENT_DATA(__type) _declspec(dllexport) __type
106 #define PR_CALLBACK_DECL
107 #define PR_STATIC_CALLBACK(__x) static __x
109 #elif defined(XP_BEOS)
111 #define PR_EXPORT(__type) extern __declspec(dllexport) __type
112 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
113 #define PR_IMPORT(__type) extern __declspec(dllexport) __type
114 #define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
116 #define PR_EXTERN(__type) extern __declspec(dllexport) __type
117 #define PR_IMPLEMENT(__type) __declspec(dllexport) __type
118 #define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
119 #define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
122 #define PR_CALLBACK_DECL
123 #define PR_STATIC_CALLBACK(__x) static __x
127 #define PR_CALLBACK_DECL __cdecl
130 #define PR_EXPORT(__type) extern __type _cdecl _export _loadds
131 #define PR_IMPORT(__type) extern __type _cdecl _export _loadds
132 #define PR_EXPORT_DATA(__type) extern __type _export
133 #define PR_IMPORT_DATA(__type) extern __type _export
135 #define PR_EXTERN(__type) extern __type _cdecl _export _loadds
136 #define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
137 #define PR_EXTERN_DATA(__type) extern __type _export
138 #define PR_IMPLEMENT_DATA(__type) __type _export
140 #define PR_CALLBACK __cdecl __loadds
141 #define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
143 #else /* this must be .EXE */
144 #define PR_EXPORT(__type) extern __type _cdecl _export
145 #define PR_IMPORT(__type) extern __type _cdecl _export
146 #define PR_EXPORT_DATA(__type) extern __type _export
147 #define PR_IMPORT_DATA(__type) extern __type _export
149 #define PR_EXTERN(__type) extern __type _cdecl _export
150 #define PR_IMPLEMENT(__type) __type _cdecl _export
151 #define PR_EXTERN_DATA(__type) extern __type _export
152 #define PR_IMPLEMENT_DATA(__type) __type _export
154 #define PR_CALLBACK __cdecl __loadds
155 #define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
158 #elif defined(XP_MAC)
160 #define PR_EXPORT(__type) extern __declspec(export) __type
161 #define PR_EXPORT_DATA(__type) extern __declspec(export) __type
162 #define PR_IMPORT(__type) extern __declspec(export) __type
163 #define PR_IMPORT_DATA(__type) extern __declspec(export) __type
165 #define PR_EXTERN(__type) extern __declspec(export) __type
166 #define PR_IMPLEMENT(__type) __declspec(export) __type
167 #define PR_EXTERN_DATA(__type) extern __declspec(export) __type
168 #define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
171 #define PR_CALLBACK_DECL
172 #define PR_STATIC_CALLBACK(__x) static __x
174 #elif defined(XP_OS2_VACPP)
176 #define PR_EXPORT(__type) extern __type
177 #define PR_EXPORT_DATA(__type) extern __type
178 #define PR_IMPORT(__type) extern __type
179 #define PR_IMPORT_DATA(__type) extern __type
181 #define PR_EXTERN(__type) extern __type
182 #define PR_IMPLEMENT(__type) __type
183 #define PR_EXTERN_DATA(__type) extern __type
184 #define PR_IMPLEMENT_DATA(__type) __type
185 #define PR_CALLBACK _Optlink
186 #define PR_CALLBACK_DECL
187 #define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
191 #define PR_EXPORT(__type) extern __type
192 #define PR_EXPORT_DATA(__type) extern __type
193 #define PR_IMPORT(__type) extern __type
194 #define PR_IMPORT_DATA(__type) extern __type
196 #define PR_EXTERN(__type) extern __type
197 #define PR_IMPLEMENT(__type) __type
198 #define PR_EXTERN_DATA(__type) extern __type
199 #define PR_IMPLEMENT_DATA(__type) __type
201 #define PR_CALLBACK_DECL
202 #define PR_STATIC_CALLBACK(__x) static __x
206 #if defined(_NSPR_BUILD_)
207 #define NSPR_API(__type) PR_EXPORT(__type)
208 #define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
210 #define NSPR_API(__type) PR_IMPORT(__type)
211 #define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
214 /***********************************************************************
215 ** MACROS: PR_BEGIN_MACRO
218 ** Macro body brackets so that macros with compound statement definitions
219 ** behave syntactically more like functions when called.
220 ***********************************************************************/
221 #define PR_BEGIN_MACRO do {
222 #define PR_END_MACRO } while (0)
224 /***********************************************************************
225 ** MACROS: PR_BEGIN_EXTERN_C
228 ** Macro shorthands for conditional C++ extern block delimiters.
229 ***********************************************************************/
231 #define PR_BEGIN_EXTERN_C extern "C" {
232 #define PR_END_EXTERN_C }
234 #define PR_BEGIN_EXTERN_C
235 #define PR_END_EXTERN_C
238 /***********************************************************************
242 ** Bit masking macros. XXX n must be <= 31 to be portable
243 ***********************************************************************/
244 #define PR_BIT(n) ((PRUint32)1 << (n))
245 #define PR_BITMASK(n) (PR_BIT(n) - 1)
247 /***********************************************************************
248 ** MACROS: PR_ROUNDUP
253 ** Commonly used macros for operations on compatible types.
254 ***********************************************************************/
255 #define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y))
256 #define PR_MIN(x,y) ((x)<(y)?(x):(y))
257 #define PR_MAX(x,y) ((x)>(y)?(x):(y))
258 #define PR_ABS(x) ((x)<0?-(x):(x))
262 /************************************************************************
266 ** The int8 types are known to be 8 bits each. There is no type that
267 ** is equivalent to a plain "char".
268 ************************************************************************/
269 #if PR_BYTES_PER_BYTE == 1
270 typedef unsigned char PRUint8;
272 ** Some cfront-based C++ compilers do not like 'signed char' and
273 ** issue the warning message:
274 ** warning: "signed" not implemented (ignored)
275 ** For these compilers, we have to define PRInt8 as plain 'char'.
276 ** Make sure that plain 'char' is indeed signed under these compilers.
278 #if (defined(HPUX) && defined(__cplusplus) \
279 && !defined(__GNUC__) && __cplusplus < 199707L) \
280 || (defined(SCO) && defined(__cplusplus) \
281 && !defined(__GNUC__) && __cplusplus == 1L)
284 typedef signed char PRInt8;
287 #error No suitable type for PRInt8/PRUint8
290 /************************************************************************
291 * MACROS: PR_INT8_MAX
295 * The maximum and minimum values of a PRInt8 or PRUint8.
296 ************************************************************************/
298 #define PR_INT8_MAX 127
299 #define PR_INT8_MIN (-128)
300 #define PR_UINT8_MAX 255U
302 /************************************************************************
306 ** The int16 types are known to be 16 bits each.
307 ************************************************************************/
308 #if PR_BYTES_PER_SHORT == 2
309 typedef unsigned short PRUint16;
310 typedef short PRInt16;
312 #error No suitable type for PRInt16/PRUint16
315 /************************************************************************
316 * MACROS: PR_INT16_MAX
320 * The maximum and minimum values of a PRInt16 or PRUint16.
321 ************************************************************************/
323 #define PR_INT16_MAX 32767
324 #define PR_INT16_MIN (-32768)
325 #define PR_UINT16_MAX 65535U
327 /************************************************************************
331 ** The int32 types are known to be 32 bits each.
332 ************************************************************************/
333 #if PR_BYTES_PER_INT == 4
334 typedef unsigned int PRUint32;
336 #define PR_INT32(x) x
337 #define PR_UINT32(x) x ## U
338 #elif PR_BYTES_PER_LONG == 4
339 typedef unsigned long PRUint32;
340 typedef long PRInt32;
341 #define PR_INT32(x) x ## L
342 #define PR_UINT32(x) x ## UL
344 #error No suitable type for PRInt32/PRUint32
347 /************************************************************************
348 * MACROS: PR_INT32_MAX
352 * The maximum and minimum values of a PRInt32 or PRUint32.
353 ************************************************************************/
355 #define PR_INT32_MAX PR_INT32(2147483647)
356 #define PR_INT32_MIN (-PR_INT32_MAX - 1)
357 #define PR_UINT32_MAX PR_UINT32(4294967295)
359 /************************************************************************
363 ** The int64 types are known to be 64 bits each. Care must be used when
364 ** declaring variables of type PRUint64 or PRInt64. Different hardware
365 ** architectures and even different compilers have varying support for
366 ** 64 bit values. The only guaranteed portability requires the use of
367 ** the LL_ macros (see prlong.h).
368 ************************************************************************/
369 #ifdef HAVE_LONG_LONG
370 #if PR_BYTES_PER_LONG == 8
371 typedef long PRInt64;
372 typedef unsigned long PRUint64;
374 typedef __int64 PRInt64;
375 typedef unsigned __int64 PRUint64;
376 #elif defined(WIN32) && !defined(__GNUC__)
377 typedef __int64 PRInt64;
378 typedef unsigned __int64 PRUint64;
380 typedef long long PRInt64;
381 typedef unsigned long long PRUint64;
382 #endif /* PR_BYTES_PER_LONG == 8 */
383 #else /* !HAVE_LONG_LONG */
385 #ifdef IS_LITTLE_ENDIAN
391 typedef PRInt64 PRUint64;
392 #endif /* !HAVE_LONG_LONG */
394 /************************************************************************
398 ** The PRIntn types are most appropriate for automatic variables. They are
399 ** guaranteed to be at least 16 bits, though various architectures may
400 ** define them to be wider (e.g., 32 or even 64 bits). These types are
401 ** never valid for fields of a structure.
402 ************************************************************************/
403 #if PR_BYTES_PER_INT >= 2
405 typedef unsigned int PRUintn;
407 #error 'sizeof(int)' not sufficient for platform use
410 /************************************************************************
413 ** NSPR's floating point type is always 64 bits.
414 ************************************************************************/
415 typedef double PRFloat64;
417 /************************************************************************
420 ** A type for representing the size of objects.
421 ************************************************************************/
422 typedef size_t PRSize;
425 /************************************************************************
426 ** TYPES: PROffset32, PROffset64
428 ** A type for representing byte offsets from some location.
429 ************************************************************************/
430 typedef PRInt32 PROffset32;
431 typedef PRInt64 PROffset64;
433 /************************************************************************
436 ** A type for pointer difference. Variables of this type are suitable
437 ** for storing a pointer or pointer sutraction.
438 ************************************************************************/
439 typedef ptrdiff_t PRPtrdiff;
441 /************************************************************************
444 ** A type for pointer difference. Variables of this type are suitable
445 ** for storing a pointer or pointer sutraction.
446 ************************************************************************/
447 typedef unsigned long PRUptrdiff;
449 /************************************************************************
452 ** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE
453 ** for clarity of target type in assignments and actual arguments. Use
454 ** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
455 ** juast as you would C int-valued conditions.
456 ************************************************************************/
457 typedef PRIntn PRBool;
461 /************************************************************************
462 ** TYPES: PRPackedBool
464 ** Use PRPackedBOol within structs where bitfields are not desireable
465 ** but minimum and consistant overhead matters.
466 ************************************************************************/
467 typedef PRUint8 PRPackedBool;
470 ** Status code used by some routines that have a single point of failure or
471 ** special status return.
473 typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
477 * EXPERIMENTAL: This type may be removed in a future release.
479 #ifndef __PRUNICHAR__
480 #define __PRUNICHAR__
481 #if defined(WIN32) || defined(XP_MAC)
482 typedef wchar_t PRUnichar;
484 typedef PRUint16 PRUnichar;
487 #endif /* MOZ_UNICODE */
490 ** WARNING: The undocumented data types PRWord and PRUword are
491 ** only used in the garbage collection and arena code. Do not
492 ** use PRWord and PRUword in new code.
494 ** A PRWord is an integer that is the same size as a void*.
495 ** It implements the notion of a "word" in the Java Virtual
496 ** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine
497 ** Specification, Addison-Wesley, September 1996.
498 ** http://java.sun.com/docs/books/vmspec/index.html.)
501 typedef unsigned long PRUword;
503 #if defined(NO_NSPR_10_SUPPORT)
505 /********* ???????????????? FIX ME ??????????????????????????? *****/
506 /********************** Some old definitions until pr=>ds transition is done ***/
507 /********************** Also, we are still using NSPR 1.0. GC ******************/
509 ** Fundamental NSPR macros, used nearly everywhere.
512 #define PR_PUBLIC_API PR_IMPLEMENT
515 ** Macro body brackets so that macros with compound statement definitions
516 ** behave syntactically more like functions when called.
518 #define NSPR_BEGIN_MACRO do {
519 #define NSPR_END_MACRO } while (0)
522 ** Macro shorthands for conditional C++ extern block delimiters.
524 #ifdef NSPR_BEGIN_EXTERN_C
525 #undef NSPR_BEGIN_EXTERN_C
527 #ifdef NSPR_END_EXTERN_C
528 #undef NSPR_END_EXTERN_C
532 #define NSPR_BEGIN_EXTERN_C extern "C" {
533 #define NSPR_END_EXTERN_C }
535 #define NSPR_BEGIN_EXTERN_C
536 #define NSPR_END_EXTERN_C
540 #include "protypes.h"
542 #include "obsolete/protypes.h"
545 /********* ????????????? End Fix me ?????????????????????????????? *****/
546 #endif /* NO_NSPR_10_SUPPORT */
550 #endif /* prtypes_h___ */