Team Ai
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
mutex.h72 linesDownload Raw Back to src
1/*2** 2007 August 283**4** The author disclaims copyright to this source code.  In place of5** a legal notice, here is a blessing:6**7**    May you do good and not evil.8**    May you find forgiveness for yourself and forgive others.9**    May you share freely, never taking more than you give.10**11*************************************************************************12**13** This file contains the common header for all mutex implementations.14** The sqliteInt.h header #includes this file so that it is available15** to all source files.  We break it out in an effort to keep the code16** better organized.17**18** NOTE:  source files should *not* #include this header file directly.19** Source files should #include the sqliteInt.h file and let that file20** include this one indirectly.21*/22 23 24/*25** Figure out what version of the code to use.  The choices are26**27**   SQLITE_MUTEX_OMIT         No mutex logic.  Not even stubs.  The28**                             mutexes implementation cannot be overridden29**                             at start-time.30**31**   SQLITE_MUTEX_NOOP         For single-threaded applications.  No32**                             mutual exclusion is provided.  But this33**                             implementation can be overridden at34**                             start-time.35**36**   SQLITE_MUTEX_PTHREADS     For multi-threaded applications on Unix.37**38**   SQLITE_MUTEX_W32          For multi-threaded applications on Win32.39*/40#if !SQLITE_THREADSAFE41# define SQLITE_MUTEX_OMIT42#endif43#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP)44#  if SQLITE_OS_UNIX45#    define SQLITE_MUTEX_PTHREADS46#  elif SQLITE_OS_WIN47#    define SQLITE_MUTEX_W3248#  else49#    define SQLITE_MUTEX_NOOP50#  endif51#endif52 53#ifdef SQLITE_MUTEX_OMIT54/*55** If this is a no-op implementation, implement everything as macros.56*/57#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)58#define sqlite3_mutex_free(X)59#define sqlite3_mutex_enter(X)    60#define sqlite3_mutex_try(X)      SQLITE_OK61#define sqlite3_mutex_leave(X)    62#define sqlite3_mutex_held(X)     ((void)(X),1)63#define sqlite3_mutex_notheld(X)  ((void)(X),1)64#define sqlite3MutexAlloc(X)      ((sqlite3_mutex*)8)65#define sqlite3MutexInit()        SQLITE_OK66#define sqlite3MutexEnd()67#define MUTEX_LOGIC(X)68#else69#define MUTEX_LOGIC(X)            X70int sqlite3_mutex_held(sqlite3_mutex*);71#endif /* defined(SQLITE_MUTEX_OMIT) */72