Bug 449533. Set the mFixedPitch flag within SetFixedPitch. r+sr=vlad
[wine-gecko.git] / nsprpub / pr / include / prtypes.h
blob66814841713e0a9f23ee8801b51efadfb7021147
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is the Netscape Portable Runtime (NSPR).
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 ** File: prtypes.h
40 ** Description: Definitions of NSPR's basic types
42 ** Prototypes and macros used to make up for deficiencies that we have found
43 ** in ANSI environments.
45 ** Since we do not wrap <stdlib.h> and all the other standard headers, authors
46 ** of portable code will not know in general that they need these definitions.
47 ** Instead of requiring these authors to find the dependent uses in their code
48 ** and take the following steps only in those C files, we take steps once here
49 ** for all C files.
50 **/
52 #ifndef prtypes_h___
53 #define prtypes_h___
55 #ifdef MDCPUCFG
56 #include MDCPUCFG
57 #else
58 #include "prcpucfg.h"
59 #endif
61 #include <stddef.h>
63 /***********************************************************************
64 ** MACROS: PR_EXTERN
65 ** PR_IMPLEMENT
66 ** DESCRIPTION:
67 ** These are only for externally visible routines and globals. For
68 ** internal routines, just use "extern" for type checking and that
69 ** will not export internal cross-file or forward-declared symbols.
70 ** Define a macro for declaring procedures return types. We use this to
71 ** deal with windoze specific type hackery for DLL definitions. Use
72 ** PR_EXTERN when the prototype for the method is declared. Use
73 ** PR_IMPLEMENT for the implementation of the method.
75 ** Example:
76 ** in dowhim.h
77 ** PR_EXTERN( void ) DoWhatIMean( void );
78 ** in dowhim.c
79 ** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
82 ***********************************************************************/
83 #if defined(WIN32)
85 #define PR_EXPORT(__type) extern __declspec(dllexport) __type
86 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
87 #define PR_IMPORT(__type) __declspec(dllimport) __type
88 #define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
90 #define PR_EXTERN(__type) extern __declspec(dllexport) __type
91 #define PR_IMPLEMENT(__type) __declspec(dllexport) __type
92 #define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
93 #define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
95 #define PR_CALLBACK
96 #define PR_CALLBACK_DECL
97 #define PR_STATIC_CALLBACK(__x) static __x
99 #elif defined(XP_BEOS)
101 #define PR_EXPORT(__type) extern __declspec(dllexport) __type
102 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
103 #define PR_IMPORT(__type) extern __declspec(dllexport) __type
104 #define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
106 #define PR_EXTERN(__type) extern __declspec(dllexport) __type
107 #define PR_IMPLEMENT(__type) __declspec(dllexport) __type
108 #define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
109 #define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
111 #define PR_CALLBACK
112 #define PR_CALLBACK_DECL
113 #define PR_STATIC_CALLBACK(__x) static __x
115 #elif defined(WIN16)
117 #define PR_CALLBACK_DECL __cdecl
119 #if defined(_WINDLL)
120 #define PR_EXPORT(__type) extern __type _cdecl _export _loadds
121 #define PR_IMPORT(__type) extern __type _cdecl _export _loadds
122 #define PR_EXPORT_DATA(__type) extern __type _export
123 #define PR_IMPORT_DATA(__type) extern __type _export
125 #define PR_EXTERN(__type) extern __type _cdecl _export _loadds
126 #define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
127 #define PR_EXTERN_DATA(__type) extern __type _export
128 #define PR_IMPLEMENT_DATA(__type) __type _export
130 #define PR_CALLBACK __cdecl __loadds
131 #define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
133 #else /* this must be .EXE */
134 #define PR_EXPORT(__type) extern __type _cdecl _export
135 #define PR_IMPORT(__type) extern __type _cdecl _export
136 #define PR_EXPORT_DATA(__type) extern __type _export
137 #define PR_IMPORT_DATA(__type) extern __type _export
139 #define PR_EXTERN(__type) extern __type _cdecl _export
140 #define PR_IMPLEMENT(__type) __type _cdecl _export
141 #define PR_EXTERN_DATA(__type) extern __type _export
142 #define PR_IMPLEMENT_DATA(__type) __type _export
144 #define PR_CALLBACK __cdecl __loadds
145 #define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
146 #endif /* _WINDLL */
148 #elif defined(XP_MAC)
150 #define PR_EXPORT(__type) extern __declspec(export) __type
151 #define PR_EXPORT_DATA(__type) extern __declspec(export) __type
152 #define PR_IMPORT(__type) extern __declspec(export) __type
153 #define PR_IMPORT_DATA(__type) extern __declspec(export) __type
155 #define PR_EXTERN(__type) extern __declspec(export) __type
156 #define PR_IMPLEMENT(__type) __declspec(export) __type
157 #define PR_EXTERN_DATA(__type) extern __declspec(export) __type
158 #define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
160 #define PR_CALLBACK
161 #define PR_CALLBACK_DECL
162 #define PR_STATIC_CALLBACK(__x) static __x
164 #elif defined(XP_OS2) && defined(__declspec)
166 #define PR_EXPORT(__type) extern __declspec(dllexport) __type
167 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
168 #define PR_IMPORT(__type) extern __declspec(dllimport) __type
169 #define PR_IMPORT_DATA(__type) extern __declspec(dllimport) __type
171 #define PR_EXTERN(__type) extern __declspec(dllexport) __type
172 #define PR_IMPLEMENT(__type) __declspec(dllexport) __type
173 #define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
174 #define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
176 #define PR_CALLBACK
177 #define PR_CALLBACK_DECL
178 #define PR_STATIC_CALLBACK(__x) static __x
180 #elif defined(SYMBIAN)
182 #define PR_EXPORT(__type) extern __declspec(dllexport) __type
183 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
184 #ifdef __WINS__
185 #define PR_IMPORT(__type) extern __declspec(dllexport) __type
186 #define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
187 #else
188 #define PR_IMPORT(__type) extern __declspec(dllimport) __type
189 #define PR_IMPORT_DATA(__type) extern __declspec(dllimport) __type
190 #endif
192 #define PR_EXTERN(__type) extern __type
193 #define PR_IMPLEMENT(__type) __type
194 #define PR_EXTERN_DATA(__type) extern __type
195 #define PR_IMPLEMENT_DATA(__type) __type
197 #define PR_CALLBACK
198 #define PR_CALLBACK_DECL
199 #define PR_STATIC_CALLBACK(__x) static __x
201 #else /* Unix */
203 /* GCC 3.3 and later support the visibility attribute. */
204 #if (__GNUC__ >= 4) || \
205 (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
206 #define PR_VISIBILITY_DEFAULT __attribute__((visibility("default")))
207 #else
208 #define PR_VISIBILITY_DEFAULT
209 #endif
211 #define PR_EXPORT(__type) extern PR_VISIBILITY_DEFAULT __type
212 #define PR_EXPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
213 #define PR_IMPORT(__type) extern PR_VISIBILITY_DEFAULT __type
214 #define PR_IMPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
216 #define PR_EXTERN(__type) extern PR_VISIBILITY_DEFAULT __type
217 #define PR_IMPLEMENT(__type) PR_VISIBILITY_DEFAULT __type
218 #define PR_EXTERN_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
219 #define PR_IMPLEMENT_DATA(__type) PR_VISIBILITY_DEFAULT __type
220 #define PR_CALLBACK
221 #define PR_CALLBACK_DECL
222 #define PR_STATIC_CALLBACK(__x) static __x
224 #endif
226 #if defined(_NSPR_BUILD_)
227 #define NSPR_API(__type) PR_EXPORT(__type)
228 #define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
229 #else
230 #define NSPR_API(__type) PR_IMPORT(__type)
231 #define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
232 #endif
234 /***********************************************************************
235 ** MACROS: PR_BEGIN_MACRO
236 ** PR_END_MACRO
237 ** DESCRIPTION:
238 ** Macro body brackets so that macros with compound statement definitions
239 ** behave syntactically more like functions when called.
240 ***********************************************************************/
241 #define PR_BEGIN_MACRO do {
242 #define PR_END_MACRO } while (0)
244 /***********************************************************************
245 ** MACROS: PR_BEGIN_EXTERN_C
246 ** PR_END_EXTERN_C
247 ** DESCRIPTION:
248 ** Macro shorthands for conditional C++ extern block delimiters.
249 ***********************************************************************/
250 #ifdef __cplusplus
251 #define PR_BEGIN_EXTERN_C extern "C" {
252 #define PR_END_EXTERN_C }
253 #else
254 #define PR_BEGIN_EXTERN_C
255 #define PR_END_EXTERN_C
256 #endif
258 /***********************************************************************
259 ** MACROS: PR_BIT
260 ** PR_BITMASK
261 ** DESCRIPTION:
262 ** Bit masking macros. XXX n must be <= 31 to be portable
263 ***********************************************************************/
264 #define PR_BIT(n) ((PRUint32)1 << (n))
265 #define PR_BITMASK(n) (PR_BIT(n) - 1)
267 /***********************************************************************
268 ** MACROS: PR_ROUNDUP
269 ** PR_MIN
270 ** PR_MAX
271 ** PR_ABS
272 ** DESCRIPTION:
273 ** Commonly used macros for operations on compatible types.
274 ***********************************************************************/
275 #define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y))
276 #define PR_MIN(x,y) ((x)<(y)?(x):(y))
277 #define PR_MAX(x,y) ((x)>(y)?(x):(y))
278 #define PR_ABS(x) ((x)<0?-(x):(x))
280 PR_BEGIN_EXTERN_C
282 /************************************************************************
283 ** TYPES: PRUint8
284 ** PRInt8
285 ** DESCRIPTION:
286 ** The int8 types are known to be 8 bits each. There is no type that
287 ** is equivalent to a plain "char".
288 ************************************************************************/
289 #if PR_BYTES_PER_BYTE == 1
290 typedef unsigned char PRUint8;
292 ** Some cfront-based C++ compilers do not like 'signed char' and
293 ** issue the warning message:
294 ** warning: "signed" not implemented (ignored)
295 ** For these compilers, we have to define PRInt8 as plain 'char'.
296 ** Make sure that plain 'char' is indeed signed under these compilers.
298 #if (defined(HPUX) && defined(__cplusplus) \
299 && !defined(__GNUC__) && __cplusplus < 199707L) \
300 || (defined(SCO) && defined(__cplusplus) \
301 && !defined(__GNUC__) && __cplusplus == 1L)
302 typedef char PRInt8;
303 #else
304 typedef signed char PRInt8;
305 #endif
306 #else
307 #error No suitable type for PRInt8/PRUint8
308 #endif
310 /************************************************************************
311 * MACROS: PR_INT8_MAX
312 * PR_INT8_MIN
313 * PR_UINT8_MAX
314 * DESCRIPTION:
315 * The maximum and minimum values of a PRInt8 or PRUint8.
316 ************************************************************************/
318 #define PR_INT8_MAX 127
319 #define PR_INT8_MIN (-128)
320 #define PR_UINT8_MAX 255U
322 /************************************************************************
323 ** TYPES: PRUint16
324 ** PRInt16
325 ** DESCRIPTION:
326 ** The int16 types are known to be 16 bits each.
327 ************************************************************************/
328 #if PR_BYTES_PER_SHORT == 2
329 typedef unsigned short PRUint16;
330 typedef short PRInt16;
331 #else
332 #error No suitable type for PRInt16/PRUint16
333 #endif
335 /************************************************************************
336 * MACROS: PR_INT16_MAX
337 * PR_INT16_MIN
338 * PR_UINT16_MAX
339 * DESCRIPTION:
340 * The maximum and minimum values of a PRInt16 or PRUint16.
341 ************************************************************************/
343 #define PR_INT16_MAX 32767
344 #define PR_INT16_MIN (-32768)
345 #define PR_UINT16_MAX 65535U
347 /************************************************************************
348 ** TYPES: PRUint32
349 ** PRInt32
350 ** DESCRIPTION:
351 ** The int32 types are known to be 32 bits each.
352 ************************************************************************/
353 #if PR_BYTES_PER_INT == 4
354 typedef unsigned int PRUint32;
355 typedef int PRInt32;
356 #define PR_INT32(x) x
357 #define PR_UINT32(x) x ## U
358 #elif PR_BYTES_PER_LONG == 4
359 typedef unsigned long PRUint32;
360 typedef long PRInt32;
361 #define PR_INT32(x) x ## L
362 #define PR_UINT32(x) x ## UL
363 #else
364 #error No suitable type for PRInt32/PRUint32
365 #endif
367 /************************************************************************
368 * MACROS: PR_INT32_MAX
369 * PR_INT32_MIN
370 * PR_UINT32_MAX
371 * DESCRIPTION:
372 * The maximum and minimum values of a PRInt32 or PRUint32.
373 ************************************************************************/
375 #define PR_INT32_MAX PR_INT32(2147483647)
376 #define PR_INT32_MIN (-PR_INT32_MAX - 1)
377 #define PR_UINT32_MAX PR_UINT32(4294967295)
379 /************************************************************************
380 ** TYPES: PRUint64
381 ** PRInt64
382 ** DESCRIPTION:
383 ** The int64 types are known to be 64 bits each. Care must be used when
384 ** declaring variables of type PRUint64 or PRInt64. Different hardware
385 ** architectures and even different compilers have varying support for
386 ** 64 bit values. The only guaranteed portability requires the use of
387 ** the LL_ macros (see prlong.h).
388 ************************************************************************/
389 #ifdef HAVE_LONG_LONG
390 #if PR_BYTES_PER_LONG == 8
391 typedef long PRInt64;
392 typedef unsigned long PRUint64;
393 #elif defined(WIN16)
394 typedef __int64 PRInt64;
395 typedef unsigned __int64 PRUint64;
396 #elif defined(WIN32) && !defined(__GNUC__)
397 typedef __int64 PRInt64;
398 typedef unsigned __int64 PRUint64;
399 #else
400 typedef long long PRInt64;
401 typedef unsigned long long PRUint64;
402 #endif /* PR_BYTES_PER_LONG == 8 */
403 #else /* !HAVE_LONG_LONG */
404 typedef struct {
405 #ifdef IS_LITTLE_ENDIAN
406 PRUint32 lo, hi;
407 #else
408 PRUint32 hi, lo;
409 #endif
410 } PRInt64;
411 typedef PRInt64 PRUint64;
412 #endif /* !HAVE_LONG_LONG */
414 /************************************************************************
415 ** TYPES: PRUintn
416 ** PRIntn
417 ** DESCRIPTION:
418 ** The PRIntn types are most appropriate for automatic variables. They are
419 ** guaranteed to be at least 16 bits, though various architectures may
420 ** define them to be wider (e.g., 32 or even 64 bits). These types are
421 ** never valid for fields of a structure.
422 ************************************************************************/
423 #if PR_BYTES_PER_INT >= 2
424 typedef int PRIntn;
425 typedef unsigned int PRUintn;
426 #else
427 #error 'sizeof(int)' not sufficient for platform use
428 #endif
430 /************************************************************************
431 ** TYPES: PRFloat64
432 ** DESCRIPTION:
433 ** NSPR's floating point type is always 64 bits.
434 ************************************************************************/
435 typedef double PRFloat64;
437 /************************************************************************
438 ** TYPES: PRSize
439 ** DESCRIPTION:
440 ** A type for representing the size of objects.
441 ************************************************************************/
442 typedef size_t PRSize;
445 /************************************************************************
446 ** TYPES: PROffset32, PROffset64
447 ** DESCRIPTION:
448 ** A type for representing byte offsets from some location.
449 ************************************************************************/
450 typedef PRInt32 PROffset32;
451 typedef PRInt64 PROffset64;
453 /************************************************************************
454 ** TYPES: PRPtrDiff
455 ** DESCRIPTION:
456 ** A type for pointer difference. Variables of this type are suitable
457 ** for storing a pointer or pointer subtraction.
458 ************************************************************************/
459 typedef ptrdiff_t PRPtrdiff;
461 /************************************************************************
462 ** TYPES: PRUptrdiff
463 ** DESCRIPTION:
464 ** A type for pointer difference. Variables of this type are suitable
465 ** for storing a pointer or pointer sutraction.
466 ************************************************************************/
467 #ifdef _WIN64
468 typedef unsigned __int64 PRUptrdiff;
469 #else
470 typedef unsigned long PRUptrdiff;
471 #endif
473 /************************************************************************
474 ** TYPES: PRBool
475 ** DESCRIPTION:
476 ** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE
477 ** for clarity of target type in assignments and actual arguments. Use
478 ** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
479 ** just as you would C int-valued conditions.
480 ************************************************************************/
481 typedef PRIntn PRBool;
482 #define PR_TRUE 1
483 #define PR_FALSE 0
485 /************************************************************************
486 ** TYPES: PRPackedBool
487 ** DESCRIPTION:
488 ** Use PRPackedBool within structs where bitfields are not desirable
489 ** but minimum and consistant overhead matters.
490 ************************************************************************/
491 typedef PRUint8 PRPackedBool;
494 ** Status code used by some routines that have a single point of failure or
495 ** special status return.
497 typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
499 #ifndef __PRUNICHAR__
500 #define __PRUNICHAR__
501 #if defined(WIN32) || defined(XP_MAC)
502 typedef wchar_t PRUnichar;
503 #else
504 typedef PRUint16 PRUnichar;
505 #endif
506 #endif
509 ** WARNING: The undocumented data types PRWord and PRUword are
510 ** only used in the garbage collection and arena code. Do not
511 ** use PRWord and PRUword in new code.
513 ** A PRWord is an integer that is the same size as a void*.
514 ** It implements the notion of a "word" in the Java Virtual
515 ** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine
516 ** Specification, Addison-Wesley, September 1996.
517 ** http://java.sun.com/docs/books/vmspec/index.html.)
519 #ifdef _WIN64
520 typedef __int64 PRWord;
521 typedef unsigned __int64 PRUword;
522 #else
523 typedef long PRWord;
524 typedef unsigned long PRUword;
525 #endif
527 #if defined(NO_NSPR_10_SUPPORT)
528 #else
529 /********* ???????????????? FIX ME ??????????????????????????? *****/
530 /********************** Some old definitions until pr=>ds transition is done ***/
531 /********************** Also, we are still using NSPR 1.0. GC ******************/
533 ** Fundamental NSPR macros, used nearly everywhere.
536 #define PR_PUBLIC_API PR_IMPLEMENT
539 ** Macro body brackets so that macros with compound statement definitions
540 ** behave syntactically more like functions when called.
542 #define NSPR_BEGIN_MACRO do {
543 #define NSPR_END_MACRO } while (0)
546 ** Macro shorthands for conditional C++ extern block delimiters.
548 #ifdef NSPR_BEGIN_EXTERN_C
549 #undef NSPR_BEGIN_EXTERN_C
550 #endif
551 #ifdef NSPR_END_EXTERN_C
552 #undef NSPR_END_EXTERN_C
553 #endif
555 #ifdef __cplusplus
556 #define NSPR_BEGIN_EXTERN_C extern "C" {
557 #define NSPR_END_EXTERN_C }
558 #else
559 #define NSPR_BEGIN_EXTERN_C
560 #define NSPR_END_EXTERN_C
561 #endif
563 #ifdef XP_MAC
564 #include "protypes.h"
565 #else
566 #include "obsolete/protypes.h"
567 #endif
569 /********* ????????????? End Fix me ?????????????????????????????? *****/
570 #endif /* NO_NSPR_10_SUPPORT */
572 PR_END_EXTERN_C
574 #endif /* prtypes_h___ */