Remove S60/symbian specific code in corelib/arch

Clean up and remove Symbian specific code and
data.

Change-Id: I41794085fd5122310b1fdf4c524c6e77d22e8500
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Liang Qi 2011-10-31 13:39:25 +01:00 committed by Qt by Nokia
parent 9a9d2e8ba2
commit 0d95e16c29
14 changed files with 1 additions and 7469 deletions

View File

@ -7,9 +7,6 @@ win32-g++*:HEADERS += arch/qatomic_i386.h \
mac:HEADERS += arch/qatomic_macosx.h \
arch/qatomic_generic.h
symbian:HEADERS += arch/qatomic_symbian.h \
arch/qatomic_generic.h
vxworks:HEADERS += arch/qatomic_vxworks.h
integrity:HEADERS += arch/qatomic_integrity.h
@ -37,4 +34,4 @@ QT_ARCH_CPP = $$QT_SOURCE_TREE/src/corelib/arch/$$QT_ARCH
DEPENDPATH += $$QT_ARCH_CPP
!isEmpty(QT_ARCH) {
include($$QT_ARCH_CPP/arch.pri, "", true)
}
}

View File

@ -84,8 +84,6 @@ QT_BEGIN_HEADER
# include "QtCore/qatomic_windowsce.h"
#elif defined(QT_ARCH_X86_64)
# include "QtCore/qatomic_x86_64.h"
#elif defined(QT_ARCH_SYMBIAN)
# include "QtCore/qatomic_symbian.h"
#elif defined(QT_ARCH_SH)
# include "QtCore/qatomic_sh.h"
#elif defined(QT_ARCH_SH4A)

View File

@ -1,18 +0,0 @@
#
# Symbian architecture
#
SOURCES += $$QT_ARCH_CPP/qatomic_symbian.cpp \
$$QT_ARCH_CPP/qatomic_generic_armv6.cpp \
$$QT_ARCH_CPP/heap_hybrid.cpp \
$$QT_ARCH_CPP/debugfunction.cpp \
$$QT_ARCH_CPP/qt_heapsetup_symbian.cpp
HEADERS += $$QT_ARCH_CPP/dla_p.h \
$$QT_ARCH_CPP/heap_hybrid_p.h \
$$QT_ARCH_CPP/common_p.h \
$$QT_ARCH_CPP/page_alloc_p.h \
$$QT_ARCH_CPP/slab_p.h \
$$QT_ARCH_CPP/qt_hybridHeap_symbian_p.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

View File

