Thanks to visit codestin.com
Credit goes to chromium.googlesource.com

blob: a6806a2505900b821b6389c8f5f17ec33e8ef8fe [file] [log] [blame]
drh437b9012007-08-28 16:34:421/*
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:4221*/
22
23
drh437b9012007-08-28 16:34:4224/*
25** Figure out what version of the code to use. The choices are
26**
drh18472fa2008-10-07 15:25:4827** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The
peter.d.reid60ec9142014-09-06 16:39:4628** mutexes implementation cannot be overridden
drh18472fa2008-10-07 15:25:4829** at start-time.
drh437b9012007-08-28 16:34:4230**
drh18472fa2008-10-07 15:25:4831** 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:4235**
36** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix.
37**
drhc7ce76a2007-08-30 14:10:3038** SQLITE_MUTEX_W32 For multi-threaded applications on Win32.
drh437b9012007-08-28 16:34:4239*/
drh18472fa2008-10-07 15:25:4840#if !SQLITE_THREADSAFE
41# define SQLITE_MUTEX_OMIT
drh437b9012007-08-28 16:34:4242#endif
drh18472fa2008-10-07 15:25:4843#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP)
44# if SQLITE_OS_UNIX
45# define SQLITE_MUTEX_PTHREADS
46# elif SQLITE_OS_WIN
47# define SQLITE_MUTEX_W32
drh18472fa2008-10-07 15:25:4848# else
49# define SQLITE_MUTEX_NOOP
50# endif
drh437b9012007-08-28 16:34:4251#endif
52
drh18472fa2008-10-07 15:25:4853#ifdef SQLITE_MUTEX_OMIT
drh437b9012007-08-28 16:34:4254/*
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)
drh30ddce62011-10-15 00:16:3059#define sqlite3_mutex_enter(X)
drh437b9012007-08-28 16:34:4260#define sqlite3_mutex_try(X) SQLITE_OK
drh30ddce62011-10-15 00:16:3061#define sqlite3_mutex_leave(X)
shanehbd2aaf92010-09-01 02:38:2162#define sqlite3_mutex_held(X) ((void)(X),1)
63#define sqlite3_mutex_notheld(X) ((void)(X),1)
drh8c4d6b92008-06-19 01:50:0964#define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8)
danielk1977d0251742008-06-18 18:57:4265#define sqlite3MutexInit() SQLITE_OK
66#define sqlite3MutexEnd()
drh30ddce62011-10-15 00:16:3067#define MUTEX_LOGIC(X)
68#else
69#define MUTEX_LOGIC(X) X
drhe2b7a762019-10-02 00:25:0870int sqlite3_mutex_held(sqlite3_mutex*);
dan1cf021e2009-09-30 04:28:0471#endif /* defined(SQLITE_MUTEX_OMIT) */