kernel/eka/include/e32cmn.h
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
  1100 	IMPORT_C TBool IsMirrored() const;
  1100 	IMPORT_C TBool IsMirrored() const;
  1101 	IMPORT_C TInt GetNumericValue() const;
  1101 	IMPORT_C TInt GetNumericValue() const;
  1102 	IMPORT_C TCjkWidth GetCjkWidth() const;
  1102 	IMPORT_C TCjkWidth GetCjkWidth() const;
  1103 	IMPORT_C static TBool Compose(TUint& aResult,const TDesC16& aSource);
  1103 	IMPORT_C static TBool Compose(TUint& aResult,const TDesC16& aSource);
  1104 	IMPORT_C TBool Decompose(TPtrC16& aResult) const;
  1104 	IMPORT_C TBool Decompose(TPtrC16& aResult) const;
  1105 	
       
  1106 	// surrogate specific ones
       
  1107 	inline static TBool IsSupplementary(TUint aChar);
       
  1108 	inline static TBool IsSurrogate(TText16 aInt16);
       
  1109 	inline static TBool IsHighSurrogate(TText16 aInt16);
       
  1110 	inline static TBool IsLowSurrogate(TText16 aInt16);
       
  1111 	inline static TUint JoinSurrogate(TText16 aHighSurrogate, TText16 aLowSurrogate);
       
  1112 	inline static TText16 GetHighSurrogate(TUint aChar);
       
  1113 	inline static TText16 GetLowSurrogate(TUint aChar);
       
  1114 
  1105 
  1115 protected:
  1106 protected:
  1116 	inline void SetChar(TUint aChar);
  1107 	inline void SetChar(TUint aChar);
  1117 #endif
  1108 #endif
  1118 private:
  1109 private:
  1969 
  1960 
  1970 /**
  1961 /**
  1971 Structure for compile-time definition of a secure ID
  1962 Structure for compile-time definition of a secure ID
  1972 @internalComponent
  1963 @internalComponent
  1973 */
  1964 */
  1974 #if defined(__ARMCC__) && __ARMCC_VERSION >= 400000
       
  1975 #pragma push
       
  1976 #pragma diag_suppress 430 
       
  1977 #endif
       
  1978 class SSecureId
  1965 class SSecureId
  1979 	{
  1966 	{
  1980 public:
  1967 public:
  1981 	inline const TSecureId* operator&() const;
  1968 	inline const TSecureId* operator&() const;
  1982 	inline operator const TSecureId&() const;
  1969 	inline operator const TSecureId&() const;
  1983 	inline operator TUint32() const;
  1970 	inline operator TUint32() const;
  1984 	inline operator TUid() const;
  1971 	inline operator TUid() const;
  1985 public:
  1972 public:
  1986 	TUint32 iId;
  1973 	TUint32 iId;
  1987 	};
  1974 	};
  1988 #if defined(__ARMCC__) && __ARMCC_VERSION >= 400000	
  1975 
  1989 #pragma pop 	
       
  1990 #endif
       
  1991 
  1976 
  1992 	
  1977 	
  1993 	
  1978 	
  1994 /**
  1979 /**
  1995 Structure for compile-time definition of a vendor ID
  1980 Structure for compile-time definition of a vendor ID
  1996 @internalComponent
  1981 @internalComponent
  1997 */
  1982 */
  1998 #if defined(__ARMCC__) && __ARMCC_VERSION >= 400000
       
  1999 #pragma push
       
  2000 #pragma diag_suppress 430 
       
  2001 #endif
       
  2002 class SVendorId
  1983 class SVendorId
  2003 	{
  1984 	{
  2004 public:
  1985 public:
  2005 	inline const TVendorId* operator&() const;
  1986 	inline const TVendorId* operator&() const;
  2006 	inline operator const TVendorId&() const;
  1987 	inline operator const TVendorId&() const;
  2007 	inline operator TUint32() const;
  1988 	inline operator TUint32() const;
  2008 	inline operator TUid() const;
  1989 	inline operator TUid() const;
  2009 public:
  1990 public:
  2010 	TUint32 iId;
  1991 	TUint32 iId;
  2011 	};
  1992 	};
  2012 #if defined(__ARMCC__) && __ARMCC_VERSION >= 400000	
  1993 
  2013 #pragma pop 	
       
  2014 #endif
       
  2015 
  1994 
  2016 
  1995 
  2017 
  1996 
  2018 /**
  1997 /**
  2019 Macro for compile-time definition of a secure ID
  1998 Macro for compile-time definition of a secure ID
  2486 	IMPORT_C TInt OpenGlobal(const TDesC& aName,TOwnerType aType=EOwnerProcess);
  2465 	IMPORT_C TInt OpenGlobal(const TDesC& aName,TOwnerType aType=EOwnerProcess);
  2487 	IMPORT_C TInt Open(RMessagePtr2 aMessage,TInt aParam,TOwnerType aType=EOwnerProcess);
  2466 	IMPORT_C TInt Open(RMessagePtr2 aMessage,TInt aParam,TOwnerType aType=EOwnerProcess);
  2488 	IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess);
  2467 	IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess);
  2489 	IMPORT_C void Wait();
  2468 	IMPORT_C void Wait();
  2490 	IMPORT_C TInt Wait(TInt aTimeout);	// timeout in microseconds
  2469 	IMPORT_C TInt Wait(TInt aTimeout);	// timeout in microseconds
  2491 	IMPORT_C TInt Poll();		// acquire the semaphore if possible, but don't block
       
  2492 	IMPORT_C void Signal();
  2470 	IMPORT_C void Signal();
  2493 	IMPORT_C void Signal(TInt aCount);
  2471 	IMPORT_C void Signal(TInt aCount);
  2494 #endif
  2472 #endif
  2495 	};
  2473 	};
  2496 
  2474 
  2510 	{
  2488 	{
  2511 public:
  2489 public:
  2512 	inline RFastLock();
  2490 	inline RFastLock();
  2513 	IMPORT_C TInt CreateLocal(TOwnerType aType=EOwnerProcess);
  2491 	IMPORT_C TInt CreateLocal(TOwnerType aType=EOwnerProcess);
  2514 	IMPORT_C void Wait();
  2492 	IMPORT_C void Wait();
  2515 	IMPORT_C TInt Wait(TInt aTimeout);	// timeout in microseconds
       
  2516 	IMPORT_C TInt Poll();		// acquire the lock if possible, but don't block
       
  2517 	IMPORT_C void Signal();
  2493 	IMPORT_C void Signal();
  2518 private:
  2494 private:
  2519 	TInt iCount;
  2495 	TInt iCount;
  2520 	};
  2496 	};
  2521 
  2497 
  2652 Base class for heaps.
  2628 Base class for heaps.
  2653 */
  2629 */
  2654 class RAllocator : public MAllocator
  2630 class RAllocator : public MAllocator
  2655 	{
  2631 	{
  2656 public:
  2632 public:
  2657 	/**
  2633 
  2658 	A set of heap allocation failure flags.
  2634 
  2659 
  2635     /**
  2660 	This enumeration indicates how to simulate heap allocation failure.
  2636     A set of heap allocation failure flags.
  2661 
  2637     
  2662 	@see RAllocator::__DbgSetAllocFail()
  2638     This enumeration indicates how to simulate heap allocation failure.
  2663 	*/
  2639 
  2664 	enum TAllocFail
  2640     @see RAllocator::__DbgSetAllocFail()
  2665 		{
  2641     */
  2666 		/**
  2642 	enum TAllocFail {
  2667 		Attempts to allocate from this heap fail at a random rate;
  2643                     /**
  2668 		however, the interval pattern between failures is the same
  2644                     Attempts to allocate from this heap fail at a random rate;
  2669 		every time simulation is started.
  2645                     however, the interval pattern between failures is the same
  2670 		*/
  2646                     every time simulation is started.
  2671 		ERandom,
  2647                     */
  2672 
  2648 	                ERandom,
  2673 		/**
  2649 	                
  2674 		Attempts to allocate from this heap fail at a random rate.
  2650 	                
  2675 		The interval pattern between failures may be different every
  2651                   	/**
  2676 		time the simulation is started.
  2652                   	Attempts to allocate from this heap fail at a random rate.
  2677 		*/
  2653                   	The interval pattern between failures may be different every
  2678 		ETrueRandom,
  2654                   	time the simulation is started.
  2679 
  2655                   	*/
  2680 		/**
  2656 	                ETrueRandom,
  2681 		Attempts to allocate from this heap fail at a rate aRate;
  2657 	                
  2682 		for example, if aRate is 3, allocation fails at every
  2658 	                
  2683 		third attempt.
  2659                     /**
  2684 		*/
  2660                     Attempts to allocate from this heap fail at a rate aRate;
  2685 		EDeterministic,
  2661                     for example, if aRate is 3, allocation fails at every
  2686 
  2662                     third attempt.
  2687 		/**
  2663                     */
  2688 		Cancels simulated heap allocation failure.
  2664 	                EDeterministic,
  2689 		*/
  2665 
  2690 		ENone,
  2666 	                
  2691 
  2667 	                /**
  2692 		/**
  2668 	                Cancels simulated heap allocation failure.
  2693 		An allocation from this heap will fail after the next aRate - 1
  2669 	                */
  2694 		allocation attempts. For example, if aRate = 1 then the next
  2670 	                ENone,
  2695 		attempt to allocate from this heap will fail.
  2671 	                
  2696 		*/
  2672 	                
  2697 		EFailNext,
  2673 	                /**
  2698 
  2674 	                An allocation from this heap will fail after the next aRate - 1 
  2699 		/**
  2675 					allocation attempts. For example, if aRate = 1 then the next 
  2700 		Cancels simulated heap allocation failure, and sets
  2676 					attempt to allocate from this heap will fail.
  2701 		the nesting level for all allocated cells to zero.
  2677 	                */
  2702 		*/
  2678 	                EFailNext,
  2703 		EReset,
  2679 	                
  2704 
  2680 	                /**
  2705 		/**
  2681 	                Cancels simulated heap allocation failure, and sets
  2706 		aBurst allocations from this heap fail at a random rate;
  2682 	                the nesting level for all allocated cells to zero.
  2707 		however, the interval pattern between failures is the same
  2683 	                */
  2708 		every time the simulation is started.
  2684 	                EReset,
  2709 		*/
  2685 
  2710 		EBurstRandom,
  2686                     /**
  2711 
  2687                     aBurst allocations from this heap fail at a random rate;
  2712 		/**
  2688                     however, the interval pattern between failures is the same
  2713 		aBurst allocations from this heap fail at a random rate.
  2689                     every time the simulation is started.
  2714 		The interval pattern between failures may be different every
  2690                     */
  2715 		time the simulation is started.
  2691 	                EBurstRandom,
  2716 		*/
  2692 	                
  2717 		EBurstTrueRandom,
  2693 	                
  2718 
  2694                   	/**
  2719 		/**
  2695                   	aBurst allocations from this heap fail at a random rate.
  2720 		aBurst allocations from this heap fail at a rate aRate.
  2696                   	The interval pattern between failures may be different every
  2721 		For example, if aRate is 10 and aBurst is 2, then 2 allocations
  2697                   	time the simulation is started.
  2722 		will fail at every tenth attempt.
  2698                   	*/
  2723 		*/
  2699 	                EBurstTrueRandom,
  2724 		EBurstDeterministic,
  2700 	                
  2725 
  2701 	                
  2726 		/**
  2702                     /**
  2727 		aBurst allocations from this heap will fail after the next aRate - 1
  2703                     aBurst allocations from this heap fail at a rate aRate.
  2728 		allocation attempts have occurred. For example, if aRate = 1 and
  2704                     For example, if aRate is 10 and aBurst is 2, then 2 allocations
  2729 		aBurst = 3 then the next 3 attempts to allocate from this heap will fail.
  2705 					will fail at every tenth attempt.
  2730 		*/
  2706                     */
  2731 		EBurstFailNext,
  2707 	                EBurstDeterministic,
  2732 
  2708 
  2733 		/**
  2709 	                /**
  2734 		Use this to determine how many times the current debug
  2710 	                aBurst allocations from this heap will fail after the next aRate - 1 
  2735 		failure mode has failed so far.
  2711 					allocation attempts have occurred. For example, if aRate = 1 and 
  2736 		@see RAllocator::__DbgCheckFailure()
  2712 					aBurst = 3 then the next 3 attempts to allocate from this heap will fail.
  2737 		*/
  2713 	                */
  2738 		ECheckFailure,
  2714 	                EBurstFailNext,
  2739 		};
  2715 
  2740 
  2716 					/**
  2741 	/**
  2717 					Use this to determine how many times the current debug 
  2742 	Heap debug checking type flag.
  2718 					failure mode has failed so far.
  2743 	*/
  2719 					@see RAllocator::__DbgCheckFailure()
  2744 	enum TDbgHeapType
  2720 					*/
  2745 		{
  2721 					ECheckFailure,
  2746 		/**
  2722 	                };
  2747 		The heap is a user heap.
  2723 	                
  2748 		*/
  2724 	                
  2749 		EUser,
  2725     /**
  2750 
  2726     Heap debug checking type flag.
  2751 		/**
  2727     */
  2752 		The heap is the Kernel heap.
  2728 	enum TDbgHeapType {
  2753 		*/
  2729                       /**
  2754 		EKernel
  2730                       The heap is a user heap.
  2755 		};
  2731                       */
  2756 
  2732 	                  EUser,
  2757 	enum TAllocDebugOp
  2733 	                  
  2758 		{
  2734                       /**
  2759 		ECount, EMarkStart, EMarkEnd, ECheck, ESetFail, ECopyDebugInfo, ESetBurstFail, EGetFail,
  2735                       The heap is the Kernel heap.
  2760 		EGetSize=48, EGetMaxLength, EGetBase, EAlignInteger, EAlignAddr
  2736                       */	                  
  2761 		};
  2737 	                  EKernel
  2762 
  2738 	                  };
       
  2739 	                  
       
  2740 	                  
       
  2741 	enum TAllocDebugOp {ECount, EMarkStart, EMarkEnd, ECheck, ESetFail, ECopyDebugInfo, ESetBurstFail};
       
  2742 	
       
  2743 	
  2763 	/**
  2744 	/**
  2764 	Flags controlling reallocation.
  2745 	Flags controlling reallocation.
  2765 	*/
  2746 	*/
  2766 	enum TReAllocMode
  2747 	enum TReAllocMode {
  2767 		{
  2748 	                  /**
  2768 		/**
  2749 	                  A reallocation of a cell must not change
  2769 		A reallocation of a cell must not change
  2750 	                  the start address of the cell.
  2770 		the start address of the cell.
  2751 	                  */
  2771 		*/
  2752 	                  ENeverMove=1,
  2772 		ENeverMove=1,
  2753 	                  
  2773 
  2754 	                  /**
  2774 		/**
  2755 	                  Allows the start address of the cell to change
  2775 		Allows the start address of the cell to change
  2756 	                  if the cell shrinks in size.
  2776 		if the cell shrinks in size.
  2757 	                  */
  2777 		*/
  2758 	                  EAllowMoveOnShrink=2
  2778 		EAllowMoveOnShrink=2
  2759 	                  };
  2779 		};
  2760 	                  
  2780 
  2761 	                  
  2781 	enum TFlags {ESingleThreaded=1, EFixedSize=2, ETraceAllocs=4, EMonitorMemory=8,};
  2762 	enum TFlags {ESingleThreaded=1, EFixedSize=2, ETraceAllocs=4, EMonitorMemory=8,};
  2782 	struct SCheckInfo {TBool iAll; TInt iCount; const TDesC8* iFileName; TInt iLineNum;};
  2763 	struct SCheckInfo {TBool iAll; TInt iCount; const TDesC8* iFileName; TInt iLineNum;};
  2783 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
  2764 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
  2784 	struct SRAllocatorBurstFail {TInt iBurst; TInt iRate; TInt iUnused[2];};
  2765 	struct SRAllocatorBurstFail {TInt iBurst; TInt iRate; TInt iUnused[2];};
  2785 #endif
  2766 #endif
  2803 	UIMPORT_C void __DbgMarkStart();
  2784 	UIMPORT_C void __DbgMarkStart();
  2804 	UIMPORT_C TUint32 __DbgMarkEnd(TInt aCount);
  2785 	UIMPORT_C TUint32 __DbgMarkEnd(TInt aCount);
  2805 	UIMPORT_C TInt __DbgMarkCheck(TBool aCountAll, TInt aCount, const TDesC8& aFileName, TInt aLineNum);
  2786 	UIMPORT_C TInt __DbgMarkCheck(TBool aCountAll, TInt aCount, const TDesC8& aFileName, TInt aLineNum);
  2806 	inline void __DbgMarkCheck(TBool aCountAll, TInt aCount, const TUint8* aFileName, TInt aLineNum);
  2787 	inline void __DbgMarkCheck(TBool aCountAll, TInt aCount, const TUint8* aFileName, TInt aLineNum);
  2807 	UIMPORT_C void __DbgSetAllocFail(TAllocFail aType, TInt aRate);
  2788 	UIMPORT_C void __DbgSetAllocFail(TAllocFail aType, TInt aRate);
  2808 	UIMPORT_C TAllocFail __DbgGetAllocFail();
       
  2809 	UIMPORT_C void __DbgSetBurstAllocFail(TAllocFail aType, TUint aRate, TUint aBurst);
  2789 	UIMPORT_C void __DbgSetBurstAllocFail(TAllocFail aType, TUint aRate, TUint aBurst);
  2810 	UIMPORT_C TUint __DbgCheckFailure();
  2790 	UIMPORT_C TUint __DbgCheckFailure();
  2811 	UIMPORT_C TInt Size() const;
       
  2812 	UIMPORT_C TInt MaxLength() const;
       
  2813 	UIMPORT_C TUint8* Base() const;
       
  2814 	UIMPORT_C TInt Align(TInt a) const;
       
  2815 	UIMPORT_C TAny* Align(TAny* a) const;
       
  2816 
       
  2817 protected:
  2791 protected:
  2818 	UIMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
  2792 	UIMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
  2819 #ifndef __KERNEL_MODE__
  2793 #ifndef __KERNEL_MODE__
  2820 	IMPORT_C virtual void DoClose();
  2794 	IMPORT_C virtual void DoClose();
  2821 #endif
  2795 #endif
  2822 
       
  2823 protected:
  2796 protected:
  2824 	TInt	iAccessCount;		// Value of the allocator's access count (ie. Number of times RAllocator::Open() has been called)
  2797 	TInt iAccessCount;
  2825 	TInt	iHandleCount;		// Number of handles in the iHandles array
  2798 	TInt iHandleCount;
  2826 	TInt*	iHandles;			// Array of handles to chunks used by the heap implementation
  2799 	TInt* iHandles;
  2827 	TUint32	iFlags;				// Flags describing attributes of the heap; see RAllocator::TFlags
  2800 	TUint32 iFlags;
  2828 	TInt	iCellCount;			// Internal debugger use only; use MAllocator::AllocSize() instead
  2801 	TInt iCellCount;
  2829 	TInt	iTotalAllocSize;	// Internal debugger use only; use MAllocator::AllocSize() instead
  2802 	TInt iTotalAllocSize;
  2830 	};
  2803 	};
  2831 
  2804 
       
  2805 
       
  2806 
       
  2807 
  2832 class UserHeap;
  2808 class UserHeap;
  2833 
       
  2834 // This #define is for tools such as MemSpy that need to work across different versions of
       
  2835 // Symbian and need to know whether they are working with the new or old heap
       
  2836 
       
  2837 #define __SYMBIAN_KERNEL_HYBRID_HEAP__
       
  2838 
       
  2839 /**
  2809 /**
  2840 @publishedAll
  2810 @publishedAll
  2841 @released
  2811 @released
  2842 
  2812 
  2843 Represents the default implementation for a heap.
  2813 Represents the default implementation for a heap.
  2844 
  2814 
  2845 The default implementation uses an address-ordered first fit type algorithm.
  2815 The default implementation uses an address-ordered first fit type algorithm.
  2846 
  2816 
  2847 The heap itself is contained in a chunk and may be the only occupant of the
  2817 The heap itself is contained in a chunk and may be the only occupant of the 
  2848 chunk or may share the chunk with the program stack.
  2818 chunk or may share the chunk with the program stack.
  2849 
  2819 
  2850 The class contains member functions for allocating, adjusting, freeing individual
  2820 The class contains member functions for allocating, adjusting, freeing individual 
  2851 cells and generally managing the heap.
  2821 cells and generally managing the heap.
  2852 
  2822 
  2853 The class is not a handle in the same sense that RChunk is a handle; i.e.
  2823 The class is not a handle in the same sense that RChunk is a handle; i.e. 
  2854 there is no Kernel object which corresponds to the heap.
  2824 there is no Kernel object which corresponds to the heap.
  2855 */
  2825 */
  2856 
       
  2857 class RHeap : public RAllocator
  2826 class RHeap : public RAllocator
  2858 	{
  2827 	{
  2859 public:
  2828 public:
  2860 
  2829     /**
       
  2830     The structure of a heap cell header for a heap cell on the free list.
       
  2831     */
       
  2832 	struct SCell {
       
  2833 	             /**
       
  2834 	             The length of the cell, which includes the length of
       
  2835 	             this header.
       
  2836 	             */
       
  2837 	             TInt len; 
       
  2838 	             
       
  2839 	             
       
  2840 	             /**
       
  2841 	             A pointer to the next cell in the free list.
       
  2842 	             */
       
  2843 	             SCell* next;
       
  2844 	             };
       
  2845 
       
  2846 
       
  2847 	/**
       
  2848     The structure of a heap cell header for an allocated heap cell in a debug build.
       
  2849     */             
       
  2850 	struct SDebugCell {
       
  2851 	                  /**
       
  2852 	                  The length of the cell, which includes the length of
       
  2853                       this header.
       
  2854 	                  */
       
  2855 	                  TInt len;
       
  2856 	                  
       
  2857 	                  
       
  2858 	                  /**
       
  2859 	                  The nested level.
       
  2860 	                  */
       
  2861 	                  TInt nestingLevel;
       
  2862 	                  
       
  2863 	                  
       
  2864 	                  /**
       
  2865 	                  The cumulative number of allocated cells
       
  2866 	                  */
       
  2867 	                  TInt allocCount;
       
  2868 	                  };
       
  2869 
       
  2870 	/**
       
  2871     @internalComponent
       
  2872     */
       
  2873 	struct SHeapCellInfo { RHeap* iHeap; TInt iTotalAlloc;	TInt iTotalAllocSize; TInt iTotalFree; TInt iLevelAlloc; SDebugCell* iStranded; };
       
  2874 
       
  2875 	/**
       
  2876 	@internalComponent
       
  2877 	*/
       
  2878 	struct _s_align {char c; double d;};
       
  2879 
       
  2880 	/** 
       
  2881 	The default cell alignment.
       
  2882 	*/
       
  2883 	enum {ECellAlignment = sizeof(_s_align)-sizeof(double)};
       
  2884 	
       
  2885 	/**
       
  2886 	Size of a free cell header.
       
  2887 	*/
       
  2888 	enum {EFreeCellSize = sizeof(SCell)};
       
  2889 
       
  2890 
       
  2891 #ifdef _DEBUG
       
  2892     /**
       
  2893     Size of an allocated cell header in a debug build.
       
  2894     */
       
  2895 	enum {EAllocCellSize = sizeof(SDebugCell)};
       
  2896 #else
       
  2897     /**
       
  2898     Size of an allocated cell header in a release build.
       
  2899     */
       
  2900 	enum {EAllocCellSize = sizeof(SCell*)};
       
  2901 #endif
       
  2902 
       
  2903 
       
  2904     /**
       
  2905     @internalComponent
       
  2906     */
       
  2907 	enum TDebugOp {EWalk=128};
       
  2908 	
       
  2909 	
       
  2910     /**
       
  2911     @internalComponent
       
  2912     */
       
  2913 	enum TCellType
       
  2914 		{EGoodAllocatedCell, EGoodFreeCell, EBadAllocatedCellSize, EBadAllocatedCellAddress,
       
  2915 		EBadFreeCellAddress, EBadFreeCellSize};
       
  2916 
       
  2917 		
       
  2918     /**
       
  2919     @internalComponent
       
  2920     */
       
  2921 	enum TDebugHeapId {EUser=0, EKernel=1};
       
  2922     
       
  2923     /**
       
  2924     @internalComponent
       
  2925     */
       
  2926     enum TDefaultShrinkRatios {EShrinkRatio1=256, EShrinkRatioDflt=512};
       
  2927 
       
  2928 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
  2929 	/**
       
  2930     @internalComponent
       
  2931     */
       
  2932 #else
       
  2933 private:
       
  2934 #endif
       
  2935     typedef void (*TWalkFunc)(TAny*, TCellType, TAny*, TInt);
       
  2936 
       
  2937 public:
  2861 	UIMPORT_C virtual TAny* Alloc(TInt aSize);
  2938 	UIMPORT_C virtual TAny* Alloc(TInt aSize);
  2862 	UIMPORT_C virtual void Free(TAny* aPtr);
  2939 	UIMPORT_C virtual void Free(TAny* aPtr);
  2863 	UIMPORT_C virtual TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode=0);
  2940 	UIMPORT_C virtual TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode=0);
  2864 	UIMPORT_C virtual TInt AllocLen(const TAny* aCell) const;
  2941 	UIMPORT_C virtual TInt AllocLen(const TAny* aCell) const;
  2865 #ifndef __KERNEL_MODE__
  2942 #ifndef __KERNEL_MODE__
  2869 	UIMPORT_C virtual TInt Available(TInt& aBiggestBlock) const;
  2946 	UIMPORT_C virtual TInt Available(TInt& aBiggestBlock) const;
  2870 #endif
  2947 #endif
  2871 	UIMPORT_C virtual TInt DebugFunction(TInt aFunc, TAny* a1=NULL, TAny* a2=NULL);
  2948 	UIMPORT_C virtual TInt DebugFunction(TInt aFunc, TAny* a1=NULL, TAny* a2=NULL);
  2872 protected:
  2949 protected:
  2873 	UIMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
  2950 	UIMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
  2874 	inline RHeap() { }
  2951 public:
  2875 
  2952 	UIMPORT_C RHeap(TInt aMaxLength, TInt aAlign=0, TBool aSingleThread=ETrue);
  2876 public:
  2953 	UIMPORT_C RHeap(TInt aChunkHandle, TInt aOffset, TInt aMinLength, TInt aMaxLength, TInt aGrowBy, TInt aAlign=0, TBool aSingleThread=EFalse);
  2877 
  2954 	UIMPORT_C TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW;
  2878 	/**
  2955 	inline void operator delete(TAny* aPtr, TAny* aBase);
  2879 	@internalComponent
  2956 	inline TUint8* Base() const;
  2880 
  2957 	inline TInt Size() const;
  2881 	The structure of a heap cell header for an allocated heap cell in a debug build.
  2958 	inline TInt MaxLength() const;
  2882 	*/
  2959 	inline TInt Align(TInt a) const;
  2883 	struct SDebugCell
  2960 	inline const TAny* Align(const TAny* a) const;
  2884 		{
  2961 	inline TBool IsLastCell(const SCell* aCell) const;
  2885 		/**
  2962 	inline void Lock() const;
  2886 		The nested level.
  2963 	inline void Unlock() const;
  2887 		*/
  2964 	inline TInt ChunkHandle() const;
  2888 		TInt nestingLevel;
       
  2889 
       
  2890 		/**
       
  2891 		The cumulative number of allocated cells
       
  2892 		*/
       
  2893 		TInt allocCount;
       
  2894 		};
       
  2895 
       
  2896 	/**
       
  2897 	@internalComponent
       
  2898 	*/
       
  2899 	struct SHeapCellInfo { RHeap* iHeap; TInt iTotalAlloc;	TInt iTotalAllocSize; TInt iTotalFree; TInt iLevelAlloc; SDebugCell* iStranded; };
       
  2900 
       
  2901 	/**
       
  2902 	Size of a free cell header.
       
  2903 	*/
       
  2904 	enum { EDebugHdrSize = sizeof(SDebugCell) };
       
  2905 
       
  2906 	/**
       
  2907 	The default cell alignment.
       
  2908 	*/
       
  2909 	enum { ECellAlignment = 8 };
       
  2910 
       
  2911 	/**
       
  2912 	Size of a free cell header.
       
  2913 	*/
       
  2914 	enum { EFreeCellSize = 4 };
       
  2915 
       
  2916 #ifdef _DEBUG
       
  2917 	/**
       
  2918 	Size of an allocated cell header in a debug build.
       
  2919 	*/
       
  2920 	enum { EAllocCellSize = (4 + EDebugHdrSize) };
       
  2921 #else
       
  2922 	/**
       
  2923 	Size of an allocated cell header in a release build.
       
  2924 	*/
       
  2925 	enum { EAllocCellSize = 4 };
       
  2926 #endif
       
  2927 
       
  2928 	/**
       
  2929 	@internalComponent
       
  2930 	*/
       
  2931 	enum TDebugOp { EWalk = 128, EHybridHeap };
       
  2932 
       
  2933 	/**
       
  2934 	@internalComponent
       
  2935 	*/
       
  2936 	enum TCellType
       
  2937 		{
       
  2938 		EGoodAllocatedCell, EGoodFreeCell, EBadAllocatedCellSize, EBadAllocatedCellAddress,
       
  2939 		EBadFreeCellAddress, EBadFreeCellSize
       
  2940 		};
       
  2941 
       
  2942 	/**
       
  2943 	@internalComponent
       
  2944 	*/
       
  2945 	enum TDebugHeapId { EUser = 0, EKernel = 1 };
       
  2946 
       
  2947 	/**
       
  2948 	@internalComponent
       
  2949 	*/
       
  2950 	enum TDefaultShrinkRatios { EShrinkRatio1 = 256, EShrinkRatioDflt = 512 };
       
  2951 
       
  2952 	/**
       
  2953 	@internalComponent
       
  2954 	*/
       
  2955 	typedef void (*TWalkFunc)(TAny*, TCellType, TAny*, TInt);
       
  2956 
       
  2957 protected:
  2965 protected:
  2958 
  2966 	inline RHeap();
  2959 	// These variables are present only for downwards binary compatibility.  Most are unused,
  2967 	void Initialise();
  2960 	// but some must be present so that previously inline functions continue to work.  These
  2968 	SCell* DoAlloc(TInt aSize, SCell*& aLastFree);
  2961 	// old inline functions are now replaced with non inline versions so recompiling existing
  2969 	void DoFree(SCell* pC);
  2962 	// code will automatically switch to the new versions and you should no longer access any
  2970 	TInt TryToGrowHeap(TInt aSize, SCell* aLastFree);
  2963 	// of the variables in here.
  2971 	inline void FindFollowingFreeCell(SCell* aCell, SCell*& pPrev, SCell*& aNext);
  2964 	//
  2972 	TInt TryToGrowCell(SCell* pC, SCell* pP, SCell* pE, TInt aSize);
  2965 	// These variables should now all be considered private and should NOT be accessed directly!
  2973 	TInt Reduce(SCell* aCell);
  2966 	//
  2974 	UIMPORT_C SCell* GetAddress(const TAny* aCell) const;
  2967 	TInt		iUnused1;		// Present for binary compatibility reasons only
  2975 	void CheckCell(const SCell* aCell) const;
  2968 	TInt		iMaxLength;		// Use RAllocator::MaxLength() to get this information now
  2976 	void Walk(TWalkFunc aFunc, TAny* aPtr);
  2969 	TInt		iUnused2;		// Present for binary compatibility reasons only
  2977 	static void WalkCheckCell(TAny* aPtr, TCellType aType, TAny* aCell, TInt aLen);
  2970 	TInt		iUnused3;		// Present for binary compatibility reasons only
  2978 	TInt DoCountAllocFree(TInt& aFree);
  2971 	// These next two variables must remain in this order for correct object destruction
  2979 	TInt DoCheckHeap(SCheckInfo* aInfo);
  2972 	TInt		iChunkHandle;	// Do not use; consider undocumented
  2980 	void DoMarkStart();
  2973 	RFastLock	iLock;			// Do not use; consider undocumented
  2981 	TUint32 DoMarkEnd(TInt aExpected);
  2974 	TUint8*		iBase;			// Use RAllocator::Base() to get this information now
  2982 	void DoSetAllocFail(TAllocFail aType, TInt aRate);
  2975 	TUint8*		iTop;			// Do not use; consider undocumented
  2983 	TBool CheckForSimulatedAllocFail();
  2976 	TInt		iAlign;			// Use RAllocator::Align() to get this information now
  2984 	inline TInt SetBrk(TInt aBrk);
  2977 
  2985 	inline TAny* ReAllocImpl(TAny* aPtr, TInt aSize, TInt aMode);
  2978 	// These variables are temporary to prevent source breaks from req417-52840.  They are deprecated in
  2986 	void DoSetAllocFail(TAllocFail aType, TInt aRate, TUint aBurst);
  2979 	// favour of non hacky ways of determining this information but are required during the switchover to
  2987 protected:
  2980 	// this method
  2988 	TInt iMinLength;
  2981 	TAllocFail	iFailType;		// Use RAllocator::__DbgGetAllocFail() to get this information now
  2989 	TInt iMaxLength;
  2982 	TInt		iNestingLevel;	// Do not use; consider undocumented
  2990 	TInt iOffset;
  2983 	TAny*		iTestData;		// Do not use; consider undocumented
  2991 	TInt iGrowBy;
       
  2992 	TInt iChunkHandle;
       
  2993 	RFastLock iLock;
       
  2994 	TUint8* iBase;
       
  2995 	TUint8* iTop;
       
  2996 	TInt iAlign;
       
  2997 	TInt iMinCell;
       
  2998 	TInt iPageSize;
       
  2999 	SCell iFree;
       
  3000 protected:
       
  3001 	TInt iNestingLevel;
       
  3002 	TInt iAllocCount;
       
  3003 	TAllocFail iFailType;
       
  3004 	TInt iFailRate;
       
  3005 	TBool iFailed;
       
  3006 	TInt iFailAllocCount;
       
  3007 	TInt iRand;
       
  3008 	TAny* iTestData;
  2984 
  3009 
  2985 	friend class UserHeap;
  3010 	friend class UserHeap;
  2986 	};
  3011 	};
       
  3012 
       
  3013 
       
  3014 
       
  3015 
  2987 
  3016 
  2988 class OnlyCreateWithNull;
  3017 class OnlyCreateWithNull;
  2989 
  3018 
  2990 /** @internalTechnology */
  3019 /** @internalTechnology */
  2991 typedef void (OnlyCreateWithNull::* __NullPMF)();
  3020 typedef void (OnlyCreateWithNull::* __NullPMF)();
  3846 @param i2 The second TUint8
  3875 @param i2 The second TUint8
  3847 @param i3 The third TUint8
  3876 @param i3 The third TUint8
  3848 @param i4 The fourth TUint8
  3877 @param i4 The fourth TUint8
  3849 @internalComponent
  3878 @internalComponent
  3850 */
  3879 */
  3851 #define FOUR_TUINT8(i1,i2,i3,i4)		  \
  3880 #define FOUR_TUINT8(i1,i2,i3,i4) \
  3852 	(									  \
  3881 	(TUint32)(				\
  3853 		(TUint32)((i1) & 0xFF)			| \
  3882 		(TUint8)i1 		 | 	\
  3854 		(TUint32)((i2) & 0xFF) << 8		| \
  3883 		(TUint8)i2 << 8  | 	\
  3855 		(TUint32)((i3) & 0xFF) << 16	| \
  3884 		(TUint8)i3 << 16 | 	\
  3856 		(TUint32)((i4) & 0xFF) << 24	  \
  3885 		(TUint8)i4 << 24	\
  3857 	)
  3886 	)
  3858 
  3887 
  3859 
  3888 
  3860 /** Macro for compile-time initialisation of a security policy object that
  3889 /** Macro for compile-time initialisation of a security policy object that
  3861 always fails.  That is, checks against this policy will always fail,
  3890 always fails.  That is, checks against this policy will always fail,