Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Only do the specialized MacOS single-core zone_malloc initialization if compiled with the SQLITE_MIGHT_BE_SINGLE_CORE flag. This avoids a (harmless) warning about OSAtomicCompareAndSwapPtrBarrier() being deprecated. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
4e6a03d9e12b120d15946b025f97a976 |
User & Date: | drh 2017-03-18 13:59:46.558 |
Context
2017-03-20
| ||
13:03 | Documentation fix: SQLITE_SOURCE_ID is a now a SHA3-256 hash. (check-in: 2aa22509e7 user: drh tags: trunk) | |
2017-03-18
| ||
13:59 | Only do the specialized MacOS single-core zone_malloc initialization if compiled with the SQLITE_MIGHT_BE_SINGLE_CORE flag. This avoids a (harmless) warning about OSAtomicCompareAndSwapPtrBarrier() being deprecated. (check-in: 4e6a03d9e1 user: drh tags: trunk) | |
2017-03-17
| ||
23:08 | Fix an error in the newly revised documentation for SQLITE_LIMIT_VDBE_OP. No changes to code. (check-in: f4cf8635e6 user: drh tags: trunk) | |
Changes
Changes to src/mem1.c.
︙ | ︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /* ** Use the zone allocator available on apple products unless the ** SQLITE_WITHOUT_ZONEMALLOC symbol is defined. */ #include <sys/sysctl.h> #include <malloc/malloc.h> #include <libkern/OSAtomic.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) \ (_sqliteZone_ ? _sqliteZone_->size(_sqliteZone_,x) : malloc_size(x)) | > > | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | /* ** Use the zone allocator available on apple products unless the ** SQLITE_WITHOUT_ZONEMALLOC symbol is defined. */ #include <sys/sysctl.h> #include <malloc/malloc.h> #ifdef SQLITE_MIGHT_BE_SINGLE_CORE #include <libkern/OSAtomic.h> #endif /* SQLITE_MIGHT_BE_SINGLE_CORE */ 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) \ (_sqliteZone_ ? _sqliteZone_->size(_sqliteZone_,x) : malloc_size(x)) |
︙ | ︙ | |||
232 233 234 235 236 237 238 | } /* ** Initialize this module. */ static int sqlite3MemInit(void *NotUsed){ #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) | < < > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | > | > | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | } /* ** Initialize this module. */ static int sqlite3MemInit(void *NotUsed){ #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) if( _sqliteZone_ ){ return SQLITE_OK; } #ifndef SQLITE_MIGHT_BE_SINGLE_CORE /* If not compiled with the SQLITE_MIGHT_BE_SINGLE_CORE flag, assume ** that multiple cores are always available. This is the default case. */ _sqliteZone_ = malloc_default_zone(); #else /* With the SQLITE_MIGHT_BE_SINGLE_CORE compile-time option, check the ** number of cores. Different malloc() strategies are used for single-core and ** multi-core machines. */ { int cpuCount; size_t len; len = sizeof(cpuCount); /* One usually wants to use hw.acctivecpu for MT decisions, but not here */ sysctlbyname("hw.ncpu", &cpuCount, &len, NULL, 0); if( cpuCount>1 ){ /* defer MT decisions to system malloc */ _sqliteZone_ = malloc_default_zone(); }else{ /* 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, (void * volatile *)&_sqliteZone_); }while(!_sqliteZone_); if( !success ){ /* somebody registered a zone first */ malloc_destroy_zone(newzone); } } } #endif /* SQLITE_MIGHT_BE_SINGLE_CORE */ #endif /* defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) */ UNUSED_PARAMETER(NotUsed); return SQLITE_OK; } /* ** Deinitialize this module. */ |
︙ | ︙ |