DISCLAIMER: I am *NOT* an expert on Mac OS X programming.
That being said, I think the following patch might work
(this is UNTESTED, as I have no readily available Apple hardware):
Index: src/mem1.c
==================================================================
--- src/mem1.c
+++ src/mem1.c
@@ -72,10 +72,11 @@
** SQLITE_WITHOUT_ZONEMALLOC symbol is defined.
*/
#include <sys/sysctl.h>
#include <malloc/malloc.h>
#include <libkern/OSAtomic.h>
+#include <AvailabilityMacros.h>
static malloc_zone_t* _sqliteZone_;
#define SQLITE_MALLOC(x) malloc_zone_malloc(_sqliteZone_, (x))
#define SQLITE_FREE(x) malloc_zone_free(_sqliteZone_, (x));
#define SQLITE_REALLOC(x,y) malloc_zone_realloc(_sqliteZone_, (x), (y))
#define SQLITE_MALLOCSIZE(x) \
@@ -236,12 +237,18 @@
** 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{
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone,
(void * volatile *)&_sqliteZone_);
+#else
+ success = OSAtomicCompareAndSwapPtr(NULL, newzone,
+ (void * volatile *)&_sqliteZone_);
+ OSMemoryBarrier();
+#endif
}while(!_sqliteZone_);
if( !success ){
/* somebody registered a zone first */
malloc_destroy_zone(newzone);
}
--
Joe Mistachkin
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users