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