OLD | NEW |
1 /* | 1 /* |
2 ** 2007 August 28 | 2 ** 2007 August 28 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
11 ************************************************************************* | 11 ************************************************************************* |
12 ** | 12 ** |
13 ** This file contains the common header for all mutex implementations. | 13 ** This file contains the common header for all mutex implementations. |
14 ** The sqliteInt.h header #includes this file so that it is available | 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 | 15 ** to all source files. We break it out in an effort to keep the code |
16 ** better organized. | 16 ** better organized. |
17 ** | 17 ** |
18 ** NOTE: source files should *not* #include this header file directly. | 18 ** NOTE: source files should *not* #include this header file directly. |
19 ** Source files should #include the sqliteInt.h file and let that file | 19 ** Source files should #include the sqliteInt.h file and let that file |
20 ** include this one indirectly. | 20 ** include this one indirectly. |
21 */ | 21 */ |
22 | 22 |
23 | 23 |
24 /* | 24 /* |
25 ** Figure out what version of the code to use. The choices are | 25 ** Figure out what version of the code to use. The choices are |
26 ** | 26 ** |
27 ** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The | 27 ** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The |
28 ** mutexes implemention cannot be overridden | 28 ** mutexes implementation cannot be overridden |
29 ** at start-time. | 29 ** at start-time. |
30 ** | 30 ** |
31 ** SQLITE_MUTEX_NOOP For single-threaded applications. No | 31 ** SQLITE_MUTEX_NOOP For single-threaded applications. No |
32 ** mutual exclusion is provided. But this | 32 ** mutual exclusion is provided. But this |
33 ** implementation can be overridden at | 33 ** implementation can be overridden at |
34 ** start-time. | 34 ** start-time. |
35 ** | 35 ** |
36 ** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix. | 36 ** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix. |
37 ** | 37 ** |
38 ** SQLITE_MUTEX_W32 For multi-threaded applications on Win32. | 38 ** SQLITE_MUTEX_W32 For multi-threaded applications on Win32. |
39 ** | |
40 ** SQLITE_MUTEX_OS2 For multi-threaded applications on OS/2. | |
41 */ | 39 */ |
42 #if !SQLITE_THREADSAFE | 40 #if !SQLITE_THREADSAFE |
43 # define SQLITE_MUTEX_OMIT | 41 # define SQLITE_MUTEX_OMIT |
44 #endif | 42 #endif |
45 #if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP) | 43 #if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP) |
46 # if SQLITE_OS_UNIX | 44 # if SQLITE_OS_UNIX |
47 # define SQLITE_MUTEX_PTHREADS | 45 # define SQLITE_MUTEX_PTHREADS |
48 # elif SQLITE_OS_WIN | 46 # elif SQLITE_OS_WIN |
49 # define SQLITE_MUTEX_W32 | 47 # define SQLITE_MUTEX_W32 |
50 # elif SQLITE_OS_OS2 | |
51 # define SQLITE_MUTEX_OS2 | |
52 # else | 48 # else |
53 # define SQLITE_MUTEX_NOOP | 49 # define SQLITE_MUTEX_NOOP |
54 # endif | 50 # endif |
55 #endif | 51 #endif |
56 | 52 |
57 #ifdef SQLITE_MUTEX_OMIT | 53 #ifdef SQLITE_MUTEX_OMIT |
58 /* | 54 /* |
59 ** If this is a no-op implementation, implement everything as macros. | 55 ** If this is a no-op implementation, implement everything as macros. |
60 */ | 56 */ |
61 #define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8) | 57 #define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8) |
62 #define sqlite3_mutex_free(X) | 58 #define sqlite3_mutex_free(X) |
63 #define sqlite3_mutex_enter(X) | 59 #define sqlite3_mutex_enter(X) |
64 #define sqlite3_mutex_try(X) SQLITE_OK | 60 #define sqlite3_mutex_try(X) SQLITE_OK |
65 #define sqlite3_mutex_leave(X) | 61 #define sqlite3_mutex_leave(X) |
66 #define sqlite3_mutex_held(X) ((void)(X),1) | 62 #define sqlite3_mutex_held(X) ((void)(X),1) |
67 #define sqlite3_mutex_notheld(X) ((void)(X),1) | 63 #define sqlite3_mutex_notheld(X) ((void)(X),1) |
68 #define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8) | 64 #define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8) |
69 #define sqlite3MutexInit() SQLITE_OK | 65 #define sqlite3MutexInit() SQLITE_OK |
70 #define sqlite3MutexEnd() | 66 #define sqlite3MutexEnd() |
| 67 #define MUTEX_LOGIC(X) |
| 68 #else |
| 69 #define MUTEX_LOGIC(X) X |
71 #endif /* defined(SQLITE_MUTEX_OMIT) */ | 70 #endif /* defined(SQLITE_MUTEX_OMIT) */ |
OLD | NEW |