epoc32/include/e32def.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 e32def.h
     1 /*
       
     2 * Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * e32\include\e32def.h
       
    16 * NOTE: THIS FILE SHOULD BE ACCEPTABLE TO A C COMPILER
       
    17 * 
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef __E32DEF_H__
       
    26 #define __E32DEF_H__
       
    27 
       
    28 /*
       
    29  * __LEAVE_EQUALS_THROW__ requires the compiler to support C++ exceptions
       
    30  */
       
    31 #ifndef __SUPPORT_CPP_EXCEPTIONS__
       
    32 #undef __LEAVE_EQUALS_THROW__
       
    33 #endif
       
    34 
       
    35 
       
    36 
       
    37 
       
    38 
       
    39 #ifdef __PROFILING__
       
    40 
       
    41 /**
       
    42 @publishedPartner
       
    43 @removed
       
    44 */
       
    45 #define __PROFILE_START(aBin) RDebug::ProfileStart(aBin)
       
    46 
       
    47 /**
       
    48 @publishedPartner
       
    49 @removed
       
    50 */
       
    51 #define __PROFILE_END(aBin)   RDebug::ProfileEnd(aBin)
       
    52 
       
    53 /**
       
    54 @publishedPartner
       
    55 @removed
       
    56 */
       
    57 #define __PROFILE_RESET(aNumberOfBins) RDebug::ProfileReset(0,aNumberOfBins)
       
    58 
       
    59 /**
       
    60 @publishedPartner
       
    61 @removed
       
    62 */
       
    63 #define __PROFILE_DISPLAY(aNumberOfBins) \
       
    64 			{	TFixedArray<TProfile, aNumberOfBins> result; \
       
    65 				RDebug::ProfileResult(result.Begin(), 0, aNumberOfBins); \
       
    66 				for (TInt i=0; i<aNumberOfBins; i++)   \
       
    67 				RDebug::Print(_L("Profile bin %d:  Calls: %d, Clock ticks: %d\n" ),i,res[i].iCount,result[i].iTime);  \
       
    68 			}
       
    69 #else /* __PROFILING__ */
       
    70 #define __PROFILE_START(aBin) 
       
    71 #define __PROFILE_END(aBin)   
       
    72 #define __PROFILE_RESET(aNumberOfBins) 
       
    73 #define __PROFILE_DISPLAY(aNumberOfBins)
       
    74 #endif
       
    75 
       
    76 
       
    77 
       
    78 #if defined(__VC32__)
       
    79 /**
       
    80 @publishedAll
       
    81 @released
       
    82 */
       
    83 #define __NO_CLASS_CONSTS__
       
    84 #if (_MSC_VER >= 1200)
       
    85 /**
       
    86 @publishedAll
       
    87 @released
       
    88 */
       
    89 #define __NORETURN__ __declspec(noreturn)
       
    90 #else
       
    91 #define __NORETURN__
       
    92 #endif
       
    93 /**
       
    94 @publishedAll
       
    95 @released
       
    96 */
       
    97 #define __NORETURN_TERMINATOR()
       
    98 /**
       
    99 @publishedAll
       
   100 @released
       
   101 */
       
   102 #define IMPORT_C __declspec(dllexport)
       
   103 /**
       
   104 @publishedAll
       
   105 @released
       
   106 */
       
   107 #define EXPORT_C __declspec(dllexport)
       
   108 /**
       
   109 @publishedAll
       
   110 @released
       
   111 */
       
   112 #define NONSHARABLE_CLASS(x) class x
       
   113 /**
       
   114 @publishedAll
       
   115 @released
       
   116 */
       
   117 #define NONSHARABLE_STRUCT(x) struct x
       
   118 /**
       
   119 @publishedAll
       
   120 @released
       
   121 */
       
   122 #define __NO_THROW throw()
       
   123 /**
       
   124 @publishedAll
       
   125 @released
       
   126 */
       
   127 #define __THROW(t) throw(t)
       
   128 #pragma warning( disable : 4355 )	/* 'this' used in base member initializer list */
       
   129 #pragma warning( disable : 4511 )	/* copy constructor could not be generated */
       
   130 #pragma warning( disable : 4512 )	/* assignment operator could not be generated */
       
   131 #pragma warning( disable : 4514 )	/* unreferenced inline function has been removed */
       
   132 #pragma warning( disable : 4699 )	/* Note: Using precompiled header %s */
       
   133 #pragma warning( disable : 4710 )	/* function not inlined */
       
   134 #pragma warning( disable : 4121 )	/* alignment sensitive to packing */
       
   135 #pragma warning( disable : 4273 )
       
   136 #pragma warning( disable : 4097 )	/* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
       
   137 #pragma warning( disable : 4291 )	/* 'TAny *CBase::operator new(TUint,TLeave)' : no matching operator delete found; memory will not be freed if initialization throws an exception */
       
   138 
       
   139 #if _MSC_VER  >= 1100
       
   140 /**
       
   141 @publishedAll
       
   142 @released
       
   143 */
       
   144 #define TEMPLATE_SPECIALIZATION template<>
       
   145 #else
       
   146 #define TEMPLATE_SPECIALIZATION
       
   147 #endif
       
   148 #endif
       
   149 
       
   150 
       
   151 
       
   152 #if defined(__CW32__)
       
   153 #undef __embedded_cplusplus
       
   154 /** @internalTechnology */
       
   155 #define __embedded_cplusplus	1
       
   156 #define __NO_CLASS_CONSTS__
       
   157 #define __NORETURN__
       
   158 #define __NORETURN_TERMINATOR()
       
   159 #define IMPORT_C __declspec(dllexport)
       
   160 #define EXPORT_C __declspec(dllexport)
       
   161 #define NONSHARABLE_CLASS(x) class x
       
   162 #define NONSHARABLE_STRUCT(x) struct x
       
   163 #define __NO_THROW throw()
       
   164 #define __THROW(t) throw(t)
       
   165 
       
   166 #define TEMPLATE_SPECIALIZATION template<>
       
   167 /**
       
   168 @publishedAll
       
   169 @released
       
   170 */
       
   171 #define _asm	asm
       
   172 #ifndef __int64
       
   173 #pragma longlong on
       
   174 /** @internalTechnology */
       
   175 #define __int64  long long
       
   176 #endif
       
   177 #ifndef __SUPPORT_CPP_EXCEPTIONS__
       
   178 #pragma exceptions off    /* no support for C++ exception handling */
       
   179 #pragma RTTI off          /* no support for C++ runtime type information */
       
   180 #endif
       
   181 #if __MWERKS__ >= 0x3200
       
   182 #pragma warning off (10480)	/* deleteing void pointer is undefined */
       
   183 #pragma warning off (10350) /* N pad byte(s) inserted after data member */
       
   184 #endif
       
   185 #endif
       
   186 
       
   187 
       
   188 
       
   189 #if defined(__GCC32__)
       
   190 #define __NO_CLASS_CONSTS__
       
   191 #define __NORETURN__  __attribute__ ((noreturn))
       
   192 #ifdef __GCCV3__
       
   193 #define __NORETURN_TERMINATOR()
       
   194 #else
       
   195 #define __NORETURN_TERMINATOR()		abort()
       
   196 #endif
       
   197 #define IMPORT_C
       
   198 #if !defined __WINS__ && defined _WIN32 /* VC++ Browser Hack */
       
   199 #define EXPORT_C
       
   200 /** @internalTechnology */
       
   201 #define asm(x)
       
   202 #else
       
   203 #define EXPORT_C __declspec(dllexport)
       
   204 #endif
       
   205 #define NONSHARABLE_CLASS(x) class x
       
   206 #define NONSHARABLE_STRUCT(x) struct x
       
   207 #define __NO_THROW
       
   208 #define __THROW(t)
       
   209 #ifdef __EABI__
       
   210 #define TEMPLATE_SPECIALIZATION template<>
       
   211 #else
       
   212 #define TEMPLATE_SPECIALIZATION
       
   213 #endif
       
   214 #endif
       
   215 
       
   216 
       
   217 
       
   218 #ifdef __GCC32__
       
   219 /**
       
   220 @publishedAll
       
   221 @released
       
   222 */
       
   223 #define __DOUBLE_WORDS_SWAPPED__
       
   224 #endif
       
   225 
       
   226 
       
   227 
       
   228 /** @internalTechnology */
       
   229 #define __NO_MUTABLE_KEYWORD
       
   230 #if defined(__NO_MUTABLE_KEYWORD)
       
   231 /**
       
   232 @publishedAll
       
   233 @deprecated
       
   234 */
       
   235 #define __MUTABLE
       
   236 #else
       
   237 #define __MUTABLE mutable
       
   238 #endif
       
   239 
       
   240 
       
   241 
       
   242 /**
       
   243 @publishedAll
       
   244 @deprecated
       
   245 */
       
   246 #define CONST_CAST(type,exp) (const_cast<type>(exp))
       
   247 
       
   248 /**
       
   249 @publishedAll
       
   250 @deprecated
       
   251 */
       
   252 #define STATIC_CAST(type,exp) (static_cast<type>(exp))
       
   253 
       
   254 /**
       
   255 @publishedAll
       
   256 @deprecated
       
   257 */
       
   258 #define REINTERPRET_CAST(type,exp) (reinterpret_cast<type>(exp))
       
   259 
       
   260 #if defined(__NO_MUTABLE_KEYWORD)
       
   261 /**
       
   262 @publishedAll
       
   263 @deprecated
       
   264 */
       
   265 #define MUTABLE_CAST(type,exp) (const_cast<type>(exp))
       
   266 #else
       
   267 #define MUTABLE_CAST(type,exp) (exp)
       
   268 #endif
       
   269 
       
   270 /**
       
   271 @publishedAll
       
   272 @deprecated
       
   273 */
       
   274 #define GLREF_D extern
       
   275 /**
       
   276 @publishedAll
       
   277 @deprecated
       
   278 */
       
   279 #define GLDEF_D
       
   280 /**
       
   281 @publishedAll
       
   282 @deprecated
       
   283 */
       
   284 #define LOCAL_D static
       
   285 /**
       
   286 @publishedAll
       
   287 @deprecated
       
   288 */
       
   289 #define GLREF_C extern
       
   290 /**
       
   291 @publishedAll
       
   292 @deprecated
       
   293 */
       
   294 #define GLDEF_C
       
   295 /**
       
   296 @publishedAll
       
   297 @deprecated
       
   298 */
       
   299 #define LOCAL_C static
       
   300 /**
       
   301 @publishedAll
       
   302 @deprecated
       
   303 */
       
   304 #define FOREVER for(;;)
       
   305 
       
   306 
       
   307 
       
   308 
       
   309 /**
       
   310 @publishedAll
       
   311 @released
       
   312 
       
   313 Symbolic definition for a true value.
       
   314 */
       
   315 #define TRUE 1
       
   316 
       
   317 
       
   318 
       
   319 
       
   320 /**
       
   321 @publishedAll
       
   322 @released
       
   323 
       
   324 Symbolic definition for a false value.
       
   325 */
       
   326 #define FALSE 0
       
   327 #ifndef NULL
       
   328 
       
   329 
       
   330 
       
   331 
       
   332 /**
       
   333 @publishedAll
       
   334 @released
       
   335 
       
   336 Symbolic definition for a NULL value.
       
   337 */
       
   338 #define NULL 0
       
   339 #endif
       
   340 
       
   341 
       
   342 
       
   343 
       
   344 #ifndef VA_START
       
   345 /**
       
   346 @publishedAll
       
   347 @released
       
   348 
       
   349 A macro used by Symbian OS code for handling a variable argument list
       
   350 in a function call.
       
   351 
       
   352 Sets a pointer to point to the first of the variable arguments.
       
   353 
       
   354 Typical usage:
       
   355 
       
   356 @code
       
   357 Foo(CAbcdef aAbcdef,...)
       
   358    {
       
   359    VA_LIST list;
       
   360    VA_START(list, aAbcdef);
       
   361    // other code
       
   362    } 
       
   363 @endcode
       
   364 
       
   365 @param ap   A pointer used to hold the address of an argument in
       
   366             the variable argument list. After execution of the code generated 
       
   367             by this macro, the pointer points to the first argument in
       
   368             the variable argument list.
       
   369             This symbol is usually declared as a VA_LIST type. 
       
   370 
       
   371 @param pn   The argument that immediately precedes the variable argument list.
       
   372 
       
   373 @see VA_LIST
       
   374 @see VA_ARG
       
   375 */
       
   376 #define VA_START(ap,pn) ((ap)[0]=(TInt8 *)&pn+((sizeof(pn)+sizeof(TInt)-1)&~(sizeof(TInt)-1)),(void)0)
       
   377 #endif
       
   378 
       
   379 
       
   380 
       
   381 
       
   382 #ifndef VA_ARG
       
   383 /**
       
   384 @publishedAll
       
   385 @released
       
   386 
       
   387 A macro used by Symbian OS code for handling a variable argument list
       
   388 in a function call.
       
   389 
       
   390 Increments a pointer to a variable argument list to point to the next argument
       
   391 in the list. The current argument is assumed to be of a type defined by
       
   392 the second parameter to this macro.
       
   393 
       
   394 Typical usage:
       
   395 
       
   396 @code
       
   397 Foo(CAbcdef aAbcdef,...)
       
   398    {
       
   399    VA_LIST list;
       
   400    VA_START(list, aAbcdef);
       
   401    ...
       
   402    TInt x = VA_ARG(list,TInt);
       
   403    ...
       
   404    const TDesC *pS=VA_ARG(aList,const TDesC*);
       
   405    ... 
       
   406    etc
       
   407    } 
       
   408 @endcode
       
   409 
       
   410 @param ap   A pointer used to hold the address of an argument in
       
   411             the variable argument list. It is assumed to point to the current
       
   412             argument in the variable argument list. After execution of the code
       
   413             generated by this macro, the pointer points to the next argument in
       
   414             the list. This symbol is usually declared as a VA_LIST type. 
       
   415 
       
   416 @param type The type of the current argument.
       
   417             This can be any valid type, for example, TInt, const TDesC*, etc.
       
   418             
       
   419 @see VA_LIST
       
   420 @see VA_START            
       
   421 */
       
   422 #define VA_ARG(ap,type) ((ap)[0]+=((sizeof(type)+sizeof(TInt)-1)&~(sizeof(TInt)-1)),(*(type *)((ap)[0]-((sizeof(type)+sizeof(TInt)-1)&~(sizeof(TInt)-1)))))
       
   423 #endif
       
   424 
       
   425 
       
   426 
       
   427 
       
   428 #ifndef VA_END
       
   429 /**
       
   430 @publishedAll
       
   431 @released
       
   432 
       
   433 A macro used by Symbian OS code for handling a variable argument list
       
   434 in a function call.
       
   435 
       
   436 Sets a pointer to zero.
       
   437 
       
   438 @param ap   A pointer used to hold the address of an argument in
       
   439             the variable argument list. After execution of the code generated 
       
   440             by this macro, the pointer is reset to 0.
       
   441             This symbol is usually declared as a VA_LIST type. 
       
   442             
       
   443 @see VA_LIST
       
   444 @see VA_START
       
   445 @see VA_ARG            
       
   446 */
       
   447 #define VA_END(ap) ((ap)[0]=0,(void)0)
       
   448 #endif
       
   449 	
       
   450 
       
   451 
       
   452 /**
       
   453 @publishedAll
       
   454 @released
       
   455 
       
   456 Calculates the offset of member f within class c.
       
   457 
       
   458 This is used in the TSglQue and TDblQue constructors to set the offset of
       
   459 the link object from the start of a list element.
       
   460 
       
   461 @param c The name of the class.
       
   462 @param f The name of the member within the specified class.
       
   463 
       
   464 @see TSglQue
       
   465 @see TDblQue
       
   466 */
       
   467 #ifndef _FOFF
       
   468 #if __GNUC__ < 4
       
   469 #define _FOFF(c,f)			(((TInt)&(((c *)0x1000)->f))-0x1000)
       
   470 #else
       
   471 #define _FOFF(c,f)			__builtin_offsetof(c,f)
       
   472 #endif
       
   473 #endif
       
   474 
       
   475 
       
   476 
       
   477 /**
       
   478 @internalTechnology
       
   479 @released
       
   480 */
       
   481 #define _ALIGN_DOWN(x,a)	((x)&~((a)-1))
       
   482 /**
       
   483 @internalTechnology
       
   484 @released
       
   485 */
       
   486 #define _ALIGN_UP(x,a)		_ALIGN_DOWN((x)+(a)-1, a)
       
   487 
       
   488 
       
   489 
       
   490 
       
   491 /** 
       
   492 @publishedAll
       
   493 @released
       
   494 
       
   495 Pointer to any type.
       
   496 
       
   497 TAny* is equivalent to void* in standard C or C++. TAny* is used in preference 
       
   498 to void* because it is more suggestive of the actual meaning,
       
   499 e.g. TAny* foo();.
       
   500 
       
   501 TAny is not used where it really means "nothing", as in the declaration of 
       
   502 functions which do not return a value; void is used instead, e.g. void Foo();.
       
   503 */
       
   504 typedef void TAny;
       
   505 
       
   506 
       
   507 
       
   508 
       
   509 /**
       
   510 @publishedAll
       
   511 @released
       
   512 
       
   513 8-bit signed integer type, used in Symbian OS to mean an 8-bit
       
   514 signed integer, independent of the implementation.
       
   515 */
       
   516 typedef signed char TInt8;
       
   517 
       
   518 
       
   519 
       
   520 
       
   521 /**
       
   522 @publishedAll
       
   523 @released
       
   524 
       
   525 8-bit unsigned integer type; used in Symbian OS to mean an 8-bit
       
   526 unsigned integer, independent of the implementation.
       
   527 */
       
   528 typedef unsigned char TUint8;
       
   529 
       
   530 
       
   531 
       
   532 
       
   533 /**
       
   534 @publishedAll
       
   535 @released
       
   536 
       
   537 16-bit signed integer type, used in Symbian OS to mean a 16-bit
       
   538 signed integer, independent of the implementation.
       
   539 */
       
   540 typedef short int TInt16;
       
   541 
       
   542 
       
   543 
       
   544 
       
   545 /**
       
   546 @publishedAll
       
   547 @released
       
   548 
       
   549 16-bit unsigned integer type. used in Symbian OS to mean a 16-bit
       
   550 unsigned integer, independent of the implementation.
       
   551 */
       
   552 typedef unsigned short int TUint16;
       
   553 
       
   554 
       
   555 
       
   556 
       
   557 /**
       
   558 @publishedAll
       
   559 @released
       
   560 
       
   561 32-bit signed integer type, used in Symbian OS to mean a 32-bit
       
   562 signed integer, independent of the implementation.
       
   563 */
       
   564 typedef long int TInt32;
       
   565 
       
   566 
       
   567 
       
   568 
       
   569 /**
       
   570 @publishedAll
       
   571 @released
       
   572 
       
   573 32-bit unsigned integer type; used in Symbian OS to mean a 32-bit
       
   574 unsigned integer, independent of the implementation.
       
   575 */
       
   576 typedef unsigned long int TUint32;
       
   577 
       
   578 
       
   579 
       
   580 
       
   581 /**
       
   582 @publishedAll
       
   583 @released
       
   584 
       
   585 Signed integer type of the natural machine word length.
       
   586 
       
   587 This is as defined by the C++ implementation's int type. In all
       
   588 implementations, this is guaranteed to be at least 32 bits.
       
   589 
       
   590 A TInt should be used in preference to a sized integer (TInt32, TInt16) for 
       
   591 all general use. Sized integers should only be used when packing is essential. 
       
   592 C++'s type conversion rules imply that all sized integers smaller than the 
       
   593 natural machine word are in any case broadened to the natural machine word 
       
   594 size when passed as function parameters.
       
   595 
       
   596 A TInt should be used in preference to an unsigned integer (TUint) for all 
       
   597 general use. Unsigned integers should only be used for flags (which use Boolean 
       
   598 operations but not arithmetic) and, in very rare cases, for numbers whose 
       
   599 range exceeds that available from signed integers. Although it is natural 
       
   600 to attempt to use unsigned integers for quantities which cannot by nature 
       
   601 be negative, the C++ language does not provide the support necessary to enforce 
       
   602 the "expected" behaviour in these circumstances, and experience has shown 
       
   603 that it is better to use signed integers unless there is good reason not to.
       
   604 
       
   605 @see TUint
       
   606 @see TInt32
       
   607 @see TInt16
       
   608 */
       
   609 typedef signed int TInt;
       
   610 
       
   611 
       
   612 
       
   613 
       
   614 /**
       
   615 @publishedAll
       
   616 @released
       
   617 
       
   618 Unsigned integer type of the natural machine word length. 
       
   619 
       
   620 This is guaranteed to be at least 32 bits in all implementations.
       
   621 
       
   622 In almost all circumstances, a TInt should be used in preference to a TUint. 
       
   623 The main exception is in flags bytes.
       
   624 
       
   625 @see TInt
       
   626 */
       
   627 typedef unsigned int TUint;
       
   628 
       
   629 
       
   630 
       
   631 
       
   632 /**
       
   633 @publishedAll
       
   634 @released
       
   635 
       
   636 32-bit floating point number, providing IEEE754 single precision on all Symbian 
       
   637 OS implementations.
       
   638 
       
   639 TReal should normally be used in preference to TReal32.
       
   640 
       
   641 Use of floating-point numbers should generally be avoided unless a natural 
       
   642 part of the problem specification. Most Symbian OS implementations do not 
       
   643 have a hardware floating point unit: as a result, their floating-point performance 
       
   644 is hundreds of times slower than integer performance.
       
   645 */
       
   646 typedef float TReal32;
       
   647 
       
   648 
       
   649 
       
   650 
       
   651 /**
       
   652 @publishedAll
       
   653 @released
       
   654 
       
   655 64-bit floating point number, providing IEEE754 double precision on all Symbian 
       
   656 OS implementations.
       
   657 
       
   658 Use of floating-point numbers should generally be avoided unless a natural 
       
   659 part of the problem specification. Most Symbian OS implementations do not 
       
   660 have a hardware floating point unit: as a result, their floating-point performance 
       
   661 is hundreds of times slower than integer performance.
       
   662 
       
   663 This type is identical to TReal.
       
   664 
       
   665 @see TReal
       
   666 */
       
   667 typedef double TReal64;
       
   668 
       
   669 
       
   670 
       
   671 
       
   672 /**
       
   673 @publishedAll
       
   674 @released
       
   675 
       
   676 64-bit floating point number; identical to TReal64.
       
   677 
       
   678 Use of floating-point numbers should generally be avoided unless a natural 
       
   679 part of the problem specification. Most Symbian OS implementations do not 
       
   680 have a hardware floating point unit: as a result, their floating-point performance 
       
   681 is hundreds of times slower than integer performance.
       
   682 
       
   683 Most serious floating-point calculations require double-precision. All standard 
       
   684 math functions (see Math class) take double-precision arguments. Single-precision 
       
   685 should only be used where space and performance are at a premium, and when 
       
   686 their limited precision is acceptable.
       
   687 
       
   688 @see TReal64
       
   689 @see Math
       
   690 */
       
   691 typedef double TReal;
       
   692 
       
   693 
       
   694 
       
   695 
       
   696 /**
       
   697 @publishedAll
       
   698 @released
       
   699 
       
   700 8-bit unsigned character.
       
   701 
       
   702 Use instead of C++ built-in char type because it is guaranteed to be unsigned. 
       
   703 Use instead of TInt8 where the application is really for text rather than 
       
   704 8-bit arithmetic or binary quantities.
       
   705 
       
   706 For most purposes, you should use TText rather than TText8. TText is mapped 
       
   707 onto either TText8 or TText16 depending on whether a non-Unicode or Unicode 
       
   708 variant is being built. Use TText8 only when you are dealing explicitly with 
       
   709 8-bit text, regardless of build.
       
   710 
       
   711 @see TText */
       
   712 typedef unsigned char TText8;
       
   713 
       
   714 
       
   715 
       
   716 
       
   717 /**
       
   718 @publishedAll
       
   719 @released
       
   720 
       
   721 16-bit unsigned character.
       
   722 
       
   723 Use instead of C++ wchar_t type because it is guaranteed to be unsigned. Use 
       
   724 instead of TInt16 where the application is really for text rather than 8-bit 
       
   725 arithmetic or binary quantities.
       
   726 
       
   727 For most purposes, you should use TText rather than TText16. TText is mapped 
       
   728 onto either TText8 or TText16 depending on whether a non-Unicode or Unicode 
       
   729 variant is being built. Use TText16 only when you are dealing explicitly with 
       
   730 16-bit text, regardless of build.
       
   731 
       
   732 @see TText
       
   733 */
       
   734 typedef unsigned short int TText16;
       
   735 
       
   736 
       
   737 
       
   738 
       
   739 /**
       
   740 @publishedAll
       
   741 @released
       
   742 
       
   743 Boolean type which takes the value either ETrue or EFalse.
       
   744 
       
   745 Although only a single bit would theoretically be necessary to represent a 
       
   746 Boolean, a machine word is used instead, so that these quantities can be easily 
       
   747 passed. Also, TBool must map onto int because of C++'s interpretation of 
       
   748 operands in conditional expressions.
       
   749 
       
   750 On implementations of Symbian OS in which the compiler supports the ANSI-recommended 
       
   751 bool type, TBool will be typedef'ed to bool instead of int.
       
   752 */
       
   753 typedef int TBool;
       
   754 
       
   755 
       
   756 
       
   757 
       
   758 /**
       
   759 @publishedPartner
       
   760 @released
       
   761 
       
   762 Defines a linear (virtual) address type.
       
   763 */
       
   764 typedef TUint32 TLinAddr;
       
   765 
       
   766 /**
       
   767 @internalTechnology
       
   768 
       
   769 A sorted list of all the code segments in ROM that contain an Exception Descriptor.
       
   770 
       
   771 */
       
   772 typedef struct TRomExceptionSearchTable
       
   773 	{
       
   774 	/**
       
   775 	The number of entries in the following table.
       
   776 	*/
       
   777 	TInt32 iNumEntries;
       
   778 	
       
   779 	/**
       
   780 	Address of the code segment of each TRomImageHeader that has an Exception Descriptor.
       
   781 	*/
       
   782 	TLinAddr iEntries[1];
       
   783 	} TRomExceptionSearchTable;
       
   784 
       
   785 /**
       
   786 @internalComponent
       
   787 */
       
   788 typedef struct TExceptionDescriptor 
       
   789 	{
       
   790 	TLinAddr iExIdxBase;
       
   791 	TLinAddr iExIdxLimit;
       
   792 	TLinAddr iROSegmentBase;
       
   793 	TLinAddr iROSegmentLimit;
       
   794 	} TExceptionDescriptor;
       
   795 
       
   796 
       
   797 #if defined(__GCC32__)
       
   798 
       
   799 
       
   800 
       
   801 
       
   802 /**
       
   803 @publishedAll
       
   804 @released
       
   805 
       
   806 Defines a 64-bit signed integer type.
       
   807 */
       
   808 typedef long long Int64;
       
   809 
       
   810 
       
   811 
       
   812 
       
   813 /**
       
   814 @publishedAll
       
   815 @released
       
   816 
       
   817 Defines a 64-bit unsigned integer type.
       
   818 */
       
   819 typedef unsigned long long Uint64;
       
   820 
       
   821 
       
   822 
       
   823 
       
   824 /**
       
   825 @publishedAll
       
   826 @released
       
   827 */
       
   828 #define	I64LIT(x)	x##LL
       
   829 /**
       
   830 @publishedAll
       
   831 @released
       
   832 */
       
   833 #define	UI64LIT(x)	x##ULL
       
   834 
       
   835 #elif defined(__VC32__)
       
   836 typedef __int64 Int64;
       
   837 typedef unsigned __int64 Uint64;
       
   838 #define	I64LIT(x)	(__int64)##x
       
   839 #define	UI64LIT(x)	(unsigned __int64)##x
       
   840 
       
   841 #elif defined(__CW32__)
       
   842 #pragma longlong on
       
   843 typedef long long Int64;
       
   844 typedef unsigned long long Uint64;
       
   845 #define	I64LIT(x)	x##LL
       
   846 #define	UI64LIT(x)	x##ULL
       
   847 #endif
       
   848 
       
   849 
       
   850 
       
   851 
       
   852 /**
       
   853 @publishedAll
       
   854 @released
       
   855 
       
   856 Defines a 64-bit signed integer type.
       
   857 
       
   858 NOTE: For those migrating from versions of Symbian OS before 8.1b (i.e. 8.1a, 7.0s etc)
       
   859 TInt64 is now defined as a built-in type instead of as a class type. This means
       
   860 that the member functions of the old TInt64 class are no longer exported
       
   861 from EUSER.LIB, and represents a compatibility break.
       
   862 
       
   863 To ease migration of source code, a number of macros are provided. Similar
       
   864 macros have also been defined in Symbian OS versions 7.0s and 8.1a, but
       
   865 implemented in terms of the old TInt64 class. This is important for code that
       
   866 is common to : one or both of these Symbian OS versions, and to 8.1b and
       
   867 subsequent versions.
       
   868 
       
   869 The following list shows the new macros and the functions that they replace.
       
   870 It also shows some alternative techniques.
       
   871 In this list: x, v and r are declared as TInt64, c is declared as TInt, High
       
   872 and Low are declared as TUint.
       
   873 
       
   874 @code
       
   875 OLD USAGE						REPLACEMENT
       
   876 
       
   877 TInt64(High,Low);				MAKE_TINT64(High,Low);
       
   878 x.Set(High,Low);				MAKE_TINT64(High,Low);
       
   879 x.Low();						I64LOW(x);
       
   880 x.High();						I64HIGH(x); 
       
   881 x.GetTInt();					I64INT(x); 
       
   882 x.GetTReal();					I64REAL(x); 
       
   883 x.Lsr(c);						I64LSR(x,c); 
       
   884 x.Mul10();						x*=10; 
       
   885 x.MulTop(a);					I64MULTOP(x,a); 
       
   886 x.DivMod(v,r);					r=x%v; x/=v;
       
   887 @endcode 
       
   888 */
       
   889 typedef	Int64	TInt64;
       
   890 
       
   891 
       
   892 
       
   893 
       
   894 /**
       
   895 @publishedAll
       
   896 @released
       
   897  
       
   898 Defines a 64-bit unsigned integer type.
       
   899 */
       
   900 typedef	Uint64	TUint64;
       
   901 
       
   902 
       
   903 
       
   904 
       
   905 /** @internalComponent */
       
   906 #define _MAKE_TINT64_ZX(x)	((TInt64)((TUint32)(x)))
       
   907 
       
   908 /** @internalComponent */
       
   909 #define _MAKE_TUINT64_ZX(x)	((TUint64)((TUint32)(x)))
       
   910 
       
   911 
       
   912 
       
   913 
       
   914 /**
       
   915 @publishedAll
       
   916 @released
       
   917 */
       
   918 #define MAKE_TINT64(h,l)	( (_MAKE_TINT64_ZX(h)<<32) | _MAKE_TINT64_ZX(l) )
       
   919 
       
   920 
       
   921 
       
   922 
       
   923 /**
       
   924 @publishedAll
       
   925 @released
       
   926 */
       
   927 #define MAKE_TUINT64(h,l)	( (_MAKE_TUINT64_ZX(h)<<32) | _MAKE_TUINT64_ZX(l) )
       
   928 
       
   929 
       
   930 
       
   931 
       
   932 /**
       
   933 @publishedAll
       
   934 @released
       
   935 
       
   936 Generates code to access the high order 32 bits of a 64 bit number.
       
   937 */
       
   938 #define	I64HIGH(x)			( (TUint32)((x)>>32) )
       
   939 
       
   940 
       
   941 
       
   942 
       
   943 /**
       
   944 @publishedAll
       
   945 @released
       
   946 
       
   947 Generates code to access the low order 32 bits of a 64 bit number.
       
   948 */
       
   949 #define	I64LOW(x)			( (TUint32)(x) )
       
   950 
       
   951 
       
   952 
       
   953 
       
   954 /**
       
   955 @publishedAll
       
   956 @released
       
   957 
       
   958 Generates code to cast a 64 bit value as an signed integer.
       
   959 */
       
   960 #define	I64INT(x)			( (TInt)(x) )
       
   961 
       
   962 
       
   963 
       
   964 
       
   965 /**
       
   966 @publishedAll
       
   967 @released
       
   968 
       
   969 Generates code to cast a 64 bit value as a TReal type.
       
   970 */
       
   971 #define	I64REAL(x)			( (TReal)(x) )
       
   972 
       
   973 
       
   974 
       
   975 
       
   976 /**
       
   977 @publishedAll
       
   978 @released
       
   979 
       
   980 Generates code to logically shift a 64 bit integer right.
       
   981 */
       
   982 #define	I64LSR(x, shift)	( *reinterpret_cast<TUint64*>(&(x)) >>= (shift) )
       
   983 
       
   984 
       
   985 
       
   986 /**
       
   987 @publishedAll
       
   988 @released
       
   989 
       
   990 Generates code to multiply a 64 bit integer by 10.
       
   991 */
       
   992 #define	I64MUL10(x)			( (x) *= 10 )
       
   993 
       
   994 
       
   995 
       
   996 /**
       
   997 @publishedAll
       
   998 @released
       
   999 
       
  1000 Generates code to divide a 64 bit integer by another and find the remainder.
       
  1001 */
       
  1002 #define	I64DIVMOD(x, divisor, remainder)	( ((remainder) = (x) % (divisor), (x) /= (divisor)) )
       
  1003 
       
  1004 
       
  1005 
       
  1006 
       
  1007 /**
       
  1008 @publishedAll
       
  1009 @released
       
  1010 
       
  1011 Generates code to cast a double to a 64 bit integer.
       
  1012 */
       
  1013 #define	I64DOUBLECAST(x)	( static_cast<TInt64>(x) )
       
  1014 
       
  1015 
       
  1016 
       
  1017 
       
  1018 /**
       
  1019 @publishedAll
       
  1020 @deprecated Use _LIT8 instead.
       
  1021 
       
  1022 8-bit literal.
       
  1023 
       
  1024 The macro defines an explicit 8-bit constant literal which is suitable
       
  1025 for non-Unicode literal text, regardless of the build.
       
  1026 
       
  1027 @see _L
       
  1028 @see _LIT8
       
  1029 @see _LIT
       
  1030 */
       
  1031 #define _L8(a) (TPtrC8((const TText8 *)(a)))
       
  1032 
       
  1033 
       
  1034 
       
  1035 
       
  1036 /**
       
  1037 @publishedAll
       
  1038 @released
       
  1039 
       
  1040 Defines an explicit 8-bit string which is suitable when non-Unicode text
       
  1041 is required, regardless of the build.
       
  1042 
       
  1043 This is used by the deprecated literal descriptor _L8.
       
  1044 */
       
  1045 #define _S8(a) ((const TText8 *)a)
       
  1046 
       
  1047 
       
  1048 
       
  1049 
       
  1050 /**
       
  1051 @publishedAll
       
  1052 @released
       
  1053 
       
  1054 Constructs a constant literal descriptor of type TLitC8<TInt> with
       
  1055 the specified name and text.
       
  1056 
       
  1057 The 8-bit build variant is generated for both non-Unicode and Unicode builds.
       
  1058 
       
  1059 @param name The name of the C++ variable to be generated.
       
  1060 @param s    The literal text enclosed within a pair of double quotes. 
       
  1061 
       
  1062 @see _LIT
       
  1063 */
       
  1064 #define _LIT8(name,s) const static TLitC8<sizeof(s)> name={sizeof(s)-1,s}
       
  1065 
       
  1066 
       
  1067 
       
  1068 
       
  1069 /**
       
  1070 @publishedAll
       
  1071 @deprecated Use _LIT16 instead.
       
  1072 
       
  1073 16-bit literal.
       
  1074 
       
  1075 The macro defines an explicit 16-bit constant literal which is suitable
       
  1076 for Unicode literal text, regardless of the build.
       
  1077 
       
  1078 @see _L
       
  1079 @see _LIT16
       
  1080 @see _LIT
       
  1081 */
       
  1082 #define _L16(a) (TPtrC16((const TText16 *)L ## a))
       
  1083 
       
  1084 
       
  1085 
       
  1086 /**
       
  1087 @publishedAll
       
  1088 @released
       
  1089 
       
  1090 Defines an explicit 16-bit string which is suitable when Unicode text
       
  1091 is required, regardless of the build.
       
  1092 
       
  1093 This is used by the deprecated literal descriptor _L16.
       
  1094 */
       
  1095 #define _S16(a) ((const TText16 *)L ## a)
       
  1096 
       
  1097 
       
  1098 
       
  1099 
       
  1100 /**
       
  1101 @publishedAll
       
  1102 @released
       
  1103 
       
  1104 Constructs a constant literal descriptor of type TLitC16<TInt> with
       
  1105 the specified name and text.
       
  1106 
       
  1107 The 16-bit build variant is generated for both non-Unicode and Unicode builds.
       
  1108 
       
  1109 @param name The name of the C++ variable to be generated.
       
  1110 @param s    The literal text enclosed within a pair of double quotes. 
       
  1111 
       
  1112 @see _LIT
       
  1113 */
       
  1114 #define _LIT16(name,s) const static TLitC16<sizeof(L##s)/2> name={sizeof(L##s)/2-1,L##s}
       
  1115 
       
  1116 
       
  1117 
       
  1118 
       
  1119 #if defined(_UNICODE) && !defined(__KERNEL_MODE__)
       
  1120 /**
       
  1121 @publishedAll
       
  1122 @released
       
  1123 
       
  1124 Build independent general text character.
       
  1125 
       
  1126 In non-Unicode builds, this is mapped to TText8. In Unicode builds, this is 
       
  1127 mapped to TText16. Use the classes with explicit width only when you wish 
       
  1128 the width to be independent of the build variant.
       
  1129 
       
  1130 Use this class rather than TChar for general use.
       
  1131 */
       
  1132 typedef TText16 TText;
       
  1133 
       
  1134 
       
  1135 
       
  1136 /**
       
  1137 @publishedAll
       
  1138 @deprecated Use _LIT instead.
       
  1139 
       
  1140 Build independent literal. 
       
  1141 
       
  1142 The macro defines either an 8-bit constant literal (for non-Unicode text),
       
  1143 or a 16-bit constant literal (for Unicode text) depending on the build.
       
  1144 
       
  1145 @see _LIT
       
  1146 @see _L16
       
  1147 @see _L8
       
  1148 */
       
  1149 #define _L(a) (TPtrC((const TText *)L ## a))
       
  1150 
       
  1151 
       
  1152 
       
  1153 
       
  1154 /**
       
  1155 @publishedAll
       
  1156 @released
       
  1157 
       
  1158 Defines either an 8-bit string (for non-Unicode text),
       
  1159 or a 16-bit string (for Unicode text) depending on the build.
       
  1160 
       
  1161 This is used by the deprecated build independent literal _L.
       
  1162 */
       
  1163 #define _S(a) ((const TText *)L ## a)
       
  1164 
       
  1165 
       
  1166 
       
  1167 
       
  1168 /**
       
  1169 @publishedAll
       
  1170 @released
       
  1171 
       
  1172 Constructs a build independent constant literal descriptor of type TLitC<TInt>
       
  1173 with the specified name and text.
       
  1174 
       
  1175 An 8-bit build variant is generated for a non-Unicode build;
       
  1176 A 16-bit build variant is generated for a Unicode build.
       
  1177 
       
  1178 @param name The name of the C++ variable to be generated.
       
  1179 @param s    The literal text enclosed within a pair of double quotes. 
       
  1180 
       
  1181 @see _LIT16
       
  1182 @see _LIT8
       
  1183 */
       
  1184 #define _LIT(name,s) const static TLitC<sizeof(L##s)/2> name={sizeof(L##s)/2-1,L##s}
       
  1185 
       
  1186 
       
  1187 
       
  1188 
       
  1189 #else
       
  1190 /**
       
  1191 @publishedAll
       
  1192 @released
       
  1193 
       
  1194 Build independent general text character.
       
  1195 
       
  1196 In non-Unicode builds, this is mapped to TText8. In Unicode builds, this is 
       
  1197 mapped to TText16. Use the classes with explicit width only when you wish 
       
  1198 the width to be independent of the build variant.
       
  1199 
       
  1200 Use this class rather than TChar for general use.
       
  1201 */
       
  1202 typedef TText8 TText;
       
  1203 
       
  1204 
       
  1205 
       
  1206 /**
       
  1207 @publishedAll
       
  1208 @released
       
  1209 
       
  1210 @deprecated Use _LIT instead.
       
  1211 
       
  1212 Build independent literal. 
       
  1213 
       
  1214 The macro defines either an 8-bit constant literal (for non-Unicode text),
       
  1215 or a 16-bit constant literal (for Unicode text) depending on the build.
       
  1216 
       
  1217 @see _LIT
       
  1218 @see _L16
       
  1219 @see _L8
       
  1220 */
       
  1221 #define _L(a) (TPtrC((const TText *)(a)))
       
  1222 
       
  1223 
       
  1224 
       
  1225 
       
  1226 /**
       
  1227 @publishedAll
       
  1228 @released
       
  1229 
       
  1230 Defines either an 8-bit string (for non-Unicode text),
       
  1231 or a 16-bit string (for Unicode text) depending on the build.
       
  1232 
       
  1233 This is used by the deprecated build independent literal _L.
       
  1234 */
       
  1235 #define _S(a) ((const TText *)a)
       
  1236 
       
  1237 
       
  1238 
       
  1239 
       
  1240 /**
       
  1241 @publishedAll
       
  1242 @released
       
  1243 
       
  1244 Constructs a build independent constant literal descriptor of type TLitC<TInt>
       
  1245 with the specified name and text.
       
  1246 
       
  1247 An 8-bit build variant is generated for a non-Unicode build;
       
  1248 A 16-bit build variant is generated for a Unicode build.
       
  1249 
       
  1250 @param name The name of the C++ variable to be generated.
       
  1251 @param s    The literal text enclosed within a pair of double quotes. 
       
  1252 
       
  1253 @see _LIT16
       
  1254 @see _LIT8
       
  1255 */
       
  1256 #define _LIT(name,s) const static TLitC<sizeof(s)> name={sizeof(s)-1,s}
       
  1257 #endif
       
  1258 
       
  1259 
       
  1260 
       
  1261 
       
  1262 #ifndef __VA_LIST_defined
       
  1263 /** 
       
  1264 @publishedAll
       
  1265 @released
       
  1266 
       
  1267 Defines a 'C' style array of pointers to TInt8 types.
       
  1268 
       
  1269 The type is most commonly used by code that needs to deal with a variable
       
  1270 number of arguments passed to a function.
       
  1271 
       
  1272 @see TInt8
       
  1273 */
       
  1274 typedef TInt8 *VA_LIST[1];
       
  1275 #endif
       
  1276 
       
  1277 /** 
       
  1278 @publishedAll
       
  1279 @released
       
  1280 
       
  1281 Asserts that a condition is true.
       
  1282 
       
  1283 Code is generated for all builds.
       
  1284 
       
  1285 This macro is used as a C++ statement to assert the truth of some condition,
       
  1286 and to take appropriate action if the condition is false. Unlike __ASSERT_DEBUG
       
  1287 it is defined in both release and debug builds.
       
  1288 
       
  1289 The most common use for this macro is to check that the external environment of
       
  1290 a function or class is behaving as expected; for example, that parameters
       
  1291 passed to a function are credible, or that called functions are behaving as
       
  1292 expected; the macro is commonly placed at the beginning of a function.
       
  1293 
       
  1294 The effect of the macro is to generate code which tests
       
  1295 the conditional expression c; if the expression is false, then
       
  1296 function p is called. In the majority of cases, the function p is one that
       
  1297 raises a panic.
       
  1298 
       
  1299 Note that the macro definition is, in effect, equivalent to: 
       
  1300 
       
  1301 @code
       
  1302 if !(c)p;
       
  1303 @endcode
       
  1304 
       
  1305 @param c a conditional expression which results in true or false.
       
  1306 @param p a function which is called if the conditional expression c is false.
       
  1307 
       
  1308 @see __ASSERT_DEBUG
       
  1309 */
       
  1310 #define __ASSERT_ALWAYS(c,p) (void)((c)||(p,0))
       
  1311 
       
  1312 
       
  1313 
       
  1314 #ifdef __WINS__
       
  1315 #ifdef __CW32__
       
  1316 /** 
       
  1317 @internalAll
       
  1318 @released
       
  1319 */
       
  1320 #define __BREAKPOINT()			\
       
  1321 	{							\
       
  1322 	__asm { byte 0xcc };		\
       
  1323 	}
       
  1324 #else // !__CW32__
       
  1325 /** 
       
  1326 @internalAll
       
  1327 @released
       
  1328 */
       
  1329 #define __BREAKPOINT()			\
       
  1330 	{							\
       
  1331 	__asm { int 3 };			\
       
  1332 	}
       
  1333 #endif //__CW32__
       
  1334 #else
       
  1335 /** 
       
  1336 @internalAll
       
  1337 @released
       
  1338 */
       
  1339 #define __BREAKPOINT()
       
  1340 #endif
       
  1341 
       
  1342 #if defined(_DEBUG)
       
  1343 
       
  1344 /** 
       
  1345 @internalComponent
       
  1346 @deprecated
       
  1347 */
       
  1348 #define __ASSERT_DEBUG_MB(aCond,aPanicNo) (void)((aCond)||(PanicMB(aPanicNo,_L(#aPanicNo),_L(#aCond)),0))
       
  1349 
       
  1350 
       
  1351 
       
  1352 
       
  1353 /** 
       
  1354 @publishedAll
       
  1355 @released
       
  1356 
       
  1357 Asserts that a condition is true.
       
  1358 
       
  1359 Code is generated for debug builds only.
       
  1360 
       
  1361 This macro is used as a C++ statement to assert the truth of some condition,
       
  1362 and to take appropriate action if the condition is false. It is used in
       
  1363 the same way as __ASSERT_ALWAYS, except that it is only defined for debug builds.
       
  1364 
       
  1365 The macro may be used to insert extra checks at various points in source code
       
  1366 as desired; the code will only be generated in debug builds and not in release
       
  1367 builds.
       
  1368 
       
  1369 @param c A conditional expression which results in true or false.
       
  1370 @param p A function which is called if the conditional expression c is false.
       
  1371 
       
  1372 @see __ASSERT_ALWAYS
       
  1373 */
       
  1374 #define __ASSERT_DEBUG(c,p) (void)((c)||(p,0))
       
  1375 
       
  1376 
       
  1377 
       
  1378 /** 
       
  1379 @internalAll
       
  1380 @removed
       
  1381 */
       
  1382 #define __DECLARE_NAME(t)
       
  1383 
       
  1384 
       
  1385 
       
  1386 
       
  1387 /** 
       
  1388 @publishedAll
       
  1389 @released
       
  1390 
       
  1391 Calls the function for testing object invariance.
       
  1392 
       
  1393 Classes can define a standard member function __DbgTestInvariant(),
       
  1394 which checks that the object is in a valid state, and panics if it is not.
       
  1395 In debug builds, this macro simply expands to call that function. For details on how
       
  1396 to define __DbgTestInvariant(), and an example of its use, see __DECLARE_TEST.
       
  1397 
       
  1398 The macro is typically invoked at the beginning of all the member functions of
       
  1399 the class. For non-const functions (those which can change the object’s state),
       
  1400 you can ensure that the object has been left in a stable state by invoking
       
  1401 the macro at the end of the function.
       
  1402 
       
  1403 In release builds, no code is generated for the macro. 
       
  1404 */
       
  1405 #define __TEST_INVARIANT __DbgTestInvariant()
       
  1406 
       
  1407 
       
  1408 
       
  1409 
       
  1410 /**
       
  1411 @publishedAll
       
  1412 @released
       
  1413 
       
  1414 Marks the start of checking the current thread's heap. 
       
  1415 
       
  1416 This macro is defined only for debug builds.
       
  1417 
       
  1418 This macro must be matched by a corresponding call to __UHEAP_MARKEND or __UHEAP_MARKENDC.
       
  1419 
       
  1420 Calls to this macro can be nested but each call must be matched by corresponding 
       
  1421 call to __UHEAP_MARKEND or __UHEAP_MARKENDC.
       
  1422 
       
  1423 @see User::__DbgMarkStart()
       
  1424 @see __UHEAP_MARKEND
       
  1425 @see __UHEAP_MARKENDC
       
  1426 */
       
  1427 #define __UHEAP_MARK User::__DbgMarkStart(FALSE)
       
  1428 
       
  1429 
       
  1430 
       
  1431 
       
  1432 /**
       
  1433 @publishedAll
       
  1434 @released
       
  1435 
       
  1436 Checks that the number of allocated cells at the current nested level on the 
       
  1437 current thread's heap is the same as the specified value.
       
  1438 
       
  1439 This macro is defined only for debug builds.
       
  1440 
       
  1441 The macro also takes the name of the file containing this source code statement 
       
  1442 and the line number of this source code statement; they are displayed as part 
       
  1443 of the panic category, if the checks fail.
       
  1444 
       
  1445 The macro assumes that:
       
  1446 
       
  1447 1. the heap being checked is a user heap
       
  1448 
       
  1449 2. checking is being done for the number of allocated cells at the current nested 
       
  1450    level; i.e. that aCountAll is set to false
       
  1451 
       
  1452 3. the line number is the line number of this source code statement.
       
  1453 
       
  1454 4. the file name is the full path name of the file containing this source statement
       
  1455 
       
  1456 @param aCount The number of heap cells expected to be allocated at
       
  1457               the current nest level.
       
  1458 
       
  1459 @see User::__DbgMarkCheck()
       
  1460 @see __KHEAP_CHECK
       
  1461 */
       
  1462 #define __UHEAP_CHECK(aCount) User::__DbgMarkCheck(FALSE,FALSE,aCount,(TText8*)__FILE__,__LINE__)
       
  1463 
       
  1464 
       
  1465 
       
  1466 
       
  1467 /**
       
  1468 @publishedAll
       
  1469 @released
       
  1470 
       
  1471 Checks that the total number of allocated cells on the current thread's heap 
       
  1472 is the same as the specified value.
       
  1473 
       
  1474 This macro is defined only for debug builds.
       
  1475 
       
  1476 The macro also takes the name of the file containing this source code statement 
       
  1477 and the line number of this source code statement; they are displayed as part 
       
  1478 of the panic category, if the checks fail.
       
  1479 
       
  1480 @param aCount The total number of heap cells expected to be allocated.
       
  1481 
       
  1482 @see User::__DbgMarkCheck()
       
  1483 @see __KHEAP_CHECKALL
       
  1484 */
       
  1485 #define __UHEAP_CHECKALL(aCount) User::__DbgMarkCheck(FALSE,TRUE,aCount,(TText8*)__FILE__,__LINE__)
       
  1486 
       
  1487 
       
  1488 
       
  1489 
       
  1490 /**
       
  1491 @publishedAll
       
  1492 @released
       
  1493 
       
  1494 Marks the end of checking the current thread's heap. 
       
  1495 
       
  1496 The macro expects zero heap cells to remain allocated at the current nest 
       
  1497 level. This macro is defined only for debug builds.
       
  1498 
       
  1499 This macro must match an earlier call to __UHEAP_MARK.
       
  1500 
       
  1501 @see User::__DbgMarkEnd()
       
  1502 @see __UHEAP_MARK
       
  1503 */
       
  1504 #define __UHEAP_MARKEND User::__DbgMarkEnd(FALSE,0)
       
  1505 
       
  1506 
       
  1507 
       
  1508 
       
  1509 /**
       
  1510 @publishedAll
       
  1511 @released
       
  1512 
       
  1513 Marks the end of checking the current thread's heap. 
       
  1514 
       
  1515 The macro expects aCount heap cells to remain allocated at the current nest 
       
  1516 level.
       
  1517 
       
  1518 This macro must match an earlier call to __UHEAP_MARK.
       
  1519 
       
  1520 @param aCount The number of heap cells expected to remain allocated at
       
  1521               the current nest level.
       
  1522 
       
  1523 @see User::__DbgMarkEnd()
       
  1524 @see __UHEAP_MARK
       
  1525 */
       
  1526 #define __UHEAP_MARKENDC(aCount) User::__DbgMarkEnd(FALSE,aCount)
       
  1527 
       
  1528 
       
  1529 
       
  1530 
       
  1531 /**
       
  1532 @publishedAll
       
  1533 @released
       
  1534 
       
  1535 Simulates heap allocation failure for the current thread's heap.
       
  1536 
       
  1537 The failure occurs on the next call to new or any of the functions which 
       
  1538 allocate memory from the heap. This macro is defined only for debug builds.
       
  1539 
       
  1540 @param aCount Determines when the allocation will fail.
       
  1541               Heap allocation fails on attempt number aCount - later
       
  1542               allocations will succeed.
       
  1543               For example, if aCount is 3, then heap allocation fails
       
  1544               on the 3rd attempt, but all subsequent allocations succeed. 
       
  1545 
       
  1546 @see User::__DbgSetAllocFail()
       
  1547 */
       
  1548 #define __UHEAP_FAILNEXT(aCount) User::__DbgSetAllocFail(FALSE,RAllocator::EFailNext,aCount)
       
  1549 
       
  1550 /**
       
  1551 @publishedAll
       
  1552 @released
       
  1553 
       
  1554 Simulates heap allocation failure for the current thread's heap.
       
  1555 
       
  1556 The failures will occur for aBurst times from the next call to new or any of the functions which 
       
  1557 allocate memory from the heap. This macro is defined only for debug builds.
       
  1558 
       
  1559 @param aCount Determines when the allocation will fail.
       
  1560               Heap allocation fails on attempt number aCount - later
       
  1561               allocations will succeed.
       
  1562               For example, if aCount is 3, then heap allocation fails
       
  1563               on the 3rd attempt, but all subsequent allocations succeed.  
       
  1564               Note when used with RHeap the maximum value aCount can be set 
       
  1565               to is KMaxTUint16.
       
  1566 @param aBurst The number of consecutive allocations that will fail.  Note 
       
  1567               when used with RHeap the maximum value aBurst can be set to 
       
  1568               is KMaxTUint16.
       
  1569 
       
  1570 @see User::__DbgSetBurstAllocFail()
       
  1571 */
       
  1572 #define __UHEAP_BURSTFAILNEXT(aCount,aBurst) User::__DbgSetBurstAllocFail(FALSE,RAllocator::EBurstFailNext,aCount,aBurst)
       
  1573 
       
  1574 
       
  1575 
       
  1576 /**
       
  1577 @publishedAll
       
  1578 @released
       
  1579 
       
  1580 Simulates heap allocation failure for the current thread's heap. 
       
  1581 
       
  1582 The failure occurs on subsequent calls to new or any of the functions which 
       
  1583 allocate memory from the heap. This macro is defined only for debug builds.
       
  1584 
       
  1585 @param aType  The type of failure to be simulated.
       
  1586 @param aRate The failure rate.
       
  1587 
       
  1588 @see User::__DbgSetAllocFail()
       
  1589 @see RAllocator::TAllocFail
       
  1590 */
       
  1591 #define __UHEAP_SETFAIL(aType,aRate) User::__DbgSetAllocFail(FALSE, aType, aRate)
       
  1592 
       
  1593 /**
       
  1594 @publishedAll
       
  1595 @released
       
  1596 
       
  1597 Simulates heap allocation failure for the current thread's heap. 
       
  1598 
       
  1599 The failure occurs on subsequent calls to new or any of the functions which 
       
  1600 allocate memory from the heap. This macro is defined only for debug builds.
       
  1601 
       
  1602 @param aType  The type of failure to be simulated.
       
  1603 @param aRate  The failure rate.  Note when used with RHeap the maximum value 
       
  1604               aRate can be set to is KMaxTUint16.
       
  1605 @param aBurst The number of consecutive allocations that will fail.    Note 
       
  1606               when used with RHeap the maximum value aBurst can be set 
       
  1607               to is KMaxTUint16.
       
  1608 
       
  1609 @see User::__DbgSetBurstAllocFail()
       
  1610 @see RAllocator::TAllocFail
       
  1611 */
       
  1612 #define __UHEAP_SETBURSTFAIL(aType,aRate,aBurst) User::__DbgSetBurstAllocFail(FALSE, aType, aRate, aBurst)
       
  1613 
       
  1614 
       
  1615 
       
  1616 /**
       
  1617 @publishedAll
       
  1618 @released
       
  1619 
       
  1620 Cancels simulated heap allocation failure for the current thread's heap. 
       
  1621 
       
  1622 This macro is defined only for debug builds.
       
  1623 
       
  1624 @see User::__DbgSetAllocFail()
       
  1625 */
       
  1626 #define __UHEAP_RESET User::__DbgSetAllocFail(FALSE,RAllocator::ENone,1)
       
  1627 
       
  1628 
       
  1629 /**
       
  1630 @publishedAll
       
  1631 @released
       
  1632 
       
  1633 Cancels simulated heap allocation failure for the current thread's heap. 
       
  1634 It walks the the heap and sets the nesting level for all allocated
       
  1635 cells to zero.
       
  1636 
       
  1637 This macro is defined only for debug builds.
       
  1638 */
       
  1639 #define __UHEAP_TOTAL_RESET User::__DbgSetAllocFail(FALSE,RAllocator::EReset,1)
       
  1640 
       
  1641 /**
       
  1642 @publishedAll
       
  1643 @released
       
  1644 
       
  1645 Returns the number of heap allocation failures the current debug allocator fail
       
  1646 function has caused so far.
       
  1647 
       
  1648 This is intended to only be used with fail types RAllocator::EFailNext,
       
  1649 RAllocator::EBurstFailNext, RAllocator::EDeterministic and
       
  1650 RAllocator::EBurstDeterministic.  The return value is unreliable for 
       
  1651 all other fail types.
       
  1652 
       
  1653 @return The number of heap allocation failures the current debug fail 
       
  1654 function has caused.
       
  1655 
       
  1656 @see RAllocator::TAllocFail
       
  1657 */
       
  1658 #define __UHEAP_CHECKFAILURE User::__DbgCheckFailure(FALSE)
       
  1659 
       
  1660 
       
  1661 
       
  1662 
       
  1663 /**
       
  1664 @publishedPartner
       
  1665 @released
       
  1666 
       
  1667 Marks the start of Kernel heap checking. 
       
  1668 
       
  1669 Checking the Kernel heap is only useful when developing Kernel side code such 
       
  1670 as device drivers and media drivers.
       
  1671 
       
  1672 This macro is defined only for debug builds.
       
  1673 
       
  1674 This macro must be matched by a corresponding call to __KHEAP_MARKEND or __KHEAP_MARKENDC. 
       
  1675 Calls to this macro can be nested but each call must be matched by corresponding 
       
  1676 call to __KHEAP_MARKEND or __KHEAP_MARKENDC.
       
  1677 
       
  1678 @see User::__DbgMarkStart()
       
  1679 @see __KHEAP_MARKEND
       
  1680 @see __KHEAP_MARKENDC
       
  1681 */
       
  1682 #define __KHEAP_MARK User::__DbgMarkStart(TRUE)
       
  1683 
       
  1684 
       
  1685 
       
  1686 
       
  1687 /**
       
  1688 @publishedPartner
       
  1689 @released
       
  1690 
       
  1691 Checks that the number of allocated cells at the current nested level of the 
       
  1692 Kernel heap is the same as the specified value. This macro is defined only 
       
  1693 for debug builds. Checking the Kernel heap is only useful when developing 
       
  1694 Kernel side code such as device drivers and media drivers.
       
  1695 
       
  1696 The macro also takes the name of the file containing this source code statement 
       
  1697 and the line number of this source code statement; they are displayed as part 
       
  1698 of the panic category, if the checks fail.
       
  1699 
       
  1700 @param aCount The number of heap cells expected to be allocated at
       
  1701               the current nest level.
       
  1702 
       
  1703 @see User::__DbgMarkCheck()
       
  1704 @see __UHEAP_CHECK
       
  1705 */
       
  1706 #define __KHEAP_CHECK(aCount) User::__DbgMarkCheck(TRUE,FALSE,aCount,(TText8*)__FILE__,__LINE__)
       
  1707 
       
  1708 
       
  1709 
       
  1710 
       
  1711 /**
       
  1712 @publishedPartner
       
  1713 @released
       
  1714 
       
  1715 Checks that the total number of allocated cells on the Kernel heap is the same 
       
  1716 as the specified value.
       
  1717 
       
  1718 It is only useful when developing Kernel side code such as device drivers 
       
  1719 and media drivers. 
       
  1720 
       
  1721 The macro also takes the name of the file containing this source code statement 
       
  1722 and the line number of this source code statement; they are displayed as part 
       
  1723 of the panic category, if the checks fail.
       
  1724 
       
  1725 This macro is defined only for debug builds.
       
  1726 
       
  1727 @param aCount The total number of heap cells expected to be allocated
       
  1728 
       
  1729 @see User::__DbgMarkCheck()
       
  1730 @see __UHEAP_CHECKALL
       
  1731 */
       
  1732 #define __KHEAP_CHECKALL(aCount) User::__DbgMarkCheck(TRUE,TRUE,aCount,(TText8*)__FILE__,__LINE__)
       
  1733 
       
  1734 
       
  1735 
       
  1736 
       
  1737 /**
       
  1738 @publishedPartner
       
  1739 @released
       
  1740 
       
  1741 Marks the end of Kernel heap checking. The macro expects zero heap cells to 
       
  1742 remain allocated at the current nest level.
       
  1743 
       
  1744 This macro is defined only for debug builds. Checking the Kernel heap is only 
       
  1745 useful when developing Kernel side code such as device drivers and media drivers.
       
  1746 
       
  1747 This macro must match an earlier call to __KHEAP_MARK.
       
  1748 
       
  1749 @see User::__DbgMarkEnd()
       
  1750 @see __KHEAP_MARK
       
  1751 */
       
  1752 #define __KHEAP_MARKEND User::__DbgMarkEnd(TRUE,0)
       
  1753 
       
  1754 
       
  1755 
       
  1756 
       
  1757 /**
       
  1758 @publishedPartner
       
  1759 @released
       
  1760 
       
  1761 Marks the end of Kernel heap checking. The macro expects aCount heap cells 
       
  1762 to remain allocated at the current nest level.
       
  1763 
       
  1764 This macro is defined only for debug builds.
       
  1765 
       
  1766 This macro must match an earlier call to __KHEAP_MARK.
       
  1767 
       
  1768 @param aCount The number of heap cells expected to remain allocated at
       
  1769               the current nest level.
       
  1770 
       
  1771 @see User::__DbgMarkEnd()
       
  1772 @see __KHEAP_MARK
       
  1773 */
       
  1774 #define __KHEAP_MARKENDC(aCount) User::__DbgMarkEnd(TRUE,aCount)
       
  1775 
       
  1776 
       
  1777 
       
  1778 
       
  1779 /**
       
  1780 @publishedPartner
       
  1781 @released
       
  1782 
       
  1783 Simulates Kernel heap allocation failure. The failure occurs on the next call 
       
  1784 to new or any of the functions which allocate memory from the heap. This macro 
       
  1785 is defined only for debug builds.
       
  1786 
       
  1787 Checking the Kernel heap is only useful when developing Kernel side code such 
       
  1788 as device drivers and media drivers.
       
  1789 
       
  1790 @param aCount The rate of failure - heap allocation fails every aCount attempt.
       
  1791 
       
  1792 @see User::__DbgSetAllocFail()
       
  1793 */
       
  1794 #define __KHEAP_FAILNEXT(aCount) User::__DbgSetAllocFail(TRUE,RAllocator::EFailNext,aCount)
       
  1795 
       
  1796 /**
       
  1797 @publishedPartner
       
  1798 @released
       
  1799 
       
  1800 Simulates Kernel heap allocation failures. aBurst failures will occur on the next call 
       
  1801 to new or any of the functions which allocate memory from the heap. This macro 
       
  1802 is defined only for debug builds.
       
  1803 
       
  1804 Checking the Kernel heap is only useful when developing Kernel side code such 
       
  1805 as device drivers and media drivers.
       
  1806 
       
  1807 @param aCount The heap allocation will fail after aCount-1 allocation attempts. 
       
  1808               Note when used with RHeap the maximum value aCount can be set 
       
  1809               to is KMaxTUint16.
       
  1810 @param aBurst The number of allocations that will fail after aCount-1 allocation 
       
  1811               attempts.  Note when used with RHeap the maximum value aBurst can be 
       
  1812               set to is KMaxTUint16.
       
  1813 
       
  1814 
       
  1815 @see User::__DbgSetBurstAllocFail()
       
  1816 */
       
  1817 #define __KHEAP_BURSTFAILNEXT(aCount,aBurst) User::__DbgSetBurstAllocFail(TRUE,RAllocator::EBurstFailNext,aCount,aBurst)
       
  1818 
       
  1819 
       
  1820 /**
       
  1821 @publishedPartner
       
  1822 @released
       
  1823 
       
  1824 Simulates Kernel heap allocation failure. 
       
  1825 
       
  1826 The failure occurs on subsequent calls to new or any of the functions which 
       
  1827 allocate memory from this heap.
       
  1828 
       
  1829 This macro is defined only for debug builds.
       
  1830 
       
  1831 @param aType  The type of failure to be simulated.
       
  1832 @param aRate The failure rate.
       
  1833 
       
  1834 @see RAllocator::TAllocFail
       
  1835 @see User::__DbgSetAllocFail()
       
  1836 */
       
  1837 #define __KHEAP_SETFAIL(aType,aRate) User::__DbgSetAllocFail(TRUE,aType,aRate)
       
  1838 
       
  1839 /**
       
  1840 @publishedPartner
       
  1841 @released
       
  1842 
       
  1843 Simulates Kernel heap allocation failure. 
       
  1844 
       
  1845 The failure occurs on subsequent calls to new or any of the functions which 
       
  1846 allocate memory from this heap.
       
  1847 
       
  1848 This macro is defined only for debug builds.
       
  1849 
       
  1850 @param aType  The type of failure to be simulated.
       
  1851 @param aRate  The failure rate.  Note when used with RHeap the maximum value 
       
  1852               aRate can be set to is KMaxTUint16.
       
  1853 @param aBurst The number of consecutive allocations that will fail.  Note 
       
  1854               when used with RHeap the maximum value aBurst can be set to 
       
  1855               is KMaxTUint16.
       
  1856 
       
  1857 @see RAllocator::TAllocFail
       
  1858 @see User::__DbgSetBurstAllocFail()
       
  1859 */
       
  1860 #define __KHEAP_SETBURSTFAIL(aType,aRate,aBurst) User::__DbgSetBurstAllocFail(TRUE,aType,aRate,aBurst)
       
  1861 
       
  1862 
       
  1863 
       
  1864 /**
       
  1865 @publishedPartner
       
  1866 @released
       
  1867 
       
  1868 Cancels simulated Kernel heap allocation failure. 
       
  1869 
       
  1870 Checking the Kernel heap is only useful when developing Kernel side code such 
       
  1871 as device drivers and media drivers.
       
  1872 
       
  1873 This macro is defined only for debug builds.
       
  1874 
       
  1875 @see User::__DbgSetAllocFail()
       
  1876 */
       
  1877 #define __KHEAP_RESET User::__DbgSetAllocFail(TRUE,RAllocator::ENone,1)
       
  1878 
       
  1879 
       
  1880 
       
  1881 
       
  1882 /**
       
  1883 @publishedPartner
       
  1884 @released
       
  1885 
       
  1886 Cancels simulated kernel heap allocation failure. 
       
  1887 It walks the the heap and sets the nesting level for all allocated
       
  1888 cells to zero.
       
  1889 
       
  1890 Checking the kernel heap is only useful when developing kernel side code such 
       
  1891 as device drivers and media drivers.
       
  1892 
       
  1893 This macro is defined only for debug builds.
       
  1894 */
       
  1895 #define __KHEAP_TOTAL_RESET User::__DbgSetAllocFail(TRUE,RAllocator::EReset,1)
       
  1896 
       
  1897 /**
       
  1898 @publishedAll
       
  1899 @released
       
  1900 
       
  1901 Returns the number of kernel heap allocation failures the current debug 
       
  1902 allocator fail function has caused so far.
       
  1903 
       
  1904 This is intended to only be used with fail types RAllocator::EFailNext,
       
  1905 RAllocator::EBurstFailNext, RAllocator::EDeterministic and
       
  1906 RAllocator::EBurstDeterministic.  The return value is unreliable for 
       
  1907 all other fail types.
       
  1908 
       
  1909 @return The number of heap allocation failures the current debug fail 
       
  1910 function has caused.
       
  1911 
       
  1912 @see RAllocator::TAllocFail
       
  1913 */
       
  1914 #define __KHEAP_CHECKFAILURE User::__DbgCheckFailure(TRUE)
       
  1915 
       
  1916 
       
  1917 
       
  1918 /**
       
  1919 @publishedAll
       
  1920 @released
       
  1921 
       
  1922 Marks the start of heap checking for the specific heap. 
       
  1923 
       
  1924 This macro is defined only for debug builds.
       
  1925 
       
  1926 This macro must be matched by a corresponding call to __RHEAP_MARKEND or __RHEAP_MARKENDC.
       
  1927 
       
  1928 Calls to this macro can be nested but each call must be matched by corresponding 
       
  1929 call to __RHEAP_MARKEND or __RHEAP_MARKENDC.
       
  1930 
       
  1931 @param aHeap A pointer to the specific RHeap
       
  1932 
       
  1933 @see RHeap
       
  1934 @see RAllocator::__DbgMarkStart()
       
  1935 @see __RHEAP_MARKEND
       
  1936 @see __RHEAP_MARKENDC
       
  1937 */
       
  1938 #define __RHEAP_MARK(aHeap) (aHeap)->__DbgMarkStart()
       
  1939 
       
  1940 
       
  1941 
       
  1942 
       
  1943 /**
       
  1944 @publishedAll
       
  1945 @released
       
  1946 
       
  1947 Checks that the number of allocated cells at the current nested level on the 
       
  1948 specified heap is the same as the specified value. 
       
  1949 
       
  1950 The macro also takes the name of the file containing this source code statement 
       
  1951 and the line number of this source code statement; they are displayed as part 
       
  1952 of the panic category, if the checks fail. 
       
  1953 
       
  1954 This macro is defined only for debug builds.
       
  1955 
       
  1956 @param aHeap  A pointer to the specific RHeap.
       
  1957 @param aCount The number of heap cells expected to be allocated at
       
  1958               the current nest level.
       
  1959 
       
  1960 @see RAllocator::__DbgMarkCheck()
       
  1961 */
       
  1962 #define __RHEAP_CHECK(aHeap,aCount) (aHeap)->__DbgMarkCheck(FALSE,aCount,(TText8*)__FILE__,__LINE__)
       
  1963 
       
  1964 
       
  1965 
       
  1966 
       
  1967 /**
       
  1968 @publishedAll
       
  1969 @released
       
  1970 
       
  1971 Checks that the total number of allocated cells on the specified heap is the 
       
  1972 same as the specified value.
       
  1973 
       
  1974 The macro also takes the name of the file containing this source code statement 
       
  1975 and the line number of this source code statement; they are displayed as part 
       
  1976 of the panic category, if the checks fail.
       
  1977 
       
  1978 This macro is defined only for debug builds.
       
  1979 
       
  1980 @param aHeap  A pointer to the specific RHeap.
       
  1981 @param aCount The total number of heap cells expected to be allocated.
       
  1982 
       
  1983 @see RAllocator::__DbgMarkCheck()
       
  1984 */
       
  1985 #define __RHEAP_CHECKALL(aHeap,aCount) (aHeap)->__DbgMarkCheck(TRUE,aCount,(TText8*)__FILE__,__LINE__)
       
  1986 
       
  1987 
       
  1988 
       
  1989 
       
  1990 /**
       
  1991 @publishedAll
       
  1992 @released
       
  1993 
       
  1994 Marks the end of heap checking for the specific heap.
       
  1995 
       
  1996 The macro expects zero heap cells to remain allocated at the current nest 
       
  1997 level. This macro is defined only for debug builds.
       
  1998 
       
  1999 This macro must match an earlier call to __RHEAP_MARK.
       
  2000 
       
  2001 @param aHeap A pointer to the specific RHeap.
       
  2002 
       
  2003 @see RAllocator::__DbgMarkEnd()
       
  2004 @see __RHEAP_MARK
       
  2005 */
       
  2006 #define __RHEAP_MARKEND(aHeap) (aHeap)->__DbgMarkEnd(0)
       
  2007 
       
  2008 
       
  2009 
       
  2010 
       
  2011 /**
       
  2012 @publishedAll
       
  2013 @released
       
  2014 
       
  2015 Marks the end of heap checking for the specific heap.
       
  2016 
       
  2017 The macro expects aCount heap cells to remain allocated at the current nest 
       
  2018 level. This macro is defined only for debug builds.
       
  2019 
       
  2020 This macro must match an earlier call to __RHEAP_MARK.
       
  2021 
       
  2022 @param aHeap  A pointer to the specific RHeap.
       
  2023 @param aCount The number of heap cells expected to remain allocated at
       
  2024               the current nest level
       
  2025 
       
  2026 @see RAllocator::__DbgMarkEnd()
       
  2027 @see __RHEAP_MARK
       
  2028 */
       
  2029 #define __RHEAP_MARKENDC(aHeap,aCount) (aHeap)->__DbgMarkEnd(aCount)
       
  2030 
       
  2031 
       
  2032 
       
  2033 
       
  2034 /**
       
  2035 @publishedAll
       
  2036 @released
       
  2037 
       
  2038 Simulates an allocation failure for the specific heap.
       
  2039 
       
  2040 The failure occurs on the next call to new or any of the functions which allocate 
       
  2041 memory from the heap. This macro is defined only for debug builds.
       
  2042 
       
  2043 @param aHeap  A pointer to the specific RHeap.
       
  2044 @param aCount The rate of failure - heap allocation fails every aCount attempt.
       
  2045 
       
  2046 @see RAllocator::__DbgSetAllocFail()
       
  2047 */
       
  2048 #define __RHEAP_FAILNEXT(aHeap,aCount) (aHeap)->__DbgSetAllocFail(RAllocator::EFailNext,aCount)
       
  2049 
       
  2050 /**
       
  2051 @publishedAll
       
  2052 @released
       
  2053 
       
  2054 Simulates aBurst allocation failures for the specific heap.
       
  2055 
       
  2056 The failure occurs on the next call to new or any of the functions which allocate 
       
  2057 memory from the heap. This macro is defined only for debug builds.
       
  2058 
       
  2059 @param aHeap  A pointer to the specific RHeap.
       
  2060 @param aCount The heap allocation will fail after aCount-1 allocation attempts. 
       
  2061               Note when used with RHeap the maximum value aCount can be set 
       
  2062               to is KMaxTUint16.
       
  2063 @param aBurst The number of consecutive allocations that will fail.  Note 
       
  2064               when used with RHeap the maximum value aBurst can be set 
       
  2065               to is KMaxTUint16.
       
  2066 
       
  2067 @see RAllocator::__DbgSetBurstAllocFail()
       
  2068 */
       
  2069 #define __RHEAP_BURSTFAILNEXT(aHeap,aCount,aBurst) (aHeap)->__DbgSetBurstAllocFail(RAllocator::EBurstFailNext,aCount, aBurst)
       
  2070 
       
  2071 
       
  2072 
       
  2073 /**
       
  2074 @publishedAll
       
  2075 @released
       
  2076 
       
  2077 Simulates an allocation failure for the specific heap. 
       
  2078 
       
  2079 The failure occurs on subsequent calls to new or any of the functions which 
       
  2080 allocate memory from the heap. This macro is defined only for debug builds.
       
  2081 
       
  2082 @param aHeap  A pointer to the specific RHeap.
       
  2083 @param aType  The type of failure to be simulated. 
       
  2084 @param aRate The failure rate.
       
  2085 
       
  2086 @see RAllocator::__DbgSetAllocFail()
       
  2087 */
       
  2088 #define __RHEAP_SETFAIL(aHeap,aType,aRate) (aHeap)->__DbgSetAllocFail(aType,aRate)
       
  2089 
       
  2090 /**
       
  2091 @publishedAll
       
  2092 @released
       
  2093 
       
  2094 Simulates an allocation failure for the specific heap. 
       
  2095 
       
  2096 The failure occurs on subsequent calls to new or any of the functions which 
       
  2097 allocate memory from the heap. This macro is defined only for debug builds.
       
  2098 
       
  2099 @param aHeap  A pointer to the specific RHeap.
       
  2100 @param aType  The type of failure to be simulated. 
       
  2101 @param aRate  The failure rate.  Note when used with RHeap the maximum value 
       
  2102               aRate can be set to is KMaxTUint16.
       
  2103 @param aBurst The number of consecutive allocations that will fail.  Note 
       
  2104               when used with RHeap the maximum value aBurst can be set 
       
  2105               to is KMaxTUint16.
       
  2106 
       
  2107 @see RAllocator::__DbgSetBurstAllocFail()
       
  2108 */
       
  2109 #define __RHEAP_SETBURSTFAIL(aHeap,aType,aRate,aBurst) (aHeap)->__DbgSetBurstAllocFail(aType,aRate,aBurst)
       
  2110 
       
  2111 
       
  2112 
       
  2113 /**
       
  2114 @publishedAll
       
  2115 @released
       
  2116 
       
  2117 Cancels simulated allocation failure for the specific heap.
       
  2118 
       
  2119 This macro is defined only for debug builds.
       
  2120 
       
  2121 @param aHeap A pointer to the specific RHeap.
       
  2122 
       
  2123 @see RAllocator::__DbgSetAllocFail()
       
  2124 */
       
  2125 #define __RHEAP_RESET(aHeap) (aHeap)->__DbgSetAllocFail(RAllocator::ENone,1)
       
  2126 
       
  2127 
       
  2128 
       
  2129 /**
       
  2130 @publishedAll
       
  2131 @released
       
  2132 
       
  2133 Cancels simulated allocation failure for the specific heap.
       
  2134 It walks the the heap and sets the nesting level for all allocated
       
  2135 cells to zero.
       
  2136 
       
  2137 This macro is defined only for debug builds.
       
  2138 
       
  2139 @param aHeap A pointer to the specific RHeap.
       
  2140 
       
  2141 @see RAllocator::__DbgSetAllocFail()
       
  2142 */
       
  2143 #define __RHEAP_TOTAL_RESET(aHeap) (aHeap)->__DbgSetAllocFail(RAllocator::EReset,1)
       
  2144 
       
  2145 /**
       
  2146 @publishedAll
       
  2147 @released
       
  2148 
       
  2149 Returns the number of heap allocation failures the current debug allocator fail
       
  2150 function has caused so far.
       
  2151 
       
  2152 This is intended to only be used with fail types RAllocator::EFailNext,
       
  2153 RAllocator::EBurstFailNext, RAllocator::EDeterministic and
       
  2154 RAllocator::EBurstDeterministic.  The return value is unreliable for 
       
  2155 all other fail types.
       
  2156 
       
  2157 @return The number of heap allocation failures the current debug fail 
       
  2158 function has caused.
       
  2159 
       
  2160 @see RAllocator::TAllocFail
       
  2161 */
       
  2162 #define __RHEAP_CHECKFAILURE(aHeap) (aHeap)->__DbgCheckFailure()
       
  2163 
       
  2164 
       
  2165 #if defined (__WINS__) 
       
  2166 
       
  2167 /**
       
  2168 @publishedAll
       
  2169 @released
       
  2170 */
       
  2171 #define __DEBUGGER() {if (User::JustInTime()) __BREAKPOINT()}
       
  2172 
       
  2173 #else
       
  2174 #define __DEBUGGER()
       
  2175 #endif
       
  2176 
       
  2177 
       
  2178 #if defined(__DLL__)
       
  2179 /**
       
  2180 @publishedAll
       
  2181 @released
       
  2182 
       
  2183 Declares a function for testing object invariance.
       
  2184 
       
  2185 For complex classes, it is often useful to provide a function that can
       
  2186 be called to check that the object is in a valid state.
       
  2187 The __DECLARE_TEST macro supplies a standard prototype for such a function
       
  2188 named __DbgTestInvariant(). A companion macro __TEST_INVARIANT is provided
       
  2189 to call the function.
       
  2190 
       
  2191 For DLLs, as opposed to EXEs, __DbgTestInvariant() is exported,
       
  2192 i.e. the macro expands to:
       
  2193 
       
  2194 @code
       
  2195 public: IMPORT_C void __DbgTestInvariant() const; void __DbgTest(TAny *aPtr) const
       
  2196 @endcode
       
  2197 
       
  2198 This macro should placed as the last item in a class declaration (as it 
       
  2199 switches back to public access). Note that a terminating semi-colon must be used.
       
  2200 
       
  2201 You should define the __DbgTestInvariant() function to check that the object
       
  2202 is in a healthy state. If it finds an error, it should call User::Invariant(),
       
  2203 which will cause a panic. 
       
  2204 
       
  2205 If a class is derived from a base class, then the base class __DbgTestInvariant()
       
  2206 should be called first, and then any further checking done. 
       
  2207 
       
  2208 The second function declared, __DbgTest(), is intended to allow test code a way
       
  2209 of directly accessing non-public members of a class. The function is
       
  2210 implemented by any test code that requires it, rather than in the class’s own
       
  2211 source code. The function is therefore not exported.
       
  2212 
       
  2213 __DECLARE_TEST is defined for both debug and release builds. This point is
       
  2214 particularly important for DLLs, as otherwise the exported interfaces would
       
  2215 differ between the build versions, giving potential binary compatibility
       
  2216 problems. To avoid using memory unnecessarily in release builds, you can,
       
  2217 however, use preprocessor directives to define the code within
       
  2218 __DbgTestInvariant() only for debug builds. __DbgTestInvariant() is never
       
  2219 called in release builds.
       
  2220 
       
  2221 @see __TEST_INVARIANT
       
  2222 */
       
  2223 #define __DECLARE_TEST public: IMPORT_C void __DbgTestInvariant() const; void __DbgTest(TAny *aPtr) const
       
  2224 #else
       
  2225 #define __DECLARE_TEST public: void __DbgTestInvariant() const; void __DbgTest(TAny *aPtr) const
       
  2226 #endif
       
  2227 
       
  2228 #else
       
  2229 #define __ASSERT_DEBUG(c,p)
       
  2230 #define __DECLARE_NAME(t)
       
  2231 #define __TEST_INVARIANT
       
  2232 #if defined(__DLL__)
       
  2233 #define __DECLARE_TEST public: IMPORT_C void __DbgTestInvariant() const; void __DbgTest(TAny *aPtr) const
       
  2234 #else
       
  2235 #define __DECLARE_TEST public: void __DbgTestInvariant() const; void __DbgTest(TAny *aPtr) const
       
  2236 #endif
       
  2237 
       
  2238 
       
  2239 
       
  2240 
       
  2241 /**
       
  2242 @publishedAll
       
  2243 @released
       
  2244 
       
  2245 Marks the start of checking the current thread's heap. 
       
  2246 
       
  2247 This macro is defined only for debug builds.
       
  2248 
       
  2249 This macro must be matched by a corresponding call to __UHEAP_MARKEND or __UHEAP_MARKENDC.
       
  2250 
       
  2251 Calls to this macro can be nested but each call must be matched by corresponding 
       
  2252 call to __UHEAP_MARKEND or __UHEAP_MARKENDC.
       
  2253 
       
  2254 @see User::__DbgMarkStart()
       
  2255 @see __UHEAP_MARKEND
       
  2256 @see __UHEAP_MARKENDC
       
  2257 */
       
  2258 #define __UHEAP_MARK
       
  2259 
       
  2260 
       
  2261 
       
  2262 
       
  2263 /**
       
  2264 @publishedAll
       
  2265 @released
       
  2266 
       
  2267 Checks that the number of allocated cells at the current nested level on the 
       
  2268 current thread's heap is the same as the specified value.
       
  2269 
       
  2270 This macro is defined only for debug builds.
       
  2271 
       
  2272 The macro also takes the name of the file containing this source code statement 
       
  2273 and the line number of this source code statement; they are displayed as part 
       
  2274 of the panic category, if the checks fail.
       
  2275 
       
  2276 The macro assumes that:
       
  2277 
       
  2278 1. the heap being checked is a user heap
       
  2279 
       
  2280 2. checking is being done for the number of allocated cells at the current nested 
       
  2281    level; i.e. that aCountAll is set to false
       
  2282 
       
  2283 3. the line number is the line number of this source code statement.
       
  2284 
       
  2285 4. the file name is the full path name of the file containing this source statement
       
  2286 
       
  2287 @param aCount The number of heap cells expected to be allocated at
       
  2288               the current nest level.
       
  2289 
       
  2290 @see User::__DbgMarkCheck()
       
  2291 @see __KHEAP_CHECK
       
  2292 */
       
  2293 #define __UHEAP_CHECK(aCount)
       
  2294 
       
  2295 
       
  2296 
       
  2297 
       
  2298 /**
       
  2299 @publishedAll
       
  2300 @released
       
  2301 
       
  2302 Checks that the total number of allocated cells on the current thread's heap 
       
  2303 is the same as the specified value.
       
  2304 
       
  2305 This macro is defined only for debug builds.
       
  2306 
       
  2307 The macro also takes the name of the file containing this source code statement 
       
  2308 and the line number of this source code statement; they are displayed as part 
       
  2309 of the panic category, if the checks fail.
       
  2310 
       
  2311 @param aCount The total number of heap cells expected to be allocated.
       
  2312 
       
  2313 @see User::__DbgMarkCheck()
       
  2314 @see __KHEAP_CHECKALL
       
  2315 */
       
  2316 #define __UHEAP_CHECKALL(aCount)
       
  2317 
       
  2318 
       
  2319 
       
  2320 
       
  2321 /**
       
  2322 @publishedAll
       
  2323 @released
       
  2324 
       
  2325 Marks the end of checking the current thread's heap. 
       
  2326 
       
  2327 The macro expects zero heap cells to remain allocated at the current nest 
       
  2328 level. This macro is defined only for debug builds.
       
  2329 
       
  2330 This macro must match an earlier call to __UHEAP_MARK.
       
  2331 
       
  2332 @see User::__DbgMarkEnd()
       
  2333 @see __UHEAP_MARK
       
  2334 */
       
  2335 #define __UHEAP_MARKEND
       
  2336 
       
  2337 
       
  2338 
       
  2339 
       
  2340 /**
       
  2341 @publishedAll
       
  2342 @released
       
  2343 
       
  2344 Marks the end of checking the current thread's heap. 
       
  2345 
       
  2346 The macro expects aCount heap cells to remain allocated at the current nest 
       
  2347 level.
       
  2348 
       
  2349 This macro must match an earlier call to __UHEAP_MARK.
       
  2350 
       
  2351 @param aCount The number of heap cells expected to remain allocated at
       
  2352               the current nest level.
       
  2353 
       
  2354 @see User::__DbgMarkEnd()
       
  2355 @see __UHEAP_MARK
       
  2356 */
       
  2357 #define __UHEAP_MARKENDC(aCount)
       
  2358 
       
  2359 
       
  2360 
       
  2361 
       
  2362 /**
       
  2363 @publishedAll
       
  2364 @released
       
  2365 
       
  2366 Simulates heap allocation failure for the current thread's heap.
       
  2367 
       
  2368 The failure occurs on the next call to new or any of the functions which 
       
  2369 allocate memory from the heap. This macro is defined only for debug builds.
       
  2370 
       
  2371 @param aCount Determines when the allocation will fail.
       
  2372               Heap allocation fails on attempt number aCount - later
       
  2373               allocations will succeed.
       
  2374               For example, if aCount is 3, then heap allocation fails
       
  2375               on the 3rd attempt, but all subsequent allocations succeed. 
       
  2376 
       
  2377 @see User::__DbgSetAllocFail()
       
  2378 */
       
  2379 #define __UHEAP_FAILNEXT(aCount)
       
  2380 
       
  2381 /**
       
  2382 @publishedAll
       
  2383 @released
       
  2384 
       
  2385 Simulates heap allocation failure for the current thread's heap.
       
  2386 
       
  2387 The failures will occur for aBurst times from the next call to new or any of the functions which 
       
  2388 allocate memory from the heap. This macro is defined only for debug builds.
       
  2389 
       
  2390 @param aCount Determines when the allocation will fail.
       
  2391               Heap allocation fails on attempt number aCount - later
       
  2392               allocations will succeed.
       
  2393               For example, if aCount is 3, then heap allocation fails
       
  2394               on the 3rd attempt, but all subsequent allocations succeed.   
       
  2395               Note when used with RHeap the maximum value aBurst can be 
       
  2396               set to is KMaxTUint16.
       
  2397 @param aBurst The number of consecutive allocations that will fail.  Note 
       
  2398               when used with RHeap the maximum value aBurst can be set 
       
  2399               to is KMaxTUint16.
       
  2400 
       
  2401 @see User::__DbgSetBurstAllocFail()
       
  2402 */
       
  2403 #define __UHEAP_BURSTFAILNEXT(aCount,aBurst)
       
  2404 
       
  2405 
       
  2406 
       
  2407 /**
       
  2408 @publishedAll
       
  2409 @released
       
  2410 
       
  2411 Simulates heap allocation failure for the current thread's heap. 
       
  2412 
       
  2413 The failure occurs on subsequent calls to new or any of the functions which 
       
  2414 allocate memory from the heap. This macro is defined only for debug builds.
       
  2415 
       
  2416 @param aType  The type of failure to be simulated.
       
  2417 @param aRate The failure rate.
       
  2418 
       
  2419 @see User::__DbgSetAllocFail()
       
  2420 */
       
  2421 #define __UHEAP_SETFAIL(aType,aRate)
       
  2422 
       
  2423 /**
       
  2424 @publishedAll
       
  2425 @released
       
  2426 
       
  2427 Simulates heap allocation failure for the current thread's heap. 
       
  2428 
       
  2429 The failure occurs on subsequent calls to new or any of the functions which 
       
  2430 allocate memory from the heap. This macro is defined only for debug builds.
       
  2431 
       
  2432 @param aType  The type of failure to be simulated.
       
  2433 @param aRate  The failure rate.  Note when used with RHeap the maximum value 
       
  2434               aRate can be set to is KMaxTUint16.
       
  2435 @param aBurst The number of consecutive allocations that will fail.  Note 
       
  2436               when used with RHeap the maximum value aBurst can be set 
       
  2437               to is KMaxTUint16.
       
  2438 
       
  2439 @see User::__DbgSetBurstAllocFail()
       
  2440 @see RAllocator::TAllocFail
       
  2441 */
       
  2442 #define __UHEAP_SETBURSTFAIL(aType,aRate,aBurst)
       
  2443 
       
  2444 
       
  2445 
       
  2446 /**
       
  2447 @publishedAll
       
  2448 @released
       
  2449 
       
  2450 Cancels simulated heap allocation failure for the current thread's heap. 
       
  2451 
       
  2452 This macro is defined only for debug builds.
       
  2453 
       
  2454 @see User::__DbgSetAllocFail()
       
  2455 */
       
  2456 #define __UHEAP_RESET
       
  2457 
       
  2458 
       
  2459 
       
  2460 /**
       
  2461 @publishedAll
       
  2462 @released
       
  2463 
       
  2464 Cancels simulated heap allocation failure for the current thread's heap. 
       
  2465 It walks the the heap and sets the nesting level for all allocated
       
  2466 cells to zero.
       
  2467 
       
  2468 This macro is defined only for debug builds.
       
  2469 */
       
  2470 #define __UHEAP_TOTAL_RESET
       
  2471 
       
  2472 /**
       
  2473 @publishedAll
       
  2474 @released
       
  2475 
       
  2476 Returns the number of heap allocation failures the current debug allocator fail
       
  2477 function has caused so far.
       
  2478 
       
  2479 This is intended to only be used with fail types RAllocator::EFailNext,
       
  2480 RAllocator::EBurstFailNext, RAllocator::EDeterministic and
       
  2481 RAllocator::EBurstDeterministic.  The return value is unreliable for 
       
  2482 all other fail types.
       
  2483 
       
  2484 @return The number of heap allocation failures the current debug fail 
       
  2485 function has caused.
       
  2486 
       
  2487 @see RAllocator::TAllocFail
       
  2488 */
       
  2489 #define __UHEAP_CHECKFAILURE ((TUint)0)
       
  2490 
       
  2491 
       
  2492 /**
       
  2493 @publishedPartner
       
  2494 @released
       
  2495 
       
  2496 Marks the start of Kernel heap checking. 
       
  2497 
       
  2498 Checking the Kernel heap is only useful when developing Kernel side code such 
       
  2499 as device drivers and media drivers.
       
  2500 
       
  2501 This macro is defined only for debug builds.
       
  2502 
       
  2503 This macro must be matched by a corresponding call to __KHEAP_MARKEND or __KHEAP_MARKENDC. 
       
  2504 Calls to this macro can be nested but each call must be matched by corresponding 
       
  2505 call to __KHEAP_MARKEND or __KHEAP_MARKENDC.
       
  2506 
       
  2507 @see User::__DbgMarkStart()
       
  2508 @see __KHEAP_MARKEND
       
  2509 @see __KHEAP_MARKENDC
       
  2510 */
       
  2511 #define __KHEAP_MARK
       
  2512 
       
  2513 
       
  2514 
       
  2515 
       
  2516 /**
       
  2517 @publishedPartner
       
  2518 @released
       
  2519 
       
  2520 Checks that the number of allocated cells at the current nested level of the 
       
  2521 Kernel heap is the same as the specified value. This macro is defined only 
       
  2522 for debug builds. Checking the Kernel heap is only useful when developing 
       
  2523 Kernel side code such as device drivers and media drivers.
       
  2524 
       
  2525 The macro also takes the name of the file containing this source code statement 
       
  2526 and the line number of this source code statement; they are displayed as part 
       
  2527 of the panic category, if the checks fail.
       
  2528 
       
  2529 @param aCount The number of heap cells expected to be allocated at
       
  2530               the current nest level.
       
  2531 
       
  2532 @see User::__DbgMarkCheck()
       
  2533 @see __UHEAP_CHECK
       
  2534 */
       
  2535 #define __KHEAP_CHECK(aCount)
       
  2536 
       
  2537 
       
  2538 
       
  2539 
       
  2540 /**
       
  2541 @publishedPartner
       
  2542 @released
       
  2543 
       
  2544 Checks that the total number of allocated cells on the Kernel heap is the same 
       
  2545 as the specified value.
       
  2546 
       
  2547 It is only useful when developing Kernel side code such as device drivers 
       
  2548 and media drivers. 
       
  2549 
       
  2550 The macro also takes the name of the file containing this source code statement 
       
  2551 and the line number of this source code statement; they are displayed as part 
       
  2552 of the panic category, if the checks fail.
       
  2553 
       
  2554 This macro is defined only for debug builds.
       
  2555 
       
  2556 @param aCount The total number of heap cells expected to be allocated
       
  2557 
       
  2558 @see User::__DbgMarkCheck()
       
  2559 @see __UHEAP_CHECKALL
       
  2560 */
       
  2561 #define __KHEAP_CHECKALL(aCount)
       
  2562 
       
  2563 
       
  2564 
       
  2565 
       
  2566 /**
       
  2567 @publishedPartner
       
  2568 @released
       
  2569 
       
  2570 Marks the end of Kernel heap checking. The macro expects zero heap cells to 
       
  2571 remain allocated at the current nest level.
       
  2572 
       
  2573 This macro is defined only for debug builds. Checking the Kernel heap is only 
       
  2574 useful when developing Kernel side code such as device drivers and media drivers.
       
  2575 
       
  2576 This macro must match an earlier call to __KHEAP_MARK.
       
  2577 
       
  2578 @see User::__DbgMarkEnd()
       
  2579 @see __KHEAP_MARK
       
  2580 */
       
  2581 #define __KHEAP_MARKEND
       
  2582 
       
  2583 
       
  2584 
       
  2585 
       
  2586 /**
       
  2587 @publishedPartner
       
  2588 @released
       
  2589 
       
  2590 Marks the end of Kernel heap checking. The macro expects aCount heap cells 
       
  2591 to remain allocated at the current nest level.
       
  2592 
       
  2593 This macro is defined only for debug builds.
       
  2594 
       
  2595 This macro must match an earlier call to __KHEAP_MARK.
       
  2596 
       
  2597 @param aCount The number of heap cells expected to remain allocated at
       
  2598               the current nest level.
       
  2599 
       
  2600 @see User::__DbgMarkEnd()
       
  2601 @see __KHEAP_MARK
       
  2602 */
       
  2603 #define __KHEAP_MARKENDC(aCount)
       
  2604 
       
  2605 
       
  2606 
       
  2607 
       
  2608 /**
       
  2609 @publishedPartner
       
  2610 @released
       
  2611 
       
  2612 Simulates Kernel heap allocation failure. The failure occurs on the next call 
       
  2613 to new or any of the functions which allocate memory from the heap. This macro 
       
  2614 is defined only for debug builds.
       
  2615 
       
  2616 Checking the Kernel heap is only useful when developing Kernel side code such 
       
  2617 as device drivers and media drivers.
       
  2618 
       
  2619 @param aCount The rate of failure - heap allocation fails every aCount attempt.
       
  2620 
       
  2621 @see User::__DbgSetAllocFail()
       
  2622 */
       
  2623 #define __KHEAP_FAILNEXT(aCount)
       
  2624 
       
  2625 /**
       
  2626 @publishedPartner
       
  2627 @released
       
  2628 
       
  2629 Simulates Kernel heap allocation failures. aBurst failures will occur on the next call 
       
  2630 to new or any of the functions which allocate memory from the heap. This macro 
       
  2631 is defined only for debug builds.
       
  2632 
       
  2633 Checking the Kernel heap is only useful when developing Kernel side code such 
       
  2634 as device drivers and media drivers.
       
  2635 
       
  2636 @param aCount The heap allocation will fail after aCount-1 allocation attempts.  
       
  2637               Note when used with RHeap the maximum value aCount can be set 
       
  2638               to is KMaxTUint16.
       
  2639 @param aBurst The number of allocations that will fail after aCount-1 allocation
       
  2640               attempts.  Note when used with RHeap the maximum value aBurst can 
       
  2641               be set to is KMaxTUint16.
       
  2642 
       
  2643 @see User::__DbgSetBurstAllocFail()
       
  2644 */
       
  2645 #define __KHEAP_BURSTFAILNEXT(aCount,aBurst)
       
  2646 
       
  2647 
       
  2648 
       
  2649 /**
       
  2650 @publishedPartner
       
  2651 @released
       
  2652 
       
  2653 Simulates Kernel heap allocation failure. 
       
  2654 
       
  2655 The failure occurs on subsequent calls to new or any of the functions which 
       
  2656 allocate memory from this heap.
       
  2657 
       
  2658 This macro is defined only for debug builds.
       
  2659 
       
  2660 @param aType  The type of failure to be simulated.
       
  2661 @param aRate The failure rate.
       
  2662 
       
  2663 @see User::__DbgSetAllocFail()
       
  2664 */
       
  2665 #define __KHEAP_SETFAIL(aType,aRate)
       
  2666 
       
  2667 /**
       
  2668 @publishedPartner
       
  2669 @released
       
  2670 
       
  2671 Simulates Kernel heap allocation failure. 
       
  2672 
       
  2673 The failure occurs on subsequent calls to new or any of the functions which 
       
  2674 allocate memory from this heap.
       
  2675 
       
  2676 This macro is defined only for debug builds.
       
  2677 
       
  2678 @param aType  The type of failure to be simulated.
       
  2679 @param aRate  The failure rate.  Note when used with RHeap the maximum value 
       
  2680               aRate can be set to is KMaxTUint16.
       
  2681 @param aBurst The number of consecutive allocations that will fail.  Note 
       
  2682               when used with RHeap the maximum value aBurst can be set 
       
  2683               to is KMaxTUint16.
       
  2684 
       
  2685 @see User::__DbgSetBurstAllocFail()
       
  2686 */
       
  2687 #define __KHEAP_SETBURSTFAIL(aType,aRate,aBurst)
       
  2688 
       
  2689 
       
  2690 
       
  2691 /**
       
  2692 @publishedPartner
       
  2693 @released
       
  2694 
       
  2695 Cancels simulated Kernel heap allocation failure. 
       
  2696 
       
  2697 Checking the Kernel heap is only useful when developing Kernel side code such 
       
  2698 as device drivers and media drivers.
       
  2699 
       
  2700 This macro is defined only for debug builds.
       
  2701 
       
  2702 @see User::__DbgSetAllocFail()
       
  2703 */
       
  2704 #define __KHEAP_RESET
       
  2705 
       
  2706 
       
  2707 
       
  2708 /**
       
  2709 @publishedPartner
       
  2710 @released
       
  2711 
       
  2712 Cancels simulated kernel heap allocation failure. 
       
  2713 It walks the the heap and sets the nesting level for all allocated
       
  2714 cells to zero.
       
  2715 
       
  2716 Checking the kernel heap is only useful when developing kernel side code such 
       
  2717 as device drivers and media drivers.
       
  2718 
       
  2719 This macro is defined only for debug builds.
       
  2720 */
       
  2721 #define __KHEAP_TOTAL_RESET
       
  2722 
       
  2723 
       
  2724 /**
       
  2725 @publishedAll
       
  2726 @released
       
  2727 
       
  2728 Returns the number of kernel heap allocation failures the current debug 
       
  2729 allocator fail function has caused so far.
       
  2730 
       
  2731 This is intended to only be used with fail types RAllocator::EFailNext,
       
  2732 RAllocator::EBurstFailNext, RAllocator::EDeterministic and
       
  2733 RAllocator::EBurstDeterministic.  The return value is unreliable for 
       
  2734 all other fail types.
       
  2735 
       
  2736 @return The number of heap allocation failures the current debug fail 
       
  2737 function has caused.
       
  2738 
       
  2739 @see RAllocator::TAllocFail
       
  2740 */
       
  2741 #define __KHEAP_CHECKFAILURE ((TUint)0)
       
  2742 
       
  2743 /**
       
  2744 @publishedAll
       
  2745 @released
       
  2746 
       
  2747 Marks the start of heap checking for the specific heap. 
       
  2748 
       
  2749 This macro is defined only for debug builds.
       
  2750 
       
  2751 This macro must be matched by a corresponding call to __RHEAP_MARKEND or __RHEAP_MARKENDC.
       
  2752 
       
  2753 Calls to this macro can be nested but each call must be matched by corresponding 
       
  2754 call to __RHEAP_MARKEND or __RHEAP_MARKENDC.
       
  2755 
       
  2756 @param aHeap A pointer to the specific RHeap
       
  2757 
       
  2758 @see RHeap
       
  2759 @see RAllocator::__DbgMarkStart()
       
  2760 @see __RHEAP_MARKEND
       
  2761 @see __RHEAP_MARKENDC
       
  2762 */
       
  2763 #define __RHEAP_MARK(aHeap)
       
  2764 
       
  2765 
       
  2766 
       
  2767 
       
  2768 /**
       
  2769 @publishedAll
       
  2770 @released
       
  2771 
       
  2772 Checks that the number of allocated cells at the current nested level on the 
       
  2773 specified heap is the same as the specified value. 
       
  2774 
       
  2775 The macro also takes the name of the file containing this source code statement 
       
  2776 and the line number of this source code statement; they are displayed as part 
       
  2777 of the panic category, if the checks fail. 
       
  2778 
       
  2779 This macro is defined only for debug builds.
       
  2780 
       
  2781 @param aHeap  A pointer to the specific RHeap.
       
  2782 @param aCount The number of heap cells expected to be allocated at
       
  2783               the current nest level.
       
  2784 
       
  2785 @see RAllocator::__DbgMarkCheck()
       
  2786 */
       
  2787 #define __RHEAP_CHECK(aHeap,aCount)
       
  2788 
       
  2789 
       
  2790 
       
  2791 
       
  2792 /**
       
  2793 @publishedAll
       
  2794 @released
       
  2795 
       
  2796 Checks that the total number of allocated cells on the specified heap is the 
       
  2797 same as the specified value.
       
  2798 
       
  2799 The macro also takes the name of the file containing this source code statement 
       
  2800 and the line number of this source code statement; they are displayed as part 
       
  2801 of the panic category, if the checks fail.
       
  2802 
       
  2803 This macro is defined only for debug builds.
       
  2804 
       
  2805 @param aHeap  A pointer to the specific RHeap.
       
  2806 @param aCount The total number of heap cells expected to be allocated.
       
  2807 
       
  2808 @see RAllocator::__DbgMarkCheck()
       
  2809 */
       
  2810 #define __RHEAP_CHECKALL(aHeap,aCount)
       
  2811 
       
  2812 
       
  2813 
       
  2814 
       
  2815 /**
       
  2816 @publishedAll
       
  2817 @released
       
  2818 
       
  2819 Marks the end of heap checking for the specific heap.
       
  2820 
       
  2821 The macro expects zero heap cells to remain allocated at the current nest 
       
  2822 level. This macro is defined only for debug builds.
       
  2823 
       
  2824 This macro must match an earlier call to __RHEAP_MARK.
       
  2825 
       
  2826 @param aHeap A pointer to the specific RHeap.
       
  2827 
       
  2828 @see RAllocator::__DbgMarkEnd()
       
  2829 @see __RHEAP_MARK
       
  2830 */
       
  2831 #define __RHEAP_MARKEND(aHeap)
       
  2832 
       
  2833 
       
  2834 
       
  2835 
       
  2836 /**
       
  2837 @publishedAll
       
  2838 @released
       
  2839 
       
  2840 Marks the end of heap checking for the specific heap.
       
  2841 
       
  2842 The macro expects aCount heap cells to remain allocated at the current nest 
       
  2843 level. This macro is defined only for debug builds.
       
  2844 
       
  2845 This macro must match an earlier call to __RHEAP_MARK.
       
  2846 
       
  2847 @param aHeap  A pointer to the specific RHeap.
       
  2848 @param aCount The number of heap cells expected to remain allocated at
       
  2849               the current nest level
       
  2850 
       
  2851 @see RAllocator::__DbgMarkEnd()
       
  2852 @see __RHEAP_MARK
       
  2853 */
       
  2854 #define __RHEAP_MARKENDC(aHeap,aCount)
       
  2855 
       
  2856 
       
  2857 
       
  2858 
       
  2859 /**
       
  2860 @publishedAll
       
  2861 @released
       
  2862 
       
  2863 Simulates an allocation failure for the specific heap.
       
  2864 
       
  2865 The failure occurs on the next call to new or any of the functions which allocate 
       
  2866 memory from the heap. This macro is defined only for debug builds.
       
  2867 
       
  2868 @param aHeap  A pointer to the specific RHeap.
       
  2869 @param aCount The rate of failure - heap allocation fails every aCount attempt.
       
  2870 
       
  2871 @see RAllocator::__DbgSetAllocFail()
       
  2872 */
       
  2873 #define __RHEAP_FAILNEXT(aHeap,aCount)
       
  2874 
       
  2875 /**
       
  2876 @publishedAll
       
  2877 @released
       
  2878 
       
  2879 Simulates aBurst allocation failures for the specific heap.
       
  2880 
       
  2881 The failure occurs on the next call to new or any of the functions which allocate 
       
  2882 memory from the heap. This macro is defined only for debug builds.
       
  2883 
       
  2884 @param aHeap  A pointer to the specific RHeap.
       
  2885 @param aCount The heap allocation will fail after aCount-1 allocation attempts. 
       
  2886               Note when used with RHeap the maximum value aCount can be set 
       
  2887               to is KMaxTUint16.
       
  2888 @param aBurst The number of consecutive allocations that will fail.  Note 
       
  2889               when used with RHeap the maximum value aBurst can be set 
       
  2890               to is KMaxTUint16.
       
  2891 
       
  2892 @see RAllocator::__DbgSetBurstAllocFail()
       
  2893 */
       
  2894 #define __RHEAP_BURSTFAILNEXT(aHeap,aCount,aBurst)
       
  2895 
       
  2896 
       
  2897 
       
  2898 /**
       
  2899 @publishedAll
       
  2900 @released
       
  2901 
       
  2902 Simulates an allocation failure for the specific heap. 
       
  2903 
       
  2904 The failure occurs on subsequent calls to new or any of the functions which 
       
  2905 allocate memory from the heap. This macro is defined only for debug builds.
       
  2906 
       
  2907 @param aHeap  A pointer to the specific RHeap.
       
  2908 @param aType  The type of failure to be simulated. 
       
  2909 @param aRate The failure rate.
       
  2910 
       
  2911 @see RAllocator::__DbgSetAllocFail()
       
  2912 */
       
  2913 #define __RHEAP_SETFAIL(aHeap,aType,aRate)
       
  2914 
       
  2915 /**
       
  2916 @publishedAll
       
  2917 @released
       
  2918 
       
  2919 Simulates an allocation failure for the specific heap. 
       
  2920 
       
  2921 The failure occurs on subsequent calls to new or any of the functions which 
       
  2922 allocate memory from the heap. This macro is defined only for debug builds.
       
  2923 
       
  2924 @param aHeap  A pointer to the specific RHeap.
       
  2925 @param aType  The type of failure to be simulated. 
       
  2926 @param aRate  The failure rate.  Note when used with RHeap the maximum value 
       
  2927               aRate can be set to is KMaxTUint16.
       
  2928 @param aBurst The number of consecutive allocations that will fail.  Note 
       
  2929               when used with RHeap the maximum value aBurst can be set 
       
  2930               to is KMaxTUint16.
       
  2931 
       
  2932 @see RAllocator::__DbgSetBurstAllocFail()
       
  2933 */
       
  2934 #define __RHEAP_SETBURSTFAIL(aHeap,aType,aRate,aBurst)
       
  2935 
       
  2936 
       
  2937 
       
  2938 /**
       
  2939 @publishedAll
       
  2940 @released
       
  2941 
       
  2942 Cancels simulated allocation failure for the specific heap.
       
  2943 
       
  2944 This macro is defined only for debug builds.
       
  2945 
       
  2946 @param aHeap A pointer to the specific RHeap.
       
  2947 
       
  2948 @see RAllocator::__DbgSetAllocFail()
       
  2949 */
       
  2950 #define __RHEAP_RESET(aHeap)
       
  2951 
       
  2952 
       
  2953 
       
  2954 /**
       
  2955 @publishedAll
       
  2956 @released
       
  2957 
       
  2958 Cancels simulated allocation failure for the specific heap.
       
  2959 It walks the the heap and sets the nesting level for all allocated
       
  2960 cells to zero.
       
  2961 
       
  2962 This macro is defined only for debug builds.
       
  2963 
       
  2964 @param aHeap A pointer to the specific RHeap.
       
  2965 
       
  2966 @see RAllocator::__DbgSetAllocFail()
       
  2967 */
       
  2968 #define __RHEAP_TOTAL_RESET(aHeap)
       
  2969 
       
  2970 
       
  2971 /**
       
  2972 @publishedAll
       
  2973 @released
       
  2974 
       
  2975 Returns the number of heap allocation failures the current debug allocator fail
       
  2976 function has caused so far.
       
  2977 
       
  2978 This is intended to only be used with fail types RAllocator::EFailNext,
       
  2979 RAllocator::EBurstFailNext, RAllocator::EDeterministic and
       
  2980 RAllocator::EBurstDeterministic.  The return value is unreliable for 
       
  2981 all other fail types.
       
  2982 
       
  2983 @return The number of heap allocation failures the current debug fail 
       
  2984 function has caused.
       
  2985 
       
  2986 @see RAllocator::TAllocFail
       
  2987 */
       
  2988 #define __RHEAP_CHECKFAILURE(aHeap) ((TUint)0)
       
  2989 
       
  2990 #define __DEBUGGER()
       
  2991 #endif
       
  2992 
       
  2993 #if defined (__WINS__)
       
  2994 /** @internalTechnology */
       
  2995 #define __EMULATOR_IMAGE_HEADER2(aUid0,aUid1,aUid2,aPriority,aCap0,aCap1,aSid,aVid,aVer,aFlags)	TEmulatorImageHeader uid={{aUid0,aUid1,aUid2},aPriority,{aSid,aVid,{aCap0,aCap1}},0,0,aVer,aFlags};
       
  2996 /** @internalTechnology */
       
  2997 #define __EMULATOR_IMAGE_HEADER(aUid0,aUid1,aUid2,aPriority,aCap,aFlags)					TEmulatorImageHeader uid={{aUid0,aUid1,aUid2},aPriority,{aUid2,0,{aCap,0}},0,0,0x00010000u,aFlags};
       
  2998 #else
       
  2999 #define __EMULATOR_IMAGE_HEADER2(aUid0,aUid1,aUid2,aPriority,aCap0,aCap1,aSid,aVer,aFlags)
       
  3000 #define __EMULATOR_IMAGE_HEADER(aUid0,aUid1,aUid2,aPriority,aCap,aFlags)
       
  3001 #endif
       
  3002 
       
  3003 #if defined(__OPT__)
       
  3004 /**
       
  3005 @internalComponent
       
  3006 @deprecated
       
  3007 */
       
  3008 #define __ASSERT_OPT(c,p) (void)((c)||(p,0))
       
  3009 #else
       
  3010 #define __ASSERT_OPT(c,p)
       
  3011 #endif
       
  3012 
       
  3013 #if defined(_UNICODE)
       
  3014 #if !defined(UNICODE)
       
  3015 /**
       
  3016 @publishedAll
       
  3017 @deprecated
       
  3018 */
       
  3019 #define UNICODE
       
  3020 #endif
       
  3021 #endif
       
  3022 
       
  3023 #if defined(_DEBUG)
       
  3024 /**
       
  3025 @internalComponent
       
  3026 @deprecated
       
  3027 */
       
  3028 #define __DECLARE_TEST_DEBUG __DECLARE_TEST
       
  3029 #else
       
  3030 #define __DECLARE_TEST_DEBUG
       
  3031 #endif
       
  3032 
       
  3033 
       
  3034 
       
  3035 
       
  3036 #if !defined(ASSERT)
       
  3037 /**
       
  3038 @publishedAll
       
  3039 @released
       
  3040 
       
  3041 Generates _ASSERT_DEBUG code that calls User::Invariant() if the specified
       
  3042 condition is not true.
       
  3043 
       
  3044 @param x A conditional expression which results in true or false.
       
  3045 */
       
  3046 #define ASSERT(x) __ASSERT_DEBUG(x,User::Invariant())
       
  3047 #endif
       
  3048 
       
  3049 
       
  3050 
       
  3051 
       
  3052 #ifndef __VALUE_IN_REGS__ 
       
  3053 /**
       
  3054 @publishedPartner
       
  3055 @released
       
  3056 */
       
  3057 #define __VALUE_IN_REGS__ 
       
  3058 #endif
       
  3059 
       
  3060 
       
  3061 
       
  3062 
       
  3063 #if defined(_DEBUG)
       
  3064 /**
       
  3065 @publishedAll
       
  3066 @released
       
  3067 */
       
  3068 #define __DEBUG_ONLY(x) x
       
  3069 #else
       
  3070 #define __DEBUG_ONLY(x)
       
  3071 #endif
       
  3072 
       
  3073 
       
  3074 
       
  3075 
       
  3076 #ifdef __KERNEL_MODE__
       
  3077 
       
  3078 /** @internalComponent */
       
  3079 #define	KIMPORT_C	IMPORT_C
       
  3080 
       
  3081 /** @internalComponent */
       
  3082 #define	KEXPORT_C	EXPORT_C
       
  3083 
       
  3084 /** @internalComponent */
       
  3085 #define	UIMPORT_C
       
  3086 
       
  3087 /** @internalComponent */
       
  3088 #define	UEXPORT_C
       
  3089 #else
       
  3090 #define	KIMPORT_C
       
  3091 #define	KEXPORT_C
       
  3092 #define	UIMPORT_C	IMPORT_C
       
  3093 #define	UEXPORT_C	EXPORT_C
       
  3094 #endif
       
  3095 
       
  3096 
       
  3097 
       
  3098 
       
  3099 /**
       
  3100 @publishedAll
       
  3101 @released
       
  3102 
       
  3103 Asserts that a condition is true at compilation time.
       
  3104 
       
  3105 @param x Condition to assert
       
  3106 */
       
  3107 #define __ASSERT_COMPILE(x)		void __compile_time_assert(int __check[(x)?1:-1])
       
  3108 
       
  3109 #ifdef __REMOVE_PLATSEC_DIAGNOSTICS__
       
  3110 /**
       
  3111 @publishedPartner
       
  3112 @released
       
  3113 */
       
  3114 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
       
  3115 #define __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
       
  3116 #endif /*__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__*/
       
  3117 #endif /*__REMOVE_PLATSEC_DIAGNOSTICS__*/
       
  3118 
       
  3119 /**
       
  3120 @internalComponent
       
  3121 */
       
  3122 static const char* const KSuppressPlatSecDiagnosticMagicValue = (const char*)1;
       
  3123 
       
  3124 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
       
  3125 /**
       
  3126 @internalComponent
       
  3127 */
       
  3128 #define __PLATSEC_DIAGNOSTIC_FILE_AND_LINE_HELPER(l) #l
       
  3129 /**
       
  3130 @internalComponent
       
  3131 */
       
  3132 #define __PLATSEC_DIAGNOSTIC_FILE_AND_LINE_HELPER2(f,l) f "(" __PLATSEC_DIAGNOSTIC_FILE_AND_LINE_HELPER(l) ")"
       
  3133 /**
       
  3134 @publishedPartner
       
  3135 @released
       
  3136 */
       
  3137 #define __PLATSEC_DIAGNOSTIC_FILE_AND_LINE __PLATSEC_DIAGNOSTIC_FILE_AND_LINE_HELPER2(__FILE__,__LINE__)
       
  3138 
       
  3139 /**
       
  3140 @publishedPartner
       
  3141 @released
       
  3142 
       
  3143 A macro that should be used to enclose a platform security diagnostic
       
  3144 'C' style string that can be passed to a capability checking function such
       
  3145 as RThread::HasCapability() and Kern::CurrentThreadHasCapability().
       
  3146 
       
  3147 The content of the string is emitted if the capability test finds that
       
  3148 the capability is not present.
       
  3149 
       
  3150 The macro provides a convenient mechanism that allows the strings to
       
  3151 be removed from future versions of Symbian OS.
       
  3152 
       
  3153 For example:
       
  3154 
       
  3155 @code
       
  3156 if(!Kern::CurrentThreadHasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetState")))
       
  3157     {
       
  3158     return KErrPermissionDenied;
       
  3159     }			
       
  3160 @endcode
       
  3161 
       
  3162 In this example, the string:
       
  3163 
       
  3164 @code
       
  3165 Checked by Hal function EDisplayHalSetState
       
  3166 @endcode
       
  3167 
       
  3168 is emitted if the calling process does not have the ECapabilityPowerMgmt capability.
       
  3169 
       
  3170 @param s A C-style string.
       
  3171 
       
  3172 @see RProcess::HasCapability()
       
  3173 @see RThread::HasCapability()
       
  3174 @see RMessagePtr2::HasCapability()
       
  3175 @see User::CreatorHasCapability()
       
  3176 */
       
  3177 #define __PLATSEC_DIAGNOSTIC_STRING(s) s
       
  3178 
       
  3179 /**
       
  3180 When this value is used in Platform Security APIs as the value for the aDiagnosticText
       
  3181 argument, these APIs will not emit any form of diagnostic message.
       
  3182 @publishedPartner
       
  3183 @released
       
  3184 */
       
  3185 // Note this value is the same as KSuppressPlatSecDiagnosticMagicValue
       
  3186 // and used to be a set by it but that caused an error with GCCE compiler
       
  3187 static const char* const KSuppressPlatSecDiagnostic = (const char*)1;
       
  3188 
       
  3189 #else /* __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ */
       
  3190 
       
  3191 #define __PLATSEC_DIAGNOSTIC_STRING(s) NULL
       
  3192 
       
  3193 #ifndef __KERNEL_MODE__
       
  3194 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
       
  3195 /**
       
  3196 When this value is used in Platform Security APIs as the value for the aDiagnostic
       
  3197 argument, these APIs will not emit any form of diagnostic message.
       
  3198 @publishedPartner
       
  3199 @released
       
  3200 */
       
  3201 #define KSuppressPlatSecDiagnostic		NULL, NULL
       
  3202 
       
  3203 #else /* __REMOVE_PLATSEC_DIAGNOSTICS__ */
       
  3204 
       
  3205 /**
       
  3206 When this value is used in Platform Security APIs as the value for the aDiagnostic
       
  3207 argument, these APIs will not emit any form of diagnostic message.
       
  3208 @publishedPartner
       
  3209 @release
       
  3210 */
       
  3211 #define KSuppressPlatSecDiagnostic		NULL
       
  3212 
       
  3213 #endif /* !__REMOVE_PLATSEC_DIAGNOSTICS__ */
       
  3214 #endif /* !__KERNEL_MODE__ */
       
  3215 #endif /* !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ */
       
  3216 
       
  3217 /*
       
  3218  * MSVC operator new and operator new[] header guards
       
  3219  */
       
  3220 #ifdef __PLACEMENT_NEW
       
  3221 #define __PLACEMENT_NEW_INLINE
       
  3222 #endif /* __PLACEMENT_NEW */
       
  3223 
       
  3224 #if defined(__VC32__) && (_MSC_VER < 1300)
       
  3225 #define __PLACEMENT_VEC_NEW_INLINE
       
  3226 #endif /* version of MSVC that doesn't support overloaded operator new[] */
       
  3227 
       
  3228 /**
       
  3229 Calling convention qualifier for functions involving floating point 
       
  3230 variables passed or returned by value.
       
  3231 @publishedAll
       
  3232 @released
       
  3233 */
       
  3234 #ifndef __SOFTFP
       
  3235 #define __SOFTFP
       
  3236 #endif /* __SOFTFP */
       
  3237 
       
  3238 #endif /* __E32DEF_H__ */