summaryrefslogtreecommitdiffstats
path: root/src/corelib/arch/symbian
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2010-09-24 13:18:21 +0100
committermread <qt-info@nokia.com>2010-09-30 15:48:34 +0100
commit91b7fef1dff86eac3e210a322208405b44f5c580 (patch)
tree1da69cf830816926e86b19de1f0f2f90ebbc9316 /src/corelib/arch/symbian
parentfb072fde30ec17d3a25b1535de82252579b81113 (diff)
getting fast allocator to compile on S60 5.0 SDK
This change adds flagging and definitions necessary to get the fast allocator compiling on 5.0 Task-number: QT-3967 Reviewed-by: Shane Kearns
Diffstat (limited to 'src/corelib/arch/symbian')
-rw-r--r--src/corelib/arch/symbian/arch.pri3
-rw-r--r--src/corelib/arch/symbian/common_p.h3
-rw-r--r--src/corelib/arch/symbian/debugfunction.cpp13
-rw-r--r--src/corelib/arch/symbian/heap_hybrid.cpp17
-rw-r--r--src/corelib/arch/symbian/heap_hybrid_p.h9
-rw-r--r--src/corelib/arch/symbian/qt_hybridHeap_symbian_p.h79
6 files changed, 110 insertions, 14 deletions
diff --git a/src/corelib/arch/symbian/arch.pri b/src/corelib/arch/symbian/arch.pri
index a10fefea60..70daee30d8 100644
--- a/src/corelib/arch/symbian/arch.pri
+++ b/src/corelib/arch/symbian/arch.pri
@@ -14,4 +14,5 @@ HEADERS += $$QT_ARCH_CPP/dla_p.h \
$$QT_ARCH_CPP/slab_p.h \
$$QT_ARCH_CPP/qt_hybridHeap_symbian_p.h
-exists($$EPOCROOT/epoc32/include/u32std.h):DEFINES += QT_SYMBIAN_HAVE_U32STD_H
+exists($${EPOCROOT}epoc32/include/platform/u32std.h):DEFINES += QT_SYMBIAN_HAVE_U32STD_H
+exists($${EPOCROOT}epoc32/include/platform/e32btrace.h):DEFINES += QT_SYMBIAN_HAVE_E32BTRACE_H
diff --git a/src/corelib/arch/symbian/common_p.h b/src/corelib/arch/symbian/common_p.h
index 4b1c64e411..1076621433 100644
--- a/src/corelib/arch/symbian/common_p.h
+++ b/src/corelib/arch/symbian/common_p.h
@@ -56,9 +56,6 @@
#include <e32panic.h>
// backport of Symbian^4 allocator to Symbian^3 SDK does not contain u32exec.h
//#include <u32exec.h>
-// but the following are needed
-#include <u32std.h>
-#include <e32btrace.h>
#endif
GLREF_C void Panic(TCdtPanic aPanic);
diff --git a/src/corelib/arch/symbian/debugfunction.cpp b/src/corelib/arch/symbian/debugfunction.cpp
index 12ffcd3119..ecffc64585 100644
--- a/src/corelib/arch/symbian/debugfunction.cpp
+++ b/src/corelib/arch/symbian/debugfunction.cpp
@@ -42,11 +42,18 @@
#include "qt_hybridheap_symbian_p.h"
#ifdef QT_USE_NEW_SYMBIAN_ALLOCATOR
+#define RAllocator RHybridHeap
#define GM (&iGlobalMallocState)
+#ifdef ENABLE_BTRACE
#define __HEAP_CORRUPTED_TRACE(t,p,l) BTraceContext12(BTrace::EHeap, BTrace::EHeapCorruption, (TUint32)t, (TUint32)p, (TUint32)l);
#define __HEAP_CORRUPTED_TEST(c,x, p,l) if (!c) { if (iFlags & (EMonitorMemory+ETraceAllocs) ) __HEAP_CORRUPTED_TRACE(this,p,l) HEAP_PANIC(x); }
#define __HEAP_CORRUPTED_TEST_STATIC(c,t,x,p,l) if (!c) { if (t && (t->iFlags & (EMonitorMemory+ETraceAllocs) )) __HEAP_CORRUPTED_TRACE(t,p,l) HEAP_PANIC(x); }
+#else
+#define __HEAP_CORRUPTED_TRACE(t,p,l)
+#define __HEAP_CORRUPTED_TEST(c,x, p,l)
+#define __HEAP_CORRUPTED_TEST_STATIC(c,t,x,p,l)
+#endif
TInt RHybridHeap::DebugFunction(TInt aFunc, TAny* a1, TAny* a2)
{
@@ -79,11 +86,9 @@ TInt RHybridHeap::DebugFunction(TInt aFunc, TAny* a1, TAny* a2)
__DEBUG_ONLY(DoSetAllocFail((TAllocFail)(TInt)a1, (TInt)a2));
break;
-#ifndef SYMBIAN4_ALLOCATOR_UNWANTED_CODE
case RAllocator::EGetFail:
__DEBUG_ONLY(r = iFailType);
break;
-#endif // SYMBIAN4_ALLOCATOR_UNWANTED_CODE
case RAllocator::ESetBurstFail:
#if _DEBUG
@@ -107,7 +112,6 @@ TInt RHybridHeap::DebugFunction(TInt aFunc, TAny* a1, TAny* a2)
break;
}
-#ifndef SYMBIAN4_ALLOCATOR_UNWANTED_CODE
case RAllocator::EGetSize:
{
r = iChunkSize - sizeof(RHybridHeap);
@@ -193,8 +197,7 @@ TInt RHybridHeap::DebugFunction(TInt aFunc, TAny* a1, TAny* a2)
break;
}
#endif // __KERNEL_MODE
-#endif // SYMBIAN4_ALLOCATOR_UNWANTED_CODE
-
+
default:
return KErrNotSupported;
diff --git a/src/corelib/arch/symbian/heap_hybrid.cpp b/src/corelib/arch/symbian/heap_hybrid.cpp
index 2471f7957b..1be3cf5a80 100644
--- a/src/corelib/arch/symbian/heap_hybrid.cpp
+++ b/src/corelib/arch/symbian/heap_hybrid.cpp
@@ -43,9 +43,6 @@
#ifdef QT_USE_NEW_SYMBIAN_ALLOCATOR
-// enables btrace code compiling into
-#define ENABLE_BTRACE
-
// if non zero this causes the iSlabs to be configured only when the chunk size exceeds this level
#define DELAYED_SLAB_THRESHOLD (64*1024) // 64KB seems about right based on trace data
#define SLAB_CONFIG 0xabe // Use slabs of size 48, 40, 32, 24, 20, 16, 12, and 8 bytes
@@ -95,6 +92,7 @@
#define __INIT_COUNTERS(i) iCellCount=i,iTotalAllocSize=i
#define __POWER_OF_2(x) (!((x)&((x)-1)))
+#ifdef ENABLE_BTRACE
#define __DL_BFR_CHECK(M,P) \
if ( MEMORY_MONITORED ) \
if ( !IS_ALIGNED(P) || ((TUint8*)(P)<M->iSeg.iBase) || ((TUint8*)(P)>(M->iSeg.iBase+M->iSeg.iSize))) \
@@ -114,6 +112,11 @@
BTraceContext12(BTrace::EHeap, BTrace::EHeapCorruption, (TUint32)this, (TUint32)P, (TUint32)0), HEAP_PANIC(ETHeapBadCellAddress)
#endif
+#else
+#define __DL_BFR_CHECK(M,P)
+#define __SLAB_BFR_CHECK(S,P,B)
+#define __PAGE_BFR_CHECK(P)
+#endif
#ifdef _MSC_VER
// This is required while we are still using VC6 to compile, so as to avoid warnings that cannot be fixed
@@ -2832,6 +2835,7 @@ inline void* RHybridHeap::Bitmap2addr(unsigned pos) const
{ return iMemBase + (1 << (PAGESHIFT-1))*pos; }
+#ifndef QT_SYMBIAN4_ALLOCATOR_UNWANTED_CODE
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@@ -3070,6 +3074,7 @@ Note that the size of the heap cannot be adjusted by more than aMaxLength.
return ChunkHeap(createInfo);
}
+#endif // QT_SYMBIAN4_ALLOCATOR_UNWANTED_CODE
EXPORT_C RHeap* UserHeap::ChunkHeap(RChunk aChunk, TInt aMinLength, TInt aGrowBy, TInt aMaxLength, TInt aAlign, TBool aSingleThread, TUint32 aMode)
/**
@@ -3279,8 +3284,10 @@ EXPORT_C TInt UserHeap::CreateThreadHeap(SStdEpocThreadCreateInfo& aInfo, RHeap*
GET_PAGE_SIZE(page_size);
TInt minLength = _ALIGN_UP(aInfo.iHeapInitialSize, page_size);
TInt maxLength = Max(aInfo.iHeapMaxSize, minLength);
+#ifndef QT_SYMBIAN4_ALLOCATOR_UNWANTED_CODE
if (UserTestDebugMaskBit(96)) // 96 == KUSERHEAPTRACE in nk_trace.h
aInfo.iFlags |= ETraceHeapAllocs;
+#endif // QT_SYMBIAN4_ALLOCATOR_UNWANTED_CODE
// Create the thread's heap chunk.
RChunk c;
TChunkCreateInfo createInfo;
@@ -3293,6 +3300,7 @@ EXPORT_C TInt UserHeap::CreateThreadHeap(SStdEpocThreadCreateInfo& aInfo, RHeap*
maxLength = 2*maxLength;
createInfo.SetDisconnected(0, 0, maxLength);
#endif
+#ifndef QT_SYMBIAN4_ALLOCATOR_UNWANTED_CODE
// Set the paging policy of the heap chunk based on the thread's paging policy.
TUint pagingflags = aInfo.iFlags & EThreadCreateFlagPagingMask;
switch (pagingflags)
@@ -3308,6 +3316,7 @@ EXPORT_C TInt UserHeap::CreateThreadHeap(SStdEpocThreadCreateInfo& aInfo, RHeap*
// paging policy is used.
break;
}
+#endif // QT_SYMBIAN4_ALLOCATOR_UNWANTED_CODE
TInt r = c.Create(createInfo);
if (r!=KErrNone)
@@ -3319,6 +3328,7 @@ EXPORT_C TInt UserHeap::CreateThreadHeap(SStdEpocThreadCreateInfo& aInfo, RHeap*
if ( !aHeap )
return KErrNoMemory;
+#ifdef ENABLE_BTRACE
if (aInfo.iFlags & ETraceHeapAllocs)
{
aHeap->iFlags |= RHeap::ETraceAllocs;
@@ -3328,6 +3338,7 @@ EXPORT_C TInt UserHeap::CreateThreadHeap(SStdEpocThreadCreateInfo& aInfo, RHeap*
}
if (aInfo.iFlags & EMonitorHeapMemory)
aHeap->iFlags |= RHeap::EMonitorMemory;
+#endif // ENABLE_BTRACE
return KErrNone;
}
diff --git a/src/corelib/arch/symbian/heap_hybrid_p.h b/src/corelib/arch/symbian/heap_hybrid_p.h
index b76541784f..467bd694ec 100644
--- a/src/corelib/arch/symbian/heap_hybrid_p.h
+++ b/src/corelib/arch/symbian/heap_hybrid_p.h
@@ -94,8 +94,15 @@ class RHybridHeap : public RHeap
{
public:
- // declaration copied from RHeap to make it visible
+ // declarations copied from Symbian^4 RAllocator and RHeap
typedef void (*TWalkFunc)(TAny*, RHeap::TCellType, TAny*, TInt);
+ enum TFlags {ESingleThreaded=1, EFixedSize=2, ETraceAllocs=4, EMonitorMemory=8,};
+ enum TAllocDebugOp
+ {
+ ECount, EMarkStart, EMarkEnd, ECheck, ESetFail, ECopyDebugInfo, ESetBurstFail, EGetFail,
+ EGetSize=48, EGetMaxLength, EGetBase, EAlignInteger, EAlignAddr
+ };
+ enum TDebugOp { EWalk = 128, EHybridHeap };
struct HeapInfo
{
diff --git a/src/corelib/arch/symbian/qt_hybridHeap_symbian_p.h b/src/corelib/arch/symbian/qt_hybridHeap_symbian_p.h
index cfb5d78c26..0269adb642 100644
--- a/src/corelib/arch/symbian/qt_hybridHeap_symbian_p.h
+++ b/src/corelib/arch/symbian/qt_hybridHeap_symbian_p.h
@@ -47,6 +47,14 @@
#ifdef QT_USE_NEW_SYMBIAN_ALLOCATOR
#include "common_p.h"
+#ifdef QT_SYMBIAN_HAVE_U32STD_H
+#include <u32std.h>
+#endif
+#ifdef QT_SYMBIAN_HAVE_E32BTRACE_H
+#include <e32btrace.h>
+// enables btrace code compiling into
+#define ENABLE_BTRACE
+#endif
#ifdef __KERNEL_MODE__
#include <kernel/kern_priv.h>
#endif
@@ -70,7 +78,76 @@
#define IMPORT_D
// disabling code ported from Symbian^4 that we don't want/can't have in earlier platforms
-#define SYMBIAN4_ALLOCATOR_UNWANTED_CODE
+#define QT_SYMBIAN4_ALLOCATOR_UNWANTED_CODE
+
+#ifndef QT_SYMBIAN_HAVE_U32STD_H
+struct SThreadCreateInfo
+ {
+ TAny* iHandle;
+ TInt iType;
+ TThreadFunction iFunction;
+ TAny* iPtr;
+ TAny* iSupervisorStack;
+ TInt iSupervisorStackSize;
+ TAny* iUserStack;
+ TInt iUserStackSize;
+ TInt iInitialThreadPriority;
+ TPtrC iName;
+ TInt iTotalSize; // Size including any extras (must be a multiple of 8 bytes)
+ };
+
+struct SStdEpocThreadCreateInfo : public SThreadCreateInfo
+ {
+ RAllocator* iAllocator;
+ TInt iHeapInitialSize;
+ TInt iHeapMaxSize;
+ TInt iPadding; // Make structure size a multiple of 8 bytes
+ };
+
+class TChunkCreate
+ {
+public:
+ // Attributes for chunk creation that are used by both euser and the kernel
+ // by classes TChunkCreateInfo and SChunkCreateInfo, respectively.
+ enum TChunkCreateAtt
+ {
+ ENormal = 0x00000000,
+ EDoubleEnded = 0x00000001,
+ EDisconnected = 0x00000002,
+ ECache = 0x00000003,
+ EMappingMask = 0x0000000f,
+ ELocal = 0x00000000,
+ EGlobal = 0x00000010,
+ EData = 0x00000000,
+ ECode = 0x00000020,
+ EMemoryNotOwned = 0x00000040,
+
+ // Force local chunk to be named. Only required for thread heap
+ // chunks, all other local chunks should be nameless.
+ ELocalNamed = 0x000000080,
+
+ // Make global chunk read only to all processes but the controlling owner
+ EReadOnly = 0x000000100,
+
+ // Paging attributes for chunks.
+ EPagingUnspec = 0x00000000,
+ EPaged = 0x80000000,
+ EUnpaged = 0x40000000,
+ EPagingMask = EPaged | EUnpaged,
+
+ EChunkCreateAttMask = EMappingMask | EGlobal | ECode |
+ ELocalNamed | EReadOnly | EPagingMask,
+ };
+public:
+ TUint iAtt;
+ TBool iForceFixed;
+ TInt iInitialBottom;
+ TInt iInitialTop;
+ TInt iMaxSize;
+ TUint8 iClearByte;
+ };
+
+#endif // QT_SYMBIAN_HAVE_U32STD_H
#endif /* QT_USE_NEW_SYMBIAN_ALLOCATOR */