OLD | NEW |
1 /* | 1 /* |
2 ** 2001 September 16 | 2 ** 2001 September 16 |
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 header file (together with is companion C source-code file | 13 ** This header file (together with is companion C source-code file |
14 ** "os.c") attempt to abstract the underlying operating system so that | 14 ** "os.c") attempt to abstract the underlying operating system so that |
15 ** the SQLite library will work on both POSIX and windows systems. | 15 ** the SQLite library will work on both POSIX and windows systems. |
16 ** | 16 ** |
17 ** This header file is #include-ed by sqliteInt.h and thus ends up | 17 ** This header file is #include-ed by sqliteInt.h and thus ends up |
18 ** being included by every source file. | 18 ** being included by every source file. |
19 */ | 19 */ |
20 #ifndef _SQLITE_OS_H_ | 20 #ifndef _SQLITE_OS_H_ |
21 #define _SQLITE_OS_H_ | 21 #define _SQLITE_OS_H_ |
22 | 22 |
23 /* | 23 /* |
24 ** Figure out if we are dealing with Unix, Windows, or some other | 24 ** Attempt to automatically detect the operating system and setup the |
25 ** operating system. After the following block of preprocess macros, | 25 ** necessary pre-processor macros for it. |
26 ** all of SQLITE_OS_UNIX, SQLITE_OS_WIN, SQLITE_OS_OS2, and SQLITE_OS_OTHER | |
27 ** will defined to either 1 or 0. One of the four will be 1. The other | |
28 ** three will be 0. | |
29 */ | 26 */ |
30 #if defined(SQLITE_OS_OTHER) | 27 #include "os_setup.h" |
31 # if SQLITE_OS_OTHER==1 | |
32 # undef SQLITE_OS_UNIX | |
33 # define SQLITE_OS_UNIX 0 | |
34 # undef SQLITE_OS_WIN | |
35 # define SQLITE_OS_WIN 0 | |
36 # undef SQLITE_OS_OS2 | |
37 # define SQLITE_OS_OS2 0 | |
38 # else | |
39 # undef SQLITE_OS_OTHER | |
40 # endif | |
41 #endif | |
42 #if !defined(SQLITE_OS_UNIX) && !defined(SQLITE_OS_OTHER) | |
43 # define SQLITE_OS_OTHER 0 | |
44 # ifndef SQLITE_OS_WIN | |
45 # if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MIN
GW32__) || defined(__BORLANDC__) | |
46 # define SQLITE_OS_WIN 1 | |
47 # define SQLITE_OS_UNIX 0 | |
48 # define SQLITE_OS_OS2 0 | |
49 # elif defined(__EMX__) || defined(_OS2) || defined(OS2) || defined(_OS2_) ||
defined(__OS2__) | |
50 # define SQLITE_OS_WIN 0 | |
51 # define SQLITE_OS_UNIX 0 | |
52 # define SQLITE_OS_OS2 1 | |
53 # else | |
54 # define SQLITE_OS_WIN 0 | |
55 # define SQLITE_OS_UNIX 1 | |
56 # define SQLITE_OS_OS2 0 | |
57 # endif | |
58 # else | |
59 # define SQLITE_OS_UNIX 0 | |
60 # define SQLITE_OS_OS2 0 | |
61 # endif | |
62 #else | |
63 # ifndef SQLITE_OS_WIN | |
64 # define SQLITE_OS_WIN 0 | |
65 # endif | |
66 #endif | |
67 | |
68 /* | |
69 ** Determine if we are dealing with WindowsCE - which has a much | |
70 ** reduced API. | |
71 */ | |
72 #if defined(_WIN32_WCE) | |
73 # define SQLITE_OS_WINCE 1 | |
74 #else | |
75 # define SQLITE_OS_WINCE 0 | |
76 #endif | |
77 | |
78 | |
79 /* | |
80 ** Define the maximum size of a temporary filename | |
81 */ | |
82 #if SQLITE_OS_WIN | |
83 # include <windows.h> | |
84 # define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) | |
85 #elif SQLITE_OS_OS2 | |
86 # if (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && defined(OS2_HIGH_
MEMORY) | |
87 # include <os2safe.h> /* has to be included before os2.h for linking to work */ | |
88 # endif | |
89 # define INCL_DOSDATETIME | |
90 # define INCL_DOSFILEMGR | |
91 # define INCL_DOSERRORS | |
92 # define INCL_DOSMISC | |
93 # define INCL_DOSPROCESS | |
94 # define INCL_DOSMODULEMGR | |
95 # define INCL_DOSSEMAPHORES | |
96 # include <os2.h> | |
97 # include <uconv.h> | |
98 # define SQLITE_TEMPNAME_SIZE (CCHMAXPATHCOMP) | |
99 #else | |
100 # define SQLITE_TEMPNAME_SIZE 200 | |
101 #endif | |
102 | 28 |
103 /* If the SET_FULLSYNC macro is not defined above, then make it | 29 /* If the SET_FULLSYNC macro is not defined above, then make it |
104 ** a no-op | 30 ** a no-op |
105 */ | 31 */ |
106 #ifndef SET_FULLSYNC | 32 #ifndef SET_FULLSYNC |
107 # define SET_FULLSYNC(x,y) | 33 # define SET_FULLSYNC(x,y) |
108 #endif | 34 #endif |
109 | 35 |
110 /* | 36 /* |
111 ** The default size of a disk sector | 37 ** The default size of a disk sector |
112 */ | 38 */ |
113 #ifndef SQLITE_DEFAULT_SECTOR_SIZE | 39 #ifndef SQLITE_DEFAULT_SECTOR_SIZE |
114 # define SQLITE_DEFAULT_SECTOR_SIZE 512 | 40 # define SQLITE_DEFAULT_SECTOR_SIZE 4096 |
115 #endif | 41 #endif |
116 | 42 |
117 /* | 43 /* |
118 ** Temporary files are named starting with this prefix followed by 16 random | 44 ** Temporary files are named starting with this prefix followed by 16 random |
119 ** alphanumeric characters, and no file extension. They are stored in the | 45 ** alphanumeric characters, and no file extension. They are stored in the |
120 ** OS's standard temporary file directory, and are deleted prior to exit. | 46 ** OS's standard temporary file directory, and are deleted prior to exit. |
121 ** If sqlite is being embedded in another program, you may wish to change the | 47 ** If sqlite is being embedded in another program, you may wish to change the |
122 ** prefix to reflect your program's name, so that if your program exits | 48 ** prefix to reflect your program's name, so that if your program exits |
123 ** prematurely, old temporary files can be easily identified. This can be done | 49 ** prematurely, old temporary files can be easily identified. This can be done |
124 ** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line. | 50 ** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 ** will support two or more Win95 readers or two or more WinNT readers. | 113 ** will support two or more Win95 readers or two or more WinNT readers. |
188 ** But a single Win95 reader will lock out all WinNT readers and a single | 114 ** But a single Win95 reader will lock out all WinNT readers and a single |
189 ** WinNT reader will lock out all other Win95 readers. | 115 ** WinNT reader will lock out all other Win95 readers. |
190 ** | 116 ** |
191 ** The following #defines specify the range of bytes used for locking. | 117 ** The following #defines specify the range of bytes used for locking. |
192 ** SHARED_SIZE is the number of bytes available in the pool from which | 118 ** SHARED_SIZE is the number of bytes available in the pool from which |
193 ** a random byte is selected for a shared lock. The pool of bytes for | 119 ** a random byte is selected for a shared lock. The pool of bytes for |
194 ** shared locks begins at SHARED_FIRST. | 120 ** shared locks begins at SHARED_FIRST. |
195 ** | 121 ** |
196 ** The same locking strategy and | 122 ** The same locking strategy and |
197 ** byte ranges are used for Unix. This leaves open the possiblity of having | 123 ** byte ranges are used for Unix. This leaves open the possibility of having |
198 ** clients on win95, winNT, and unix all talking to the same shared file | 124 ** clients on win95, winNT, and unix all talking to the same shared file |
199 ** and all locking correctly. To do so would require that samba (or whatever | 125 ** and all locking correctly. To do so would require that samba (or whatever |
200 ** tool is being used for file sharing) implements locks correctly between | 126 ** tool is being used for file sharing) implements locks correctly between |
201 ** windows and unix. I'm guessing that isn't likely to happen, but by | 127 ** windows and unix. I'm guessing that isn't likely to happen, but by |
202 ** using the same locking range we are at least open to the possibility. | 128 ** using the same locking range we are at least open to the possibility. |
203 ** | 129 ** |
204 ** Locking in windows is manditory. For this reason, we cannot store | 130 ** Locking in windows is manditory. For this reason, we cannot store |
205 ** actual data in the bytes used for locking. The pager never allocates | 131 ** actual data in the bytes used for locking. The pager never allocates |
206 ** the pages involved in locking therefore. SHARED_SIZE is selected so | 132 ** the pages involved in locking therefore. SHARED_SIZE is selected so |
207 ** that all locks will fit on a single page even at the minimum page size. | 133 ** that all locks will fit on a single page even at the minimum page size. |
(...skipping 29 matching lines...) Expand all Loading... |
237 int sqlite3OsClose(sqlite3_file*); | 163 int sqlite3OsClose(sqlite3_file*); |
238 int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset); | 164 int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset); |
239 int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset); | 165 int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset); |
240 int sqlite3OsTruncate(sqlite3_file*, i64 size); | 166 int sqlite3OsTruncate(sqlite3_file*, i64 size); |
241 int sqlite3OsSync(sqlite3_file*, int); | 167 int sqlite3OsSync(sqlite3_file*, int); |
242 int sqlite3OsFileSize(sqlite3_file*, i64 *pSize); | 168 int sqlite3OsFileSize(sqlite3_file*, i64 *pSize); |
243 int sqlite3OsLock(sqlite3_file*, int); | 169 int sqlite3OsLock(sqlite3_file*, int); |
244 int sqlite3OsUnlock(sqlite3_file*, int); | 170 int sqlite3OsUnlock(sqlite3_file*, int); |
245 int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut); | 171 int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut); |
246 int sqlite3OsFileControl(sqlite3_file*,int,void*); | 172 int sqlite3OsFileControl(sqlite3_file*,int,void*); |
| 173 void sqlite3OsFileControlHint(sqlite3_file*,int,void*); |
247 #define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0 | 174 #define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0 |
248 int sqlite3OsSectorSize(sqlite3_file *id); | 175 int sqlite3OsSectorSize(sqlite3_file *id); |
249 int sqlite3OsDeviceCharacteristics(sqlite3_file *id); | 176 int sqlite3OsDeviceCharacteristics(sqlite3_file *id); |
250 int sqlite3OsShmMap(sqlite3_file *,int,int,int,void volatile **); | 177 int sqlite3OsShmMap(sqlite3_file *,int,int,int,void volatile **); |
251 int sqlite3OsShmLock(sqlite3_file *id, int, int, int); | 178 int sqlite3OsShmLock(sqlite3_file *id, int, int, int); |
252 void sqlite3OsShmBarrier(sqlite3_file *id); | 179 void sqlite3OsShmBarrier(sqlite3_file *id); |
253 int sqlite3OsShmUnmap(sqlite3_file *id, int); | 180 int sqlite3OsShmUnmap(sqlite3_file *id, int); |
| 181 int sqlite3OsFetch(sqlite3_file *id, i64, int, void **); |
| 182 int sqlite3OsUnfetch(sqlite3_file *, i64, void *); |
| 183 |
254 | 184 |
255 /* | 185 /* |
256 ** Functions for accessing sqlite3_vfs methods | 186 ** Functions for accessing sqlite3_vfs methods |
257 */ | 187 */ |
258 int sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file*, int, int *); | 188 int sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file*, int, int *); |
259 int sqlite3OsDelete(sqlite3_vfs *, const char *, int); | 189 int sqlite3OsDelete(sqlite3_vfs *, const char *, int); |
260 int sqlite3OsAccess(sqlite3_vfs *, const char *, int, int *pResOut); | 190 int sqlite3OsAccess(sqlite3_vfs *, const char *, int, int *pResOut); |
261 int sqlite3OsFullPathname(sqlite3_vfs *, const char *, int, char *); | 191 int sqlite3OsFullPathname(sqlite3_vfs *, const char *, int, char *); |
262 #ifndef SQLITE_OMIT_LOAD_EXTENSION | 192 #ifndef SQLITE_OMIT_LOAD_EXTENSION |
263 void *sqlite3OsDlOpen(sqlite3_vfs *, const char *); | 193 void *sqlite3OsDlOpen(sqlite3_vfs *, const char *); |
264 void sqlite3OsDlError(sqlite3_vfs *, int, char *); | 194 void sqlite3OsDlError(sqlite3_vfs *, int, char *); |
265 void (*sqlite3OsDlSym(sqlite3_vfs *, void *, const char *))(void); | 195 void (*sqlite3OsDlSym(sqlite3_vfs *, void *, const char *))(void); |
266 void sqlite3OsDlClose(sqlite3_vfs *, void *); | 196 void sqlite3OsDlClose(sqlite3_vfs *, void *); |
267 #endif /* SQLITE_OMIT_LOAD_EXTENSION */ | 197 #endif /* SQLITE_OMIT_LOAD_EXTENSION */ |
268 int sqlite3OsRandomness(sqlite3_vfs *, int, char *); | 198 int sqlite3OsRandomness(sqlite3_vfs *, int, char *); |
269 int sqlite3OsSleep(sqlite3_vfs *, int); | 199 int sqlite3OsSleep(sqlite3_vfs *, int); |
270 int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64*); | 200 int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64*); |
271 | 201 |
272 /* | 202 /* |
273 ** Convenience functions for opening and closing files using | 203 ** Convenience functions for opening and closing files using |
274 ** sqlite3_malloc() to obtain space for the file-handle structure. | 204 ** sqlite3_malloc() to obtain space for the file-handle structure. |
275 */ | 205 */ |
276 int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*); | 206 int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*); |
277 int sqlite3OsCloseFree(sqlite3_file *); | 207 int sqlite3OsCloseFree(sqlite3_file *); |
278 | 208 |
279 #endif /* _SQLITE_OS_H_ */ | 209 #endif /* _SQLITE_OS_H_ */ |
OLD | NEW |