Index: main.mk ================================================================== --- main.mk +++ main.mk @@ -7,17 +7,10 @@ # "configure.in" script. # # BCC C Compiler and options for use in building executables that # will run on the platform that is doing the build. # -# USLEEP If the target operating system supports the "usleep()" system -# call, then define the HAVE_USLEEP macro for all C modules. -# -# THREADSAFE If you want the SQLite library to be safe for use within a -# multi-threaded program, then define the following macro -# appropriately: -# # THREADLIB Specify any extra linker options needed to make the library # thread safe # # OPTS Extra compiler command-line options. # @@ -49,11 +42,11 @@ # build the SQLite library and testing tools. ################################################################################ # This is how we compile # -TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src +TCCX = $(TCC) $(OPTS) -I. -I$(TOP)/src # Object files for the SQLite library. # LIBOBJ+= alter.o analyze.o attach.o auth.o btmutex.o btree.o build.o \ callback.o complete.o date.o delete.o \ Index: src/btree.c ================================================================== --- src/btree.c +++ src/btree.c @@ -7,11 +7,11 @@ ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btree.c,v 1.421 2007/09/03 15:19:35 drh Exp $ +** $Id: btree.c,v 1.422 2007/09/03 22:00:39 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** See the header comment on "btreeInt.h" for additional information. ** Including a description of file format and an overview of operation. */ @@ -1265,15 +1265,17 @@ */ if( p->sharable ){ sqlite3_mutex *mutexShared; pBt->nRef = 1; mutexShared = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); - pBt->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); - if( pBt->mutex==0 ){ - rc = SQLITE_NOMEM; - pSqlite->mallocFailed = 0; - goto btree_open_out; + if( SQLITE_THREADSAFE ){ + pBt->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); + if( pBt->mutex==0 ){ + rc = SQLITE_NOMEM; + pSqlite->mallocFailed = 0; + goto btree_open_out; + } } sqlite3_mutex_enter(mutexShared); pBt->pNext = sqlite3SharedCacheList; sqlite3SharedCacheList = pBt; sqlite3_mutex_leave(mutexShared); @@ -1352,11 +1354,13 @@ } if( pList ){ pList->pNext = pBt->pNext; } } - sqlite3_mutex_free(pBt->mutex); + if( SQLITE_THREADSAFE ){ + sqlite3_mutex_free(pBt->mutex); + } removed = 1; } sqlite3_mutex_leave(pMaster); return removed; #else