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