blob: c24f3da4c622c1904cc74e25babb3e524283a844 [file] [log] [blame]
drh437b9012007-08-28 16:34:42 +00001/*
2** 2007 August 28
3**
4** The author disclaims copyright to this source code. In place of
5** 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 available
15** to all source files. We break it out in an effort to keep the code
16** 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 file
20** include this one indirectly.
drh437b9012007-08-28 16:34:42 +000021*/
22
23
drh437b9012007-08-28 16:34:42 +000024/*
25** Figure out what version of the code to use. The choices are
26**
drh18472fa2008-10-07 15:25:48 +000027** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The
28** mutexes implemention cannot be overridden
29** at start-time.
drh437b9012007-08-28 16:34:42 +000030**
drh18472fa2008-10-07 15:25:48 +000031** SQLITE_MUTEX_NOOP For single-threaded applications. No
32** mutual exclusion is provided. But this
33** implementation can be overridden at
34** start-time.
drh437b9012007-08-28 16:34:42 +000035**
36** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix.
37**
drhc7ce76a2007-08-30 14:10:30 +000038** SQLITE_MUTEX_W32 For multi-threaded applications on Win32.
drh437b9012007-08-28 16:34:42 +000039**
40** SQLITE_MUTEX_OS2 For multi-threaded applications on OS/2.
41*/
drh18472fa2008-10-07 15:25:48 +000042#if !SQLITE_THREADSAFE
43# define SQLITE_MUTEX_OMIT
drh437b9012007-08-28 16:34:42 +000044#endif
drh18472fa2008-10-07 15:25:48 +000045#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP)
46# if SQLITE_OS_UNIX
47# define SQLITE_MUTEX_PTHREADS
48# elif SQLITE_OS_WIN
49# define SQLITE_MUTEX_W32
50# elif SQLITE_OS_OS2
51# define SQLITE_MUTEX_OS2
52# else
53# define SQLITE_MUTEX_NOOP
54# endif
drh437b9012007-08-28 16:34:42 +000055#endif
56
drh18472fa2008-10-07 15:25:48 +000057#ifdef SQLITE_MUTEX_OMIT
drh437b9012007-08-28 16:34:42 +000058/*
59** If this is a no-op implementation, implement everything as macros.
60*/
61#define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8)
62#define sqlite3_mutex_free(X)
63#define sqlite3_mutex_enter(X)
64#define sqlite3_mutex_try(X) SQLITE_OK
65#define sqlite3_mutex_leave(X)
shanehbd2aaf92010-09-01 02:38:21 +000066#define sqlite3_mutex_held(X) ((void)(X),1)
67#define sqlite3_mutex_notheld(X) ((void)(X),1)
drh8c4d6b92008-06-19 01:50:09 +000068#define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8)
danielk1977d0251742008-06-18 18:57:42 +000069#define sqlite3MutexInit() SQLITE_OK
70#define sqlite3MutexEnd()
dan1cf021e2009-09-30 04:28:04 +000071#endif /* defined(SQLITE_MUTEX_OMIT) */