Joe Mistachkin wrote:
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); }
With this algorithm, where there are not multiple memory objects having some defined, coordinated meaning with respect to each other, the barrier not necessary. So this code could be simplified to simply use the non-barrier pointer swap, always.
Cheers, -- Larry Brasfield _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users