epoc32/include/mw/prtypes.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 1 666f914201fb
permissions -rw-r--r--
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 -*- */
     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.
    12  * 
    13  * The Original Code is the Netscape Portable Runtime (NSPR).
    14  * 
    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.
    19  * 
    20  * Contributor(s):
    21  *    Portions Copyright (c) 2004-2006, Nokia Corporation
    22  *
    23  * 
    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
    34  * GPL.
    35  */
    36 
    37 /* NOTES:
    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.
    40  */
    41 
    42 
    43 /*
    44 ** File:                prtypes.h
    45 ** Description: Definitions of NSPR's basic types
    46 **
    47 ** Prototypes and macros used to make up for deficiencies in ANSI environments
    48 ** that we have found.
    49 **
    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
    54 ** for all C files.
    55 **/
    56 
    57 #ifndef prtypes_h___
    58 #define prtypes_h___
    59 
    60 #ifdef MDCPUCFG
    61 #include MDCPUCFG
    62 #else
    63 #include "prcpucfg.h"
    64 #endif
    65 
    66 #include <stddef.h>
    67 
    68 /***********************************************************************
    69 ** MACROS:      PR_EXTERN
    70 **              PR_IMPLEMENT
    71 ** DESCRIPTION:
    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.
    79 **
    80 ** Example:
    81 **   in dowhim.h
    82 **     PR_EXTERN( void ) DoWhatIMean( void );
    83 **   in dowhim.c
    84 **     PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
    85 **
    86 **
    87 ***********************************************************************/
    88 #if defined(WIN32)
    89 
    90 #if defined(__GNUC__)
    91 #undef _declspec
    92 #define _declspec(x) __declspec(x)
    93 #endif
    94 
    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
    99 
   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
   104 
   105 #define PR_CALLBACK
   106 #define PR_CALLBACK_DECL
   107 #define PR_STATIC_CALLBACK(__x) static __x
   108 
   109 #elif defined(XP_BEOS)
   110 
   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
   115 
   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
   120 
   121 #define PR_CALLBACK
   122 #define PR_CALLBACK_DECL
   123 #define PR_STATIC_CALLBACK(__x) static __x
   124 
   125 #elif defined(WIN16)
   126 
   127 #define PR_CALLBACK_DECL        __cdecl
   128 
   129 #if defined(_WINDLL)
   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
   134 
   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
   139 
   140 #define PR_CALLBACK             __cdecl __loadds
   141 #define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
   142 
   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
   148 
   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
   153 
   154 #define PR_CALLBACK             __cdecl __loadds
   155 #define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
   156 #endif /* _WINDLL */
   157 
   158 #elif defined(XP_MAC)
   159 
   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
   164 
   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
   169 
   170 #define PR_CALLBACK
   171 #define PR_CALLBACK_DECL
   172 #define PR_STATIC_CALLBACK(__x) static __x
   173 
   174 #elif defined(XP_OS2_VACPP) 
   175 
   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
   180 
   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
   188 
   189 #else /* Unix */
   190 
   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
   195 
   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
   200 #define PR_CALLBACK
   201 #define PR_CALLBACK_DECL
   202 #define PR_STATIC_CALLBACK(__x) static __x
   203 
   204 #endif
   205 
   206 #if defined(_NSPR_BUILD_)
   207 #define NSPR_API(__type) PR_EXPORT(__type)
   208 #define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
   209 #else
   210 #define NSPR_API(__type) PR_IMPORT(__type)
   211 #define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
   212 #endif
   213 
   214 /***********************************************************************
   215 ** MACROS:      PR_BEGIN_MACRO
   216 **              PR_END_MACRO
   217 ** DESCRIPTION:
   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)
   223 
   224 /***********************************************************************
   225 ** MACROS:      PR_BEGIN_EXTERN_C
   226 **              PR_END_EXTERN_C
   227 ** DESCRIPTION:
   228 **      Macro shorthands for conditional C++ extern block delimiters.
   229 ***********************************************************************/
   230 #ifdef __cplusplus
   231 #define PR_BEGIN_EXTERN_C       extern "C" {
   232 #define PR_END_EXTERN_C         }
   233 #else
   234 #define PR_BEGIN_EXTERN_C
   235 #define PR_END_EXTERN_C
   236 #endif
   237 
   238 /***********************************************************************
   239 ** MACROS:      PR_BIT
   240 **              PR_BITMASK
   241 ** DESCRIPTION:
   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)
   246 
   247 /***********************************************************************
   248 ** MACROS:      PR_ROUNDUP
   249 **              PR_MIN
   250 **              PR_MAX
   251 **              PR_ABS
   252 ** DESCRIPTION:
   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))
   259 
   260 PR_BEGIN_EXTERN_C
   261 
   262 /************************************************************************
   263 ** TYPES:       PRUint8
   264 **              PRInt8
   265 ** DESCRIPTION:
   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;
   271 /*
   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.
   277 */
   278 #if (defined(HPUX) && defined(__cplusplus) \
   279         && !defined(__GNUC__) && __cplusplus < 199707L) \
   280     || (defined(SCO) && defined(__cplusplus) \
   281         && !defined(__GNUC__) && __cplusplus == 1L)
   282 typedef char PRInt8;
   283 #else
   284 typedef signed char PRInt8;
   285 #endif
   286 #else
   287 #error No suitable type for PRInt8/PRUint8
   288 #endif
   289 
   290 /************************************************************************
   291  * MACROS:      PR_INT8_MAX
   292  *              PR_INT8_MIN
   293  *              PR_UINT8_MAX
   294  * DESCRIPTION:
   295  *  The maximum and minimum values of a PRInt8 or PRUint8.
   296 ************************************************************************/
   297 
   298 #define PR_INT8_MAX 127
   299 #define PR_INT8_MIN (-128)
   300 #define PR_UINT8_MAX 255U
   301 
   302 /************************************************************************
   303 ** TYPES:       PRUint16
   304 **              PRInt16
   305 ** DESCRIPTION:
   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;
   311 #else
   312 #error No suitable type for PRInt16/PRUint16
   313 #endif
   314 
   315 /************************************************************************
   316  * MACROS:      PR_INT16_MAX
   317  *              PR_INT16_MIN
   318  *              PR_UINT16_MAX
   319  * DESCRIPTION:
   320  *  The maximum and minimum values of a PRInt16 or PRUint16.
   321 ************************************************************************/
   322 
   323 #define PR_INT16_MAX 32767
   324 #define PR_INT16_MIN (-32768)
   325 #define PR_UINT16_MAX 65535U
   326 
   327 /************************************************************************
   328 ** TYPES:       PRUint32
   329 **              PRInt32
   330 ** DESCRIPTION:
   331 **  The int32 types are known to be 32 bits each. 
   332 ************************************************************************/
   333 #if PR_BYTES_PER_INT == 4
   334 typedef unsigned int PRUint32;
   335 typedef int PRInt32;
   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
   343 #else
   344 #error No suitable type for PRInt32/PRUint32
   345 #endif
   346 
   347 /************************************************************************
   348  * MACROS:      PR_INT32_MAX
   349  *              PR_INT32_MIN
   350  *              PR_UINT32_MAX
   351  * DESCRIPTION:
   352  *  The maximum and minimum values of a PRInt32 or PRUint32.
   353 ************************************************************************/
   354 
   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)
   358 
   359 /************************************************************************
   360 ** TYPES:       PRUint64
   361 **              PRInt64
   362 ** DESCRIPTION:
   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;
   373 #elif defined(WIN16)
   374 typedef __int64 PRInt64;
   375 typedef unsigned __int64 PRUint64;
   376 #elif defined(WIN32) && !defined(__GNUC__)
   377 typedef __int64  PRInt64;
   378 typedef unsigned __int64 PRUint64;
   379 #else
   380 typedef long long PRInt64;
   381 typedef unsigned long long PRUint64;
   382 #endif /* PR_BYTES_PER_LONG == 8 */
   383 #else  /* !HAVE_LONG_LONG */
   384 typedef struct {
   385 #ifdef IS_LITTLE_ENDIAN
   386     PRUint32 lo, hi;
   387 #else
   388     PRUint32 hi, lo;
   389 #endif
   390 } PRInt64;
   391 typedef PRInt64 PRUint64;
   392 #endif /* !HAVE_LONG_LONG */
   393 
   394 /************************************************************************
   395 ** TYPES:       PRUintn
   396 **              PRIntn
   397 ** DESCRIPTION:
   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
   404 typedef int PRIntn;
   405 typedef unsigned int PRUintn;
   406 #else
   407 #error 'sizeof(int)' not sufficient for platform use
   408 #endif
   409 
   410 /************************************************************************
   411 ** TYPES:       PRFloat64
   412 ** DESCRIPTION:
   413 **  NSPR's floating point type is always 64 bits. 
   414 ************************************************************************/
   415 typedef double          PRFloat64;
   416 
   417 /************************************************************************
   418 ** TYPES:       PRSize
   419 ** DESCRIPTION:
   420 **  A type for representing the size of objects. 
   421 ************************************************************************/
   422 typedef size_t PRSize;
   423 
   424 
   425 /************************************************************************
   426 ** TYPES:       PROffset32, PROffset64
   427 ** DESCRIPTION:
   428 **  A type for representing byte offsets from some location. 
   429 ************************************************************************/
   430 typedef PRInt32 PROffset32;
   431 typedef PRInt64 PROffset64;
   432 
   433 /************************************************************************
   434 ** TYPES:       PRPtrDiff
   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 ptrdiff_t PRPtrdiff;
   440 
   441 /************************************************************************
   442 ** TYPES:       PRUptrdiff
   443 ** DESCRIPTION:
   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;
   448 
   449 /************************************************************************
   450 ** TYPES:       PRBool
   451 ** DESCRIPTION:
   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;
   458 #define PR_TRUE 1
   459 #define PR_FALSE 0
   460 
   461 /************************************************************************
   462 ** TYPES:       PRPackedBool
   463 ** DESCRIPTION:
   464 **  Use PRPackedBOol within structs where bitfields are not desireable
   465 **      but minimum and consistant overhead matters.
   466 ************************************************************************/
   467 typedef PRUint8 PRPackedBool;
   468 
   469 /*
   470 ** Status code used by some routines that have a single point of failure or 
   471 ** special status return.
   472 */
   473 typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
   474 
   475 #ifdef MOZ_UNICODE
   476 /*
   477  * EXPERIMENTAL: This type may be removed in a future release.
   478  */
   479 #ifndef __PRUNICHAR__
   480 #define __PRUNICHAR__
   481 #if defined(WIN32) || defined(XP_MAC)
   482 typedef wchar_t PRUnichar;
   483 #else
   484 typedef PRUint16 PRUnichar;
   485 #endif
   486 #endif
   487 #endif /* MOZ_UNICODE */
   488 
   489 /*
   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.
   493 **
   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.)
   499 */
   500 typedef long PRWord;
   501 typedef unsigned long PRUword;
   502 
   503 #if defined(NO_NSPR_10_SUPPORT)
   504 #else
   505 /********* ???????????????? FIX ME       ??????????????????????????? *****/
   506 /********************** Some old definitions until pr=>ds transition is done ***/
   507 /********************** Also, we are still using NSPR 1.0. GC ******************/
   508 /*
   509 ** Fundamental NSPR macros, used nearly everywhere.
   510 */
   511 
   512 #define PR_PUBLIC_API   PR_IMPLEMENT
   513 
   514 /*
   515 ** Macro body brackets so that macros with compound statement definitions
   516 ** behave syntactically more like functions when called.
   517 */
   518 #define NSPR_BEGIN_MACRO        do {
   519 #define NSPR_END_MACRO          } while (0)
   520 
   521 /*
   522 ** Macro shorthands for conditional C++ extern block delimiters.
   523 */
   524 #ifdef NSPR_BEGIN_EXTERN_C
   525 #undef NSPR_BEGIN_EXTERN_C
   526 #endif
   527 #ifdef NSPR_END_EXTERN_C
   528 #undef NSPR_END_EXTERN_C
   529 #endif
   530 
   531 #ifdef __cplusplus
   532 #define NSPR_BEGIN_EXTERN_C     extern "C" {
   533 #define NSPR_END_EXTERN_C       }
   534 #else
   535 #define NSPR_BEGIN_EXTERN_C
   536 #define NSPR_END_EXTERN_C
   537 #endif
   538 
   539 #ifdef XP_MAC
   540 #include "protypes.h"
   541 #else
   542 #include "obsolete/protypes.h"
   543 #endif
   544 
   545 /********* ????????????? End Fix me ?????????????????????????????? *****/
   546 #endif /* NO_NSPR_10_SUPPORT */
   547 
   548 PR_END_EXTERN_C
   549 
   550 #endif /* prtypes_h___ */
   551