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