| author | Matt Woodrow <pred@alliedmods.net> |
| Wed Apr 16 05:41:34 2008 +0000 (2008-04-16) | |
| changeset 2005 | 92033efef85f |
| parent 1952 | b7aa2b626807 |
| permissions | -rw-r--r-- |
| ds@1952 | 1 |
/* |
| ds@1952 | 2 |
** 2007 August 28 |
| ds@1952 | 3 |
** |
| ds@1952 | 4 |
** The author disclaims copyright to this source code. In place of |
| ds@1952 | 5 |
** a legal notice, here is a blessing: |
| ds@1952 | 6 |
** |
| ds@1952 | 7 |
** May you do good and not evil. |
| ds@1952 | 8 |
** May you find forgiveness for yourself and forgive others. |
| ds@1952 | 9 |
** May you share freely, never taking more than you give. |
| ds@1952 | 10 |
** |
| ds@1952 | 11 |
************************************************************************* |
| ds@1952 | 12 |
** |
| ds@1952 | 13 |
** This file contains the common header for all mutex implementations. |
| ds@1952 | 14 |
** The sqliteInt.h header #includes this file so that it is available |
| ds@1952 | 15 |
** to all source files. We break it out in an effort to keep the code |
| ds@1952 | 16 |
** better organized. |
| ds@1952 | 17 |
** |
| ds@1952 | 18 |
** NOTE: source files should *not* #include this header file directly. |
| ds@1952 | 19 |
** Source files should #include the sqliteInt.h file and let that file |
| ds@1952 | 20 |
** include this one indirectly. |
| ds@1952 | 21 |
** |
| ds@1952 | 22 |
** $Id$ |
| ds@1952 | 23 |
*/ |
| ds@1952 | 24 |
|
| ds@1952 | 25 |
|
| ds@1952 | 26 |
#ifdef SQLITE_MUTEX_APPDEF |
| ds@1952 | 27 |
/* |
| ds@1952 | 28 |
** If SQLITE_MUTEX_APPDEF is defined, then this whole module is |
| ds@1952 | 29 |
** omitted and equivalent functionality must be provided by the |
| ds@1952 | 30 |
** application that links against the SQLite library. |
| ds@1952 | 31 |
*/ |
| ds@1952 | 32 |
#else |
| ds@1952 | 33 |
/* |
| ds@1952 | 34 |
** Figure out what version of the code to use. The choices are |
| ds@1952 | 35 |
** |
| ds@1952 | 36 |
** SQLITE_MUTEX_NOOP For single-threaded applications that |
| ds@1952 | 37 |
** do not desire error checking. |
| ds@1952 | 38 |
** |
| ds@1952 | 39 |
** SQLITE_MUTEX_NOOP_DEBUG For single-threaded applications with |
| ds@1952 | 40 |
** error checking to help verify that mutexes |
| ds@1952 | 41 |
** are being used correctly even though they |
| ds@1952 | 42 |
** are not needed. Used when SQLITE_DEBUG is |
| ds@1952 | 43 |
** defined on single-threaded builds. |
| ds@1952 | 44 |
** |
| ds@1952 | 45 |
** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix. |
| ds@1952 | 46 |
** |
| ds@1952 | 47 |
** SQLITE_MUTEX_W32 For multi-threaded applications on Win32. |
| ds@1952 | 48 |
** |
| ds@1952 | 49 |
** SQLITE_MUTEX_OS2 For multi-threaded applications on OS/2. |
| ds@1952 | 50 |
*/ |
| ds@1952 | 51 |
#define SQLITE_MUTEX_NOOP 1 /* The default */ |
| ds@1952 | 52 |
#if defined(SQLITE_DEBUG) && !SQLITE_THREADSAFE |
| ds@1952 | 53 |
# undef SQLITE_MUTEX_NOOP |
| ds@1952 | 54 |
# define SQLITE_MUTEX_NOOP_DEBUG |
| ds@1952 | 55 |
#endif |
| ds@1952 | 56 |
#if defined(SQLITE_MUTEX_NOOP) && SQLITE_THREADSAFE && OS_UNIX |
| ds@1952 | 57 |
# undef SQLITE_MUTEX_NOOP |
| ds@1952 | 58 |
# define SQLITE_MUTEX_PTHREADS |
| ds@1952 | 59 |
#endif |
| ds@1952 | 60 |
#if defined(SQLITE_MUTEX_NOOP) && SQLITE_THREADSAFE && OS_WIN |
| ds@1952 | 61 |
# undef SQLITE_MUTEX_NOOP |
| ds@1952 | 62 |
# define SQLITE_MUTEX_W32 |
| ds@1952 | 63 |
#endif |
| ds@1952 | 64 |
#if defined(SQLITE_MUTEX_NOOP) && SQLITE_THREADSAFE && OS_OS2 |
| ds@1952 | 65 |
# undef SQLITE_MUTEX_NOOP |
| ds@1952 | 66 |
# define SQLITE_MUTEX_OS2 |
| ds@1952 | 67 |
#endif |
| ds@1952 | 68 |
|
| ds@1952 | 69 |
#ifdef SQLITE_MUTEX_NOOP |
| ds@1952 | 70 |
/* |
| ds@1952 | 71 |
** If this is a no-op implementation, implement everything as macros. |
| ds@1952 | 72 |
*/ |
| ds@1952 | 73 |
#define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8) |
| ds@1952 | 74 |
#define sqlite3_mutex_free(X) |
| ds@1952 | 75 |
#define sqlite3_mutex_enter(X) |
| ds@1952 | 76 |
#define sqlite3_mutex_try(X) SQLITE_OK |
| ds@1952 | 77 |
#define sqlite3_mutex_leave(X) |
| ds@1952 | 78 |
#define sqlite3_mutex_held(X) 1 |
| ds@1952 | 79 |
#define sqlite3_mutex_notheld(X) 1 |
| ds@1952 | 80 |
#endif |
| ds@1952 | 81 |
|
| ds@1952 | 82 |
#endif /* SQLITE_MUTEX_APPDEF */ |