summaryrefslogtreecommitdiff
path: root/components/external
diff options
context:
space:
mode:
authorgeniusgogo <[email protected]>2013-11-15 18:10:08 +0000
committergeniusgogo <[email protected]>2013-11-30 14:59:54 +0800
commit993374d860beed9bea309dda235ae200dcc7945c (patch)
tree7120e494bd4a1810be9e747d72f2cddb0731a9a5 /components/external
parentbb718508635fbaaf3efe6a9a9f771c7e432ed7e6 (diff)
add rtt memory management support
Diffstat (limited to 'components/external')
-rw-r--r--components/external/SQLite-3.8.1/src/mem1.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/components/external/SQLite-3.8.1/src/mem1.c b/components/external/SQLite-3.8.1/src/mem1.c
index 3578496f33..17bf6ef0df 100644
--- a/components/external/SQLite-3.8.1/src/mem1.c
+++ b/components/external/SQLite-3.8.1/src/mem1.c
@@ -75,10 +75,27 @@ static malloc_zone_t* _sqliteZone_;
#define SQLITE_MALLOCSIZE(x) \
(_sqliteZone_ ? _sqliteZone_->size(_sqliteZone_,x) : malloc_size(x))
+#elif defined(SQLITE_OS_RTT)
+/*
+** Use standard C library malloc and free on non-Apple systems.
+** Also used by rt-thread systems if SQLITE_WITHOUT_ZONEMALLOC is defined.
+*/
+#define SQLITE_MALLOC(x) rt_malloc(x)
+#define SQLITE_FREE(x) rt_free(x)
+#define SQLITE_REALLOC(x,y) rt_realloc((x),(y))
+
+#if (!defined(SQLITE_WITHOUT_MSIZE)) \
+ && (defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE))
+# error "not have malloc_usable_size()"
+#endif
+#ifdef HAVE_MALLOC_USABLE_SIZE
+# undef SQLITE_MALLOCSIZE
+#endif
+
#else /* if not __APPLE__ */
/*
-** Use standard C library malloc and free on non-Apple systems.
+** Use standard C library malloc and free on non-Apple systems.
** Also used by Apple systems if SQLITE_WITHOUT_ZONEMALLOC is defined.
*/
#define SQLITE_MALLOC(x) malloc(x)
@@ -229,13 +246,13 @@ static int sqlite3MemInit(void *NotUsed){
/* defer MT decisions to system malloc */
_sqliteZone_ = malloc_default_zone();
}else{
- /* only 1 core, use our own zone to contention over global locks,
+ /* only 1 core, use our own zone to contention over global locks,
** e.g. we have our own dedicated locks */
bool success;
malloc_zone_t* newzone = malloc_create_zone(4096, 0);
malloc_set_zone_name(newzone, "Sqlite_Heap");
do{
- success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone,
+ success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone,
(void * volatile *)&_sqliteZone_);
}while(!_sqliteZone_);
if( !success ){