]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Only do the specialized MacOS single-core zone_malloc initialization if
authordrh <drh@noemail.net>
Sat, 18 Mar 2017 13:59:46 +0000 (13:59 +0000)
committerdrh <drh@noemail.net>
Sat, 18 Mar 2017 13:59:46 +0000 (13:59 +0000)
compiled with the SQLITE_MIGHT_BE_SINGLE_CORE flag.  This avoids a (harmless)
warning about OSAtomicCompareAndSwapPtrBarrier() being deprecated.

FossilOrigin-Name: 4e6a03d9e12b120d15946b025f97a97697cb8e8af543c238ffda220c9e3f28f4

manifest
manifest.uuid
src/mem1.c

index 0f47d77aec3bb8496fad3bffdd04be51aefbd6b0..d7127e3e78ae502386add0445d5c1f7aa1661c91 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\san\serror\sin\sthe\snewly\srevised\sdocumentation\sfor\sSQLITE_LIMIT_VDBE_OP.\nNo\schanges\sto\scode.
-D 2017-03-17T23:08:11.772
+C Only\sdo\sthe\sspecialized\sMacOS\ssingle-core\szone_malloc\sinitialization\sif\ncompiled\swith\sthe\sSQLITE_MIGHT_BE_SINGLE_CORE\sflag.\s\sThis\savoids\sa\s(harmless)\nwarning\sabout\sOSAtomicCompareAndSwapPtrBarrier()\sbeing\sdeprecated.
+D 2017-03-18T13:59:46.558
 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 1faf9f06aadc9284c212dea7bbc7c0dea7e8337f0287c81001eff500912c790a
@@ -368,7 +368,7 @@ F src/loadext.c a68d8d1d14cf7488bb29dc5311cb1ce9a4404258
 F src/main.c 158326243c5ddc8b98a1e983fa488650cf76d760
 F src/malloc.c 89c98e3619d362dcffa5c1c639b364b65b474751
 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
-F src/mem1.c fd7cd6fe21d46fe0a4186367dd8dc26d87b787eb
+F src/mem1.c 79bf195f445bf7e66cadd121849837c3152fbd2f542326bbed3073b6902450c2
 F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3
 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a
 F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944
@@ -1566,7 +1566,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P f74899ed2c78019abb406432a74dcd42a0ff8d9add005f8544dc4a8905f232eb
-R 2c6af10e620c43369539bc210339bdfc
+P f4cf8635e6fec6f04075cc067aaa71abc4f71739068e0ad2c44609dcb8691009
+R 07e88bce7a34b04a1e3a36ad2d4b6f58
 U drh
-Z 53bb8f51c26aa8f2582ebee07b281f74
+Z 906adb059f738e34206863c58e96feb3
index 56308247358824da1e765d57bd7c12f63194ad2e..4d805efd7a8a64e8917211d1f6a6ecb1615f400a 100644 (file)
@@ -1 +1 @@
-f4cf8635e6fec6f04075cc067aaa71abc4f71739068e0ad2c44609dcb8691009
\ No newline at end of file
+4e6a03d9e12b120d15946b025f97a97697cb8e8af543c238ffda220c9e3f28f4
\ No newline at end of file
index efc84c41d7658a175aca40c8b612239690987524..02ed59b4d4a921e1cf31f67d074dd3edd2515163 100644 (file)
@@ -57,7 +57,9 @@
 */
 #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));
@@ -236,33 +238,46 @@ static int sqlite3MemRoundup(int n){
 */
 static int sqlite3MemInit(void *NotUsed){
 #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)
-  int cpuCount;
-  size_t len;
   if( _sqliteZone_ ){
     return SQLITE_OK;
   }
-  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);
+#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
+#endif /* SQLITE_MIGHT_BE_SINGLE_CORE */
+#endif /*  defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) */
   UNUSED_PARAMETER(NotUsed);
   return SQLITE_OK;
 }