aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mutex.c11
-rw-r--r--src/mutex_unix.c2
-rw-r--r--src/sqliteInt.h2
3 files changed, 12 insertions, 3 deletions
diff --git a/src/mutex.c b/src/mutex.c
index a2e4e6387..6f1bc9767 100644
--- a/src/mutex.c
+++ b/src/mutex.c
@@ -22,7 +22,7 @@
** allocate a mutex while the system is uninitialized.
*/
static SQLITE_WSD int mutexIsInit = 0;
-#endif /* SQLITE_DEBUG */
+#endif /* SQLITE_DEBUG && !defined(SQLITE_MUTEX_OMIT) */
#ifndef SQLITE_MUTEX_OMIT
@@ -56,6 +56,7 @@ int sqlite3MutexInit(void){
sqlite3MemoryBarrier();
pTo->xMutexAlloc = pFrom->xMutexAlloc;
}
+ assert( sqlite3GlobalConfig.mutex.xMutexInit );
rc = sqlite3GlobalConfig.mutex.xMutexInit();
#ifdef SQLITE_DEBUG
@@ -90,6 +91,7 @@ sqlite3_mutex *sqlite3_mutex_alloc(int id){
if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0;
if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0;
#endif
+ assert( sqlite3GlobalConfig.mutex.xMutexAlloc );
return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
}
@@ -98,6 +100,7 @@ sqlite3_mutex *sqlite3MutexAlloc(int id){
return 0;
}
assert( GLOBAL(int, mutexIsInit) );
+ assert( sqlite3GlobalConfig.mutex.xMutexAlloc );
return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
}
@@ -106,6 +109,7 @@ sqlite3_mutex *sqlite3MutexAlloc(int id){
*/
void sqlite3_mutex_free(sqlite3_mutex *p){
if( p ){
+ assert( sqlite3GlobalConfig.mutex.xMutexFree );
sqlite3GlobalConfig.mutex.xMutexFree(p);
}
}
@@ -116,6 +120,7 @@ void sqlite3_mutex_free(sqlite3_mutex *p){
*/
void sqlite3_mutex_enter(sqlite3_mutex *p){
if( p ){
+ assert( sqlite3GlobalConfig.mutex.xMutexEnter );
sqlite3GlobalConfig.mutex.xMutexEnter(p);
}
}
@@ -127,6 +132,7 @@ void sqlite3_mutex_enter(sqlite3_mutex *p){
int sqlite3_mutex_try(sqlite3_mutex *p){
int rc = SQLITE_OK;
if( p ){
+ assert( sqlite3GlobalConfig.mutex.xMutexTry );
return sqlite3GlobalConfig.mutex.xMutexTry(p);
}
return rc;
@@ -140,6 +146,7 @@ int sqlite3_mutex_try(sqlite3_mutex *p){
*/
void sqlite3_mutex_leave(sqlite3_mutex *p){
if( p ){
+ assert( sqlite3GlobalConfig.mutex.xMutexLeave );
sqlite3GlobalConfig.mutex.xMutexLeave(p);
}
}
@@ -150,9 +157,11 @@ void sqlite3_mutex_leave(sqlite3_mutex *p){
** intended for use inside assert() statements.
*/
int sqlite3_mutex_held(sqlite3_mutex *p){
+ assert( p==0 || sqlite3GlobalConfig.mutex.xMutexHeld );
return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);
}
int sqlite3_mutex_notheld(sqlite3_mutex *p){
+ assert( p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld );
return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
}
#endif
diff --git a/src/mutex_unix.c b/src/mutex_unix.c
index 78fba1d81..cebb96c90 100644
--- a/src/mutex_unix.c
+++ b/src/mutex_unix.c
@@ -86,7 +86,7 @@ static int pthreadMutexNotheld(sqlite3_mutex *p){
void sqlite3MemoryBarrier(void){
#if defined(SQLITE_MEMORY_BARRIER)
SQLITE_MEMORY_BARRIER;
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && GCC_VERSION>=4001000
__sync_synchronize();
#endif
}
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 98cbca519..c9452b1d5 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -3195,7 +3195,7 @@ const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);
#if !defined(SQLITE_MUTEX_OMIT) && !defined(SQLITE_MUTEX_NOOP)
void sqlite3MemoryBarrier(void);
#else
-# define sqlite3MemoryBarrier();
+# define sqlite3MemoryBarrier()
#endif
sqlite3_int64 sqlite3StatusValue(int);