Blame src/mutex.h

Packit 87b942
/*
Packit 87b942
** 2007 August 28
Packit 87b942
**
Packit 87b942
** The author disclaims copyright to this source code.  In place of
Packit 87b942
** a legal notice, here is a blessing:
Packit 87b942
**
Packit 87b942
**    May you do good and not evil.
Packit 87b942
**    May you find forgiveness for yourself and forgive others.
Packit 87b942
**    May you share freely, never taking more than you give.
Packit 87b942
**
Packit 87b942
*************************************************************************
Packit 87b942
**
Packit 87b942
** This file contains the common header for all mutex implementations.
Packit 87b942
** The sqliteInt.h header #includes this file so that it is available
Packit 87b942
** to all source files.  We break it out in an effort to keep the code
Packit 87b942
** better organized.
Packit 87b942
**
Packit 87b942
** NOTE:  source files should *not* #include this header file directly.
Packit 87b942
** Source files should #include the sqliteInt.h file and let that file
Packit 87b942
** include this one indirectly.
Packit 87b942
*/
Packit 87b942
Packit 87b942
Packit 87b942
/*
Packit 87b942
** Figure out what version of the code to use.  The choices are
Packit 87b942
**
Packit 87b942
**   SQLITE_MUTEX_OMIT         No mutex logic.  Not even stubs.  The
Packit 87b942
**                             mutexes implementation cannot be overridden
Packit 87b942
**                             at start-time.
Packit 87b942
**
Packit 87b942
**   SQLITE_MUTEX_NOOP         For single-threaded applications.  No
Packit 87b942
**                             mutual exclusion is provided.  But this
Packit 87b942
**                             implementation can be overridden at
Packit 87b942
**                             start-time.
Packit 87b942
**
Packit 87b942
**   SQLITE_MUTEX_PTHREADS     For multi-threaded applications on Unix.
Packit 87b942
**
Packit 87b942
**   SQLITE_MUTEX_W32          For multi-threaded applications on Win32.
Packit 87b942
*/
Packit 87b942
#if !SQLITE_THREADSAFE
Packit 87b942
# define SQLITE_MUTEX_OMIT
Packit 87b942
#endif
Packit 87b942
#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP)
Packit 87b942
#  if SQLITE_OS_UNIX
Packit 87b942
#    define SQLITE_MUTEX_PTHREADS
Packit 87b942
#  elif SQLITE_OS_WIN
Packit 87b942
#    define SQLITE_MUTEX_W32
Packit 87b942
#  else
Packit 87b942
#    define SQLITE_MUTEX_NOOP
Packit 87b942
#  endif
Packit 87b942
#endif
Packit 87b942
Packit 87b942
#ifdef SQLITE_MUTEX_OMIT
Packit 87b942
/*
Packit 87b942
** If this is a no-op implementation, implement everything as macros.
Packit 87b942
*/
Packit 87b942
#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)
Packit 87b942
#define sqlite3_mutex_free(X)
Packit 87b942
#define sqlite3_mutex_enter(X)    
Packit 87b942
#define sqlite3_mutex_try(X)      SQLITE_OK
Packit 87b942
#define sqlite3_mutex_leave(X)    
Packit 87b942
#define sqlite3_mutex_held(X)     ((void)(X),1)
Packit 87b942
#define sqlite3_mutex_notheld(X)  ((void)(X),1)
Packit 87b942
#define sqlite3MutexAlloc(X)      ((sqlite3_mutex*)8)
Packit 87b942
#define sqlite3MutexInit()        SQLITE_OK
Packit 87b942
#define sqlite3MutexEnd()
Packit 87b942
#define MUTEX_LOGIC(X)
Packit 87b942
#else
Packit 87b942
#define MUTEX_LOGIC(X)            X
Packit 87b942
#endif /* defined(SQLITE_MUTEX_OMIT) */