Finish refactoring of DomCodeToUsLayoutKeyboardCode().
[chromium-blink-merge.git] / third_party / sqlite / sqlite-src-3080704 / src / os_common.h
blobf6c3e7ff89463086401822f481e7e3b87b2c78c7
1 /*
2 ** 2004 May 22
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.
11 ******************************************************************************
13 ** This file contains macros and a little bit of code that is common to
14 ** all of the platform-specific files (os_*.c) and is #included into those
15 ** files.
17 ** This file should be #included by the os_*.c files only. It is not a
18 ** general purpose header file.
20 #ifndef _OS_COMMON_H_
21 #define _OS_COMMON_H_
24 ** At least two bugs have slipped in because we changed the MEMORY_DEBUG
25 ** macro to SQLITE_DEBUG and some older makefiles have not yet made the
26 ** switch. The following code should catch this problem at compile-time.
28 #ifdef MEMORY_DEBUG
29 # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
30 #endif
32 #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
33 # ifndef SQLITE_DEBUG_OS_TRACE
34 # define SQLITE_DEBUG_OS_TRACE 0
35 # endif
36 int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
37 # define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
38 #else
39 # define OSTRACE(X)
40 #endif
43 ** Macros for performance tracing. Normally turned off. Only works
44 ** on i486 hardware.
46 #ifdef SQLITE_PERFORMANCE_TRACE
48 /*
49 ** hwtime.h contains inline assembler code for implementing
50 ** high-performance timing routines.
52 #include "hwtime.h"
54 static sqlite_uint64 g_start;
55 static sqlite_uint64 g_elapsed;
56 #define TIMER_START g_start=sqlite3Hwtime()
57 #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start
58 #define TIMER_ELAPSED g_elapsed
59 #else
60 #define TIMER_START
61 #define TIMER_END
62 #define TIMER_ELAPSED ((sqlite_uint64)0)
63 #endif
66 ** If we compile with the SQLITE_TEST macro set, then the following block
67 ** of code will give us the ability to simulate a disk I/O error. This
68 ** is used for testing the I/O recovery logic.
70 #ifdef SQLITE_TEST
71 int sqlite3_io_error_hit = 0; /* Total number of I/O Errors */
72 int sqlite3_io_error_hardhit = 0; /* Number of non-benign errors */
73 int sqlite3_io_error_pending = 0; /* Count down to first I/O error */
74 int sqlite3_io_error_persist = 0; /* True if I/O errors persist */
75 int sqlite3_io_error_benign = 0; /* True if errors are benign */
76 int sqlite3_diskfull_pending = 0;
77 int sqlite3_diskfull = 0;
78 #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)
79 #define SimulateIOError(CODE) \
80 if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \
81 || sqlite3_io_error_pending-- == 1 ) \
82 { local_ioerr(); CODE; }
83 static void local_ioerr(){
84 IOTRACE(("IOERR\n"));
85 sqlite3_io_error_hit++;
86 if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++;
88 #define SimulateDiskfullError(CODE) \
89 if( sqlite3_diskfull_pending ){ \
90 if( sqlite3_diskfull_pending == 1 ){ \
91 local_ioerr(); \
92 sqlite3_diskfull = 1; \
93 sqlite3_io_error_hit = 1; \
94 CODE; \
95 }else{ \
96 sqlite3_diskfull_pending--; \
97 } \
99 #else
100 #define SimulateIOErrorBenign(X)
101 #define SimulateIOError(A)
102 #define SimulateDiskfullError(A)
103 #endif
106 ** When testing, keep a count of the number of open files.
108 #ifdef SQLITE_TEST
109 int sqlite3_open_file_count = 0;
110 #define OpenCounter(X) sqlite3_open_file_count+=(X)
111 #else
112 #define OpenCounter(X)
113 #endif
115 #endif /* !defined(_OS_COMMON_H_) */