Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: gecko-sdk/include/prtypes.h

Issue 20346: Version 1.8 of gecko-sdk. Downloaded from here:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gecko-sdk/include/prtrace.h ('k') | gecko-sdk/include/prvrsion.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
4 *
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/
9 *
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.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
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.
21 *
22 * Contributor(s):
23 *
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.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38 /*
39 ** File: prtypes.h
40 ** Description: Definitions of NSPR's basic types
41 **
42 ** Prototypes and macros used to make up for deficiencies that we have found
43 ** in ANSI environments.
44 **
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 **/
51
52 #ifndef prtypes_h___
53 #define prtypes_h___
54
55 #ifdef MDCPUCFG
56 #include MDCPUCFG
57 #else
58 #include "prcpucfg.h"
59 #endif
60
61 #include <stddef.h>
62
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.
74 **
75 ** Example:
76 ** in dowhim.h
77 ** PR_EXTERN( void ) DoWhatIMean( void );
78 ** in dowhim.c
79 ** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
80 **
81 **
82 ***********************************************************************/
83 #if defined(WIN32)
84
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
89
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
94
95 #define PR_CALLBACK
96 #define PR_CALLBACK_DECL
97 #define PR_STATIC_CALLBACK(__x) static __x
98
99 #elif defined(XP_BEOS)
100
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
105
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
110
111 #define PR_CALLBACK
112 #define PR_CALLBACK_DECL
113 #define PR_STATIC_CALLBACK(__x) static __x
114
115 #elif defined(WIN16)
116
117 #define PR_CALLBACK_DECL __cdecl
118
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
124
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
129
130 #define PR_CALLBACK __cdecl __loadds
131 #define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
132
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
138
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
143
144 #define PR_CALLBACK __cdecl __loadds
145 #define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
146 #endif /* _WINDLL */
147
148 #elif defined(XP_MAC)
149
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
154
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
159
160 #define PR_CALLBACK
161 #define PR_CALLBACK_DECL
162 #define PR_STATIC_CALLBACK(__x) static __x
163
164 #elif defined(XP_OS2_VACPP)
165
166 #define PR_EXPORT(__type) extern __type
167 #define PR_EXPORT_DATA(__type) extern __type
168 #define PR_IMPORT(__type) extern __type
169 #define PR_IMPORT_DATA(__type) extern __type
170
171 #define PR_EXTERN(__type) extern __type
172 #define PR_IMPLEMENT(__type) __type
173 #define PR_EXTERN_DATA(__type) extern __type
174 #define PR_IMPLEMENT_DATA(__type) __type
175 #define PR_CALLBACK _Optlink
176 #define PR_CALLBACK_DECL
177 #define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
178
179 #else /* Unix */
180
181 #ifdef HAVE_VISIBILITY_PRAGMA
182 #define PR_VISIBILITY_DEFAULT __attribute__((visibility("default")))
183 #else
184 #define PR_VISIBILITY_DEFAULT
185 #endif
186
187 #define PR_EXPORT(__type) extern PR_VISIBILITY_DEFAULT __type
188 #define PR_EXPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
189 #define PR_IMPORT(__type) extern PR_VISIBILITY_DEFAULT __type
190 #define PR_IMPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
191
192 #define PR_EXTERN(__type) extern PR_VISIBILITY_DEFAULT __type
193 #define PR_IMPLEMENT(__type) PR_VISIBILITY_DEFAULT __type
194 #define PR_EXTERN_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
195 #define PR_IMPLEMENT_DATA(__type) PR_VISIBILITY_DEFAULT __type
196 #define PR_CALLBACK
197 #define PR_CALLBACK_DECL
198 #define PR_STATIC_CALLBACK(__x) static __x
199
200 #endif
201
202 #if defined(_NSPR_BUILD_)
203 #define NSPR_API(__type) PR_EXPORT(__type)
204 #define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
205 #else
206 #define NSPR_API(__type) PR_IMPORT(__type)
207 #define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
208 #endif
209
210 /***********************************************************************
211 ** MACROS: PR_BEGIN_MACRO
212 ** PR_END_MACRO
213 ** DESCRIPTION:
214 ** Macro body brackets so that macros with compound statement definitions
215 ** behave syntactically more like functions when called.
216 ***********************************************************************/
217 #define PR_BEGIN_MACRO do {
218 #define PR_END_MACRO } while (0)
219
220 /***********************************************************************
221 ** MACROS: PR_BEGIN_EXTERN_C
222 ** PR_END_EXTERN_C
223 ** DESCRIPTION:
224 ** Macro shorthands for conditional C++ extern block delimiters.
225 ***********************************************************************/
226 #ifdef __cplusplus
227 #define PR_BEGIN_EXTERN_C extern "C" {
228 #define PR_END_EXTERN_C }
229 #else
230 #define PR_BEGIN_EXTERN_C
231 #define PR_END_EXTERN_C
232 #endif
233
234 /***********************************************************************
235 ** MACROS: PR_BIT
236 ** PR_BITMASK
237 ** DESCRIPTION:
238 ** Bit masking macros. XXX n must be <= 31 to be portable
239 ***********************************************************************/
240 #define PR_BIT(n) ((PRUint32)1 << (n))
241 #define PR_BITMASK(n) (PR_BIT(n) - 1)
242
243 /***********************************************************************
244 ** MACROS: PR_ROUNDUP
245 ** PR_MIN
246 ** PR_MAX
247 ** PR_ABS
248 ** DESCRIPTION:
249 ** Commonly used macros for operations on compatible types.
250 ***********************************************************************/
251 #define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y))
252 #define PR_MIN(x,y) ((x)<(y)?(x):(y))
253 #define PR_MAX(x,y) ((x)>(y)?(x):(y))
254 #define PR_ABS(x) ((x)<0?-(x):(x))
255
256 PR_BEGIN_EXTERN_C
257
258 /************************************************************************
259 ** TYPES: PRUint8
260 ** PRInt8
261 ** DESCRIPTION:
262 ** The int8 types are known to be 8 bits each. There is no type that
263 ** is equivalent to a plain "char".
264 ************************************************************************/
265 #if PR_BYTES_PER_BYTE == 1
266 typedef unsigned char PRUint8;
267 /*
268 ** Some cfront-based C++ compilers do not like 'signed char' and
269 ** issue the warning message:
270 ** warning: "signed" not implemented (ignored)
271 ** For these compilers, we have to define PRInt8 as plain 'char'.
272 ** Make sure that plain 'char' is indeed signed under these compilers.
273 */
274 #if (defined(HPUX) && defined(__cplusplus) \
275 && !defined(__GNUC__) && __cplusplus < 199707L) \
276 || (defined(SCO) && defined(__cplusplus) \
277 && !defined(__GNUC__) && __cplusplus == 1L)
278 typedef char PRInt8;
279 #else
280 typedef signed char PRInt8;
281 #endif
282 #else
283 #error No suitable type for PRInt8/PRUint8
284 #endif
285
286 /************************************************************************
287 * MACROS: PR_INT8_MAX
288 * PR_INT8_MIN
289 * PR_UINT8_MAX
290 * DESCRIPTION:
291 * The maximum and minimum values of a PRInt8 or PRUint8.
292 ************************************************************************/
293
294 #define PR_INT8_MAX 127
295 #define PR_INT8_MIN (-128)
296 #define PR_UINT8_MAX 255U
297
298 /************************************************************************
299 ** TYPES: PRUint16
300 ** PRInt16
301 ** DESCRIPTION:
302 ** The int16 types are known to be 16 bits each.
303 ************************************************************************/
304 #if PR_BYTES_PER_SHORT == 2
305 typedef unsigned short PRUint16;
306 typedef short PRInt16;
307 #else
308 #error No suitable type for PRInt16/PRUint16
309 #endif
310
311 /************************************************************************
312 * MACROS: PR_INT16_MAX
313 * PR_INT16_MIN
314 * PR_UINT16_MAX
315 * DESCRIPTION:
316 * The maximum and minimum values of a PRInt16 or PRUint16.
317 ************************************************************************/
318
319 #define PR_INT16_MAX 32767
320 #define PR_INT16_MIN (-32768)
321 #define PR_UINT16_MAX 65535U
322
323 /************************************************************************
324 ** TYPES: PRUint32
325 ** PRInt32
326 ** DESCRIPTION:
327 ** The int32 types are known to be 32 bits each.
328 ************************************************************************/
329 #if PR_BYTES_PER_INT == 4
330 typedef unsigned int PRUint32;
331 typedef int PRInt32;
332 #define PR_INT32(x) x
333 #define PR_UINT32(x) x ## U
334 #elif PR_BYTES_PER_LONG == 4
335 typedef unsigned long PRUint32;
336 typedef long PRInt32;
337 #define PR_INT32(x) x ## L
338 #define PR_UINT32(x) x ## UL
339 #else
340 #error No suitable type for PRInt32/PRUint32
341 #endif
342
343 /************************************************************************
344 * MACROS: PR_INT32_MAX
345 * PR_INT32_MIN
346 * PR_UINT32_MAX
347 * DESCRIPTION:
348 * The maximum and minimum values of a PRInt32 or PRUint32.
349 ************************************************************************/
350
351 #define PR_INT32_MAX PR_INT32(2147483647)
352 #define PR_INT32_MIN (-PR_INT32_MAX - 1)
353 #define PR_UINT32_MAX PR_UINT32(4294967295)
354
355 /************************************************************************
356 ** TYPES: PRUint64
357 ** PRInt64
358 ** DESCRIPTION:
359 ** The int64 types are known to be 64 bits each. Care must be used when
360 ** declaring variables of type PRUint64 or PRInt64. Different hardware
361 ** architectures and even different compilers have varying support for
362 ** 64 bit values. The only guaranteed portability requires the use of
363 ** the LL_ macros (see prlong.h).
364 ************************************************************************/
365 #ifdef HAVE_LONG_LONG
366 #if PR_BYTES_PER_LONG == 8
367 typedef long PRInt64;
368 typedef unsigned long PRUint64;
369 #elif defined(WIN16)
370 typedef __int64 PRInt64;
371 typedef unsigned __int64 PRUint64;
372 #elif defined(WIN32) && !defined(__GNUC__)
373 typedef __int64 PRInt64;
374 typedef unsigned __int64 PRUint64;
375 #else
376 typedef long long PRInt64;
377 typedef unsigned long long PRUint64;
378 #endif /* PR_BYTES_PER_LONG == 8 */
379 #else /* !HAVE_LONG_LONG */
380 typedef struct {
381 #ifdef IS_LITTLE_ENDIAN
382 PRUint32 lo, hi;
383 #else
384 PRUint32 hi, lo;
385 #endif
386 } PRInt64;
387 typedef PRInt64 PRUint64;
388 #endif /* !HAVE_LONG_LONG */
389
390 /************************************************************************
391 ** TYPES: PRUintn
392 ** PRIntn
393 ** DESCRIPTION:
394 ** The PRIntn types are most appropriate for automatic variables. They are
395 ** guaranteed to be at least 16 bits, though various architectures may
396 ** define them to be wider (e.g., 32 or even 64 bits). These types are
397 ** never valid for fields of a structure.
398 ************************************************************************/
399 #if PR_BYTES_PER_INT >= 2
400 typedef int PRIntn;
401 typedef unsigned int PRUintn;
402 #else
403 #error 'sizeof(int)' not sufficient for platform use
404 #endif
405
406 /************************************************************************
407 ** TYPES: PRFloat64
408 ** DESCRIPTION:
409 ** NSPR's floating point type is always 64 bits.
410 ************************************************************************/
411 typedef double PRFloat64;
412
413 /************************************************************************
414 ** TYPES: PRSize
415 ** DESCRIPTION:
416 ** A type for representing the size of objects.
417 ************************************************************************/
418 typedef size_t PRSize;
419
420
421 /************************************************************************
422 ** TYPES: PROffset32, PROffset64
423 ** DESCRIPTION:
424 ** A type for representing byte offsets from some location.
425 ************************************************************************/
426 typedef PRInt32 PROffset32;
427 typedef PRInt64 PROffset64;
428
429 /************************************************************************
430 ** TYPES: PRPtrDiff
431 ** DESCRIPTION:
432 ** A type for pointer difference. Variables of this type are suitable
433 ** for storing a pointer or pointer subtraction.
434 ************************************************************************/
435 typedef ptrdiff_t PRPtrdiff;
436
437 /************************************************************************
438 ** TYPES: PRUptrdiff
439 ** DESCRIPTION:
440 ** A type for pointer difference. Variables of this type are suitable
441 ** for storing a pointer or pointer sutraction.
442 ************************************************************************/
443 typedef unsigned long PRUptrdiff;
444
445 /************************************************************************
446 ** TYPES: PRBool
447 ** DESCRIPTION:
448 ** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE
449 ** for clarity of target type in assignments and actual arguments. Use
450 ** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
451 ** just as you would C int-valued conditions.
452 ************************************************************************/
453 typedef PRIntn PRBool;
454 #define PR_TRUE 1
455 #define PR_FALSE 0
456
457 /************************************************************************
458 ** TYPES: PRPackedBool
459 ** DESCRIPTION:
460 ** Use PRPackedBool within structs where bitfields are not desirable
461 ** but minimum and consistant overhead matters.
462 ************************************************************************/
463 typedef PRUint8 PRPackedBool;
464
465 /*
466 ** Status code used by some routines that have a single point of failure or
467 ** special status return.
468 */
469 typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
470
471 #ifdef MOZ_UNICODE
472 /*
473 * EXPERIMENTAL: This type may be removed in a future release.
474 */
475 #ifndef __PRUNICHAR__
476 #define __PRUNICHAR__
477 #if defined(WIN32) || defined(XP_MAC)
478 typedef wchar_t PRUnichar;
479 #else
480 typedef PRUint16 PRUnichar;
481 #endif
482 #endif
483 #endif /* MOZ_UNICODE */
484
485 /*
486 ** WARNING: The undocumented data types PRWord and PRUword are
487 ** only used in the garbage collection and arena code. Do not
488 ** use PRWord and PRUword in new code.
489 **
490 ** A PRWord is an integer that is the same size as a void*.
491 ** It implements the notion of a "word" in the Java Virtual
492 ** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine
493 ** Specification, Addison-Wesley, September 1996.
494 ** http://java.sun.com/docs/books/vmspec/index.html.)
495 */
496 typedef long PRWord;
497 typedef unsigned long PRUword;
498
499 #if defined(NO_NSPR_10_SUPPORT)
500 #else
501 /********* ???????????????? FIX ME ??????????????????????????? *****/
502 /********************** Some old definitions until pr=>ds transition is done *** /
503 /********************** Also, we are still using NSPR 1.0. GC ****************** /
504 /*
505 ** Fundamental NSPR macros, used nearly everywhere.
506 */
507
508 #define PR_PUBLIC_API PR_IMPLEMENT
509
510 /*
511 ** Macro body brackets so that macros with compound statement definitions
512 ** behave syntactically more like functions when called.
513 */
514 #define NSPR_BEGIN_MACRO do {
515 #define NSPR_END_MACRO } while (0)
516
517 /*
518 ** Macro shorthands for conditional C++ extern block delimiters.
519 */
520 #ifdef NSPR_BEGIN_EXTERN_C
521 #undef NSPR_BEGIN_EXTERN_C
522 #endif
523 #ifdef NSPR_END_EXTERN_C
524 #undef NSPR_END_EXTERN_C
525 #endif
526
527 #ifdef __cplusplus
528 #define NSPR_BEGIN_EXTERN_C extern "C" {
529 #define NSPR_END_EXTERN_C }
530 #else
531 #define NSPR_BEGIN_EXTERN_C
532 #define NSPR_END_EXTERN_C
533 #endif
534
535 #ifdef XP_MAC
536 #include "protypes.h"
537 #else
538 #include "obsolete/protypes.h"
539 #endif
540
541 /********* ????????????? End Fix me ?????????????????????????????? *****/
542 #endif /* NO_NSPR_10_SUPPORT */
543
544 PR_END_EXTERN_C
545
546 #endif /* prtypes_h___ */
547
OLDNEW
« no previous file with comments | « gecko-sdk/include/prtrace.h ('k') | gecko-sdk/include/prvrsion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698