@ -1,106 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef __E32_COMMON_H__
#define __E32_COMMON_H__
#ifdef __KERNEL_MODE__
#include <e32cmn.h>
#include <e32panic.h>
#include "u32std.h"
#else
#include <e32std.h>
#include <e32base.h>
#include <e32math.h>
#include <e32svr.h>
#include <e32ver.h>
#include <e32hal.h>
#include <e32panic.h>
// backport of Symbian^4 allocator to Symbian^3 SDK does not contain u32exec.h
//#include <u32exec.h>
#endif
GLREF_C void Panic(TCdtPanic aPanic);
GLDEF_C void PanicBadArrayIndex();
GLREF_C TInt __DoConvertNum(TUint, TRadix, TUint, TUint8*&);
GLREF_C TInt __DoConvertNum(Uint64, TRadix, TUint, TUint8*&);
#ifdef __KERNEL_MODE__
GLREF_C void KernHeapFault(TCdtPanic aPanic);
GLREF_C void KHeapCheckThreadState();
TInt StringLength(const TUint16* aPtr);
TInt StringLength(const TUint8* aPtr);
#define STD_CLASS Kern
#define STRING_LENGTH(s) StringLength(s)
#define STRING_LENGTH_16(s) StringLength(s)
#define PANIC_CURRENT_THREAD(c,r) Kern::PanicCurrentThread(c, r)
#define __KERNEL_CHECK_RADIX(r) __ASSERT_ALWAYS(((r)==EDecimal)||((r)==EHex),Panic(EInvalidRadix))
#define APPEND_BUF_SIZE 10
#define APPEND_BUF_SIZE_64 20
#define HEAP_PANIC(r) Kern::Printf("HEAP CORRUPTED %s %d", __FILE__, __LINE__), RHeapK::Fault(r)
#define GET_PAGE_SIZE(x) x = M::PageSizeInBytes()
#define DIVISION_BY_ZERO() FAULT()
#ifdef _DEBUG
#define __CHECK_THREAD_STATE RHeapK::CheckThreadState()
#else
#define __CHECK_THREAD_STATE
#endif
#else
#define STD_CLASS User
#define STRING_LENGTH(s) User::StringLength(s)
#define STRING_LENGTH_16(s) User::StringLength(s)
#define PANIC_CURRENT_THREAD(c,r) User::Panic(c, r)
#define MEM_COMPARE_16 Mem::Compare
#define __KERNEL_CHECK_RADIX(r)
#define APPEND_BUF_SIZE 32
#define APPEND_BUF_SIZE_64 64
#define HEAP_PANIC(r) RDebug::Printf("HEAP CORRUPTED %s %d", __FILE__, __LINE__), Panic(r)
#define GET_PAGE_SIZE(x) UserHal::PageSizeInBytes(x)
#define DIVISION_BY_ZERO() User::RaiseException(EExcIntegerDivideByZero)
#define __CHECK_THREAD_STATE
#endif // __KERNEL_MODE__
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,969 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef __DLA__
#define __DLA__
#define DEFAULT_TRIM_THRESHOLD ((size_t)4U * (size_t)1024U)
#define MSPACES 0
#define HAVE_MORECORE 1
#define MORECORE_CONTIGUOUS 1
#define HAVE_MMAP 0
#define HAVE_MREMAP 0
#define DEFAULT_GRANULARITY (4096U)
#define FOOTERS 0
#define USE_LOCKS 0
#define INSECURE 1
#define NO_MALLINFO 0
#define LACKS_SYS_TYPES_H
#ifndef LACKS_SYS_TYPES_H
#include <sys/types.h> /* For size_t */
#else
#ifndef _SIZE_T_DECLARED
typedef unsigned int size_t;
#define _SIZE_T_DECLARED
#endif
#endif /* LACKS_SYS_TYPES_H */
/* The maximum possible size_t value has all bits set */
#define MAX_SIZE_T (~(size_t)0)
#ifndef ONLY_MSPACES
#define ONLY_MSPACES 0
#endif /* ONLY_MSPACES */
#ifndef MSPACES
#if ONLY_MSPACES
#define MSPACES 1
#else /* ONLY_MSPACES */
#define MSPACES 0
#endif /* ONLY_MSPACES */
#endif /* MSPACES */
//#ifndef MALLOC_ALIGNMENT
// #define MALLOC_ALIGNMENT ((size_t)8U)
//#endif /* MALLOC_ALIGNMENT */
#ifndef FOOTERS
#define FOOTERS 0
#endif /* FOOTERS */
#ifndef ABORT
// #define ABORT abort()
// #define ABORT User::Invariant()// redefined so euser isn't dependant on oe
#define ABORT HEAP_PANIC(ETHeapBadCellAddress)
#endif /* ABORT */
#ifndef PROCEED_ON_ERROR
#define PROCEED_ON_ERROR 0
#endif /* PROCEED_ON_ERROR */
#ifndef USE_LOCKS
#define USE_LOCKS 0
#endif /* USE_LOCKS */
#ifndef INSECURE
#define INSECURE 0
#endif /* INSECURE */
#ifndef HAVE_MMAP
#define HAVE_MMAP 1
#endif /* HAVE_MMAP */
#ifndef MMAP_CLEARS
#define MMAP_CLEARS 1
#endif /* MMAP_CLEARS */
#ifndef HAVE_MREMAP
#ifdef linux
#define HAVE_MREMAP 1
#else /* linux */
#define HAVE_MREMAP 0
#endif /* linux */
#endif /* HAVE_MREMAP */
#ifndef MALLOC_FAILURE_ACTION
//#define MALLOC_FAILURE_ACTION errno = ENOMEM;
#define MALLOC_FAILURE_ACTION ;
#endif /* MALLOC_FAILURE_ACTION */
#ifndef HAVE_MORECORE
#if ONLY_MSPACES
#define HAVE_MORECORE 1 /*AMOD: has changed */
#else /* ONLY_MSPACES */
#define HAVE_MORECORE 1
#endif /* ONLY_MSPACES */
#endif /* HAVE_MORECORE */
#if !HAVE_MORECORE
#define MORECORE_CONTIGUOUS 0
#else /* !HAVE_MORECORE */
#ifndef MORECORE
#define MORECORE DLAdjust
#endif /* MORECORE */
#ifndef MORECORE_CONTIGUOUS
#define MORECORE_CONTIGUOUS 0
#endif /* MORECORE_CONTIGUOUS */
#endif /* !HAVE_MORECORE */
#ifndef DEFAULT_GRANULARITY
#if MORECORE_CONTIGUOUS
#define DEFAULT_GRANULARITY 4096 /* 0 means to compute in init_mparams */
#else /* MORECORE_CONTIGUOUS */
#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U)
#endif /* MORECORE_CONTIGUOUS */
#endif /* DEFAULT_GRANULARITY */
#ifndef DEFAULT_TRIM_THRESHOLD
#ifndef MORECORE_CANNOT_TRIM
#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U)
#else /* MORECORE_CANNOT_TRIM */
#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T
#endif /* MORECORE_CANNOT_TRIM */
#endif /* DEFAULT_TRIM_THRESHOLD */
#ifndef DEFAULT_MMAP_THRESHOLD
#if HAVE_MMAP
#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U)
#else /* HAVE_MMAP */
#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T
#endif /* HAVE_MMAP */
#endif /* DEFAULT_MMAP_THRESHOLD */
#ifndef USE_BUILTIN_FFS
#define USE_BUILTIN_FFS 0
#endif /* USE_BUILTIN_FFS */
#ifndef USE_DEV_RANDOM
#define USE_DEV_RANDOM 0
#endif /* USE_DEV_RANDOM */
#ifndef NO_MALLINFO
#define NO_MALLINFO 0
#endif /* NO_MALLINFO */
#ifndef MALLINFO_FIELD_TYPE
#define MALLINFO_FIELD_TYPE size_t
#endif /* MALLINFO_FIELD_TYPE */
/*
mallopt tuning options. SVID/XPG defines four standard parameter
numbers for mallopt, normally defined in malloc.h. None of these
are used in this malloc, so setting them has no effect. But this
malloc does support the following options.
*/
#define M_TRIM_THRESHOLD (-1)
#define M_GRANULARITY (-2)
#define M_MMAP_THRESHOLD (-3)
#if !NO_MALLINFO
/*
This version of malloc supports the standard SVID/XPG mallinfo
routine that returns a struct containing usage properties and
statistics. It should work on any system that has a
/usr/include/malloc.h defining struct mallinfo. The main
declaration needed is the mallinfo struct that is returned (by-copy)
by mallinfo(). The malloinfo struct contains a bunch of fields that
are not even meaningful in this version of malloc. These fields are
are instead filled by mallinfo() with other numbers that might be of
interest.
HAVE_USR_INCLUDE_MALLOC_H should be set if you have a
/usr/include/malloc.h file that includes a declaration of struct
mallinfo. If so, it is included; else a compliant version is
declared below. These must be precisely the same for mallinfo() to
work. The original SVID version of this struct, defined on most
systems with mallinfo, declares all fields as ints. But some others
define as unsigned long. If your system defines the fields using a
type of different width than listed here, you MUST #include your
system version and #define HAVE_USR_INCLUDE_MALLOC_H.
*/
/* #define HAVE_USR_INCLUDE_MALLOC_H */
#ifdef HAVE_USR_INCLUDE_MALLOC_H
#include "/usr/include/malloc.h"
#else /* HAVE_USR_INCLUDE_MALLOC_H */
struct mallinfo {
MALLINFO_FIELD_TYPE iArena; /* non-mmapped space allocated from system */
MALLINFO_FIELD_TYPE iOrdblks; /* number of free chunks */
MALLINFO_FIELD_TYPE iSmblks; /* always 0 */
MALLINFO_FIELD_TYPE iHblks; /* always 0 */
MALLINFO_FIELD_TYPE iHblkhd; /* space in mmapped regions */
MALLINFO_FIELD_TYPE iUsmblks; /* maximum total allocated space */
MALLINFO_FIELD_TYPE iFsmblks; /* always 0 */
MALLINFO_FIELD_TYPE iUordblks; /* total allocated space */
MALLINFO_FIELD_TYPE iFordblks; /* total free space */
MALLINFO_FIELD_TYPE iKeepcost; /* releasable (via malloc_trim) space */
MALLINFO_FIELD_TYPE iCellCount;/* Number of chunks allocated*/
};
#endif /* HAVE_USR_INCLUDE_MALLOC_H */
#endif /* NO_MALLINFO */
#if MSPACES
typedef void* mspace;
#endif /* MSPACES */
#if 0
#include <stdio.h>/* for printing in malloc_stats */
#ifndef LACKS_ERRNO_H
#include <errno.h> /* for MALLOC_FAILURE_ACTION */
#endif /* LACKS_ERRNO_H */
#if FOOTERS
#include <time.h> /* for iMagic initialization */
#endif /* FOOTERS */
#ifndef LACKS_STDLIB_H
#include <stdlib.h> /* for abort() */
#endif /* LACKS_STDLIB_H */
#if !defined(ASSERT)
#define ASSERT(x) __ASSERT_DEBUG(x, HEAP_PANIC(ETHeapBadCellAddress))
#endif
#ifndef LACKS_STRING_H
#include <string.h> /* for memset etc */
#endif /* LACKS_STRING_H */
#if USE_BUILTIN_FFS
#ifndef LACKS_STRINGS_H
#include <strings.h> /* for ffs */
#endif /* LACKS_STRINGS_H */
#endif /* USE_BUILTIN_FFS */
#if HAVE_MMAP
#ifndef LACKS_SYS_MMAN_H
#include <sys/mman.h> /* for mmap */
#endif /* LACKS_SYS_MMAN_H */
#ifndef LACKS_FCNTL_H
#include <fcntl.h>
#endif /* LACKS_FCNTL_H */
#endif /* HAVE_MMAP */
#if HAVE_MORECORE
#ifndef LACKS_UNISTD_H
#include <unistd.h> /* for sbrk */
extern void* sbrk(size_t);
#else /* LACKS_UNISTD_H */
#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
extern void* sbrk(ptrdiff_t);
/*Amod sbrk is not defined in WIN32 need to check in symbian*/
#endif /* FreeBSD etc */
#endif /* LACKS_UNISTD_H */
#endif /* HAVE_MORECORE */
#endif
/*AMOD: For MALLOC_GETPAGESIZE*/
#if 0 // replaced with GET_PAGE_SIZE() defined in heap.cpp
#ifndef WIN32
#ifndef MALLOC_GETPAGESIZE
#ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */
#ifndef _SC_PAGE_SIZE
#define _SC_PAGE_SIZE _SC_PAGESIZE
#endif
#endif
#ifdef _SC_PAGE_SIZE
#define MALLOC_GETPAGESIZE sysconf(_SC_PAGE_SIZE)
#else
#if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE)
extern size_t getpagesize();
#define MALLOC_GETPAGESIZE getpagesize()
#else
#ifdef WIN32 /* use supplied emulation of getpagesize */
#define MALLOC_GETPAGESIZE getpagesize()
#else
#ifndef LACKS_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef EXEC_PAGESIZE
#define MALLOC_GETPAGESIZE EXEC_PAGESIZE
#else
#ifdef NBPG
#ifndef CLSIZE
#define MALLOC_GETPAGESIZE NBPG
#else
#define MALLOC_GETPAGESIZE (NBPG * CLSIZE)
#endif
#else
#ifdef NBPC
#define MALLOC_GETPAGESIZE NBPC
#else
#ifdef PAGESIZE
#define MALLOC_GETPAGESIZE PAGESIZE
#else /* just guess */
#define MALLOC_GETPAGESIZE ((size_t)4096U)
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
/*AMOD: For MALLOC_GETPAGESIZE*/
/* ------------------- size_t and alignment properties -------------------- */
/* The byte and bit size of a size_t */
#define SIZE_T_SIZE (sizeof(size_t))
#define SIZE_T_BITSIZE (sizeof(size_t) << 3)
/* Some constants coerced to size_t */
/* Annoying but necessary to avoid errors on some plaftorms */
#define SIZE_T_ZERO ((size_t)0)
#define SIZE_T_ONE ((size_t)1)
#define SIZE_T_TWO ((size_t)2)
#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1)
#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2)
#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES)
#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U)
/* The bit mask value corresponding to MALLOC_ALIGNMENT */
#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE)
/* True if address a has acceptable alignment */
//#define IS_ALIGNED(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0)
#define IS_ALIGNED(A) (((unsigned int)((A)) & (CHUNK_ALIGN_MASK)) == 0)
/* the number of bytes to offset an address to align it */
#define ALIGN_OFFSET(A)\
((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\
((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK))
/* -------------------------- MMAP preliminaries ------------------------- */
/*
If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and
checks to fail so compiler optimizer can delete code rather than
using so many "#if"s.
*/
/* MORECORE and MMAP must return MFAIL on failure */
#define MFAIL ((void*)(MAX_SIZE_T))
#define CMFAIL ((TUint8*)(MFAIL)) /* defined for convenience */
#if !HAVE_MMAP
#define IS_MMAPPED_BIT (SIZE_T_ZERO)
#define USE_MMAP_BIT (SIZE_T_ZERO)
#define CALL_MMAP(s) MFAIL
#define CALL_MUNMAP(a, s) (-1)
#define DIRECT_MMAP(s) MFAIL
#else /* !HAVE_MMAP */
#define IS_MMAPPED_BIT (SIZE_T_ONE)
#define USE_MMAP_BIT (SIZE_T_ONE)
#ifndef WIN32
#define CALL_MUNMAP(a, s) DLUMMAP((a),(s)) /*munmap((a), (s))*/
#define MMAP_PROT (PROT_READ|PROT_WRITE)
#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
#define MAP_ANONYMOUS MAP_ANON
#endif /* MAP_ANON */
#ifdef MAP_ANONYMOUS
#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS)
#define CALL_MMAP(s) mmap(0, (s), MMAP_PROT, (int)MMAP_FLAGS, -1, 0)
#else /* MAP_ANONYMOUS */
/*
Nearly all versions of mmap support MAP_ANONYMOUS, so the following
is unlikely to be needed, but is supplied just in case.
*/
#define MMAP_FLAGS (MAP_PRIVATE)
//static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */
#define CALL_MMAP(s) DLMMAP(s)
/*#define CALL_MMAP(s) ((dev_zero_fd < 0) ? \
(dev_zero_fd = open("/dev/zero", O_RDWR), \
mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \
mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0))
*/
#define CALL_REMAP(a, s, d) DLREMAP((a),(s),(d))
#endif /* MAP_ANONYMOUS */
#define DIRECT_MMAP(s) CALL_MMAP(s)
#else /* WIN32 */
#define CALL_MMAP(s) win32mmap(s)
#define CALL_MUNMAP(a, s) win32munmap((a), (s))
#define DIRECT_MMAP(s) win32direct_mmap(s)
#endif /* WIN32 */
#endif /* HAVE_MMAP */
#if HAVE_MMAP && HAVE_MREMAP
#define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv))
#else /* HAVE_MMAP && HAVE_MREMAP */
#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL
#endif /* HAVE_MMAP && HAVE_MREMAP */
#if HAVE_MORECORE
#define CALL_MORECORE(S) SetBrk(S)
#else /* HAVE_MORECORE */
#define CALL_MORECORE(S) MFAIL
#endif /* HAVE_MORECORE */
/* mstate bit set if continguous morecore disabled or failed */
#define USE_NONCONTIGUOUS_BIT (4U)
/* segment bit set in create_mspace_with_base */
#define EXTERN_BIT (8U)
#if USE_LOCKS
/*
When locks are defined, there are up to two global locks:
* If HAVE_MORECORE, iMorecoreMutex protects sequences of calls to
MORECORE. In many cases sys_alloc requires two calls, that should
not be interleaved with calls by other threads. This does not
protect against direct calls to MORECORE by other threads not
using this lock, so there is still code to cope the best we can on
interference.
* iMagicInitMutex ensures that mparams.iMagic and other
unique mparams values are initialized only once.
*/
#ifndef WIN32
/* By default use posix locks */
#include <pthread.h>
#define MLOCK_T pthread_mutex_t
#define INITIAL_LOCK(l) pthread_mutex_init(l, NULL)
#define ACQUIRE_LOCK(l) pthread_mutex_lock(l)
#define RELEASE_LOCK(l) pthread_mutex_unlock(l)
#if HAVE_MORECORE
//static MLOCK_T iMorecoreMutex = PTHREAD_MUTEX_INITIALIZER;
#endif /* HAVE_MORECORE */
//static MLOCK_T iMagicInitMutex = PTHREAD_MUTEX_INITIALIZER;
#else /* WIN32 */
#define MLOCK_T long
#define INITIAL_LOCK(l) *(l)=0
#define ACQUIRE_LOCK(l) win32_acquire_lock(l)
#define RELEASE_LOCK(l) win32_release_lock(l)
#if HAVE_MORECORE
static MLOCK_T iMorecoreMutex;
#endif /* HAVE_MORECORE */
static MLOCK_T iMagicInitMutex;
#endif /* WIN32 */
#define USE_LOCK_BIT (2U)
#else /* USE_LOCKS */
#define USE_LOCK_BIT (0U)
#define INITIAL_LOCK(l)
#endif /* USE_LOCKS */
#if USE_LOCKS && HAVE_MORECORE
#define ACQUIRE_MORECORE_LOCK(M) ACQUIRE_LOCK((M->iMorecoreMutex)/*&iMorecoreMutex*/);
#define RELEASE_MORECORE_LOCK(M) RELEASE_LOCK((M->iMorecoreMutex)/*&iMorecoreMutex*/);
#else /* USE_LOCKS && HAVE_MORECORE */
#define ACQUIRE_MORECORE_LOCK(M)
#define RELEASE_MORECORE_LOCK(M)
#endif /* USE_LOCKS && HAVE_MORECORE */
#if USE_LOCKS
/*Currently not suporting this*/
#define ACQUIRE_MAGIC_INIT_LOCK(M) ACQUIRE_LOCK(((M)->iMagicInitMutex));
//AMOD: changed #define ACQUIRE_MAGIC_INIT_LOCK()
//#define RELEASE_MAGIC_INIT_LOCK()
#define RELEASE_MAGIC_INIT_LOCK(M) RELEASE_LOCK(((M)->iMagicInitMutex));
#else /* USE_LOCKS */
#define ACQUIRE_MAGIC_INIT_LOCK(M)
#define RELEASE_MAGIC_INIT_LOCK(M)
#endif /* USE_LOCKS */
/*CHUNK representation*/
struct malloc_chunk {
size_t iPrevFoot; /* Size of previous chunk (if free). */
size_t iHead; /* Size and inuse bits. */
struct malloc_chunk* iFd; /* double links -- used only if free. */
struct malloc_chunk* iBk;
};
typedef struct malloc_chunk mchunk;
typedef struct malloc_chunk* mchunkptr;
typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */
typedef unsigned int bindex_t; /* Described below */
typedef unsigned int binmap_t; /* Described below */
typedef unsigned int flag_t; /* The type of various bit flag sets */
/* ------------------- Chunks sizes and alignments ----------------------- */
#define MCHUNK_SIZE (sizeof(mchunk))
//#if FOOTERS
// #define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)
//#else /* FOOTERS */
// #define CHUNK_OVERHEAD (SIZE_T_SIZE)
//#endif /* FOOTERS */
/* MMapped chunks need a second word of overhead ... */
#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)
/* ... and additional padding for fake next-chunk at foot */
#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES)
/* The smallest size we can malloc is an aligned minimal chunk */
#define MIN_CHUNK_SIZE ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
/* conversion from malloc headers to user pointers, and back */
#define CHUNK2MEM(p) ((void*)((TUint8*)(p) + TWO_SIZE_T_SIZES))
#define MEM2CHUNK(mem) ((mchunkptr)((TUint8*)(mem) - TWO_SIZE_T_SIZES))
/* chunk associated with aligned address A */
#define ALIGN_AS_CHUNK(A) (mchunkptr)((A) + ALIGN_OFFSET(CHUNK2MEM(A)))
/* Bounds on request (not chunk) sizes. */
#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2)
#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)
/* pad request bytes into a usable size */
#define PAD_REQUEST(req) (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
/* pad request, checking for minimum (but not maximum) */
#define REQUEST2SIZE(req) (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : PAD_REQUEST(req))
/* ------------------ Operations on iHead and foot fields ----------------- */
/*
The iHead field of a chunk is or'ed with PINUSE_BIT when previous
adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in
use. If the chunk was obtained with mmap, the iPrevFoot field has
IS_MMAPPED_BIT set, otherwise holding the offset of the base of the
mmapped region to the base of the chunk.
*/
#define PINUSE_BIT (SIZE_T_ONE)
#define CINUSE_BIT (SIZE_T_TWO)
#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT)
/* Head value for fenceposts */
#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE)
/* extraction of fields from iHead words */
#define CINUSE(p) ((p)->iHead & CINUSE_BIT)
#define PINUSE(p) ((p)->iHead & PINUSE_BIT)
#define CHUNKSIZE(p) ((p)->iHead & ~(INUSE_BITS))
#define CLEAR_PINUSE(p) ((p)->iHead &= ~PINUSE_BIT)
#define CLEAR_CINUSE(p) ((p)->iHead &= ~CINUSE_BIT)
/* Treat space at ptr +/- offset as a chunk */
#define CHUNK_PLUS_OFFSET(p, s) ((mchunkptr)(((TUint8*)(p)) + (s)))
#define CHUNK_MINUS_OFFSET(p, s) ((mchunkptr)(((TUint8*)(p)) - (s)))
/* Ptr to next or previous physical malloc_chunk. */
#define NEXT_CHUNK(p) ((mchunkptr)( ((TUint8*)(p)) + ((p)->iHead & ~INUSE_BITS)))
#define PREV_CHUNK(p) ((mchunkptr)( ((TUint8*)(p)) - ((p)->iPrevFoot) ))
/* extract next chunk's PINUSE bit */
#define NEXT_PINUSE(p) ((NEXT_CHUNK(p)->iHead) & PINUSE_BIT)
/* Get/set size at footer */
#define GET_FOOT(p, s) (((mchunkptr)((TUint8*)(p) + (s)))->iPrevFoot)
#define SET_FOOT(p, s) (((mchunkptr)((TUint8*)(p) + (s)))->iPrevFoot = (s))
/* Set size, PINUSE bit, and foot */
#define SET_SIZE_AND_PINUSE_OF_FREE_CHUNK(p, s) ((p)->iHead = (s|PINUSE_BIT), SET_FOOT(p, s))
/* Set size, PINUSE bit, foot, and clear next PINUSE */
#define SET_FREE_WITH_PINUSE(p, s, n) (CLEAR_PINUSE(n), SET_SIZE_AND_PINUSE_OF_FREE_CHUNK(p, s))
#define IS_MMAPPED(p) (!((p)->iHead & PINUSE_BIT) && ((p)->iPrevFoot & IS_MMAPPED_BIT))
/* Get the internal overhead associated with chunk p */
#define OVERHEAD_FOR(p) (IS_MMAPPED(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD)
/* Return true if malloced space is not necessarily cleared */
#if MMAP_CLEARS
#define CALLOC_MUST_CLEAR(p) (!IS_MMAPPED(p))
#else /* MMAP_CLEARS */
#define CALLOC_MUST_CLEAR(p) (1)
#endif /* MMAP_CLEARS */
/* ---------------------- Overlaid data structures ----------------------- */
struct malloc_tree_chunk {
/* The first four fields must be compatible with malloc_chunk */
size_t iPrevFoot;
size_t iHead;
struct malloc_tree_chunk* iFd;
struct malloc_tree_chunk* iBk;
struct malloc_tree_chunk* iChild[2];
struct malloc_tree_chunk* iParent;
bindex_t iIndex;
};
typedef struct malloc_tree_chunk tchunk;
typedef struct malloc_tree_chunk* tchunkptr;
typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */
/* A little helper macro for trees */
#define LEFTMOST_CHILD(t) ((t)->iChild[0] != 0? (t)->iChild[0] : (t)->iChild[1])
/*Segment structur*/
//struct malloc_segment {
// TUint8* iBase; /* base address */
// size_t iSize; /* allocated size */
//};
#define IS_MMAPPED_SEGMENT(S) ((S)->iSflags & IS_MMAPPED_BIT)
#define IS_EXTERN_SEGMENT(S) ((S)->iSflags & EXTERN_BIT)
typedef struct malloc_segment msegment;
typedef struct malloc_segment* msegmentptr;
/*Malloc State data structur*/
//#define NSMALLBINS (32U)
//#define NTREEBINS (32U)
#define SMALLBIN_SHIFT (3U)
#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT)
#define TREEBIN_SHIFT (8U)
#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT)
#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE)
#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)
/*struct malloc_state {
binmap_t iSmallMap;
binmap_t iTreeMap;
size_t iDvSize;
size_t iTopSize;
mchunkptr iDv;
mchunkptr iTop;
size_t iTrimCheck;
mchunkptr iSmallBins[(NSMALLBINS+1)*2];
tbinptr iTreeBins[NTREEBINS];
msegment iSeg;
};*/
/*
struct malloc_state {
binmap_t iSmallMap;
binmap_t iTreeMap;
size_t iDvSize;
size_t iTopSize;
TUint8* iLeastAddr;
mchunkptr iDv;
mchunkptr iTop;
size_t iTrimCheck;
size_t iMagic;
mchunkptr iSmallBins[(NSMALLBINS+1)*2];
tbinptr iTreeBins[NTREEBINS];
size_t iFootprint;
size_t iMaxFootprint;
flag_t iMflags;
#if USE_LOCKS
MLOCK_T iMutex;
MLOCK_T iMagicInitMutex;
MLOCK_T iMorecoreMutex;
#endif
msegment iSeg;
};
*/
typedef struct malloc_state* mstate;
/* ------------- Global malloc_state and malloc_params ------------------- */
/*
malloc_params holds global properties, including those that can be
dynamically set using mallopt. There is a single instance, mparams,
initialized in init_mparams.
*/
struct malloc_params {
size_t iMagic;
size_t iPageSize;
size_t iGranularity;
size_t iMmapThreshold;
size_t iTrimThreshold;
flag_t iDefaultMflags;
#if USE_LOCKS
MLOCK_T iMagicInitMutex;
#endif /* USE_LOCKS */
};
/* The global malloc_state used for all non-"mspace" calls */
/*AMOD: Need to check this as this will be the member of the class*/
//static struct malloc_state _gm_;
//#define GM (&_gm_)
//#define IS_GLOBAL(M) ((M) == &_gm_)
/*AMOD: has changed*/
#define IS_GLOBAL(M) ((M) == GM)
#define IS_INITIALIZED(M) ((M)->iTop != 0)
/* -------------------------- system alloc setup ------------------------- */
/* Operations on iMflags */
#define USE_LOCK(M) ((M)->iMflags & USE_LOCK_BIT)
#define ENABLE_LOCK(M) ((M)->iMflags |= USE_LOCK_BIT)
#define DISABLE_LOCK(M) ((M)->iMflags &= ~USE_LOCK_BIT)
#define USE_MMAP(M) ((M)->iMflags & USE_MMAP_BIT)
#define ENABLE_MMAP(M) ((M)->iMflags |= USE_MMAP_BIT)
#define DISABLE_MMAP(M) ((M)->iMflags &= ~USE_MMAP_BIT)
#define USE_NONCONTIGUOUS(M) ((M)->iMflags & USE_NONCONTIGUOUS_BIT)
#define DISABLE_CONTIGUOUS(M) ((M)->iMflags |= USE_NONCONTIGUOUS_BIT)
#define SET_LOCK(M,L) ((M)->iMflags = (L)? ((M)->iMflags | USE_LOCK_BIT) : ((M)->iMflags & ~USE_LOCK_BIT))
/* page-align a size */
#define PAGE_ALIGN(S) (((S) + (mparams.iPageSize)) & ~(mparams.iPageSize - SIZE_T_ONE))
/* iGranularity-align a size */
#define GRANULARITY_ALIGN(S) (((S) + (mparams.iGranularity)) & ~(mparams.iGranularity - SIZE_T_ONE))
#define IS_PAGE_ALIGNED(S) (((size_t)(S) & (mparams.iPageSize - SIZE_T_ONE)) == 0)
#define IS_GRANULARITY_ALIGNED(S) (((size_t)(S) & (mparams.iGranularity - SIZE_T_ONE)) == 0)
/* True if segment S holds address A */
#define SEGMENT_HOLDS(S, A) ((TUint8*)(A) >= S->iBase && (TUint8*)(A) < S->iBase + S->iSize)
#ifndef MORECORE_CANNOT_TRIM
#define SHOULD_TRIM(M,s) ((s) > (M)->iTrimCheck)
#else /* MORECORE_CANNOT_TRIM */
#define SHOULD_TRIM(M,s) (0)
#endif /* MORECORE_CANNOT_TRIM */
/*
TOP_FOOT_SIZE is padding at the end of a segment, including space
that may be needed to place segment records and fenceposts when new
noncontiguous segments are added.
*/
#define TOP_FOOT_SIZE (ALIGN_OFFSET(CHUNK2MEM(0))+PAD_REQUEST(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)
#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT)
/* ------------------------------- Hooks -------------------------------- */
/*
PREACTION should be defined to return 0 on success, and nonzero on
failure. If you are not using locking, you can redefine these to do
anything you like.
*/
#if USE_LOCKS
/* Ensure locks are initialized */
#define GLOBALLY_INITIALIZE() (mparams.iPageSize == 0 && init_mparams())
#define PREACTION(M) (USE_LOCK((M))?(ACQUIRE_LOCK((M)->iMutex),0):0) /*Action to take like lock before alloc*/
#define POSTACTION(M) { if (USE_LOCK(M)) RELEASE_LOCK((M)->iMutex); }
#else /* USE_LOCKS */
#ifndef PREACTION
#define PREACTION(M) (0)
#endif /* PREACTION */
#ifndef POSTACTION
#define POSTACTION(M)
#endif /* POSTACTION */
#endif /* USE_LOCKS */
/*
CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses.
USAGE_ERROR_ACTION is triggered on detected bad frees and
reallocs. The argument p is an address that might have triggered the
fault. It is ignored by the two predefined actions, but might be
useful in custom actions that try to help diagnose errors.
*/
#if PROCEED_ON_ERROR
/* A count of the number of corruption errors causing resets */
int malloc_corruption_error_count;
/* default corruption action */
static void ResetOnError(mstate m);
#define CORRUPTION_ERROR_ACTION(m) ResetOnError(m)
#define USAGE_ERROR_ACTION(m, p)
#else /* PROCEED_ON_ERROR */
#ifndef CORRUPTION_ERROR_ACTION
#define CORRUPTION_ERROR_ACTION(m) ABORT
#endif /* CORRUPTION_ERROR_ACTION */
#ifndef USAGE_ERROR_ACTION
#define USAGE_ERROR_ACTION(m,p) ABORT
#endif /* USAGE_ERROR_ACTION */
#endif /* PROCEED_ON_ERROR */
#ifdef _DEBUG
#define CHECK_FREE_CHUNK(M,P) DoCheckFreeChunk(M,P)
#define CHECK_INUSE_CHUNK(M,P) DoCheckInuseChunk(M,P)
#define CHECK_TOP_CHUNK(M,P) DoCheckTopChunk(M,P)
#define CHECK_MALLOCED_CHUNK(M,P,N) DoCheckMallocedChunk(M,P,N)
#define CHECK_MMAPPED_CHUNK(M,P) DoCheckMmappedChunk(M,P)
#define CHECK_MALLOC_STATE(M) DoCheckMallocState(M)
#else /* DEBUG */
#define CHECK_FREE_CHUNK(M,P)
#define CHECK_INUSE_CHUNK(M,P)
#define CHECK_MALLOCED_CHUNK(M,P,N)
#define CHECK_MMAPPED_CHUNK(M,P)
#define CHECK_MALLOC_STATE(M)
#define CHECK_TOP_CHUNK(M,P)
#endif /* DEBUG */
/* ---------------------------- Indexing Bins ---------------------------- */
#define IS_SMALL(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS)
#define SMALL_INDEX(s) ((s) >> SMALLBIN_SHIFT)
#define SMALL_INDEX2SIZE(i) ((i) << SMALLBIN_SHIFT)
#define MIN_SMALL_INDEX (SMALL_INDEX(MIN_CHUNK_SIZE))
/* addressing by index. See above about smallbin repositioning */
#define SMALLBIN_AT(M, i) ((sbinptr)((TUint8*)&((M)->iSmallBins[(i)<<1])))
#define TREEBIN_AT(M,i) (&((M)->iTreeBins[i]))
/* Bit representing maximum resolved size in a treebin at i */
#define BIT_FOR_TREE_INDEX(i) (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2)
/* Shift placing maximum resolved bit in a treebin at i as sign bit */
#define LEFTSHIFT_FOR_TREE_INDEX(i) ((i == NTREEBINS-1)? 0 : ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2)))
/* The size of the smallest chunk held in bin with index i */
#define MINSIZE_FOR_TREE_INDEX(i) ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1)))
/* ------------------------ Operations on bin maps ----------------------- */
/* bit corresponding to given index */
#define IDX2BIT(i) ((binmap_t)(1) << (i))
/* Mark/Clear bits with given index */
#define MARK_SMALLMAP(M,i) ((M)->iSmallMap |= IDX2BIT(i))
#define CLEAR_SMALLMAP(M,i) ((M)->iSmallMap &= ~IDX2BIT(i))
#define SMALLMAP_IS_MARKED(M,i) ((M)->iSmallMap & IDX2BIT(i))
#define MARK_TREEMAP(M,i) ((M)->iTreeMap |= IDX2BIT(i))
#define CLEAR_TREEMAP(M,i) ((M)->iTreeMap &= ~IDX2BIT(i))
#define TREEMAP_IS_MARKED(M,i) ((M)->iTreeMap & IDX2BIT(i))
/* isolate the least set bit of a bitmap */
#define LEAST_BIT(x) ((x) & -(x))
/* mask with all bits to left of least bit of x on */
#define LEFT_BITS(x) ((x<<1) | -(x<<1))
/* mask with all bits to left of or equal to least bit of x on */
#define SAME_OR_LEFT_BITS(x) ((x) | -(x))
#if !INSECURE
/* Check if address a is at least as high as any from MORECORE or MMAP */
#define OK_ADDRESS(M, a) ((TUint8*)(a) >= (M)->iLeastAddr)
/* Check if address of next chunk n is higher than base chunk p */
#define OK_NEXT(p, n) ((TUint8*)(p) < (TUint8*)(n))
/* Check if p has its CINUSE bit on */
#define OK_CINUSE(p) CINUSE(p)
/* Check if p has its PINUSE bit on */
#define OK_PINUSE(p) PINUSE(p)
#else /* !INSECURE */
#define OK_ADDRESS(M, a) (1)
#define OK_NEXT(b, n) (1)
#define OK_CINUSE(p) (1)
#define OK_PINUSE(p) (1)
#endif /* !INSECURE */
#if (FOOTERS && !INSECURE)
/* Check if (alleged) mstate m has expected iMagic field */
#define OK_MAGIC(M) ((M)->iMagic == mparams.iMagic)
#else /* (FOOTERS && !INSECURE) */
#define OK_MAGIC(M) (1)
#endif /* (FOOTERS && !INSECURE) */
/* In gcc, use __builtin_expect to minimize impact of checks */
#if !INSECURE
#if defined(__GNUC__) && __GNUC__ >= 3
#define RTCHECK(e) __builtin_expect(e, 1)
#else /* GNUC */
#define RTCHECK(e) (e)
#endif /* GNUC */
#else /* !INSECURE */
#define RTCHECK(e) (1)
#endif /* !INSECURE */
/* macros to set up inuse chunks with or without footers */
#if !FOOTERS
#define MARK_INUSE_FOOT(M,p,s)
/* Set CINUSE bit and PINUSE bit of next chunk */
#define SET_INUSE(M,p,s) ((p)->iHead = (((p)->iHead & PINUSE_BIT)|s|CINUSE_BIT),((mchunkptr)(((TUint8*)(p)) + (s)))->iHead |= PINUSE_BIT)
/* Set CINUSE and PINUSE of this chunk and PINUSE of next chunk */
#define SET_INUSE_AND_PINUSE(M,p,s) ((p)->iHead = (s|PINUSE_BIT|CINUSE_BIT),((mchunkptr)(((TUint8*)(p)) + (s)))->iHead |= PINUSE_BIT)
/* Set size, CINUSE and PINUSE bit of this chunk */
#define SET_SIZE_AND_PINUSE_OF_INUSE_CHUNK(M, p, s) ((p)->iHead = (s|PINUSE_BIT|CINUSE_BIT))
#else /* FOOTERS */
/* Set foot of inuse chunk to be xor of mstate and seed */
#define MARK_INUSE_FOOT(M,p,s) (((mchunkptr)((TUint8*)(p) + (s)))->iPrevFoot = ((size_t)(M) ^ mparams.iMagic))
#define GET_MSTATE_FOR(p) ((mstate)(((mchunkptr)((TUint8*)(p)+(CHUNKSIZE(p))))->iPrevFoot ^ mparams.iMagic))
#define SET_INUSE(M,p,s)\
((p)->iHead = (((p)->iHead & PINUSE_BIT)|s|CINUSE_BIT),\
(((mchunkptr)(((TUint8*)(p)) + (s)))->iHead |= PINUSE_BIT), \
MARK_INUSE_FOOT(M,p,s))
#define SET_INUSE_AND_PINUSE(M,p,s)\
((p)->iHead = (s|PINUSE_BIT|CINUSE_BIT),\
(((mchunkptr)(((TUint8*)(p)) + (s)))->iHead |= PINUSE_BIT),\
MARK_INUSE_FOOT(M,p,s))
#define SET_SIZE_AND_PINUSE_OF_INUSE_CHUNK(M, p, s)\
((p)->iHead = (s|PINUSE_BIT|CINUSE_BIT),\
MARK_INUSE_FOOT(M, p, s))
#endif /* !FOOTERS */
#if ONLY_MSPACES
#define INTERNAL_MALLOC(m, b) mspace_malloc(m, b)
#define INTERNAL_FREE(m, mem) mspace_free(m,mem);
#else /* ONLY_MSPACES */
#if MSPACES
#define INTERNAL_MALLOC(m, b) (m == GM)? dlmalloc(b) : mspace_malloc(m, b)
#define INTERNAL_FREE(m, mem) if (m == GM) dlfree(mem); else mspace_free(m,mem);
#else /* MSPACES */
#define INTERNAL_MALLOC(m, b) dlmalloc(b)
#define INTERNAL_FREE(m, mem) dlfree(mem)
#endif /* MSPACES */
#endif /* ONLY_MSPACES */
#ifndef NDEBUG
#define CHECKING 1
#endif
// #define HYSTERESIS 4
#define HYSTERESIS 1
#define HYSTERESIS_BYTES (2*PAGESIZE)
#define HYSTERESIS_GROW (HYSTERESIS*PAGESIZE)
#if CHECKING
#define CHECK(x) x
#else
#undef ASSERT
#define ASSERT(x) (void)0
#define CHECK(x) (void)0
#endif
#endif/*__DLA__*/

File diff suppressed because it is too large Load Diff

View File

@ -1,406 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef __HEAP_HYBRID_H__
#define __HEAP_HYBRID_H__
#include <e32cmn.h>
#ifdef __WINS__
#define USE_HYBRID_HEAP 0
#else
#define USE_HYBRID_HEAP 1
#endif
// This stuff is all temporary in order to prevent having to include dla.h from heap_hybrid.h, which causes
// problems due to its definition of size_t (and possibly other types). This is unfortunate but we cannot
// pollute the namespace with these types or it will cause problems with Open C and other POSIX compatibility
// efforts in Symbian
#define NSMALLBINS (32U)
#define NTREEBINS (32U)
#ifndef MALLOC_ALIGNMENT
#define MALLOC_ALIGNMENT ((TUint)8U)
#endif /* MALLOC_ALIGNMENT */
#define CHUNK_OVERHEAD (sizeof(TUint))
typedef unsigned int bindex_t;
typedef unsigned int binmap_t;
typedef struct malloc_chunk* mchunkptr;
typedef struct malloc_segment msegment;
typedef struct malloc_state* mstate;
typedef struct malloc_tree_chunk* tbinptr;
typedef struct malloc_tree_chunk* tchunkptr;
struct malloc_segment {
TUint8* iBase; /* base address */
TUint iSize; /* allocated size */
};
struct malloc_state {
binmap_t iSmallMap;
binmap_t iTreeMap;
TUint iDvSize;
TUint iTopSize;
mchunkptr iDv;
mchunkptr iTop;
TUint iTrimCheck;
mchunkptr iSmallBins[(NSMALLBINS+1)*2];
tbinptr iTreeBins[NTREEBINS];
msegment iSeg;
};
class RHybridHeap : public RHeap
{
public:
// 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 };
enum THybridAllocFail
{
ERandom, ETrueRandom, EDeterministic, EHybridNone, EFailNext, EReset, EBurstRandom,
EBurstTrueRandom, EBurstDeterministic, EBurstFailNext, ECheckFailure,
};
enum { EDebugHdrSize = sizeof(SDebugCell) };
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
struct SRAllocatorBurstFail {TInt iBurst; TInt iRate; TInt iUnused[2];};
#endif
struct HeapInfo
{
unsigned iFootprint;
unsigned iMaxSize;
unsigned iAllocBytes;
unsigned iAllocN;
unsigned iFreeBytes;
unsigned iFreeN;
};
struct SHeapCellInfo { RHybridHeap* iHeap; TInt iTotalAlloc; TInt iTotalAllocSize; TInt iTotalFree; TInt iLevelAlloc; SDebugCell* iStranded; };
/**
@internalComponent
*/
enum TAllocatorType
{ESlabAllocator, EDougLeaAllocator, EPageAllocator, EFullSlab=0x80, EPartialFullSlab=0x40, EEmptySlab=0x20, ESlabSpare=0x10, ESlabMask=0xf0};
/**
@internalComponent
*/
struct SWalkInfo {
/**
Walk function address shall be called
*/
TWalkFunc iFunction;
/**
The first parameter for callback function
*/
TAny* iParam;
/**
Pointer to RHybridHeap object
*/
RHybridHeap* iHeap;
};
/**
@internalComponent
*/
struct SConfig {
/**
Required slab configuration ( bit 0=4, bit 1=8 ..
bit 13 = 56)
*/
TUint32 iSlabBits;
/**
Delayed slab threshold in bytes (0 = no threshold)
*/
TInt iDelayedSlabThreshold;
/**
2^n is smallest size allocated in paged allocator (14-31 = 16 Kb --> )
*/
TInt iPagePower;
};
/**
@internalComponent
This structure is used by test code for configuring the allocators and obtaining information
from them in order to ensure they are behaving as required. This is internal test specific
code and is liable to be changed without warning at any time. You should under no circumstances
be using it!
*/
struct STestCommand
{
TInt iCommand; // The test related command to be executed
union
{
SConfig iConfig; // Configuration used by test code only
TAny* iData; // Extra supporting data for the test command
};
};
/**
@internalComponent
Commands used by test code for configuring the allocators and obtaining information them them
*/
enum TTestCommand { EGetConfig, ESetConfig, EHeapMetaData, ETestData };
virtual TAny* Alloc(TInt aSize);
virtual void Free(TAny* aPtr);
virtual TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode=0);
virtual TInt AllocLen(const TAny* aCell) const;
#ifndef __KERNEL_MODE__
virtual TInt Compress();
virtual void Reset();
virtual TInt AllocSize(TInt& aTotalAllocSize) const;
virtual TInt Available(TInt& aBiggestBlock) const;
#endif
virtual TInt DebugFunction(TInt aFunc, TAny* a1=NULL, TAny* a2=NULL);
protected:
virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
public:
TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW;
void operator delete(TAny*, TAny*);
private:
TInt DoCountAllocFree(TInt& aFree);
TInt DoCheckHeap(SCheckInfo* aInfo);
void DoMarkStart();
TUint32 DoMarkEnd(TInt aExpected);
void DoSetAllocFail(TAllocFail aType, TInt aRate);
TBool CheckForSimulatedAllocFail();
void DoSetAllocFail(TAllocFail aType, TInt aRate, TUint aBurst);
void Lock() const;
void Unlock() const;
TInt ChunkHandle() const;
RHybridHeap(TInt aChunkHandle, TInt aOffset, TInt aMinLength, TInt aMaxLength, TInt aGrowBy, TInt aAlign, TBool aSingleThread, TBool aDlOnly, TBool aUseAdjust);
RHybridHeap(TInt aMaxLength, TInt aAlign=0, TBool aSingleThread=ETrue);
RHybridHeap();
void Init(TInt aBitmapSlab, TInt aPagePower);
inline void InitBins(mstate m);
inline void InitTop(mstate m, mchunkptr p, TUint psize);
void* SysAlloc(mstate m, TUint nb);
int SysTrim(mstate m, TUint pad);
void* TmallocLarge(mstate m, TUint nb);
void* TmallocSmall(mstate m, TUint nb);
/*MACROS converted functions*/
static inline void UnlinkFirstSmallChunk(mstate M,mchunkptr B,mchunkptr P,bindex_t& I);
static inline void InsertSmallChunk(mstate M,mchunkptr P, TUint S);
static inline void InsertChunk(mstate M,mchunkptr P,TUint S);
static inline void UnlinkLargeChunk(mstate M,tchunkptr X);
static inline void UnlinkSmallChunk(mstate M, mchunkptr P,TUint S);
static inline void UnlinkChunk(mstate M, mchunkptr P, TUint S);
static inline void ComputeTreeIndex(TUint S, bindex_t& I);
static inline void InsertLargeChunk(mstate M,tchunkptr X,TUint S);
static inline void ReplaceDv(mstate M, mchunkptr P, TUint S);
static inline void ComputeBit2idx(binmap_t X,bindex_t& I);
void DoComputeTreeIndex(TUint S, bindex_t& I);
void DoCheckAnyChunk(mstate m, mchunkptr p);
void DoCheckTopChunk(mstate m, mchunkptr p);
void DoCheckInuseChunk(mstate m, mchunkptr p);
void DoCheckFreeChunk(mstate m, mchunkptr p);
void DoCheckMallocedChunk(mstate m, void* mem, TUint s);
void DoCheckTree(mstate m, tchunkptr t);
void DoCheckTreebin(mstate m, bindex_t i);
void DoCheckSmallbin(mstate m, bindex_t i);
TInt BinFind(mstate m, mchunkptr x);
TUint TraverseAndCheck(mstate m);
void DoCheckMallocState(mstate m);
TInt GetInfo(struct HeapInfo* i, SWalkInfo* wi=NULL) const;
void InitDlMalloc(TUint capacity, int locked);
void* DlMalloc(TUint);
void DlFree(void*);
void* DlRealloc(void*, TUint, TInt);
TUint DlInfo(struct HeapInfo* i, SWalkInfo* wi) const;
void DoCheckCommittedSize(TInt aNPages, mstate aM);
TAny* ReAllocImpl(TAny* aPtr, TInt aSize, TInt aMode);
void Construct(TBool aSingleThread, TBool aDLOnly, TBool aUseAdjust, TInt aAlign);
#ifndef __KERNEL_MODE__
TInt ConstructLock(TUint32 aMode);
#endif
static void Walk(SWalkInfo* aInfo, TAny* aBfr, TInt aLth, TCellType aBfrType, TAllocatorType aAlloctorType);
static void WalkCheckCell(TAny* aPtr, TCellType aType, TAny* aCell, TInt aLen);
void* Map(void* p, TInt sz);
void Unmap(void* p,TInt sz);
private:
TInt iMinLength;
TInt iOffset; // offset of RHeap object from chunk base
TInt iGrowBy;
TInt iMinCell;
TInt iPageSize;
// Temporarily commented out and exported from RHeap to prevent source breaks from req417-52840.
// This will be moved with another REQ after submission and subsequent fixing of bad code
//TInt iNestingLevel;
TInt iAllocCount;
// Temporarily commented out. See comment above regarding req417-52840 source breaks
//TAllocFail iFailType;
TInt iFailRate;
TBool iFailed;
TInt iFailAllocCount;
TInt iRand;
// Temporarily commented out. See comment above regarding req417-52840 source breaks
//TAny* iTestData;
TInt iChunkSize;
TInt iHighWaterMark;
TBool iUseAdjust;
TBool iDLOnly;
malloc_state iGlobalMallocState;
#ifdef __KERNEL_MODE__
friend class RHeapK;
#else
friend class UserHeap;
friend class HybridHeap;
friend class TestHybridHeap;
private:
static void TreeRemove(slab* s);
static void TreeInsert(slab* s,slab** r);
enum {EOkBits = (1<<(MAXSLABSIZE>>2))-1};
void SlabInit();
void SlabConfig(unsigned slabbitmap);
void* SlabAllocate(slabset& allocator);
void SlabFree(void* p);
void* AllocNewSlab(slabset& allocator);
void* AllocNewPage(slabset& allocator);
void* InitNewSlab(slabset& allocator, slab* s);
void FreeSlab(slab* s);
void FreePage(page* p);
void SlabInfo(struct HeapInfo* i, SWalkInfo* wi) const;
static void SlabFullInfo(slab* s, struct HeapInfo* i, SWalkInfo* wi);
static void SlabPartialInfo(slab* s, struct HeapInfo* i, SWalkInfo* wi);
static void SlabEmptyInfo(slab* s, struct HeapInfo* i, SWalkInfo* wi);
static void TreeWalk(slab* const* root, void (*f)(slab*, struct HeapInfo*, SWalkInfo*), struct HeapInfo* i, SWalkInfo* wi);
static void WalkPartialFullSlab(SWalkInfo* aInfo, slab* aSlab, TCellType aBfrType, TInt aLth);
static void WalkFullSlab(SWalkInfo* aInfo, slab* aSlab, TCellType aBfrType, TInt aLth);
void DoCheckSlab(slab* aSlab, TAllocatorType aSlabType, TAny* aBfr=NULL);
void DoCheckSlabTrees();
void DoCheckSlabTree(slab** aS, TBool aPartialPage);
void BuildPartialSlabBitmap(TUint32* aBitmap, slab* aSlab, TAny* aBfr=NULL);
static inline unsigned SlabHeaderFree(unsigned h)
{return (h&0x000000ff);}
static inline unsigned SlabHeaderPagemap(unsigned h)
{return (h&0x00000f00)>>8;}
static inline unsigned SlabHeaderSize(unsigned h)
{return (h&0x0003f000)>>12;}
static inline unsigned SlabHeaderUsedm4(unsigned h)
{return (h&0x0ffc0000)>>18;}
/***paged allocator code***/
void PagedInit(TInt aPagePower);
void* PagedAllocate(unsigned size);
void PagedFree(void* p);
void* PagedReallocate(void* p, unsigned size, TInt mode);
bool PagedEncode(unsigned pos, unsigned npage);
unsigned PagedDecode(unsigned pos) const;
inline unsigned PagedSize(void* p) const;
inline bool PagedSetSize(void* p, unsigned size);
inline void PagedZapSize(void* p, unsigned size);
inline void* Bitmap2addr(unsigned pos) const;
void PagedInfo(struct HeapInfo* i, SWalkInfo* wi) const;
void ResetBitmap();
TBool CheckBitmap(void* aBfr, TInt aSize, TUint32& aDummy, TInt& aNPages);
private:
paged_bitmap iPageMap; // bitmap representing page allocator's pages
TUint8* iMemBase; // bottom of paged/slab memory (chunk base)
TUint8 iBitMapBuffer[MAXSMALLPAGEBITS>>3]; // buffer for initial page bitmap
TInt iSlabThreshold; // allocations < than this are done by the slab allocator
TInt iPageThreshold; // 2^n is smallest cell size allocated in paged allocator
TInt iSlabInitThreshold; // slab allocator will be used after chunk reaches this size
TUint32 iSlabConfigBits; // set of bits that specify which slab sizes to use
slab* iPartialPage; // partial-use page tree
slab* iFullSlab; // full slabs list (so we can find them when walking)
page* iSparePage; // cached, to avoid kernel exec calls for unmapping/remapping
TUint8 iSizeMap[(MAXSLABSIZE>>2)+1]; // index of slabset indexes based on size class
slabset iSlabAlloc[MAXSLABSIZE>>2]; // array of pointers to slabsets
#endif // __KERNEL_MODE__
};
#define HEAP_ASSERT(x) __ASSERT_DEBUG(x, HEAP_PANIC(ETHeapBadCellAddress))
template <class T> inline T Floor(const T addr, unsigned aln)
{return T((unsigned(addr))&~(aln-1));}
template <class T> inline T Ceiling(T addr, unsigned aln)
{return T((unsigned(addr)+(aln-1))&~(aln-1));}
template <class T> inline unsigned LowBits(T addr, unsigned aln)
{return unsigned(addr)&(aln-1);}
template <class T1, class T2> inline int PtrDiff(const T1* a1, const T2* a2)
{return reinterpret_cast<const unsigned char*>(a1) - reinterpret_cast<const unsigned char*>(a2);}
template <class T> inline T Offset(T addr, unsigned ofs)
{return T(unsigned(addr)+ofs);}
#endif //__HEAP_HYBRID_H__

View File

@ -1,68 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef __KERNEL_MODE__
const int MAXSMALLPAGEBITS = 68<<3;
#define MINPAGEPOWER PAGESHIFT+2
struct paged_bitmap
{
public:
inline paged_bitmap() : iBase(0), iNbits(0) {}
void Init(unsigned char* p, unsigned size, unsigned bit);
//
inline unsigned char* Addr() const;
inline unsigned Size() const;
//
inline void Set(unsigned ix, unsigned bit);
inline unsigned operator[](unsigned ix) const;
bool Is(unsigned ix, unsigned len, unsigned bit) const;
void Set(unsigned ix, unsigned len, unsigned val);
void Setn(unsigned ix, unsigned len, unsigned bit);
unsigned Bits(unsigned ix, unsigned len) const; // little endian
int Find(unsigned start, unsigned bit) const;
private:
unsigned char* iBase;
unsigned iNbits;
};
#endif // __KERNEL_MODE__

View File

@ -1,472 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
** This file implements the generic atomics interface using ARMv6 assembly
** instructions. It is more efficient than the inline versions when Qt is
** built for the THUMB instruction set, as the required instructions are
** only available in ARM state.
****************************************************************************/
#include <QtCore/qglobal.h>
#ifdef QT_HAVE_ARMV6
#ifndef SYMBIAN_E32_ATOMIC_API
QT_BEGIN_NAMESPACE
QT_USE_NAMESPACE
#ifdef Q_CC_RVCT
#pragma push
#pragma arm
Q_CORE_EXPORT asm
bool QBasicAtomicInt_testAndSetRelaxed(volatile int *_q_value, int expectedValue, int newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
bool QBasicAtomicInt_testAndSetAcquire(volatile int *_q_value, int expectedValue, int newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
bool QBasicAtomicInt_testAndSetRelease(volatile int *_q_value, int expectedValue, int newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue)
{
CODE32
//R0 = _q_value
//R1 = expectedValue
//R2 = newValue
retry_testAndSetOrdered
LDREX r3,[r0] //r3 = *_q_value
EORS r3,r3,r1 //if (r3 == expectedValue) {
STREXEQ r3,r2,[r0] //*_q_value = newvalue, r3 = error
TEQEQ r3,#1 //if error
BEQ retry_testAndSetOrdered //then goto retry }
RSBS r0,r3,#1 //return (r3 == 0)
MOVCC r0,#0
BX r14
}
Q_CORE_EXPORT asm
int QBasicAtomicInt_fetchAndStoreRelaxed(volatile int *_q_value, int newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
int QBasicAtomicInt_fetchAndStoreAcquire(volatile int *_q_value, int newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
int QBasicAtomicInt_fetchAndStoreRelease(volatile int *_q_value, int newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue)
{
CODE32
//R0 = _q_value
//R1 = newValue
retry_fetchAndStoreOrdered
LDREX r3,[r0] //r3 = *_q_value
STREX r2,r1,[r0] //*_q_value = newValue, r2 = error
TEQ r2,#0 //if error
BNE retry_fetchAndStoreOrdered //then goto retry
MOV r0,r3 //return r3
BX r14
}
Q_CORE_EXPORT asm
int QBasicAtomicInt_fetchAndAddRelaxed(volatile int *_q_value, int valueToAdd)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
int QBasicAtomicInt_fetchAndAddAcquire(volatile int *_q_value, int valueToAdd)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
int QBasicAtomicInt_fetchAndAddRelease(volatile int *_q_value, int valueToAdd)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd)
{
CODE32
//R0 = _q_value
//R1 = valueToAdd
STMDB sp!,{r12,lr}
retry_fetchAndAddOrdered
LDREX r2,[r0] //r2 = *_q_value
ADD r3,r2,r1 //r3 = r2 + r1
STREX r12,r3,[r0] //*_q_value = r3, r12 = error
TEQ r12,#0 //if error
BNE retry_fetchAndAddOrdered //then retry
MOV r0,r2 //return r2
LDMIA sp!,{r12,pc}
}
Q_CORE_EXPORT asm
bool QBasicAtomicPointer_testAndSetRelaxed(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
bool QBasicAtomicPointer_testAndSetRelease(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
bool QBasicAtomicPointer_testAndSetAcquire(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
CODE32
//R0 = _q_value
//R1 = expectedValue
//R2 = newValue
retryPointer_testAndSetOrdered
LDREX r3,[r0] //r3 = *_q_value
EORS r3,r3,r1 //if (r3 == expectedValue) {
STREXEQ r3,r2,[r0] //*_q_value = newvalue, r3 = error
TEQEQ r3,#1 //if error
BEQ retryPointer_testAndSetOrdered //then goto retry }
RSBS r0,r3,#1 //return (r3 == 0)
MOVCC r0,#0
BX r14
}
Q_CORE_EXPORT asm
void *QBasicAtomicPointer_fetchAndStoreRelaxed(void * volatile *_q_value, void *newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
void *QBasicAtomicPointer_fetchAndStoreAcquire(void * volatile *_q_value, void *newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
void *QBasicAtomicPointer_fetchAndStoreRelease(void * volatile *_q_value, void *newValue)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue)
{
CODE32
//R0 = _q_value
//R1 = newValue
retryPointer_fetchAndStoreOrdered
LDREX r3,[r0] //r3 = *_q_value
STREX r2,r1,[r0] //*_q_value = newValue, r2 = error
TEQ r2,#0 //if error
BNE retryPointer_fetchAndStoreOrdered //then goto retry
MOV r0,r3 //return r3
BX r14
}
Q_CORE_EXPORT asm
void *QBasicAtomicPointer_fetchAndAddRelaxed(void * volatile *_q_value, qptrdiff valueToAdd)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
void *QBasicAtomicPointer_fetchAndAddRelease(void * volatile *_q_value, qptrdiff valueToAdd)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
void *QBasicAtomicPointer_fetchAndAddAcquire(void * volatile *_q_value, qptrdiff valueToAdd)
{
CODE32
//fall through
}
Q_CORE_EXPORT asm
void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd)
{
CODE32
//R0 = _q_value
//R1 = valueToAdd
STMDB sp!,{r12,lr}
retryPointer_fetchAndAddOrdered
LDREX r2,[r0] //r2 = *_q_value
ADD r3,r2,r1 //r3 = r2 + r1
STREX r12,r3,[r0] //*_q_value = r3, r12 = error
TEQ r12,#0 //if error
BNE retryPointer_fetchAndAddOrdered //then retry
MOV r0,r2 //return r2
LDMIA sp!,{r12,pc}
}
#pragma pop
#elif defined (Q_CC_GCCE)
Q_CORE_EXPORT __declspec( naked )
bool QBasicAtomicInt_testAndSetRelaxed(volatile int *_q_value, int expectedValue, int newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
bool QBasicAtomicInt_testAndSetAcquire(volatile int *_q_value, int expectedValue, int newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
bool QBasicAtomicInt_testAndSetRelease(volatile int *_q_value, int expectedValue, int newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue)
{
//R0 = _q_value
//R1 = expectedValue
//R2 = newValue
asm("retry_testAndSetOrdered:");
asm(" LDREX r3,[r0]"); //r3 = *_q_value
asm(" EORS r3,r3,r1"); //if (r3 == expectedValue) {
asm(" STREXEQ r3,r2,[r0]"); //*_q_value = newvalue, r3 = error
asm(" TEQEQ r3,#1"); //if error
asm(" BEQ retry_testAndSetOrdered"); //then goto retry }
asm(" RSBS r0,r3,#1"); //return (r3 == 0)
asm(" MOVCC r0,#0");
asm(" BX r14");
}
Q_CORE_EXPORT __declspec( naked )
int QBasicAtomicInt_fetchAndStoreRelaxed(volatile int *_q_value, int newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
int QBasicAtomicInt_fetchAndStoreAcquire(volatile int *_q_value, int newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
int QBasicAtomicInt_fetchAndStoreRelease(volatile int *_q_value, int newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue)
{
//R0 = _q_value
//R1 = newValue
asm("retry_fetchAndStoreOrdered:");
asm(" LDREX r3,[r0]"); //r3 = *_q_value
asm(" STREX r2,r1,[r0]"); //*_q_value = newValue, r2 = error
asm(" TEQ r2,#0"); //if error
asm(" BNE retry_fetchAndStoreOrdered"); //then goto retry
asm(" MOV r0,r3"); //return r3
asm(" BX r14");
}
Q_CORE_EXPORT __declspec( naked )
int QBasicAtomicInt_fetchAndAddRelaxed(volatile int *_q_value, int valueToAdd)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
int QBasicAtomicInt_fetchAndAddAcquire(volatile int *_q_value, int valueToAdd)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
int QBasicAtomicInt_fetchAndAddRelease(volatile int *_q_value, int valueToAdd)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd)
{
//R0 = _q_value
//R1 = valueToAdd
asm(" STMDB sp!,{r12,lr}");
asm("retry_fetchAndAddOrdered:");
asm(" LDREX r2,[r0]"); //r2 = *_q_value
asm(" ADD r3,r2,r1 "); //r3 = r2 + r1
asm(" STREX r12,r3,[r0]"); //*_q_value = r3, r12 = error
asm(" TEQ r12,#0"); //if error
asm(" BNE retry_fetchAndAddOrdered"); //then retry
asm(" MOV r0,r2"); //return r2
asm(" LDMIA sp!,{r12,pc}");
}
Q_CORE_EXPORT __declspec( naked )
bool QBasicAtomicPointer_testAndSetRelaxed(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
bool QBasicAtomicPointer_testAndSetRelease(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
bool QBasicAtomicPointer_testAndSetAcquire(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
//R0 = _q_value
//R1 = expectedValue
//R2 = newValue
asm("retryPointer_testAndSetOrdered:");
asm(" LDREX r3,[r0]"); //r3 = *_q_value
asm(" EORS r3,r3,r1"); //if (r3 == expectedValue) {
asm(" STREXEQ r3,r2,[r0]"); //*_q_value = newvalue, r3 = error
asm(" TEQEQ r3,#1"); //if error
asm(" BEQ retryPointer_testAndSetOrdered"); //then goto retry }
asm(" RSBS r0,r3,#1"); //return (r3 == 0)
asm(" MOVCC r0,#0");
asm(" BX r14");
}
Q_CORE_EXPORT __declspec( naked )
void *QBasicAtomicPointer_fetchAndStoreRelaxed(void * volatile *_q_value, void *newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
void *QBasicAtomicPointer_fetchAndStoreAcquire(void * volatile *_q_value, void *newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
void *QBasicAtomicPointer_fetchAndStoreRelease(void * volatile *_q_value, void *newValue)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue)
{
//R0 = _q_value
//R1 = newValue
asm("retryPointer_fetchAndStoreOrdered:");
asm(" LDREX r3,[r0]"); //r3 = *_q_value
asm(" STREX r2,r1,[r0]"); //*_q_value = newValue, r2 = error
asm(" TEQ r2,#0"); //if error
asm(" BNE retryPointer_fetchAndStoreOrdered"); //then goto retry
asm(" MOV r0,r3"); //return r3
asm(" BX r14");
}
Q_CORE_EXPORT __declspec( naked )
void *QBasicAtomicPointer_fetchAndAddRelaxed(void * volatile *_q_value, qptrdiff valueToAdd)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
void *QBasicAtomicPointer_fetchAndAddRelease(void * volatile *_q_value, qptrdiff valueToAdd)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
void *QBasicAtomicPointer_fetchAndAddAcquire(void * volatile *_q_value, qptrdiff valueToAdd)
{
//fall through
}
Q_CORE_EXPORT __declspec( naked )
void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd)
{
//R0 = _q_value
//R1 = valueToAdd
asm(" STMDB sp!,{r12,lr}");
asm("retryPointer_fetchAndAddOrdered:");
asm(" LDREX r2,[r0]"); //r2 = *_q_value
asm(" ADD r3,r2,r1"); //r3 = r2 + r1
asm(" STREX r12,r3,[r0]"); //*_q_value = r3, r12 = error
asm(" TEQ r12,#0"); //if error
asm(" BNE retryPointer_fetchAndAddOrdered"); //then retry
asm(" MOV r0,r2"); //return r2
asm(" LDMIA sp!,{r12,pc}");
}
#else
#error unknown arm compiler
#endif
QT_END_NAMESPACE
#endif
#endif

View File

@ -1,527 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtCore/qglobal.h>
#include <QtCore/qatomic.h>
#ifdef SYMBIAN_E32_ATOMIC_API
#include <e32atomics.h>
#endif
#include <e32debug.h>
QT_BEGIN_NAMESPACE
// Heap and handle info printer.
// This way we can report on heap cells and handles that are really not owned by anything which still exists.
// This information can be used to detect whether memory leaks are happening, particularly if these numbers grow as the app is used more.
// This code is placed here as it happens to make it the very last static to be destroyed in a Qt app. The
// reason assumed is that this file appears before any other file declaring static data in the generated
// Symbian MMP file. This particular file was chosen as it is the earliest symbian specific file.
struct QSymbianPrintExitInfo
{
QSymbianPrintExitInfo()
{
RThread().HandleCount(initProcessHandleCount, initThreadHandleCount);
initCells = User::CountAllocCells();
}
~QSymbianPrintExitInfo()
{
RProcess myProc;
TFullName fullName = myProc.FileName();
TInt cells = User::CountAllocCells();
TInt processHandleCount=0;
TInt threadHandleCount=0;
RThread().HandleCount(processHandleCount, threadHandleCount);
RDebug::Print(_L("%S exiting with %d allocated cells, %d handles"),
&fullName,
cells - initCells,
(processHandleCount + threadHandleCount) - (initProcessHandleCount + initThreadHandleCount));
}
TInt initCells;
TInt initProcessHandleCount;
TInt initThreadHandleCount;
} symbian_printExitInfo;
Q_CORE_EXPORT bool QBasicAtomicInt::isReferenceCountingNative()
{
#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6)
return true;
#else
return false;
#endif
}
Q_CORE_EXPORT bool QBasicAtomicInt::isTestAndSetNative()
{
#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6)
return true;
#else
return false;
#endif
}
Q_CORE_EXPORT bool QBasicAtomicInt::isFetchAndStoreNative()
{
#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6)
return true;
#else
return false;
#endif
}
Q_CORE_EXPORT bool QBasicAtomicInt::isFetchAndAddNative()
{
#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6)
return true;
#else
return false;
#endif
}
Q_CORE_EXPORT bool QBasicAtomicPointer_isTestAndSetNative()
{
#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6)
return true;
#else
return false;
#endif
}
Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndStoreNative()
{
#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6)
return true;
#else
return false;
#endif
}
Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndAddNative()
{
#if !defined(SYMBIAN_E32_ATOMIC_API) && defined(QT_HAVE_ARMV6)
return true;
#else
return false;
#endif
}
#ifdef SYMBIAN_E32_ATOMIC_API
//Symbian's API is SMP-safe when using SMP kernel, and cheap when using uniprocessor kernel
//generate compiler error if casting assumptions are wrong (symbian64?)
__ASSERT_COMPILE(sizeof(int) == sizeof(TUint32));
__ASSERT_COMPILE(sizeof(void *) == sizeof(TUint32));
Q_CORE_EXPORT
bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue)
{
return static_cast<bool>(__e32_atomic_cas_ord32(_q_value,
reinterpret_cast<TUint32*>(&expectedValue), newValue));
}
Q_CORE_EXPORT
bool QBasicAtomicInt_testAndSetRelaxed(volatile int *_q_value, int expectedValue, int newValue)
{
return static_cast<bool>(__e32_atomic_cas_rlx32(_q_value,
reinterpret_cast<TUint32*>(&expectedValue), newValue));
}
Q_CORE_EXPORT
bool QBasicAtomicInt_testAndSetAcquire(volatile int *_q_value, int expectedValue, int newValue)
{
return static_cast<bool>(__e32_atomic_cas_acq32(_q_value,
reinterpret_cast<TUint32*>(&expectedValue), newValue));
}
Q_CORE_EXPORT
bool QBasicAtomicInt_testAndSetRelease(volatile int *_q_value, int expectedValue, int newValue)
{
return static_cast<bool>(__e32_atomic_cas_rel32(_q_value,
reinterpret_cast<TUint32*>(&expectedValue), newValue));
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue)
{
return static_cast<int>(__e32_atomic_swp_ord32(_q_value, newValue));
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndStoreRelaxed(volatile int *_q_value, int newValue)
{
return static_cast<int>(__e32_atomic_swp_rlx32(_q_value, newValue));
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndStoreAcquire(volatile int *_q_value, int newValue)
{
return static_cast<int>(__e32_atomic_swp_acq32(_q_value, newValue));
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndStoreRelease(volatile int *_q_value, int newValue)
{
return static_cast<int>(__e32_atomic_swp_rel32(_q_value, newValue));
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd)
{
return static_cast<int>(__e32_atomic_add_ord32(_q_value, valueToAdd));
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndAddRelaxed(volatile int *_q_value, int valueToAdd)
{
return static_cast<int>(__e32_atomic_add_rlx32(_q_value, valueToAdd));
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndAddAcquire(volatile int *_q_value, int valueToAdd)
{
return static_cast<int>(__e32_atomic_add_acq32(_q_value, valueToAdd));
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndAddRelease(volatile int *_q_value, int valueToAdd)
{
return static_cast<int>(__e32_atomic_add_rel32(_q_value, valueToAdd));
}
Q_CORE_EXPORT
bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
return static_cast<bool>(__e32_atomic_cas_ord_ptr(_q_value,
&expectedValue,
newValue));
}
Q_CORE_EXPORT
bool QBasicAtomicPointer_testAndSetRelaxed(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
return static_cast<bool>(__e32_atomic_cas_rlx_ptr(_q_value,
&expectedValue,
newValue));
}
Q_CORE_EXPORT
bool QBasicAtomicPointer_testAndSetAcquire(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
return static_cast<bool>(__e32_atomic_cas_acq_ptr(_q_value,
&expectedValue,
newValue));
}
Q_CORE_EXPORT
bool QBasicAtomicPointer_testAndSetRelease(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
return static_cast<bool>(__e32_atomic_cas_rel_ptr(_q_value,
&expectedValue,
newValue));
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue)
{
return __e32_atomic_swp_ord_ptr(_q_value, newValue);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndStoreRelaxed(void * volatile *_q_value, void *newValue)
{
return __e32_atomic_swp_rlx_ptr(_q_value, newValue);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndStoreAcquire(void * volatile *_q_value, void *newValue)
{
return __e32_atomic_swp_acq_ptr(_q_value, newValue);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndStoreRelease(void * volatile *_q_value, void *newValue)
{
return __e32_atomic_swp_rel_ptr(_q_value, newValue);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd)
{
return __e32_atomic_add_ord_ptr(_q_value, valueToAdd);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndAddRelaxed(void * volatile *_q_value, qptrdiff valueToAdd)
{
return __e32_atomic_add_rlx_ptr(_q_value, valueToAdd);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndAddAcquire(void * volatile *_q_value, qptrdiff valueToAdd)
{
return __e32_atomic_add_acq_ptr(_q_value, valueToAdd);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndAddRelease(void * volatile *_q_value, qptrdiff valueToAdd)
{
return __e32_atomic_add_rel_ptr(_q_value, valueToAdd);
}
#else
//Symbian kernels 9.4 and earlier don't expose a suitable API
//For ARMv6, the generic atomics are machine coded
#ifndef QT_HAVE_ARMV6
class QCriticalSection
{
public:
QCriticalSection() { fastlock.CreateLocal(); }
~QCriticalSection() { fastlock.Close(); }
void lock() { fastlock.Wait(); }
void unlock() { fastlock.Signal(); }
private:
RFastLock fastlock;
};
QCriticalSection qAtomicCriticalSection;
Q_CORE_EXPORT
bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue)
{
bool returnValue = false;
qAtomicCriticalSection.lock();
if (*_q_value == expectedValue) {
*_q_value = newValue;
returnValue = true;
}
qAtomicCriticalSection.unlock();
return returnValue;
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue)
{
int returnValue;
qAtomicCriticalSection.lock();
returnValue = *_q_value;
*_q_value = newValue;
qAtomicCriticalSection.unlock();
return returnValue;
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd)
{
int returnValue;
qAtomicCriticalSection.lock();
returnValue = *_q_value;
*_q_value += valueToAdd;
qAtomicCriticalSection.unlock();
return returnValue;
}
Q_CORE_EXPORT
bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
bool returnValue = false;
qAtomicCriticalSection.lock();
if (*_q_value == expectedValue) {
*_q_value = newValue;
returnValue = true;
}
qAtomicCriticalSection.unlock();
return returnValue;
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue)
{
void *returnValue;
qAtomicCriticalSection.lock();
returnValue = *_q_value;
*_q_value = newValue;
qAtomicCriticalSection.unlock();
return returnValue;
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd)
{
void *returnValue;
qAtomicCriticalSection.lock();
returnValue = *_q_value;
*_q_value = reinterpret_cast<char *>(returnValue) + valueToAdd;
qAtomicCriticalSection.unlock();
return returnValue;
}
Q_CORE_EXPORT
bool QBasicAtomicInt_testAndSetRelaxed(volatile int *_q_value, int expectedValue, int newValue)
{
return QBasicAtomicInt_testAndSetOrdered(_q_value, expectedValue, newValue);
}
Q_CORE_EXPORT
bool QBasicAtomicInt_testAndSetAcquire(volatile int *_q_value, int expectedValue, int newValue)
{
return QBasicAtomicInt_testAndSetOrdered(_q_value, expectedValue, newValue);
}
Q_CORE_EXPORT
bool QBasicAtomicInt_testAndSetRelease(volatile int *_q_value, int expectedValue, int newValue)
{
return QBasicAtomicInt_testAndSetOrdered(_q_value, expectedValue, newValue);
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndStoreRelaxed(volatile int *_q_value, int newValue)
{
return QBasicAtomicInt_fetchAndStoreOrdered(_q_value, newValue);
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndStoreAcquire(volatile int *_q_value, int newValue)
{
return QBasicAtomicInt_fetchAndStoreOrdered(_q_value, newValue);
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndStoreRelease(volatile int *_q_value, int newValue)
{
return QBasicAtomicInt_fetchAndStoreOrdered(_q_value, newValue);
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndAddRelaxed(volatile int *_q_value, int valueToAdd)
{
return QBasicAtomicInt_fetchAndAddOrdered(_q_value, valueToAdd);
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndAddAcquire(volatile int *_q_value, int valueToAdd)
{
return QBasicAtomicInt_fetchAndAddOrdered(_q_value, valueToAdd);
}
Q_CORE_EXPORT
int QBasicAtomicInt_fetchAndAddRelease(volatile int *_q_value, int valueToAdd)
{
return QBasicAtomicInt_fetchAndAddOrdered(_q_value, valueToAdd);
}
Q_CORE_EXPORT
bool QBasicAtomicPointer_testAndSetRelaxed(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
return QBasicAtomicPointer_testAndSetOrdered(_q_value, expectedValue, newValue);
}
Q_CORE_EXPORT
bool QBasicAtomicPointer_testAndSetAcquire(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
return QBasicAtomicPointer_testAndSetOrdered(_q_value, expectedValue, newValue);
}
Q_CORE_EXPORT
bool QBasicAtomicPointer_testAndSetRelease(void * volatile *_q_value,
void *expectedValue,
void *newValue)
{
return QBasicAtomicPointer_testAndSetOrdered(_q_value, expectedValue, newValue);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndStoreRelaxed(void * volatile *_q_value, void *newValue)
{
return QBasicAtomicPointer_fetchAndStoreOrdered(_q_value, newValue);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndStoreAcquire(void * volatile *_q_value, void *newValue)
{
return QBasicAtomicPointer_fetchAndStoreOrdered(_q_value, newValue);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndStoreRelease(void * volatile *_q_value, void *newValue)
{
return QBasicAtomicPointer_fetchAndStoreOrdered(_q_value, newValue);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndAddRelaxed(void * volatile *_q_value, qptrdiff valueToAdd)
{
return QBasicAtomicPointer_fetchAndAddOrdered(_q_value, valueToAdd);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndAddAcquire(void * volatile *_q_value, qptrdiff valueToAdd)
{
return QBasicAtomicPointer_fetchAndAddOrdered(_q_value, valueToAdd);
}
Q_CORE_EXPORT
void *QBasicAtomicPointer_fetchAndAddRelease(void * volatile *_q_value, qptrdiff valueToAdd)
{
return QBasicAtomicPointer_fetchAndAddOrdered(_q_value, valueToAdd);
}
#endif // QT_HAVE_ARMV6
#endif // SYMBIAN_E32_ATOMIC_API
QT_END_NAMESPACE

View File

@ -1,105 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qt_hybridheap_symbian_p.h"
#ifdef QT_USE_NEW_SYMBIAN_ALLOCATOR
extern const TInt KHeapShrinkHysRatio = 0x800;
/*
* \internal
* Called from the qtmain.lib application wrapper.
* Create a new heap as requested, but use the new allocator
*/
Q_CORE_EXPORT TInt qt_symbian_SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo)
{
TInt r = KErrNone;
if (!aInfo.iAllocator && aInfo.iHeapInitialSize>0)
{
// new heap required
RHeap* pH = NULL;
r = UserHeap::CreateThreadHeap(aInfo, pH);
}
else if (aInfo.iAllocator)
{
// sharing a heap
RAllocator* pA = aInfo.iAllocator;
pA->Open();
User::SwitchAllocator(pA);
}
return r;
}
#ifndef NO_NAMED_LOCAL_CHUNKS
void TChunkCreateInfo::SetThreadHeap(TInt aInitialSize, TInt aMaxSize, const TDesC& aName)
{
iType = TChunkCreate::ENormal | TChunkCreate::EData;
iMaxSize = aMaxSize;
iInitialBottom = 0;
iInitialTop = aInitialSize;
iAttributes |= TChunkCreate::ELocalNamed;
iName = &aName;
iOwnerType = EOwnerThread;
}
#endif // NO_NAMED_LOCAL_CHUNKS
void Panic(TCdtPanic reason)
{
_LIT(KCat, "QtHybridHeap");
User::Panic(KCat, reason);
}
#else /* QT_USE_NEW_SYMBIAN_ALLOCATOR */
#include <e32std.h>
/*
* \internal
* Called from the qtmain.lib application wrapper.
* Create a new heap as requested, using the default system allocator
*/
Q_CORE_EXPORT TInt qt_symbian_SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo)
{
return UserHeap::SetupThreadHeap(aNotFirst, aInfo);
}
#endif /* QT_USE_NEW_SYMBIAN_ALLOCATOR */

View File

@ -1,178 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QT_HYBRIDHEAP_SYMBIAN_H
#define QT_HYBRIDHEAP_SYMBIAN_H
#include <qglobal.h>
#include <e32cmn.h>
#if !defined(__SYMBIAN_KERNEL_HYBRID_HEAP__) && !defined(__WINS__)
//Enable the (backported) new allocator. When it is available in OS,
//this flag should be disabled for that OS version onward
#define QT_USE_NEW_SYMBIAN_ALLOCATOR
#endif
#ifdef QT_USE_NEW_SYMBIAN_ALLOCATOR
#ifdef Q_CC_RVCT
#pragma push
#pragma arm
#pragma Otime
#pragma O2
#endif
#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
#include "dla_p.h"
#ifndef __KERNEL_MODE__
#include "slab_p.h"
#include "page_alloc_p.h"
#endif
#include "heap_hybrid_p.h"
// disabling Symbian import/export macros to prevent heap_hybrid.cpp, copied from Symbian^4, from exporting symbols in arm builds
// this minimises the code changes to heap_hybrid.cpp to ease future integration
#undef UEXPORT_C
#define UEXPORT_C
#undef EXPORT_C
#define EXPORT_C
#undef IMPORT_D
#define IMPORT_D
// disabling code ported from Symbian^4 that we don't want/can't have in earlier platforms
#define QT_SYMBIAN4_ALLOCATOR_UNWANTED_CODE
#if defined(SYMBIAN_VERSION_9_1) || defined(SYMBIAN_VERSION_9_2) || defined(SYMBIAN_VERSION_9_3) || defined(SYMBIAN_VERSION_9_4) || defined(SYMBIAN_VERSION_SYMBIAN2)
#define NO_NAMED_LOCAL_CHUNKS
#endif
// disabling the BTrace components of heap checking macros
#ifndef ENABLE_BTRACE
inline int noBTrace() {return 0;}
#define BTraceContext12(a,b,c,d,e) noBTrace()
#endif
// declare ETHeapBadDebugFailParameter, where missing
#define ETHeapBadDebugFailParameter ((TCdtPanic)213)
#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 */
#endif /* QT_HYBRIDHEAP_SYMBIAN_H */

View File

@ -1,125 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef __KERNEL_MODE__
class slab;
class slabhdr;
#define MAXSLABSIZE 56
#define PAGESHIFT 12
#define PAGESIZE (1<<PAGESHIFT)
#define SLABSHIFT 10
#define SLABSIZE (1 << SLABSHIFT)
#define CELLALIGN 8
const unsigned slabfull = 0;
const TInt slabsperpage = (int)(PAGESIZE/SLABSIZE);
#define HIBIT(bits) (((unsigned)bits & 0xc) ? 2 + ((unsigned)bits>>3) : ((unsigned) bits>>1))
#define LOWBIT(bits) (((unsigned) bits&3) ? 1 - ((unsigned)bits&1) : 3 - (((unsigned)bits>>2)&1))
#define ZEROBITS(header) (((unsigned)header & 0x70000000) ? 0 : 1)
class slabhdr
{
public:
unsigned iHeader;
// made up of
// bits | 31 | 30..28 | 27..18 | 17..12 | 11..8 | 7..0 |
// +----------+--------+--------+--------+---------+----------+
// field | floating | zero | used-4 | size | pagemap | free pos |
//
slab** iParent; // reference to iParent's pointer to this slab in tree
slab* iChild1; // 1st iChild in tree
slab* iChild2; // 2nd iChild in tree
};
const TInt KMaxSlabPayload = SLABSIZE - sizeof(slabhdr);
#define MAXUSEDM4BITS 0x0fc00000
#define FLOATING_BIT 0x80000000
inline unsigned HeaderFloating(unsigned h)
{return (h&0x80000000);}
const unsigned maxuse = (SLABSIZE - sizeof(slabhdr))>>2;
const unsigned firstpos = sizeof(slabhdr)>>2;
#ifdef _DEBUG
#define CHECKTREE(x) DoCheckSlabTree(x,EFalse)
#define CHECKSLAB(s,t,p) DoCheckSlab(s,t,p)
#define CHECKSLABBFR(s,p) {TUint32 b[4]; BuildPartialSlabBitmap(b,s,p);}
#else
#define CHECKTREE(x) (void)0
#define CHECKSLAB(s,t,p) (void)0
#define CHECKSLABBFR(s,p) (void)0
#endif
class slabset
{
public:
slab* iPartial;
};
class slab : public slabhdr
{
public:
void Init(unsigned clz);
//static slab* SlabFor( void* p);
static slab* SlabFor(const void* p) ;
unsigned char iPayload[SLABSIZE-sizeof(slabhdr)];
};
class page
{
public:
inline static page* PageFor(slab* s);
//slab iSlabs;
slab iSlabs[slabsperpage];
};
inline page* page::PageFor(slab* s)
{
return reinterpret_cast<page*>((unsigned(s))&~(PAGESIZE-1));
}
#endif // __KERNEL_MODE__