]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Remove internal function sqlite3OsDefaultVfs(). The built-in VFS layers now register...
authordanielk1977 <danielk1977@noemail.net>
Wed, 25 Jun 2008 17:19:00 +0000 (17:19 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Wed, 25 Jun 2008 17:19:00 +0000 (17:19 +0000)
FossilOrigin-Name: 8fa33b79d7369ec5777fd9ad3349f0fa31b98fd6

manifest
manifest.uuid
src/main.c
src/os.c
src/os.h
src/os_os2.c
src/os_unix.c
src/os_win.c
src/sqliteInt.h

index 16a675e43c919b1cf36d8f968553b561ece9daf2..885ffc5ec9501de4737fd64b0f1286f5eff6c7b1 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Have\smem3.c\sand\smem5.c\sgrab\sa\smutex\swhen\srequired.\sInclude\sthem\sboth\sin\sthe\samalgamation\sagain.\s(CVS\s5306)
-D 2008-06-25T14:57:54
+C Remove\sinternal\sfunction\ssqlite3OsDefaultVfs().\sThe\sbuilt-in\sVFS\slayers\snow\sregister\stheir\sVFS\simplementations\sby\scalling\ssqlite3_vfs_register()\sfrom\swithin\ssqlite3_os_init().\s(CVS\s5307)
+D 2008-06-25T17:19:01
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in ff6f90048555a0088f6a4b7406bed5e55a7c4eff
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -114,7 +114,7 @@ F src/insert.c f8c7da31409ec19a769b960a4a2b9cca7bab80bd
 F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
 F src/legacy.c 3626c71fb70912abec9a4312beba753a9ce800df
 F src/loadext.c 40024a0f476c1279494876b9a002001b29e5d3e3
-F src/main.c 1291a974ff9ffcb771ce4060795c9c3059268049
+F src/main.c 88a34d852e8e592b89146d3975b37cea3dd3160d
 F src/malloc.c f52166df8abd7ff6990dbee1a0ce3534addc8617
 F src/md5.c 008216bbb5d34c6fbab5357aa68575ad8a31516a
 F src/mem1.c 8340fa5f969e9f9b9bdeb54106457a2003456d2b
@@ -127,12 +127,12 @@ F src/mutex.h 236677b27760d85701b5872d01b5cafedde5f0a9
 F src/mutex_os2.c 9c5637aa4c307c552566d0f0b3bd206245b54a97
 F src/mutex_unix.c c1526811f4b97a7cd9d4d72d2b9623d06abd05ce
 F src/mutex_w32.c 7aa9ad79b36931314b81ac4045f40f2c503b1e44
-F src/os.c b1c73547466b832612b3be425a8f21afd603fd9b
-F src/os.h c9a7f94e80193fd4cf27f5c5698eb56753f1b05a
+F src/os.c 3e98547ef92358a44ed32e025b81599026c2660f
+F src/os.h a7bc8d7232b69ce8ba536cafd8514c877bc3342c
 F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
-F src/os_os2.c 4647d718d7ad3f84c3d1241cda971a0ae67cb45e
-F src/os_unix.c b8c07b0cd85c9909000740dc3f29ce938091b00c
-F src/os_win.c 0b90d9a1ce18bfd2a5f3c4a6bdb13ec369c805a9
+F src/os_os2.c 205900770c90f77718dcae4d8f28c60ab4657250
+F src/os_unix.c 800138f4b9e2c26c89b0f8085441ec188fd5c19e
+F src/os_win.c 77cae913383157348a4ac0a6385e8543b28103a1
 F src/pager.c e2a49872f1e15eb83895ace704c48ac8ded998ba
 F src/pager.h 6aa3050a3c684475a5a9dbad5ff1cebad612acba
 F src/parse.y 8c2c3145eebe1964eb279cb3c4e502eae28bb0fa
@@ -144,7 +144,7 @@ F src/select.c 79f60dc4a7e90bb907c7a2cca42f45276d1ead99
 F src/shell.c 61fa61932ed52825720ebfd3f8381b8d550ef766
 F src/sqlite.h.in b5c731b88ab1275396920103b5ecbefba200d423
 F src/sqlite3ext.h f162a72daef5ebf8b211fe8c0ec96e85d22fbf9b
-F src/sqliteInt.h d045d18b412345ed2f9d2e5a05e6de25051522a5
+F src/sqliteInt.h 55d1a6c155eaad745d8e4b7f373f5904337fbaf1
 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
 F src/status.c 6cb10377992505bd69f1ca1d75c1240a65f25a58
 F src/table.c 1fa8f8113ac9cbc09ae4801c6d2a7f0af82c5822
@@ -594,7 +594,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P edf7f518361902924105142a8c67b898ba7d532f
-R 1a009318bac5f3e776bc54f3122c8111
+P 9e3c95ff4048cd8e4c56acf7a8ebedc49621e9c7
+R dd99e8c754ee82c9c2d08705cbcbd9a2
 U danielk1977
-Z 0a0f9328bf9a2e8862b4f65895b7ec64
+Z d4c5b3f927846f2701cf2cdd435f8f43
index 047abb925efc872d3f3b2c3c3ff4a76235be8a23..8eeec8f09c17be5f74727150a2c3fe6ca4bb0544 100644 (file)
@@ -1 +1 @@
-9e3c95ff4048cd8e4c56acf7a8ebedc49621e9c7
\ No newline at end of file
+8fa33b79d7369ec5777fd9ad3349f0fa31b98fd6
\ No newline at end of file
index 36fe82bbfa8fd886bb9074c154338994b167f4b8..520c16a4fca96fd6e9f15dfc89848bc847e39100 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.461 2008/06/25 14:26:08 danielk1977 Exp $
+** $Id: main.c,v 1.462 2008/06/25 17:19:01 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -53,12 +53,6 @@ void (*sqlite3IoTrace)(const char*, ...) = 0;
 */
 char *sqlite3_temp_directory = 0;
 
-/*
-** Flags to help SQLite determine if it has been initialized.
-*/
-static int sqlite3IsInit = 0;        /* Initialization has started */
-static int sqlite3FullInit = 0;      /* Initialization is complete */
-
 /*
 ** Initialize SQLite.  
 **
@@ -73,22 +67,22 @@ static int sqlite3FullInit = 0;      /* Initialization is complete */
 */
 int sqlite3_initialize(void){
   int rc;
-  if( sqlite3IsInit ) return SQLITE_OK;
+  if( sqlite3Config.isInit ) return SQLITE_OK;
   rc = sqlite3MutexInit();
   if( rc==SQLITE_OK ){
 #ifndef SQLITE_MUTEX_NOOP
     sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
 #endif
     sqlite3_mutex_enter(pMutex);
-    if( sqlite3IsInit==0 ){
-      sqlite3IsInit = 1;
+    if( sqlite3Config.isInit==0 ){
+      sqlite3Config.isInit = 1;
       sqlite3StatusReset();
       if( rc==SQLITE_OK ) rc = sqlite3MallocInit();
       if( rc==SQLITE_OK ) rc = sqlite3_os_init();
       if( rc!=SQLITE_OK ){
-        sqlite3IsInit = 0;
+        sqlite3Config.isInit = 0;
       }else{
-        sqlite3FullInit = 1;
+        sqlite3Config.isInit = 2;
       }
     }
     sqlite3_mutex_leave(pMutex);
@@ -106,8 +100,7 @@ int sqlite3_shutdown(void){
   sqlite3_os_end();
   sqlite3MallocEnd();
   sqlite3MutexEnd();
-  sqlite3FullInit = 0;
-  sqlite3IsInit = 0;
+  sqlite3Config.isInit = 0;
   return SQLITE_OK;
 }
 
@@ -126,7 +119,7 @@ int sqlite3_config(int op, ...){
 
   /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while
   ** the SQLite library is in use. */
-  if( sqlite3FullInit ) return SQLITE_MISUSE;
+  if( sqlite3Config.isInit==2 ) return SQLITE_MISUSE;
 
   va_start(ap, op);
   switch( op ){
index 2b4b2f6fd2402df0f09bd343b06fff367ad83999..a746cd72699c3db28034353a8f3f2a7a2b84c07b 100644 (file)
--- a/src/os.c
+++ b/src/os.c
@@ -13,7 +13,7 @@
 ** This file contains OS interface code that is common to all
 ** architectures.
 **
-** $Id: os.c,v 1.115 2008/06/19 16:07:07 drh Exp $
+** $Id: os.c,v 1.116 2008/06/25 17:19:01 danielk1977 Exp $
 */
 #define _SQLITE_OS_C_ 1
 #include "sqliteInt.h"
@@ -188,9 +188,7 @@ int sqlite3OsCloseFree(sqlite3_file *pFile){
 }
 
 /*
-** The list of all registered VFS implementations.  This list is
-** initialized to the single VFS returned by sqlite3OsDefaultVfs()
-** upon the first call to sqlite3_vfs_find().
+** The list of all registered VFS implementations.
 */
 static sqlite3_vfs *vfsList = 0;
 
@@ -200,7 +198,6 @@ static sqlite3_vfs *vfsList = 0;
 */
 sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
   sqlite3_vfs *pVfs = 0;
-  static int isInit = 0;
 #ifndef SQLITE_MUTEX_NOOP
   sqlite3_mutex *mutex;
 #endif
@@ -212,10 +209,6 @@ sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
   mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
 #endif
   sqlite3_mutex_enter(mutex);
-  if( !isInit ){
-    vfsList = sqlite3OsDefaultVfs();
-    isInit = 1;
-  }
   for(pVfs = vfsList; pVfs; pVfs=pVfs->pNext){
     if( zVfs==0 ) break;
     if( strcmp(zVfs, pVfs->zName)==0 ) break;
@@ -251,16 +244,17 @@ static void vfsUnlink(sqlite3_vfs *pVfs){
 */
 int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
 #ifndef SQLITE_MUTEX_NOOP
-  sqlite3_mutex *mutex;
+  sqlite3_mutex *mutex = 0;
 #endif
 #ifndef SQLITE_OMIT_AUTOINIT
   int rc = sqlite3_initialize();
   if( rc ) return rc;
 #endif
 #ifndef SQLITE_MUTEX_NOOP
-  mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
+  if( sqlite3Config.isInit!=1 ){
+    mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
+  }
 #endif
-  sqlite3_vfs_find(0);  /* Make sure we are initialized */
   sqlite3_mutex_enter(mutex);
   vfsUnlink(pVfs);
   if( makeDflt || vfsList==0 ){
@@ -288,10 +282,3 @@ int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
   return SQLITE_OK;
 }
 
-/*
-** Provide a default sqlite3OsDefaultVfs() implementation in the
-** cases where none of the standard backends are used.
-*/
-#if !OS_UNIX && !OS_WIN && !OS_OS2
-sqlite3_vfs *sqlite3OsDefaultVfs(void){ return 0; }
-#endif
index d0af1f469d8e73ca58e221cdbf5e011a0518f982..a3ad215deec1285353524ede3651a9747b06b726 100644 (file)
--- a/src/os.h
+++ b/src/os.h
@@ -17,7 +17,7 @@
 ** This header file is #include-ed by sqliteInt.h and thus ends up
 ** being included by every source file.
 **
-** $Id: os.h,v 1.103 2008/06/09 21:57:23 drh Exp $
+** $Id: os.h,v 1.104 2008/06/25 17:19:01 danielk1977 Exp $
 */
 #ifndef _SQLITE_OS_H_
 #define _SQLITE_OS_H_
@@ -271,14 +271,4 @@ int sqlite3OsCurrentTime(sqlite3_vfs *, double*);
 int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*);
 int sqlite3OsCloseFree(sqlite3_file *);
 
-/*
-** Each OS-specific backend defines an instance of the following
-** structure for returning a pointer to its sqlite3_vfs.  If OS_OTHER
-** is defined (meaning that the application-defined OS interface layer
-** is used) then there is no default VFS.   The application must
-** register one or more VFS structures using sqlite3_vfs_register()
-** before attempting to use SQLite.
-*/
-sqlite3_vfs *sqlite3OsDefaultVfs(void);
-
 #endif /* _SQLITE_OS_H_ */
index ffa767e44951e9c0bea5f5c1391ff1f977c81a6e..7594a0a439a5e572ff3c9782732167ce5efa0fec 100644 (file)
@@ -12,7 +12,7 @@
 **
 ** This file contains code that is specific to OS/2.
 **
-** $Id: os_os2.c,v 1.45 2008/06/24 22:50:06 pweilbacher Exp $
+** $Id: os_os2.c,v 1.46 2008/06/25 17:19:01 danielk1977 Exp $
 */
 
 #include "sqliteInt.h"
@@ -1046,12 +1046,9 @@ static int os2GetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
 }
 
 /*
-** Return a pointer to the sqlite3DefaultVfs structure.   We use
-** a function rather than give the structure global scope because
-** some compilers (MSVC) do not allow forward declarations of
-** initialized structures.
+** Initialize and deinitialize the operating system interface.
 */
-sqlite3_vfs *sqlite3OsDefaultVfs(void){
+int sqlite3_os_init(void){
   static sqlite3_vfs os2Vfs = {
     1,                 /* iVersion */
     sizeof(os2File),   /* szOsFile */
@@ -1073,15 +1070,11 @@ sqlite3_vfs *sqlite3OsDefaultVfs(void){
     os2CurrentTime,    /* xCurrentTime */
     os2GetLastError    /* xGetLastError */
   };
-
-  return &os2Vfs;
+  sqlite3_vfs_register(&os2Vfs, 1);
+  return SQLITE_OK; 
+}
+int sqlite3_os_end(void){ 
+  return SQLITE_OK; 
 }
-
-/*
-** Initialize and deinitialize the operating system interface.
-** These are stubs for now - populate with real code later...
-*/
-int sqlite3_os_init(void){ return SQLITE_OK; }
-int sqlite3_os_end(void){ return SQLITE_OK; }
 
 #endif /* OS_OS2 */
index 906e4b6359b7f2770024ae28040a580cc7bf4f7a..d651267620f27c5d76469937290e771ca2f2a35f 100644 (file)
@@ -12,7 +12,7 @@
 **
 ** This file contains code that is specific to Unix systems.
 **
-** $Id: os_unix.c,v 1.188 2008/06/18 17:09:10 danielk1977 Exp $
+** $Id: os_unix.c,v 1.189 2008/06/25 17:19:01 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #if OS_UNIX              /* This file is used on unix only */
@@ -2780,12 +2780,9 @@ static int unixGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
 }
 
 /*
-** Return a pointer to the sqlite3DefaultVfs structure.   We use
-** a function rather than give the structure global scope because
-** some compilers (MSVC) do not allow forward declarations of
-** initialized structures.
+** Initialize and deinitialize the operating system interface.
 */
-sqlite3_vfs *sqlite3OsDefaultVfs(void){
+int sqlite3_os_init(void){ 
   static sqlite3_vfs unixVfs = {
     1,                  /* iVersion */
     sizeof(unixFile),   /* szOsFile */
@@ -2807,16 +2804,11 @@ sqlite3_vfs *sqlite3OsDefaultVfs(void){
     unixCurrentTime,    /* xCurrentTime */
     unixGetLastError    /* xGetLastError */
   };
-  
-  return &unixVfs;
+  sqlite3_vfs_register(&unixVfs, 1);
+  return SQLITE_OK; 
+}
+int sqlite3_os_end(void){ 
+  return SQLITE_OK; 
 }
-
-/*
-** Initialize and deinitialize the operating system interface.
-** These are stubs for now - populate with real code later...
-*/
-int sqlite3_os_init(void){ return SQLITE_OK; }
-int sqlite3_os_end(void){ return SQLITE_OK; }
-
  
 #endif /* OS_UNIX */
index 4193a16209d012fb945426c0de2bd16a48d4d51e..c708314c9d9afac2897e7fc5b25a99899754013e 100644 (file)
@@ -12,7 +12,7 @@
 **
 ** This file contains code that is specific to windows.
 **
-** $Id: os_win.c,v 1.127 2008/06/13 18:24:27 drh Exp $
+** $Id: os_win.c,v 1.128 2008/06/25 17:19:01 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #if OS_WIN               /* This file is used for windows only */
@@ -1553,12 +1553,9 @@ static int winGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
 }
 
 /*
-** Return a pointer to the sqlite3DefaultVfs structure.   We use
-** a function rather than give the structure global scope because
-** some compilers (MSVC) do not allow forward declarations of
-** initialized structures.
+** Initialize and deinitialize the operating system interface.
 */
-sqlite3_vfs *sqlite3OsDefaultVfs(void){
+int sqlite3_os_init(void){
   static sqlite3_vfs winVfs = {
     1,                 /* iVersion */
     sizeof(winFile),   /* szOsFile */
@@ -1580,15 +1577,11 @@ sqlite3_vfs *sqlite3OsDefaultVfs(void){
     winCurrentTime,    /* xCurrentTime */
     winGetLastError    /* xGetLastError */
   };
-
-  return &winVfs;
+  sqlite3_vfs_register(&winVfs, 1);
+  return SQLITE_OK; 
+}
+int sqlite3_os_end(void){ 
+  return SQLITE_OK;
 }
-
-/*
-** Initialize and deinitialize the operating system interface.
-** These are stubs for now - populate with real code later...
-*/
-int sqlite3_os_init(void){ return SQLITE_OK; }
-int sqlite3_os_end(void){ return SQLITE_OK; }
 
 #endif /* OS_WIN */
index 34a69bcde54fb1bb16c4cb9b160389885a7c33d2..65c374d405b56ea60550665a97d2ea8df3d3b1b5 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.728 2008/06/25 14:26:08 danielk1977 Exp $
+** @(#) $Id: sqliteInt.h,v 1.729 2008/06/25 17:19:01 danielk1977 Exp $
 */
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
@@ -1734,6 +1734,12 @@ typedef struct {
 ** Structure containing global configuration data for the SQLite library.
 **
 ** This structure also contains some state information.
+**
+** The Sqlite3Config.isInit variable indicates whether or not
+** sqlite3_initialize() has already been called or not. Initially, isInit
+** is 0. While sqlite3_initialize() is running, it is set to 1. After
+** sqlite3_initialize has successfully run, the Sqlite3Config.isInit variable
+** is set to 2. Calling sqlite3_shutdown() resets the value to 0.
 */
 struct Sqlite3Config {
   int bMemstat;                     /* True to enable memory status */
@@ -1750,6 +1756,7 @@ struct Sqlite3Config {
   void *pPage;                      /* Page cache memory */
   int szPage;                       /* Size of each page in pPage[] */
   int nPage;                        /* Number of pages in pPage[] */
+  int isInit;                       /* Initialization state */
 };
 
 /*