Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / nsplugins / sdk / prtypes.h
blobb683610823d57502029c01846b5e7adcfeec9275
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 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/
7 *
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
18 * Rights Reserved.
20 * Contributor(s):
22 * Alternatively, the contents of this file may be used under the
23 * terms of the GNU General Public License Version 2 or later (the
24 * "GPL"), in which case the provisions of the GPL are applicable
25 * instead of those above. If you wish to allow use of your
26 * version of this file only under the terms of the GPL and not to
27 * allow others to use your version of this file under the MPL,
28 * indicate your decision by deleting the provisions above and
29 * replace them with the notice and other provisions required by
30 * the GPL. If you do not delete the provisions above, a recipient
31 * may use your version of this file under either the MPL or the
32 * GPL.
36 ** File: prtypes.h
37 ** Description: Definitions of NSPR's basic types
39 ** Prototypes and macros used to make up for deficiencies in ANSI environments
40 ** that we have found.
42 ** Since we do not wrap <stdlib.h> and all the other standard headers, authors
43 ** of portable code will not know in general that they need these definitions.
44 ** Instead of requiring these authors to find the dependent uses in their code
45 ** and take the following steps only in those C files, we take steps once here
46 ** for all C files.
47 **/
49 #ifndef prtypes_h___
50 #define prtypes_h___
52 #ifdef MDCPUCFG
53 #include MDCPUCFG
54 #else
55 #include "prcpucfg.h"
56 #endif
58 #include <stddef.h>
60 /***********************************************************************
61 ** MACROS: PR_EXTERN
62 ** PR_IMPLEMENT
63 ** DESCRIPTION:
64 ** These are only for externally visible routines and globals. For
65 ** internal routines, just use "extern" for type checking and that
66 ** will not export internal cross-file or forward-declared symbols.
67 ** Define a macro for declaring procedures return types. We use this to
68 ** deal with windoze specific type hackery for DLL definitions. Use
69 ** PR_EXTERN when the prototype for the method is declared. Use
70 ** PR_IMPLEMENT for the implementation of the method.
72 ** Example:
73 ** in dowhim.h
74 ** PR_EXTERN( void ) DoWhatIMean( void );
75 ** in dowhim.c
76 ** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
79 ***********************************************************************/
80 #if defined(WIN32)
82 #if defined(__GNUC__)
83 #undef _declspec
84 #define _declspec(x) __declspec(x)
85 #endif
87 #define PR_EXPORT(__type) extern _declspec(dllexport) __type
88 #define PR_EXPORT_DATA(__type) extern _declspec(dllexport) __type
89 #define PR_IMPORT(__type) _declspec(dllimport) __type
90 #define PR_IMPORT_DATA(__type) _declspec(dllimport) __type
92 #define PR_EXTERN(__type) extern _declspec(dllexport) __type
93 #define PR_IMPLEMENT(__type) _declspec(dllexport) __type
94 #define PR_EXTERN_DATA(__type) extern _declspec(dllexport) __type
95 #define PR_IMPLEMENT_DATA(__type) _declspec(dllexport) __type
97 #define PR_CALLBACK
98 #define PR_CALLBACK_DECL
99 #define PR_STATIC_CALLBACK(__x) static __x
101 #elif defined(XP_BEOS)
103 #define PR_EXPORT(__type) extern __declspec(dllexport) __type
104 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
105 #define PR_IMPORT(__type) extern __declspec(dllexport) __type
106 #define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
108 #define PR_EXTERN(__type) extern __declspec(dllexport) __type
109 #define PR_IMPLEMENT(__type) __declspec(dllexport) __type
110 #define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
111 #define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
113 #define PR_CALLBACK
114 #define PR_CALLBACK_DECL
115 #define PR_STATIC_CALLBACK(__x) static __x
117 #elif defined(WIN16)
119 #define PR_CALLBACK_DECL __cdecl
121 #if defined(_WINDLL)
122 #define PR_EXPORT(__type) extern __type _cdecl _export _loadds
123 #define PR_IMPORT(__type) extern __type _cdecl _export _loadds
124 #define PR_EXPORT_DATA(__type) extern __type _export
125 #define PR_IMPORT_DATA(__type) extern __type _export
127 #define PR_EXTERN(__type) extern __type _cdecl _export _loadds
128 #define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
129 #define PR_EXTERN_DATA(__type) extern __type _export
130 #define PR_IMPLEMENT_DATA(__type) __type _export
132 #define PR_CALLBACK __cdecl __loadds
133 #define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
135 #else /* this must be .EXE */
136 #define PR_EXPORT(__type) extern __type _cdecl _export
137 #define PR_IMPORT(__type) extern __type _cdecl _export
138 #define PR_EXPORT_DATA(__type) extern __type _export
139 #define PR_IMPORT_DATA(__type) extern __type _export
141 #define PR_EXTERN(__type) extern __type _cdecl _export
142 #define PR_IMPLEMENT(__type) __type _cdecl _export
143 #define PR_EXTERN_DATA(__type) extern __type _export
144 #define PR_IMPLEMENT_DATA(__type) __type _export
146 #define PR_CALLBACK __cdecl __loadds
147 #define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
148 #endif /* _WINDLL */
150 #elif defined(XP_MAC)
152 #define PR_EXPORT(__type) extern __declspec(export) __type
153 #define PR_EXPORT_DATA(__type) extern __declspec(export) __type
154 #define PR_IMPORT(__type) extern __declspec(export) __type
155 #define PR_IMPORT_DATA(__type) extern __declspec(export) __type
157 #define PR_EXTERN(__type) extern __declspec(export) __type
158 #define PR_IMPLEMENT(__type) __declspec(export) __type
159 #define PR_EXTERN_DATA(__type) extern __declspec(export) __type
160 #define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
162 #define PR_CALLBACK
163 #define PR_CALLBACK_DECL
164 #define PR_STATIC_CALLBACK(__x) static __x
166 #elif defined(XP_OS2_VACPP)
168 #define PR_EXPORT(__type) extern __type
169 #define PR_EXPORT_DATA(__type) extern __type
170 #define PR_IMPORT(__type) extern __type
171 #define PR_IMPORT_DATA(__type) extern __type
173 #define PR_EXTERN(__type) extern __type
174 #define PR_IMPLEMENT(__type) __type
175 #define PR_EXTERN_DATA(__type) extern __type
176 #define PR_IMPLEMENT_DATA(__type) __type
177 #define PR_CALLBACK _Optlink
178 #define PR_CALLBACK_DECL
179 #define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
181 #else /* Unix */
183 #define PR_EXPORT(__type) extern __type
184 #define PR_EXPORT_DATA(__type) extern __type
185 #define PR_IMPORT(__type) extern __type
186 #define PR_IMPORT_DATA(__type) extern __type
188 #define PR_EXTERN(__type) extern __type
189 #define PR_IMPLEMENT(__type) __type
190 #define PR_EXTERN_DATA(__type) extern __type
191 #define PR_IMPLEMENT_DATA(__type) __type
192 #define PR_CALLBACK
193 #define PR_CALLBACK_DECL
194 #define PR_STATIC_CALLBACK(__x) static __x
196 #endif
198 #if defined(_NSPR_BUILD_)
199 #define NSPR_API(__type) PR_EXPORT(__type)
200 #define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
201 #else
202 #define NSPR_API(__type) PR_IMPORT(__type)
203 #define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
204 #endif
206 /***********************************************************************
207 ** MACROS: PR_BEGIN_MACRO
208 ** PR_END_MACRO
209 ** DESCRIPTION:
210 ** Macro body brackets so that macros with compound statement definitions
211 ** behave syntactically more like functions when called.
212 ***********************************************************************/
213 #define PR_BEGIN_MACRO do {
214 #define PR_END_MACRO } while (0)
216 /***********************************************************************
217 ** MACROS: PR_BEGIN_EXTERN_C
218 ** PR_END_EXTERN_C
219 ** DESCRIPTION:
220 ** Macro shorthands for conditional C++ extern block delimiters.
221 ***********************************************************************/
222 #ifdef __cplusplus
223 #define PR_BEGIN_EXTERN_C extern "C" {
224 #define PR_END_EXTERN_C }
225 #else
226 #define PR_BEGIN_EXTERN_C
227 #define PR_END_EXTERN_C
228 #endif
230 /***********************************************************************
231 ** MACROS: PR_BIT
232 ** PR_BITMASK
233 ** DESCRIPTION:
234 ** Bit masking macros. XXX n must be <= 31 to be portable
235 ***********************************************************************/
236 #define PR_BIT(n) ((PRUint32)1 << (n))
237 #define PR_BITMASK(n) (PR_BIT(n) - 1)
239 /***********************************************************************
240 ** MACROS: PR_ROUNDUP
241 ** PR_MIN
242 ** PR_MAX
243 ** PR_ABS
244 ** DESCRIPTION:
245 ** Commonly used macros for operations on compatible types.
246 ***********************************************************************/
247 #define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y))
248 #define PR_MIN(x,y) ((x)<(y)?(x):(y))
249 #define PR_MAX(x,y) ((x)>(y)?(x):(y))
250 #define PR_ABS(x) ((x)<0?-(x):(x))
252 PR_BEGIN_EXTERN_C
254 /************************************************************************
255 ** TYPES: PRUint8
256 ** PRInt8
257 ** DESCRIPTION:
258 ** The int8 types are known to be 8 bits each. There is no type that
259 ** is equivalent to a plain "char".
260 ************************************************************************/
261 #if PR_BYTES_PER_BYTE == 1
262 typedef unsigned char PRUint8;
264 ** Some cfront-based C++ compilers do not like 'signed char' and
265 ** issue the warning message:
266 ** warning: "signed" not implemented (ignored)
267 ** For these compilers, we have to define PRInt8 as plain 'char'.
268 ** Make sure that plain 'char' is indeed signed under these compilers.
270 #if (defined(HPUX) && defined(__cplusplus) \
271 && !defined(__GNUC__) && __cplusplus < 199707L) \
272 || (defined(SCO) && defined(__cplusplus) \
273 && !defined(__GNUC__) && __cplusplus == 1L)
274 typedef char PRInt8;
275 #else
276 typedef signed char PRInt8;
277 #endif
278 #else
279 #error No suitable type for PRInt8/PRUint8
280 #endif
282 /************************************************************************
283 * MACROS: PR_INT8_MAX
284 * PR_INT8_MIN
285 * PR_UINT8_MAX
286 * DESCRIPTION:
287 * The maximum and minimum values of a PRInt8 or PRUint8.
288 ************************************************************************/
290 #define PR_INT8_MAX 127
291 #define PR_INT8_MIN (-128)
292 #define PR_UINT8_MAX 255U
294 /************************************************************************
295 ** TYPES: PRUint16
296 ** PRInt16
297 ** DESCRIPTION:
298 ** The int16 types are known to be 16 bits each.
299 ************************************************************************/
300 #if PR_BYTES_PER_SHORT == 2
301 typedef unsigned short PRUint16;
302 typedef short PRInt16;
303 #else
304 #error No suitable type for PRInt16/PRUint16
305 #endif
307 /************************************************************************
308 * MACROS: PR_INT16_MAX
309 * PR_INT16_MIN
310 * PR_UINT16_MAX
311 * DESCRIPTION:
312 * The maximum and minimum values of a PRInt16 or PRUint16.
313 ************************************************************************/
315 #define PR_INT16_MAX 32767
316 #define PR_INT16_MIN (-32768)
317 #define PR_UINT16_MAX 65535U
319 /************************************************************************
320 ** TYPES: PRUint32
321 ** PRInt32
322 ** DESCRIPTION:
323 ** The int32 types are known to be 32 bits each.
324 ************************************************************************/
325 #if PR_BYTES_PER_INT == 4
326 typedef unsigned int PRUint32;
327 typedef int PRInt32;
328 #define PR_INT32(x) x
329 #define PR_UINT32(x) x ## U
330 #elif PR_BYTES_PER_LONG == 4
331 typedef unsigned long PRUint32;
332 typedef long PRInt32;
333 #define PR_INT32(x) x ## L
334 #define PR_UINT32(x) x ## UL
335 #else
336 #error No suitable type for PRInt32/PRUint32
337 #endif
339 /************************************************************************
340 * MACROS: PR_INT32_MAX
341 * PR_INT32_MIN
342 * PR_UINT32_MAX
343 * DESCRIPTION:
344 * The maximum and minimum values of a PRInt32 or PRUint32.
345 ************************************************************************/
347 #define PR_INT32_MAX PR_INT32(2147483647)
348 #define PR_INT32_MIN (-PR_INT32_MAX - 1)
349 #define PR_UINT32_MAX PR_UINT32(4294967295)
351 /************************************************************************
352 ** TYPES: PRUint64
353 ** PRInt64
354 ** DESCRIPTION:
355 ** The int64 types are known to be 64 bits each. Care must be used when
356 ** declaring variables of type PRUint64 or PRInt64. Different hardware
357 ** architectures and even different compilers have varying support for
358 ** 64 bit values. The only guaranteed portability requires the use of
359 ** the LL_ macros (see prlong.h).
360 ************************************************************************/
361 #ifdef HAVE_LONG_LONG
362 #if PR_BYTES_PER_LONG == 8
363 typedef long PRInt64;
364 typedef unsigned long PRUint64;
365 #elif defined(WIN16)
366 typedef __int64 PRInt64;
367 typedef unsigned __int64 PRUint64;
368 #elif defined(WIN32) && !defined(__GNUC__)
369 typedef __int64 PRInt64;
370 typedef unsigned __int64 PRUint64;
371 #else
372 typedef long long PRInt64;
373 typedef unsigned long long PRUint64;
374 #endif /* PR_BYTES_PER_LONG == 8 */
375 #else /* !HAVE_LONG_LONG */
376 typedef struct {
377 #ifdef IS_LITTLE_ENDIAN
378 PRUint32 lo, hi;
379 #else
380 PRUint32 hi, lo;
381 #endif
382 } PRInt64;
383 typedef PRInt64 PRUint64;
384 #endif /* !HAVE_LONG_LONG */
386 /************************************************************************
387 ** TYPES: PRUintn
388 ** PRIntn
389 ** DESCRIPTION:
390 ** The PRIntn types are most appropriate for automatic variables. They are
391 ** guaranteed to be at least 16 bits, though various architectures may
392 ** define them to be wider (e.g., 32 or even 64 bits). These types are
393 ** never valid for fields of a structure.
394 ************************************************************************/
395 #if PR_BYTES_PER_INT >= 2
396 typedef int PRIntn;
397 typedef unsigned int PRUintn;
398 #else
399 #error 'sizeof(int)' not sufficient for platform use
400 #endif
402 /************************************************************************
403 ** TYPES: PRFloat64
404 ** DESCRIPTION:
405 ** NSPR's floating point type is always 64 bits.
406 ************************************************************************/
407 typedef double PRFloat64;
409 /************************************************************************
410 ** TYPES: PRSize
411 ** DESCRIPTION:
412 ** A type for representing the size of objects.
413 ************************************************************************/
414 typedef size_t PRSize;
417 /************************************************************************
418 ** TYPES: PROffset32, PROffset64
419 ** DESCRIPTION:
420 ** A type for representing byte offsets from some location.
421 ************************************************************************/
422 typedef PRInt32 PROffset32;
423 typedef PRInt64 PROffset64;
425 /************************************************************************
426 ** TYPES: PRPtrDiff
427 ** DESCRIPTION:
428 ** A type for pointer difference. Variables of this type are suitable
429 ** for storing a pointer or pointer sutraction.
430 ************************************************************************/
431 typedef ptrdiff_t PRPtrdiff;
433 /************************************************************************
434 ** TYPES: PRUptrdiff
435 ** DESCRIPTION:
436 ** A type for pointer difference. Variables of this type are suitable
437 ** for storing a pointer or pointer sutraction.
438 ************************************************************************/
439 typedef unsigned long PRUptrdiff;
441 /************************************************************************
442 ** TYPES: PRBool
443 ** DESCRIPTION:
444 ** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE
445 ** for clarity of target type in assignments and actual arguments. Use
446 ** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
447 ** juast as you would C int-valued conditions.
448 ************************************************************************/
449 typedef PRIntn PRBool;
450 #define PR_TRUE 1
451 #define PR_FALSE 0
453 /************************************************************************
454 ** TYPES: PRPackedBool
455 ** DESCRIPTION:
456 ** Use PRPackedBOol within structs where bitfields are not desireable
457 ** but minimum and consistant overhead matters.
458 ************************************************************************/
459 typedef PRUint8 PRPackedBool;
462 ** Status code used by some routines that have a single point of failure or
463 ** special status return.
465 typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
467 #ifdef MOZ_UNICODE
469 * EXPERIMENTAL: This type may be removed in a future release.
471 #ifndef __PRUNICHAR__
472 #define __PRUNICHAR__
473 #if defined(WIN32) || defined(XP_MAC)
474 typedef wchar_t PRUnichar;
475 #else
476 typedef PRUint16 PRUnichar;
477 #endif
478 #endif
479 #endif /* MOZ_UNICODE */
482 ** WARNING: The undocumented data types PRWord and PRUword are
483 ** only used in the garbage collection and arena code. Do not
484 ** use PRWord and PRUword in new code.
486 ** A PRWord is an integer that is the same size as a void*.
487 ** It implements the notion of a "word" in the Java Virtual
488 ** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine
489 ** Specification, Addison-Wesley, September 1996.
490 ** http://java.sun.com/docs/books/vmspec/index.html.)
492 typedef long PRWord;
493 typedef unsigned long PRUword;
495 #if defined(NO_NSPR_10_SUPPORT)
496 #else
497 /********* ???????????????? FIX ME ??????????????????????????? *****/
498 /********************** Some old definitions until pr=>ds transition is done ***/
499 /********************** Also, we are still using NSPR 1.0. GC ******************/
501 ** Fundamental NSPR macros, used nearly everywhere.
504 #define PR_PUBLIC_API PR_IMPLEMENT
507 ** Macro body brackets so that macros with compound statement definitions
508 ** behave syntactically more like functions when called.
510 #define NSPR_BEGIN_MACRO do {
511 #define NSPR_END_MACRO } while (0)
514 ** Macro shorthands for conditional C++ extern block delimiters.
516 #ifdef NSPR_BEGIN_EXTERN_C
517 #undef NSPR_BEGIN_EXTERN_C
518 #endif
519 #ifdef NSPR_END_EXTERN_C
520 #undef NSPR_END_EXTERN_C
521 #endif
523 #ifdef __cplusplus
524 #define NSPR_BEGIN_EXTERN_C extern "C" {
525 #define NSPR_END_EXTERN_C }
526 #else
527 #define NSPR_BEGIN_EXTERN_C
528 #define NSPR_END_EXTERN_C
529 #endif
531 #ifdef XP_MAC
532 #include "protypes.h"
533 #else
534 #include "obsolete/protypes.h"
535 #endif
537 /********* ????????????? End Fix me ?????????????????????????????? *****/
538 #endif /* NO_NSPR_10_SUPPORT */
540 PR_END_EXTERN_C
542 #endif /* prtypes_h___ */