|
1 /* |
|
2 ** 2001 September 16 |
|
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 header file (together with is companion C source-code file |
|
14 ** "os.c") attempt to abstract the underlying operating system so that |
|
15 ** the SQLite library will work on both POSIX and windows systems. |
|
16 */ |
|
17 #ifndef _SQLITE_OS_H_ |
|
18 #define _SQLITE_OS_H_ |
|
19 |
|
20 /* |
|
21 ** Figure out if we are dealing with Unix, Windows, or some other |
|
22 ** operating system. |
|
23 */ |
|
24 #if !defined(OS_UNIX) && !defined(OS_OTHER) |
|
25 # define OS_OTHER 0 |
|
26 # ifndef OS_WIN |
|
27 # if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) |
|
28 # define OS_WIN 1 |
|
29 # define OS_UNIX 0 |
|
30 # define OS_OS2 0 |
|
31 # elif defined(_EMX_) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__) |
|
32 # define OS_WIN 0 |
|
33 # define OS_UNIX 0 |
|
34 # define OS_OS2 1 |
|
35 # else |
|
36 # define OS_WIN 0 |
|
37 # define OS_UNIX 1 |
|
38 # define OS_OS2 0 |
|
39 # endif |
|
40 # else |
|
41 # define OS_UNIX 0 |
|
42 # define OS_OS2 0 |
|
43 # endif |
|
44 #else |
|
45 # ifndef OS_WIN |
|
46 # define OS_WIN 0 |
|
47 # endif |
|
48 #endif |
|
49 |
|
50 #undef OS_WIN |
|
51 #undef OS_UNIX |
|
52 #undef OS_OS2 |
|
53 #undef OS_OTHER |
|
54 |
|
55 /* |
|
56 ** Define the maximum size of a temporary filename |
|
57 */ |
|
58 #if OS_WIN |
|
59 # include <windows.h> |
|
60 # define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) |
|
61 #elif OS_OS2 |
|
62 # define INCL_DOSDATETIME |
|
63 # define INCL_DOSFILEMGR |
|
64 # define INCL_DOSERRORS |
|
65 # define INCL_DOSMISC |
|
66 # define INCL_DOSPROCESS |
|
67 # include <os2.h> |
|
68 # define SQLITE_TEMPNAME_SIZE (CCHMAXPATHCOMP) |
|
69 #else |
|
70 # define SQLITE_TEMPNAME_SIZE 200 |
|
71 #endif |
|
72 |
|
73 /* If the SET_FULLSYNC macro is not defined above, then make it |
|
74 ** a no-op |
|
75 */ |
|
76 #ifndef SET_FULLSYNC |
|
77 # define SET_FULLSYNC(x,y) |
|
78 #endif |
|
79 |
|
80 /* |
|
81 ** Temporary files are named starting with this prefix followed by 16 random |
|
82 ** alphanumeric characters, and no file extension. They are stored in the |
|
83 ** OS's standard temporary file directory, and are deleted prior to exit. |
|
84 ** If sqlite is being embedded in another program, you may wish to change the |
|
85 ** prefix to reflect your program's name, so that if your program exits |
|
86 ** prematurely, old temporary files can be easily identified. This can be done |
|
87 ** using -DTEMP_FILE_PREFIX=myprefix_ on the compiler command line. |
|
88 */ |
|
89 #ifndef TEMP_FILE_PREFIX |
|
90 # define TEMP_FILE_PREFIX "sqlite_" |
|
91 #endif |
|
92 |
|
93 /* |
|
94 ** Define the interfaces for Unix, Windows, and OS/2. |
|
95 */ |
|
96 #if OS_UNIX |
|
97 #define sqlite3OsOpenReadWrite sqlite3UnixOpenReadWrite |
|
98 #define sqlite3OsOpenExclusive sqlite3UnixOpenExclusive |
|
99 #define sqlite3OsOpenReadOnly sqlite3UnixOpenReadOnly |
|
100 #define sqlite3OsDelete sqlite3UnixDelete |
|
101 #define sqlite3OsFileExists sqlite3UnixFileExists |
|
102 #define sqlite3OsFullPathname sqlite3UnixFullPathname |
|
103 #define sqlite3OsIsDirWritable sqlite3UnixIsDirWritable |
|
104 #define sqlite3OsSyncDirectory sqlite3UnixSyncDirectory |
|
105 #define sqlite3OsTempFileName sqlite3UnixTempFileName |
|
106 #define sqlite3OsRandomSeed sqlite3UnixRandomSeed |
|
107 #define sqlite3OsSleep sqlite3UnixSleep |
|
108 #define sqlite3OsCurrentTime sqlite3UnixCurrentTime |
|
109 #define sqlite3OsEnterMutex sqlite3UnixEnterMutex |
|
110 #define sqlite3OsLeaveMutex sqlite3UnixLeaveMutex |
|
111 #define sqlite3OsInMutex sqlite3UnixInMutex |
|
112 #define sqlite3OsThreadSpecificData sqlite3UnixThreadSpecificData |
|
113 #define sqlite3OsMalloc sqlite3GenericMalloc |
|
114 #define sqlite3OsRealloc sqlite3GenericRealloc |
|
115 #define sqlite3OsFree sqlite3GenericFree |
|
116 #define sqlite3OsAllocationSize sqlite3GenericAllocationSize |
|
117 #endif |
|
118 #if OS_WIN |
|
119 #define sqlite3OsOpenReadWrite sqlite3WinOpenReadWrite |
|
120 #define sqlite3OsOpenExclusive sqlite3WinOpenExclusive |
|
121 #define sqlite3OsOpenReadOnly sqlite3WinOpenReadOnly |
|
122 #define sqlite3OsDelete sqlite3WinDelete |
|
123 #define sqlite3OsFileExists sqlite3WinFileExists |
|
124 #define sqlite3OsFullPathname sqlite3WinFullPathname |
|
125 #define sqlite3OsIsDirWritable sqlite3WinIsDirWritable |
|
126 #define sqlite3OsSyncDirectory sqlite3WinSyncDirectory |
|
127 #define sqlite3OsTempFileName sqlite3WinTempFileName |
|
128 #define sqlite3OsRandomSeed sqlite3WinRandomSeed |
|
129 #define sqlite3OsSleep sqlite3WinSleep |
|
130 #define sqlite3OsCurrentTime sqlite3WinCurrentTime |
|
131 #define sqlite3OsEnterMutex sqlite3WinEnterMutex |
|
132 #define sqlite3OsLeaveMutex sqlite3WinLeaveMutex |
|
133 #define sqlite3OsInMutex sqlite3WinInMutex |
|
134 #define sqlite3OsThreadSpecificData sqlite3WinThreadSpecificData |
|
135 #define sqlite3OsMalloc sqlite3GenericMalloc |
|
136 #define sqlite3OsRealloc sqlite3GenericRealloc |
|
137 #define sqlite3OsFree sqlite3GenericFree |
|
138 #define sqlite3OsAllocationSize sqlite3GenericAllocationSize |
|
139 #endif |
|
140 #if OS_OS2 |
|
141 #define sqlite3OsOpenReadWrite sqlite3Os2OpenReadWrite |
|
142 #define sqlite3OsOpenExclusive sqlite3Os2OpenExclusive |
|
143 #define sqlite3OsOpenReadOnly sqlite3Os2OpenReadOnly |
|
144 #define sqlite3OsDelete sqlite3Os2Delete |
|
145 #define sqlite3OsFileExists sqlite3Os2FileExists |
|
146 #define sqlite3OsFullPathname sqlite3Os2FullPathname |
|
147 #define sqlite3OsIsDirWritable sqlite3Os2IsDirWritable |
|
148 #define sqlite3OsSyncDirectory sqlite3Os2SyncDirectory |
|
149 #define sqlite3OsTempFileName sqlite3Os2TempFileName |
|
150 #define sqlite3OsRandomSeed sqlite3Os2RandomSeed |
|
151 #define sqlite3OsSleep sqlite3Os2Sleep |
|
152 #define sqlite3OsCurrentTime sqlite3Os2CurrentTime |
|
153 #define sqlite3OsEnterMutex sqlite3Os2EnterMutex |
|
154 #define sqlite3OsLeaveMutex sqlite3Os2LeaveMutex |
|
155 #define sqlite3OsInMutex sqlite3Os2InMutex |
|
156 #define sqlite3OsThreadSpecificData sqlite3Os2ThreadSpecificData |
|
157 #define sqlite3OsMalloc sqlite3GenericMalloc |
|
158 #define sqlite3OsRealloc sqlite3GenericRealloc |
|
159 #define sqlite3OsFree sqlite3GenericFree |
|
160 #define sqlite3OsAllocationSize sqlite3GenericAllocationSize |
|
161 #endif |
|
162 #if OS_SYMBIAN |
|
163 #define sqlite3OsOpenReadWrite sqlite3SymbianOpenReadWrite |
|
164 #define sqlite3OsOpenExclusive sqlite3SymbianOpenExclusive |
|
165 #define sqlite3OsOpenReadOnly sqlite3SymbianOpenReadOnly |
|
166 #define sqlite3OsDelete sqlite3SymbianDelete |
|
167 #define sqlite3OsFileExists sqlite3SymbianFileExists |
|
168 #define sqlite3OsFullPathname sqlite3SymbianFullPathname |
|
169 #define sqlite3OsIsDirWritable sqlite3SymbianIsDirWritable |
|
170 #define sqlite3OsSyncDirectory sqlite3SymbianSyncDirectory |
|
171 #define sqlite3OsTempFileName sqlite3SymbianTempFileName |
|
172 #define sqlite3OsRandomSeed sqlite3SymbianRandomSeed |
|
173 #define sqlite3OsSleep sqlite3SymbianSleep |
|
174 #define sqlite3OsCurrentTime sqlite3SymbianCurrentTime |
|
175 #define sqlite3OsEnterMutex sqlite3SymbianEnterMutex |
|
176 #define sqlite3OsLeaveMutex sqlite3SymbianLeaveMutex |
|
177 #define sqlite3OsInMutex sqlite3SymbianInMutex |
|
178 #define sqlite3OsThreadSpecificData sqlite3SymbianThreadSpecificData |
|
179 #define sqlite3OsMalloc sqlite3SymbianMalloc |
|
180 #define sqlite3OsRealloc sqlite3SymbianRealloc |
|
181 #define sqlite3OsFree sqlite3SymbianFree |
|
182 #define sqlite3OsAllocationSize sqlite3SymbianAllocationSize |
|
183 #endif |
|
184 |
|
185 |
|
186 /* |
|
187 ** If using an alternative OS interface, then we must have an "os_other.h" |
|
188 ** header file available for that interface. Presumably the "os_other.h" |
|
189 ** header file contains #defines similar to those above. |
|
190 */ |
|
191 #if OS_OTHER |
|
192 # include "os_other.h" |
|
193 #endif |
|
194 |
|
195 |
|
196 |
|
197 /* |
|
198 ** Forward declarations |
|
199 */ |
|
200 typedef struct OsFile OsFile; |
|
201 typedef struct IoMethod IoMethod; |
|
202 |
|
203 /* |
|
204 ** An instance of the following structure contains pointers to all |
|
205 ** methods on an OsFile object. |
|
206 */ |
|
207 struct IoMethod { |
|
208 int (*xClose)(OsFile**); |
|
209 int (*xOpenDirectory)(OsFile*, const char*); |
|
210 int (*xRead)(OsFile*, void*, int amt); |
|
211 int (*xWrite)(OsFile*, const void*, int amt); |
|
212 int (*xSeek)(OsFile*, i64 offset); |
|
213 int (*xTruncate)(OsFile*, i64 size); |
|
214 int (*xSync)(OsFile*, int); |
|
215 void (*xSetFullSync)(OsFile *id, int setting); |
|
216 int (*xFileHandle)(OsFile *id); |
|
217 int (*xFileSize)(OsFile*, i64 *pSize); |
|
218 int (*xLock)(OsFile*, int); |
|
219 int (*xUnlock)(OsFile*, int); |
|
220 int (*xLockState)(OsFile *id); |
|
221 int (*xCheckReservedLock)(OsFile *id); |
|
222 }; |
|
223 |
|
224 /* |
|
225 ** The OsFile object describes an open disk file in an OS-dependent way. |
|
226 ** The version of OsFile defined here is a generic version. Each OS |
|
227 ** implementation defines its own subclass of this structure that contains |
|
228 ** additional information needed to handle file I/O. But the pMethod |
|
229 ** entry (pointing to the virtual function table) always occurs first |
|
230 ** so that we can always find the appropriate methods. |
|
231 */ |
|
232 struct OsFile { |
|
233 IoMethod const *pMethod; |
|
234 }; |
|
235 |
|
236 /* |
|
237 ** The following values may be passed as the second argument to |
|
238 ** sqlite3OsLock(). The various locks exhibit the following semantics: |
|
239 ** |
|
240 ** SHARED: Any number of processes may hold a SHARED lock simultaneously. |
|
241 ** RESERVED: A single process may hold a RESERVED lock on a file at |
|
242 ** any time. Other processes may hold and obtain new SHARED locks. |
|
243 ** PENDING: A single process may hold a PENDING lock on a file at |
|
244 ** any one time. Existing SHARED locks may persist, but no new |
|
245 ** SHARED locks may be obtained by other processes. |
|
246 ** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks. |
|
247 ** |
|
248 ** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a |
|
249 ** process that requests an EXCLUSIVE lock may actually obtain a PENDING |
|
250 ** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to |
|
251 ** sqlite3OsLock(). |
|
252 */ |
|
253 #define NO_LOCK 0 |
|
254 #define SHARED_LOCK 1 |
|
255 #define RESERVED_LOCK 2 |
|
256 #define PENDING_LOCK 3 |
|
257 #define EXCLUSIVE_LOCK 4 |
|
258 |
|
259 /* |
|
260 ** File Locking Notes: (Mostly about windows but also some info for Unix) |
|
261 ** |
|
262 ** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because |
|
263 ** those functions are not available. So we use only LockFile() and |
|
264 ** UnlockFile(). |
|
265 ** |
|
266 ** LockFile() prevents not just writing but also reading by other processes. |
|
267 ** A SHARED_LOCK is obtained by locking a single randomly-chosen |
|
268 ** byte out of a specific range of bytes. The lock byte is obtained at |
|
269 ** random so two separate readers can probably access the file at the |
|
270 ** same time, unless they are unlucky and choose the same lock byte. |
|
271 ** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range. |
|
272 ** There can only be one writer. A RESERVED_LOCK is obtained by locking |
|
273 ** a single byte of the file that is designated as the reserved lock byte. |
|
274 ** A PENDING_LOCK is obtained by locking a designated byte different from |
|
275 ** the RESERVED_LOCK byte. |
|
276 ** |
|
277 ** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available, |
|
278 ** which means we can use reader/writer locks. When reader/writer locks |
|
279 ** are used, the lock is placed on the same range of bytes that is used |
|
280 ** for probabilistic locking in Win95/98/ME. Hence, the locking scheme |
|
281 ** will support two or more Win95 readers or two or more WinNT readers. |
|
282 ** But a single Win95 reader will lock out all WinNT readers and a single |
|
283 ** WinNT reader will lock out all other Win95 readers. |
|
284 ** |
|
285 ** The following #defines specify the range of bytes used for locking. |
|
286 ** SHARED_SIZE is the number of bytes available in the pool from which |
|
287 ** a random byte is selected for a shared lock. The pool of bytes for |
|
288 ** shared locks begins at SHARED_FIRST. |
|
289 ** |
|
290 ** These #defines are available in sqlite_aux.h so that adaptors for |
|
291 ** connecting SQLite to other operating systems can use the same byte |
|
292 ** ranges for locking. In particular, the same locking strategy and |
|
293 ** byte ranges are used for Unix. This leaves open the possiblity of having |
|
294 ** clients on win95, winNT, and unix all talking to the same shared file |
|
295 ** and all locking correctly. To do so would require that samba (or whatever |
|
296 ** tool is being used for file sharing) implements locks correctly between |
|
297 ** windows and unix. I'm guessing that isn't likely to happen, but by |
|
298 ** using the same locking range we are at least open to the possibility. |
|
299 ** |
|
300 ** Locking in windows is manditory. For this reason, we cannot store |
|
301 ** actual data in the bytes used for locking. The pager never allocates |
|
302 ** the pages involved in locking therefore. SHARED_SIZE is selected so |
|
303 ** that all locks will fit on a single page even at the minimum page size. |
|
304 ** PENDING_BYTE defines the beginning of the locks. By default PENDING_BYTE |
|
305 ** is set high so that we don't have to allocate an unused page except |
|
306 ** for very large databases. But one should test the page skipping logic |
|
307 ** by setting PENDING_BYTE low and running the entire regression suite. |
|
308 ** |
|
309 ** Changing the value of PENDING_BYTE results in a subtly incompatible |
|
310 ** file format. Depending on how it is changed, you might not notice |
|
311 ** the incompatibility right away, even running a full regression test. |
|
312 ** The default location of PENDING_BYTE is the first byte past the |
|
313 ** 1GB boundary. |
|
314 ** |
|
315 */ |
|
316 #ifndef SQLITE_TEST |
|
317 #define PENDING_BYTE 0x40000000 /* First byte past the 1GB boundary */ |
|
318 #else |
|
319 extern unsigned int sqlite3_pending_byte; |
|
320 #define PENDING_BYTE sqlite3_pending_byte |
|
321 #endif |
|
322 |
|
323 #define RESERVED_BYTE (PENDING_BYTE+1) |
|
324 #define SHARED_FIRST (PENDING_BYTE+2) |
|
325 #define SHARED_SIZE 510 |
|
326 |
|
327 /* |
|
328 ** Prototypes for operating system interface routines. |
|
329 */ |
|
330 int sqlite3OsClose(OsFile**); |
|
331 int sqlite3OsOpenDirectory(OsFile*, const char*); |
|
332 int sqlite3OsRead(OsFile*, void*, int amt); |
|
333 int sqlite3OsWrite(OsFile*, const void*, int amt); |
|
334 int sqlite3OsSeek(OsFile*, i64 offset); |
|
335 int sqlite3OsTruncate(OsFile*, i64 size); |
|
336 int sqlite3OsSync(OsFile*, int); |
|
337 void sqlite3OsSetFullSync(OsFile *id, int setting); |
|
338 int sqlite3OsFileHandle(OsFile *id); |
|
339 int sqlite3OsFileSize(OsFile*, i64 *pSize); |
|
340 int sqlite3OsLock(OsFile*, int); |
|
341 int sqlite3OsUnlock(OsFile*, int); |
|
342 int sqlite3OsLockState(OsFile *id); |
|
343 int sqlite3OsCheckReservedLock(OsFile *id); |
|
344 int sqlite3OsOpenReadWrite(const char*, OsFile**, int*); |
|
345 int sqlite3OsOpenExclusive(const char*, OsFile**, int); |
|
346 int sqlite3OsOpenReadOnly(const char*, OsFile**); |
|
347 int sqlite3OsDelete(const char*); |
|
348 int sqlite3OsFileExists(const char*); |
|
349 char *sqlite3OsFullPathname(const char*); |
|
350 int sqlite3OsIsDirWritable(char*); |
|
351 int sqlite3OsSyncDirectory(const char*); |
|
352 int sqlite3OsTempFileName(char*); |
|
353 int sqlite3OsRandomSeed(char*); |
|
354 int sqlite3OsSleep(int ms); |
|
355 int sqlite3OsCurrentTime(double*); |
|
356 void sqlite3OsEnterMutex(void); |
|
357 void sqlite3OsLeaveMutex(void); |
|
358 int sqlite3OsInMutex(int); |
|
359 ThreadData *sqlite3OsThreadSpecificData(int); |
|
360 void *sqlite3OsMalloc(int); |
|
361 void *sqlite3OsRealloc(void *, int); |
|
362 void sqlite3OsFree(void *); |
|
363 int sqlite3OsAllocationSize(void *); |
|
364 |
|
365 /* |
|
366 ** If the SQLITE_ENABLE_REDEF_IO macro is defined, then the OS-layer |
|
367 ** interface routines are not called directly but are invoked using |
|
368 ** pointers to functions. This allows the implementation of various |
|
369 ** OS-layer interface routines to be modified at run-time. There are |
|
370 ** obscure but legitimate reasons for wanting to do this. But for |
|
371 ** most users, a direct call to the underlying interface is preferable |
|
372 ** so the the redefinable I/O interface is turned off by default. |
|
373 */ |
|
374 #ifdef SQLITE_ENABLE_REDEF_IO |
|
375 |
|
376 /* |
|
377 ** When redefinable I/O is enabled, a single global instance of the |
|
378 ** following structure holds pointers to the routines that SQLite |
|
379 ** uses to talk with the underlying operating system. Modify this |
|
380 ** structure (before using any SQLite API!) to accomodate perculiar |
|
381 ** operating system interfaces or behaviors. |
|
382 */ |
|
383 struct sqlite3OsVtbl { |
|
384 int (*xOpenReadWrite)(const char*, OsFile**, int*); |
|
385 int (*xOpenExclusive)(const char*, OsFile**, int); |
|
386 int (*xOpenReadOnly)(const char*, OsFile**); |
|
387 |
|
388 int (*xDelete)(const char*); |
|
389 int (*xFileExists)(const char*); |
|
390 char *(*xFullPathname)(const char*); |
|
391 int (*xIsDirWritable)(char*); |
|
392 int (*xSyncDirectory)(const char*); |
|
393 int (*xTempFileName)(char*); |
|
394 |
|
395 int (*xRandomSeed)(char*); |
|
396 int (*xSleep)(int ms); |
|
397 int (*xCurrentTime)(double*); |
|
398 |
|
399 void (*xEnterMutex)(void); |
|
400 void (*xLeaveMutex)(void); |
|
401 int (*xInMutex)(int); |
|
402 ThreadData *(*xThreadSpecificData)(int); |
|
403 |
|
404 void *(*xMalloc)(int); |
|
405 void *(*xRealloc)(void *, int); |
|
406 void (*xFree)(void *); |
|
407 int (*xAllocationSize)(void *); |
|
408 }; |
|
409 |
|
410 /* Macro used to comment out routines that do not exists when there is |
|
411 ** no disk I/O |
|
412 */ |
|
413 #ifdef SQLITE_OMIT_DISKIO |
|
414 # define IF_DISKIO(X) 0 |
|
415 #else |
|
416 # define IF_DISKIO(X) X |
|
417 #endif |
|
418 |
|
419 #ifdef _SQLITE_OS_C_ |
|
420 /* |
|
421 ** The os.c file implements the global virtual function table. |
|
422 */ |
|
423 struct sqlite3OsVtbl sqlite3Os = { |
|
424 IF_DISKIO( sqlite3OsOpenReadWrite ), |
|
425 IF_DISKIO( sqlite3OsOpenExclusive ), |
|
426 IF_DISKIO( sqlite3OsOpenReadOnly ), |
|
427 IF_DISKIO( sqlite3OsDelete ), |
|
428 IF_DISKIO( sqlite3OsFileExists ), |
|
429 IF_DISKIO( sqlite3OsFullPathname ), |
|
430 IF_DISKIO( sqlite3OsIsDirWritable ), |
|
431 IF_DISKIO( sqlite3OsSyncDirectory ), |
|
432 IF_DISKIO( sqlite3OsTempFileName ), |
|
433 sqlite3OsRandomSeed, |
|
434 sqlite3OsSleep, |
|
435 sqlite3OsCurrentTime, |
|
436 sqlite3OsEnterMutex, |
|
437 sqlite3OsLeaveMutex, |
|
438 sqlite3OsInMutex, |
|
439 sqlite3OsThreadSpecificData, |
|
440 sqlite3OsMalloc, |
|
441 sqlite3OsRealloc, |
|
442 sqlite3OsFree, |
|
443 sqlite3OsAllocationSize |
|
444 }; |
|
445 #else |
|
446 /* |
|
447 ** Files other than os.c just reference the global virtual function table. |
|
448 */ |
|
449 extern struct sqlite3OsVtbl sqlite3Os; |
|
450 #endif /* _SQLITE_OS_C_ */ |
|
451 |
|
452 |
|
453 /* This additional API routine is available with redefinable I/O */ |
|
454 struct sqlite3OsVtbl *sqlite3_os_switch(void); |
|
455 |
|
456 |
|
457 /* |
|
458 ** Redefine the OS interface to go through the virtual function table |
|
459 ** rather than calling routines directly. |
|
460 */ |
|
461 #undef sqlite3OsOpenReadWrite |
|
462 #undef sqlite3OsOpenExclusive |
|
463 #undef sqlite3OsOpenReadOnly |
|
464 #undef sqlite3OsDelete |
|
465 #undef sqlite3OsFileExists |
|
466 #undef sqlite3OsFullPathname |
|
467 #undef sqlite3OsIsDirWritable |
|
468 #undef sqlite3OsSyncDirectory |
|
469 #undef sqlite3OsTempFileName |
|
470 #undef sqlite3OsRandomSeed |
|
471 #undef sqlite3OsSleep |
|
472 #undef sqlite3OsCurrentTime |
|
473 #undef sqlite3OsEnterMutex |
|
474 #undef sqlite3OsLeaveMutex |
|
475 #undef sqlite3OsInMutex |
|
476 #undef sqlite3OsThreadSpecificData |
|
477 #undef sqlite3OsMalloc |
|
478 #undef sqlite3OsRealloc |
|
479 #undef sqlite3OsFree |
|
480 #undef sqlite3OsAllocationSize |
|
481 #define sqlite3OsOpenReadWrite sqlite3Os.xOpenReadWrite |
|
482 #define sqlite3OsOpenExclusive sqlite3Os.xOpenExclusive |
|
483 #define sqlite3OsOpenReadOnly sqlite3Os.xOpenReadOnly |
|
484 #define sqlite3OsDelete sqlite3Os.xDelete |
|
485 #define sqlite3OsFileExists sqlite3Os.xFileExists |
|
486 #define sqlite3OsFullPathname sqlite3Os.xFullPathname |
|
487 #define sqlite3OsIsDirWritable sqlite3Os.xIsDirWritable |
|
488 #define sqlite3OsSyncDirectory sqlite3Os.xSyncDirectory |
|
489 #define sqlite3OsTempFileName sqlite3Os.xTempFileName |
|
490 #define sqlite3OsRandomSeed sqlite3Os.xRandomSeed |
|
491 #define sqlite3OsSleep sqlite3Os.xSleep |
|
492 #define sqlite3OsCurrentTime sqlite3Os.xCurrentTime |
|
493 #define sqlite3OsEnterMutex sqlite3Os.xEnterMutex |
|
494 #define sqlite3OsLeaveMutex sqlite3Os.xLeaveMutex |
|
495 #define sqlite3OsInMutex sqlite3Os.xInMutex |
|
496 #define sqlite3OsThreadSpecificData sqlite3Os.xThreadSpecificData |
|
497 #define sqlite3OsMalloc sqlite3Os.xMalloc |
|
498 #define sqlite3OsRealloc sqlite3Os.xRealloc |
|
499 #define sqlite3OsFree sqlite3Os.xFree |
|
500 #define sqlite3OsAllocationSize sqlite3Os.xAllocationSize |
|
501 |
|
502 #endif /* SQLITE_ENABLE_REDEF_IO */ |
|
503 |
|
504 #endif /* _SQLITE_OS_H_ */ |