Team Ai
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
os_win.c6518 linesDownload Raw Back to src
1/*2** 2004 May 223**4** The author disclaims copyright to this source code.  In place of5** 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 code that is specific to Windows.14*/15#include "sqliteInt.h"16#if SQLITE_OS_WIN               /* This file is used for Windows only */17 18/*19** Include code that is common to all os_*.c files20*/21#include "os_common.h"22 23/*24** Include the header file for the Windows VFS.25*/26#include "os_win.h"27 28/*29** Compiling and using WAL mode requires several APIs that are only30** available in Windows platforms based on the NT kernel.31*/32#if !SQLITE_OS_WINNT && !defined(SQLITE_OMIT_WAL)33#  error "WAL mode requires support from the Windows NT kernel, compile\34 with SQLITE_OMIT_WAL."35#endif36 37#if !SQLITE_OS_WINNT && SQLITE_MAX_MMAP_SIZE>038#  error "Memory mapped files require support from the Windows NT kernel,\39 compile with SQLITE_MAX_MMAP_SIZE=0."40#endif41 42/*43** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions44** based on the sub-platform)?45*/46#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_ANSI)47#  define SQLITE_WIN32_HAS_ANSI48#endif49 50/*51** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions52** based on the sub-platform)?53*/54#if (SQLITE_OS_WINCE || SQLITE_OS_WINNT) && \55    !defined(SQLITE_WIN32_NO_WIDE)56#  define SQLITE_WIN32_HAS_WIDE57#endif58 59/*60** Make sure at least one set of Win32 APIs is available.61*/62#if !defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_WIN32_HAS_WIDE)63#  error "At least one of SQLITE_WIN32_HAS_ANSI and SQLITE_WIN32_HAS_WIDE\64 must be defined."65#endif66 67/*68** Define the required Windows SDK version constants if they are not69** already available.70*/71#ifndef NTDDI_WIN872#  define NTDDI_WIN8                        0x0602000073#endif74 75#ifndef NTDDI_WINBLUE76#  define NTDDI_WINBLUE                     0x0603000077#endif78 79#ifndef NTDDI_WINTHRESHOLD80#  define NTDDI_WINTHRESHOLD                0x0604000081#endif82 83/*84** Check to see if the GetVersionEx[AW] functions are deprecated on the85** target system.  GetVersionEx was first deprecated in Win8.1.86*/87#ifndef SQLITE_WIN32_GETVERSIONEX88#  if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINBLUE89#    define SQLITE_WIN32_GETVERSIONEX   0   /* GetVersionEx() is deprecated */90#  else91#    define SQLITE_WIN32_GETVERSIONEX   1   /* GetVersionEx() is current */92#  endif93#endif94 95/*96** Check to see if the CreateFileMappingA function is supported on the97** target system.  It is unavailable when using "mincore.lib" on Win10.98** When compiling for Windows 10, always assume "mincore.lib" is in use.99*/100#ifndef SQLITE_WIN32_CREATEFILEMAPPINGA101#  if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINTHRESHOLD102#    define SQLITE_WIN32_CREATEFILEMAPPINGA   0103#  else104#    define SQLITE_WIN32_CREATEFILEMAPPINGA   1105#  endif106#endif107 108/*109** This constant should already be defined (in the "WinDef.h" SDK file).110*/111#ifndef MAX_PATH112#  define MAX_PATH                      (260)113#endif114 115/*116** Maximum pathname length (in chars) for Win32.  This should normally be117** MAX_PATH.118*/119#ifndef SQLITE_WIN32_MAX_PATH_CHARS120#  define SQLITE_WIN32_MAX_PATH_CHARS   (MAX_PATH)121#endif122 123/*124** This constant should already be defined (in the "WinNT.h" SDK file).125*/126#ifndef UNICODE_STRING_MAX_CHARS127#  define UNICODE_STRING_MAX_CHARS      (32767)128#endif129 130/*131** Maximum pathname length (in chars) for WinNT.  This should normally be132** UNICODE_STRING_MAX_CHARS.133*/134#ifndef SQLITE_WINNT_MAX_PATH_CHARS135#  define SQLITE_WINNT_MAX_PATH_CHARS   (UNICODE_STRING_MAX_CHARS)136#endif137 138/*139** Maximum pathname length (in bytes) for Win32.  The MAX_PATH macro is in140** characters, so we allocate 4 bytes per character assuming worst-case of141** 4-bytes-per-character for UTF8.142*/143#ifndef SQLITE_WIN32_MAX_PATH_BYTES144#  define SQLITE_WIN32_MAX_PATH_BYTES   (SQLITE_WIN32_MAX_PATH_CHARS*4)145#endif146 147/*148** Maximum pathname length (in bytes) for WinNT.  This should normally be149** UNICODE_STRING_MAX_CHARS * sizeof(WCHAR).150*/151#ifndef SQLITE_WINNT_MAX_PATH_BYTES152#  define SQLITE_WINNT_MAX_PATH_BYTES   \153                            (sizeof(WCHAR) * SQLITE_WINNT_MAX_PATH_CHARS)154#endif155 156/*157** Maximum error message length (in chars) for WinRT.158*/159#ifndef SQLITE_WIN32_MAX_ERRMSG_CHARS160#  define SQLITE_WIN32_MAX_ERRMSG_CHARS (1024)161#endif162 163/*164** Returns non-zero if the character should be treated as a directory165** separator.166*/167#ifndef winIsDirSep168#  define winIsDirSep(a)                (((a) == '/') || ((a) == '\\'))169#endif170 171/*172** This macro is used when a local variable is set to a value that is173** [sometimes] not used by the code (e.g. via conditional compilation).174*/175#ifndef UNUSED_VARIABLE_VALUE176#  define UNUSED_VARIABLE_VALUE(x)      (void)(x)177#endif178 179/*180** Returns the character that should be used as the directory separator.181*/182#ifndef winGetDirSep183#  define winGetDirSep()                '\\'184#endif185 186/*187** Do we need to manually define the Win32 file mapping APIs for use with WAL188** mode or memory mapped files (e.g. these APIs are available in the Windows189** CE SDK; however, they are not present in the header file)?190*/191#if SQLITE_WIN32_FILEMAPPING_API && \192        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)193 194#if defined(SQLITE_WIN32_HAS_ANSI)195WINBASEAPI HANDLE WINAPI CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, \196        DWORD, DWORD, DWORD, LPCSTR);197#endif /* defined(SQLITE_WIN32_HAS_ANSI) */198 199#if defined(SQLITE_WIN32_HAS_WIDE)200WINBASEAPI HANDLE WINAPI CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, \201        DWORD, DWORD, DWORD, LPCWSTR);202#endif /* defined(SQLITE_WIN32_HAS_WIDE) */203 204WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);205 206/*207** These file mapping APIs are common to both Win32 and WinRT.208*/209 210WINBASEAPI BOOL WINAPI FlushViewOfFile(LPCVOID, SIZE_T);211WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID);212#endif /* SQLITE_WIN32_FILEMAPPING_API */213 214/*215** Some Microsoft compilers lack this definition.216*/217#ifndef INVALID_FILE_ATTRIBUTES218# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)219#endif220 221#ifndef FILE_FLAG_MASK222# define FILE_FLAG_MASK          (0xFF3C0000)223#endif224 225#ifndef FILE_ATTRIBUTE_MASK226# define FILE_ATTRIBUTE_MASK     (0x0003FFF7)227#endif228 229#ifndef SQLITE_OMIT_WAL230/* Forward references to structures used for WAL */231typedef struct winShm winShm;           /* A connection to shared-memory */232typedef struct winShmNode winShmNode;   /* A region of shared-memory */233#endif234 235/*236** WinCE lacks native support for file locking so we have to fake it237** with some code of our own.238*/239#if SQLITE_OS_WINCE240typedef struct winceLock {241  int nReaders;       /* Number of reader locks obtained */242  BOOL bPending;      /* Indicates a pending lock has been obtained */243  BOOL bReserved;     /* Indicates a reserved lock has been obtained */244  BOOL bExclusive;    /* Indicates an exclusive lock has been obtained */245} winceLock;246#endif247 248/*249** The winFile structure is a subclass of sqlite3_file* specific to the win32250** portability layer.251*/252typedef struct winFile winFile;253struct winFile {254  const sqlite3_io_methods *pMethod; /*** Must be first ***/255  sqlite3_vfs *pVfs;      /* The VFS used to open this file */256  HANDLE h;               /* Handle for accessing the file */257  u8 locktype;            /* Type of lock currently held on this file */258  short sharedLockByte;   /* Randomly chosen byte used as a shared lock */259  u8 ctrlFlags;           /* Flags.  See WINFILE_* below */260  DWORD lastErrno;        /* The Windows errno from the last I/O error */261#ifndef SQLITE_OMIT_WAL262  winShm *pShm;           /* Instance of shared memory on this file */263#endif264  const char *zPath;      /* Full pathname of this file */265  int szChunk;            /* Chunk size configured by FCNTL_CHUNK_SIZE */266#if SQLITE_OS_WINCE267  LPWSTR zDeleteOnClose;  /* Name of file to delete when closing */268  HANDLE hMutex;          /* Mutex used to control access to shared lock */269  HANDLE hShared;         /* Shared memory segment used for locking */270  winceLock local;        /* Locks obtained by this instance of winFile */271  winceLock *shared;      /* Global shared lock memory for the file  */272#endif273#if SQLITE_MAX_MMAP_SIZE>0274  int nFetchOut;                /* Number of outstanding xFetch references */275  HANDLE hMap;                  /* Handle for accessing memory mapping */276  void *pMapRegion;             /* Area memory mapped */277  sqlite3_int64 mmapSize;       /* Size of mapped region */278  sqlite3_int64 mmapSizeMax;    /* Configured FCNTL_MMAP_SIZE value */279#endif280#ifdef SQLITE_ENABLE_SETLK_TIMEOUT281  DWORD iBusyTimeout;        /* Wait this many millisec on locks */282  int bBlockOnConnect;283#endif284};285 286#ifdef SQLITE_ENABLE_SETLK_TIMEOUT287# define winFileBusyTimeout(pDbFd) pDbFd->iBusyTimeout288#else289# define winFileBusyTimeout(pDbFd) 0290#endif291 292/*293** The winVfsAppData structure is used for the pAppData member for all of the294** Win32 VFS variants.295*/296typedef struct winVfsAppData winVfsAppData;297struct winVfsAppData {298  const sqlite3_io_methods *pMethod; /* The file I/O methods to use. */299  void *pAppData;                    /* The extra pAppData, if any. */300  BOOL bNoLock;                      /* Non-zero if locking is disabled. */301};302 303/*304** Allowed values for winFile.ctrlFlags305*/306#define WINFILE_RDONLY          0x02   /* Connection is read only */307#define WINFILE_PERSIST_WAL     0x04   /* Persistent WAL mode */308#define WINFILE_PSOW            0x10   /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */309 310/*311 * The size of the buffer used by sqlite3_win32_write_debug().312 */313#ifndef SQLITE_WIN32_DBG_BUF_SIZE314#  define SQLITE_WIN32_DBG_BUF_SIZE   ((int)(4096-sizeof(DWORD)))315#endif316 317/*318 * If compiled with SQLITE_WIN32_MALLOC on Windows, we will use the319 * various Win32 API heap functions instead of our own.320 */321#ifdef SQLITE_WIN32_MALLOC322 323/*324 * If this is non-zero, an isolated heap will be created by the native Win32325 * allocator subsystem; otherwise, the default process heap will be used.  This326 * setting has no effect when compiling for WinRT.  By default, this is enabled327 * and an isolated heap will be created to store all allocated data.328 *329 ******************************************************************************330 * WARNING: It is important to note that when this setting is non-zero and the331 *          winMemShutdown function is called (e.g. by the sqlite3_shutdown332 *          function), all data that was allocated using the isolated heap will333 *          be freed immediately and any attempt to access any of that freed334 *          data will almost certainly result in an immediate access violation.335 ******************************************************************************336 */337#ifndef SQLITE_WIN32_HEAP_CREATE338#  define SQLITE_WIN32_HEAP_CREATE        (TRUE)339#endif340 341/*342 * This is the maximum possible initial size of the Win32-specific heap, in343 * bytes.344 */345#ifndef SQLITE_WIN32_HEAP_MAX_INIT_SIZE346#  define SQLITE_WIN32_HEAP_MAX_INIT_SIZE (4294967295U)347#endif348 349/*350 * This is the extra space for the initial size of the Win32-specific heap,351 * in bytes.  This value may be zero.352 */353#ifndef SQLITE_WIN32_HEAP_INIT_EXTRA354#  define SQLITE_WIN32_HEAP_INIT_EXTRA  (4194304)355#endif356 357/*358 * Calculate the maximum legal cache size, in pages, based on the maximum359 * possible initial heap size and the default page size, setting aside the360 * needed extra space.361 */362#ifndef SQLITE_WIN32_MAX_CACHE_SIZE363#  define SQLITE_WIN32_MAX_CACHE_SIZE   (((SQLITE_WIN32_HEAP_MAX_INIT_SIZE) - \364                                          (SQLITE_WIN32_HEAP_INIT_EXTRA)) / \365                                         (SQLITE_DEFAULT_PAGE_SIZE))366#endif367 368/*369 * This is cache size used in the calculation of the initial size of the370 * Win32-specific heap.  It cannot be negative.371 */372#ifndef SQLITE_WIN32_CACHE_SIZE373#  if SQLITE_DEFAULT_CACHE_SIZE>=0374#    define SQLITE_WIN32_CACHE_SIZE     (SQLITE_DEFAULT_CACHE_SIZE)375#  else376#    define SQLITE_WIN32_CACHE_SIZE     (-(SQLITE_DEFAULT_CACHE_SIZE))377#  endif378#endif379 380/*381 * Make sure that the calculated cache size, in pages, cannot cause the382 * initial size of the Win32-specific heap to exceed the maximum amount383 * of memory that can be specified in the call to HeapCreate.384 */385#if SQLITE_WIN32_CACHE_SIZE>SQLITE_WIN32_MAX_CACHE_SIZE386#  undef SQLITE_WIN32_CACHE_SIZE387#  define SQLITE_WIN32_CACHE_SIZE       (2000)388#endif389 390/*391 * The initial size of the Win32-specific heap.  This value may be zero.392 */393#ifndef SQLITE_WIN32_HEAP_INIT_SIZE394#  define SQLITE_WIN32_HEAP_INIT_SIZE   ((SQLITE_WIN32_CACHE_SIZE) * \395                                         (SQLITE_DEFAULT_PAGE_SIZE) + \396                                         (SQLITE_WIN32_HEAP_INIT_EXTRA))397#endif398 399/*400 * The maximum size of the Win32-specific heap.  This value may be zero.401 */402#ifndef SQLITE_WIN32_HEAP_MAX_SIZE403#  define SQLITE_WIN32_HEAP_MAX_SIZE    (0)404#endif405 406/*407 * The extra flags to use in calls to the Win32 heap APIs.  This value may be408 * zero for the default behavior.409 */410#ifndef SQLITE_WIN32_HEAP_FLAGS411#  define SQLITE_WIN32_HEAP_FLAGS       (0)412#endif413 414 415/*416** The winMemData structure stores information required by the Win32-specific417** sqlite3_mem_methods implementation.418*/419typedef struct winMemData winMemData;420struct winMemData {421#ifndef NDEBUG422  u32 magic1;   /* Magic number to detect structure corruption. */423#endif424  HANDLE hHeap; /* The handle to our heap. */425  BOOL bOwned;  /* Do we own the heap (i.e. destroy it on shutdown)? */426#ifndef NDEBUG427  u32 magic2;   /* Magic number to detect structure corruption. */428#endif429};430 431#ifndef NDEBUG432#define WINMEM_MAGIC1     0x42b2830b433#define WINMEM_MAGIC2     0xbd4d7cf4434#endif435 436static struct winMemData win_mem_data = {437#ifndef NDEBUG438  WINMEM_MAGIC1,439#endif440  NULL, FALSE441#ifndef NDEBUG442  ,WINMEM_MAGIC2443#endif444};445 446#ifndef NDEBUG447#define winMemAssertMagic1() assert( win_mem_data.magic1==WINMEM_MAGIC1 )448#define winMemAssertMagic2() assert( win_mem_data.magic2==WINMEM_MAGIC2 )449#define winMemAssertMagic()  winMemAssertMagic1(); winMemAssertMagic2();450#else451#define winMemAssertMagic()452#endif453 454#define winMemGetDataPtr()  &win_mem_data455#define winMemGetHeap()     win_mem_data.hHeap456#define winMemGetOwned()    win_mem_data.bOwned457 458static void *winMemMalloc(int nBytes);459static void winMemFree(void *pPrior);460static void *winMemRealloc(void *pPrior, int nBytes);461static int winMemSize(void *p);462static int winMemRoundup(int n);463static int winMemInit(void *pAppData);464static void winMemShutdown(void *pAppData);465 466const sqlite3_mem_methods *sqlite3MemGetWin32(void);467#endif /* SQLITE_WIN32_MALLOC */468 469/*470** The following variable is (normally) set once and never changes471** thereafter.  It records whether the operating system is Win9x472** or WinNT.473**474** 0:   Operating system unknown.475** 1:   Operating system is Win9x.476** 2:   Operating system is WinNT.477**478** In order to facilitate testing on a WinNT system, the test fixture479** can manually set this value to 1 to emulate Win98 behavior.480*/481#ifdef SQLITE_TEST482LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0;483#else484static LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0;485#endif486 487#ifndef SYSCALL488#  define SYSCALL sqlite3_syscall_ptr489#endif490 491/*492** This function is not available on Windows CE or WinRT.493 */494 495#if SQLITE_OS_WINCE496#  define osAreFileApisANSI()       1497#endif498 499/*500** Many system calls are accessed through pointer-to-functions so that501** they may be overridden at runtime to facilitate fault injection during502** testing and sandboxing.  The following array holds the names and pointers503** to all overrideable system calls.504*/505static struct win_syscall {506  const char *zName;            /* Name of the system call */507  sqlite3_syscall_ptr pCurrent; /* Current value of the system call */508  sqlite3_syscall_ptr pDefault; /* Default value */509} aSyscall[] = {510#if !SQLITE_OS_WINCE511  { "AreFileApisANSI",         (SYSCALL)AreFileApisANSI,         0 },512#else513  { "AreFileApisANSI",         (SYSCALL)0,                       0 },514#endif515 516#ifndef osAreFileApisANSI517#define osAreFileApisANSI ((BOOL(WINAPI*)(VOID))aSyscall[0].pCurrent)518#endif519 520#if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)521  { "CharLowerW",              (SYSCALL)CharLowerW,              0 },522#else523  { "CharLowerW",              (SYSCALL)0,                       0 },524#endif525 526#define osCharLowerW ((LPWSTR(WINAPI*)(LPWSTR))aSyscall[1].pCurrent)527 528#if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)529  { "CharUpperW",              (SYSCALL)CharUpperW,              0 },530#else531  { "CharUpperW",              (SYSCALL)0,                       0 },532#endif533 534#define osCharUpperW ((LPWSTR(WINAPI*)(LPWSTR))aSyscall[2].pCurrent)535 536  { "CloseHandle",             (SYSCALL)CloseHandle,             0 },537 538#define osCloseHandle ((BOOL(WINAPI*)(HANDLE))aSyscall[3].pCurrent)539 540#if defined(SQLITE_WIN32_HAS_ANSI)541  { "CreateFileA",             (SYSCALL)CreateFileA,             0 },542#else543  { "CreateFileA",             (SYSCALL)0,                       0 },544#endif545 546#define osCreateFileA ((HANDLE(WINAPI*)(LPCSTR,DWORD,DWORD, \547        LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[4].pCurrent)548 549#if defined(SQLITE_WIN32_HAS_WIDE)550  { "CreateFileW",             (SYSCALL)CreateFileW,             0 },551#else552  { "CreateFileW",             (SYSCALL)0,                       0 },553#endif554 555#define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \556        LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent)557 558#if defined(SQLITE_WIN32_HAS_ANSI) && \559        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) && \560        SQLITE_WIN32_CREATEFILEMAPPINGA561  { "CreateFileMappingA",      (SYSCALL)CreateFileMappingA,      0 },562#else563  { "CreateFileMappingA",      (SYSCALL)0,                       0 },564#endif565 566#define osCreateFileMappingA ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \567        DWORD,DWORD,DWORD,LPCSTR))aSyscall[6].pCurrent)568 569#if (SQLITE_OS_WINCE || defined(SQLITE_WIN32_HAS_WIDE)) && \570        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)571  { "CreateFileMappingW",      (SYSCALL)CreateFileMappingW,      0 },572#else573  { "CreateFileMappingW",      (SYSCALL)0,                       0 },574#endif575 576#define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \577        DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent)578 579#if defined(SQLITE_WIN32_HAS_WIDE)580  { "CreateMutexW",            (SYSCALL)CreateMutexW,            0 },581#else582  { "CreateMutexW",            (SYSCALL)0,                       0 },583#endif584 585#define osCreateMutexW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,BOOL, \586        LPCWSTR))aSyscall[8].pCurrent)587 588#if defined(SQLITE_WIN32_HAS_ANSI)589  { "DeleteFileA",             (SYSCALL)DeleteFileA,             0 },590#else591  { "DeleteFileA",             (SYSCALL)0,                       0 },592#endif593 594#define osDeleteFileA ((BOOL(WINAPI*)(LPCSTR))aSyscall[9].pCurrent)595 596#if defined(SQLITE_WIN32_HAS_WIDE)597  { "DeleteFileW",             (SYSCALL)DeleteFileW,             0 },598#else599  { "DeleteFileW",             (SYSCALL)0,                       0 },600#endif601 602#define osDeleteFileW ((BOOL(WINAPI*)(LPCWSTR))aSyscall[10].pCurrent)603 604#if SQLITE_OS_WINCE605  { "FileTimeToLocalFileTime", (SYSCALL)FileTimeToLocalFileTime, 0 },606#else607  { "FileTimeToLocalFileTime", (SYSCALL)0,                       0 },608#endif609 610#define osFileTimeToLocalFileTime ((BOOL(WINAPI*)(const FILETIME*, \611        LPFILETIME))aSyscall[11].pCurrent)612 613#if SQLITE_OS_WINCE614  { "FileTimeToSystemTime",    (SYSCALL)FileTimeToSystemTime,    0 },615#else616  { "FileTimeToSystemTime",    (SYSCALL)0,                       0 },617#endif618 619#define osFileTimeToSystemTime ((BOOL(WINAPI*)(const FILETIME*, \620        LPSYSTEMTIME))aSyscall[12].pCurrent)621 622  { "FlushFileBuffers",        (SYSCALL)FlushFileBuffers,        0 },623 624#define osFlushFileBuffers ((BOOL(WINAPI*)(HANDLE))aSyscall[13].pCurrent)625 626#if defined(SQLITE_WIN32_HAS_ANSI)627  { "FormatMessageA",          (SYSCALL)FormatMessageA,          0 },628#else629  { "FormatMessageA",          (SYSCALL)0,                       0 },630#endif631 632#define osFormatMessageA ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPSTR, \633        DWORD,va_list*))aSyscall[14].pCurrent)634 635#if defined(SQLITE_WIN32_HAS_WIDE)636  { "FormatMessageW",          (SYSCALL)FormatMessageW,          0 },637#else638  { "FormatMessageW",          (SYSCALL)0,                       0 },639#endif640 641#define osFormatMessageW ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPWSTR, \642        DWORD,va_list*))aSyscall[15].pCurrent)643 644#if !defined(SQLITE_OMIT_LOAD_EXTENSION)645  { "FreeLibrary",             (SYSCALL)FreeLibrary,             0 },646#else647  { "FreeLibrary",             (SYSCALL)0,                       0 },648#endif649 650#define osFreeLibrary ((BOOL(WINAPI*)(HMODULE))aSyscall[16].pCurrent)651 652  { "GetCurrentProcessId",     (SYSCALL)GetCurrentProcessId,     0 },653 654#define osGetCurrentProcessId ((DWORD(WINAPI*)(VOID))aSyscall[17].pCurrent)655 656#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)657  { "GetDiskFreeSpaceA",       (SYSCALL)GetDiskFreeSpaceA,       0 },658#else659  { "GetDiskFreeSpaceA",       (SYSCALL)0,                       0 },660#endif661 662#define osGetDiskFreeSpaceA ((BOOL(WINAPI*)(LPCSTR,LPDWORD,LPDWORD,LPDWORD, \663        LPDWORD))aSyscall[18].pCurrent)664 665#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)666  { "GetDiskFreeSpaceW",       (SYSCALL)GetDiskFreeSpaceW,       0 },667#else668  { "GetDiskFreeSpaceW",       (SYSCALL)0,                       0 },669#endif670 671#define osGetDiskFreeSpaceW ((BOOL(WINAPI*)(LPCWSTR,LPDWORD,LPDWORD,LPDWORD, \672        LPDWORD))aSyscall[19].pCurrent)673 674#if defined(SQLITE_WIN32_HAS_ANSI)675  { "GetFileAttributesA",      (SYSCALL)GetFileAttributesA,      0 },676#else677  { "GetFileAttributesA",      (SYSCALL)0,                       0 },678#endif679 680#define osGetFileAttributesA ((DWORD(WINAPI*)(LPCSTR))aSyscall[20].pCurrent)681 682#if defined(SQLITE_WIN32_HAS_WIDE)683  { "GetFileAttributesW",      (SYSCALL)GetFileAttributesW,      0 },684#else685  { "GetFileAttributesW",      (SYSCALL)0,                       0 },686#endif687 688#define osGetFileAttributesW ((DWORD(WINAPI*)(LPCWSTR))aSyscall[21].pCurrent)689 690#if defined(SQLITE_WIN32_HAS_WIDE)691  { "GetFileAttributesExW",    (SYSCALL)GetFileAttributesExW,    0 },692#else693  { "GetFileAttributesExW",    (SYSCALL)0,                       0 },694#endif695 696#define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \697        LPVOID))aSyscall[22].pCurrent)698 699  { "GetFileSize",             (SYSCALL)GetFileSize,             0 },700 701#define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent)702 703#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)704  { "GetFullPathNameA",        (SYSCALL)GetFullPathNameA,        0 },705#else706  { "GetFullPathNameA",        (SYSCALL)0,                       0 },707#endif708 709#define osGetFullPathNameA ((DWORD(WINAPI*)(LPCSTR,DWORD,LPSTR, \710        LPSTR*))aSyscall[24].pCurrent)711 712#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)713  { "GetFullPathNameW",        (SYSCALL)GetFullPathNameW,        0 },714#else715  { "GetFullPathNameW",        (SYSCALL)0,                       0 },716#endif717 718#define osGetFullPathNameW ((DWORD(WINAPI*)(LPCWSTR,DWORD,LPWSTR, \719        LPWSTR*))aSyscall[25].pCurrent)720 721/*722** For GetLastError(), MSDN says:723**724** Minimum supported client: Windows XP [desktop apps | UWP apps]725** Minimum supported server: Windows Server 2003 [desktop apps | UWP apps]726*/727  { "GetLastError",            (SYSCALL)GetLastError,            0 },728 729#define osGetLastError ((DWORD(WINAPI*)(VOID))aSyscall[26].pCurrent)730 731#if !defined(SQLITE_OMIT_LOAD_EXTENSION)732#if SQLITE_OS_WINCE733  /* The GetProcAddressA() routine is only available on Windows CE. */734  { "GetProcAddressA",         (SYSCALL)GetProcAddressA,         0 },735#else736  /* All other Windows platforms expect GetProcAddress() to take737  ** an ANSI string regardless of the _UNICODE setting */738  { "GetProcAddressA",         (SYSCALL)GetProcAddress,          0 },739#endif740#else741  { "GetProcAddressA",         (SYSCALL)0,                       0 },742#endif743 744#define osGetProcAddressA ((FARPROC(WINAPI*)(HMODULE, \745        LPCSTR))aSyscall[27].pCurrent)746 747  { "GetSystemInfo",           (SYSCALL)GetSystemInfo,           0 },748#define osGetSystemInfo ((VOID(WINAPI*)(LPSYSTEM_INFO))aSyscall[28].pCurrent)749 750  { "GetSystemTime",           (SYSCALL)GetSystemTime,           0 },751#define osGetSystemTime ((VOID(WINAPI*)(LPSYSTEMTIME))aSyscall[29].pCurrent)752 753#if !SQLITE_OS_WINCE754  { "GetSystemTimeAsFileTime", (SYSCALL)GetSystemTimeAsFileTime, 0 },755#else756  { "GetSystemTimeAsFileTime", (SYSCALL)0,                       0 },757#endif758 759#define osGetSystemTimeAsFileTime ((VOID(WINAPI*)( \760        LPFILETIME))aSyscall[30].pCurrent)761 762#if defined(SQLITE_WIN32_HAS_ANSI)763  { "GetTempPathA",            (SYSCALL)GetTempPathA,            0 },764#else765  { "GetTempPathA",            (SYSCALL)0,                       0 },766#endif767 768#define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)769 770#if defined(SQLITE_WIN32_HAS_WIDE)771  { "GetTempPathW",            (SYSCALL)GetTempPathW,            0 },772#else773  { "GetTempPathW",            (SYSCALL)0,                       0 },774#endif775 776#define osGetTempPathW ((DWORD(WINAPI*)(DWORD,LPWSTR))aSyscall[32].pCurrent)777 778  { "GetTickCount",            (SYSCALL)GetTickCount,            0 },779 780#define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[33].pCurrent)781 782#if defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_GETVERSIONEX783  { "GetVersionExA",           (SYSCALL)GetVersionExA,           0 },784#else785  { "GetVersionExA",           (SYSCALL)0,                       0 },786#endif787 788#define osGetVersionExA ((BOOL(WINAPI*)( \789        LPOSVERSIONINFOA))aSyscall[34].pCurrent)790 791#if defined(SQLITE_WIN32_HAS_WIDE) && \792        SQLITE_WIN32_GETVERSIONEX793  { "GetVersionExW",           (SYSCALL)GetVersionExW,           0 },794#else795  { "GetVersionExW",           (SYSCALL)0,                       0 },796#endif797 798#define osGetVersionExW ((BOOL(WINAPI*)( \799        LPOSVERSIONINFOW))aSyscall[35].pCurrent)800 801  { "HeapAlloc",               (SYSCALL)HeapAlloc,               0 },802 803#define osHeapAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD, \804        SIZE_T))aSyscall[36].pCurrent)805 806  { "HeapCreate",              (SYSCALL)HeapCreate,              0 },807 808#define osHeapCreate ((HANDLE(WINAPI*)(DWORD,SIZE_T, \809        SIZE_T))aSyscall[37].pCurrent)810 811  { "HeapDestroy",             (SYSCALL)HeapDestroy,             0 },812 813#define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[38].pCurrent)814 815  { "HeapFree",                (SYSCALL)HeapFree,                0 },816 817#define osHeapFree ((BOOL(WINAPI*)(HANDLE,DWORD,LPVOID))aSyscall[39].pCurrent)818 819  { "HeapReAlloc",             (SYSCALL)HeapReAlloc,             0 },820 821#define osHeapReAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD,LPVOID, \822        SIZE_T))aSyscall[40].pCurrent)823 824  { "HeapSize",                (SYSCALL)HeapSize,                0 },825 826#define osHeapSize ((SIZE_T(WINAPI*)(HANDLE,DWORD, \827        LPCVOID))aSyscall[41].pCurrent)828 829  { "HeapValidate",            (SYSCALL)HeapValidate,            0 },830 831#define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \832        LPCVOID))aSyscall[42].pCurrent)833 834#if !SQLITE_OS_WINCE835  { "HeapCompact",             (SYSCALL)HeapCompact,             0 },836#else837  { "HeapCompact",             (SYSCALL)0,                       0 },838#endif839 840#define osHeapCompact ((UINT(WINAPI*)(HANDLE,DWORD))aSyscall[43].pCurrent)841 842#if defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_OMIT_LOAD_EXTENSION)843  { "LoadLibraryA",            (SYSCALL)LoadLibraryA,            0 },844#else845  { "LoadLibraryA",            (SYSCALL)0,                       0 },846#endif847 848#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[44].pCurrent)849 850#if defined(SQLITE_WIN32_HAS_WIDE) && \851        !defined(SQLITE_OMIT_LOAD_EXTENSION)852  { "LoadLibraryW",            (SYSCALL)LoadLibraryW,            0 },853#else854  { "LoadLibraryW",            (SYSCALL)0,                       0 },855#endif856 857#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[45].pCurrent)858 859  { "LocalFree",               (SYSCALL)LocalFree,               0 },860 861#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[46].pCurrent)862 863#if !SQLITE_OS_WINCE864  { "LockFile",                (SYSCALL)LockFile,                0 },865#else866  { "LockFile",                (SYSCALL)0,                       0 },867#endif868 869#if !defined(osLockFile) && defined(SQLITE_WIN32_HAS_ANSI)870#define osLockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \871        DWORD))aSyscall[47].pCurrent)872#endif873 874#if !SQLITE_OS_WINCE875  { "LockFileEx",              (SYSCALL)LockFileEx,              0 },876#else877  { "LockFileEx",              (SYSCALL)0,                       0 },878#endif879 880#ifndef osLockFileEx881#define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \882        LPOVERLAPPED))aSyscall[48].pCurrent)883#endif884 885#if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0886  { "MapViewOfFile",           (SYSCALL)MapViewOfFile,           0 },887#else888  { "MapViewOfFile",           (SYSCALL)0,                       0 },889#endif890 891#define osMapViewOfFile ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \892        SIZE_T))aSyscall[49].pCurrent)893 894  { "MultiByteToWideChar",     (SYSCALL)MultiByteToWideChar,     0 },895 896#define osMultiByteToWideChar ((int(WINAPI*)(UINT,DWORD,LPCSTR,int,LPWSTR, \897        int))aSyscall[50].pCurrent)898 899  { "QueryPerformanceCounter", (SYSCALL)QueryPerformanceCounter, 0 },900 901#define osQueryPerformanceCounter ((BOOL(WINAPI*)( \902        LARGE_INTEGER*))aSyscall[51].pCurrent)903 904  { "ReadFile",                (SYSCALL)ReadFile,                0 },905 906#define osReadFile ((BOOL(WINAPI*)(HANDLE,LPVOID,DWORD,LPDWORD, \907        LPOVERLAPPED))aSyscall[52].pCurrent)908 909  { "SetEndOfFile",            (SYSCALL)SetEndOfFile,            0 },910 911#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[53].pCurrent)912 913  { "SetFilePointer",          (SYSCALL)SetFilePointer,          0 },914 915#define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \916        DWORD))aSyscall[54].pCurrent)917 918  { "Sleep",                   (SYSCALL)Sleep,                   0 },919 920#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[55].pCurrent)921 922  { "SystemTimeToFileTime",    (SYSCALL)SystemTimeToFileTime,    0 },923 924#define osSystemTimeToFileTime ((BOOL(WINAPI*)(const SYSTEMTIME*, \925        LPFILETIME))aSyscall[56].pCurrent)926 927#if !SQLITE_OS_WINCE928  { "UnlockFile",              (SYSCALL)UnlockFile,              0 },929#else930  { "UnlockFile",              (SYSCALL)0,                       0 },931#endif932 933#if !defined(osUnlockFile) && defined(SQLITE_WIN32_HAS_ANSI)934#define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \935        DWORD))aSyscall[57].pCurrent)936#endif937 938#if !SQLITE_OS_WINCE939  { "UnlockFileEx",            (SYSCALL)UnlockFileEx,            0 },940#else941  { "UnlockFileEx",            (SYSCALL)0,                       0 },942#endif943 944#define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \945        LPOVERLAPPED))aSyscall[58].pCurrent)946 947#if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0948  { "UnmapViewOfFile",         (SYSCALL)UnmapViewOfFile,         0 },949#else950  { "UnmapViewOfFile",         (SYSCALL)0,                       0 },951#endif952 953#define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[59].pCurrent)954 955  { "WideCharToMultiByte",     (SYSCALL)WideCharToMultiByte,     0 },956 957#define osWideCharToMultiByte ((int(WINAPI*)(UINT,DWORD,LPCWSTR,int,LPSTR,int, \958        LPCSTR,LPBOOL))aSyscall[60].pCurrent)959 960  { "WriteFile",               (SYSCALL)WriteFile,               0 },961 962#define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \963        LPOVERLAPPED))aSyscall[61].pCurrent)964 965/*966** For WaitForSingleObject(), MSDN says:967**968** Minimum supported client: Windows XP [desktop apps | UWP apps]969** Minimum supported server: Windows Server 2003 [desktop apps | UWP apps]970*/971  { "WaitForSingleObject",     (SYSCALL)WaitForSingleObject,     0 },972 973#define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \974        DWORD))aSyscall[62].pCurrent)975 976#if !SQLITE_OS_WINCE977  { "WaitForSingleObjectEx",   (SYSCALL)WaitForSingleObjectEx,   0 },978#else979  { "WaitForSingleObjectEx",   (SYSCALL)0,                       0 },980#endif981 982#define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \983        BOOL))aSyscall[63].pCurrent)984 985  { "SetFilePointerEx",        (SYSCALL)SetFilePointerEx,        0 },986 987#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \988        PLARGE_INTEGER,DWORD))aSyscall[64].pCurrent)989 990  { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 },991 992#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \993        FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[65].pCurrent)994 995  { "CreateFile2",             (SYSCALL)CreateFile2,             0 },996 997#define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \998        LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[66].pCurrent)999 1000  { "GetTickCount64",          (SYSCALL)GetTickCount64,          0 },1001 1002#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[67].pCurrent)1003 1004  { "GetNativeSystemInfo",     (SYSCALL)GetNativeSystemInfo,     0 },1005 1006#define osGetNativeSystemInfo ((VOID(WINAPI*)( \1007        LPSYSTEM_INFO))aSyscall[68].pCurrent)1008 1009#if defined(SQLITE_WIN32_HAS_ANSI)1010  { "OutputDebugStringA",      (SYSCALL)OutputDebugStringA,      0 },1011#else1012  { "OutputDebugStringA",      (SYSCALL)0,                       0 },1013#endif1014 1015#define osOutputDebugStringA ((VOID(WINAPI*)(LPCSTR))aSyscall[69].pCurrent)1016 1017#if defined(SQLITE_WIN32_HAS_WIDE)1018  { "OutputDebugStringW",      (SYSCALL)OutputDebugStringW,      0 },1019#else1020  { "OutputDebugStringW",      (SYSCALL)0,                       0 },1021#endif1022 1023#define osOutputDebugStringW ((VOID(WINAPI*)(LPCWSTR))aSyscall[70].pCurrent)1024 1025  { "GetProcessHeap",          (SYSCALL)GetProcessHeap,          0 },1026 1027#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[71].pCurrent)1028 1029/*1030** NOTE: On some sub-platforms, the InterlockedCompareExchange "function"1031**       is really just a macro that uses a compiler intrinsic (e.g. x64).1032**       So do not try to make this is into a redefinable interface.1033*/1034#if defined(InterlockedCompareExchange)1035  { "InterlockedCompareExchange", (SYSCALL)0,                    0 },1036 1037#define osInterlockedCompareExchange InterlockedCompareExchange1038#else1039  { "InterlockedCompareExchange", (SYSCALL)InterlockedCompareExchange, 0 },1040 1041#define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG \1042        SQLITE_WIN32_VOLATILE*, LONG,LONG))aSyscall[72].pCurrent)1043#endif /* defined(InterlockedCompareExchange) */1044 1045#if !SQLITE_OS_WINCE && SQLITE_WIN32_USE_UUID1046  { "UuidCreate",               (SYSCALL)UuidCreate,             0 },1047#else1048  { "UuidCreate",               (SYSCALL)0,                      0 },1049#endif1050 1051#define osUuidCreate ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[73].pCurrent)1052 1053#if !SQLITE_OS_WINCE && SQLITE_WIN32_USE_UUID1054  { "UuidCreateSequential",     (SYSCALL)UuidCreateSequential,   0 },1055#else1056  { "UuidCreateSequential",     (SYSCALL)0,                      0 },1057#endif1058 1059#define osUuidCreateSequential \1060        ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[74].pCurrent)1061 1062#if !defined(SQLITE_NO_SYNC) && SQLITE_MAX_MMAP_SIZE>01063  { "FlushViewOfFile",          (SYSCALL)FlushViewOfFile,        0 },1064#else1065  { "FlushViewOfFile",          (SYSCALL)0,                      0 },1066#endif1067 1068#define osFlushViewOfFile \1069        ((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[75].pCurrent)1070 1071/*1072** If SQLITE_ENABLE_SETLK_TIMEOUT is defined, we require CreateEvent()1073** to implement blocking locks with timeouts. MSDN says:1074**1075** Minimum supported client: Windows XP [desktop apps | UWP apps]1076** Minimum supported server: Windows Server 2003 [desktop apps | UWP apps]1077*/1078#ifdef SQLITE_ENABLE_SETLK_TIMEOUT1079  { "CreateEvent",              (SYSCALL)CreateEvent,            0 },1080#else1081  { "CreateEvent",              (SYSCALL)0,                      0 },1082#endif1083 1084#define osCreateEvent ( \1085    (HANDLE(WINAPI*) (LPSECURITY_ATTRIBUTES,BOOL,BOOL,LPCSTR)) \1086    aSyscall[76].pCurrent \1087)1088 1089/*1090** If SQLITE_ENABLE_SETLK_TIMEOUT is defined, we require CancelIo()1091** for the case where a timeout expires and a lock request must be 1092** cancelled.1093**1094** Minimum supported client: Windows XP [desktop apps | UWP apps]1095** Minimum supported server: Windows Server 2003 [desktop apps | UWP apps]1096*/1097#ifdef SQLITE_ENABLE_SETLK_TIMEOUT1098  { "CancelIo",                 (SYSCALL)CancelIo,               0 },1099#else1100  { "CancelIo",                 (SYSCALL)0,                      0 },1101#endif1102 1103#define osCancelIo ((BOOL(WINAPI*)(HANDLE))aSyscall[77].pCurrent)1104 1105#if defined(SQLITE_WIN32_HAS_WIDE) && defined(_WIN32)1106  { "GetModuleHandleW",         (SYSCALL)GetModuleHandleW,       0 },1107#else1108  { "GetModuleHandleW",         (SYSCALL)0,                      0 },1109#endif1110 1111#define osGetModuleHandleW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[78].pCurrent)1112 1113#ifndef _WIN321114  { "getenv",                   (SYSCALL)getenv,                 0 },1115#else1116  { "getenv",                   (SYSCALL)0,                      0 },1117#endif1118 1119#define osGetenv ((const char *(*)(const char *))aSyscall[79].pCurrent)1120 1121#ifndef _WIN321122  { "getcwd",                   (SYSCALL)getcwd,                 0 },1123#else1124  { "getcwd",                   (SYSCALL)0,                      0 },1125#endif1126 1127#define osGetcwd ((char*(*)(char*,size_t))aSyscall[80].pCurrent)1128 1129#ifndef _WIN321130  { "readlink",                 (SYSCALL)readlink,               0 },1131#else1132  { "readlink",                 (SYSCALL)0,                      0 },1133#endif1134 1135#define osReadlink ((ssize_t(*)(const char*,char*,size_t))aSyscall[81].pCurrent)1136 1137#ifndef _WIN321138  { "lstat",                    (SYSCALL)lstat,                  0 },1139#else1140  { "lstat",                    (SYSCALL)0,                      0 },1141#endif1142 1143#define osLstat ((int(*)(const char*,struct stat*))aSyscall[82].pCurrent)1144 1145#ifndef _WIN321146  { "__errno",                  (SYSCALL)__errno,                0 },1147#else1148  { "__errno",                  (SYSCALL)0,                      0 },1149#endif1150 1151#define osErrno (*((int*(*)(void))aSyscall[83].pCurrent)())1152 1153#ifndef _WIN321154  { "cygwin_conv_path",         (SYSCALL)cygwin_conv_path,       0 },1155#else1156  { "cygwin_conv_path",         (SYSCALL)0,                      0 },1157#endif1158 1159#define osCygwin_conv_path ((size_t(*)(unsigned int, \1160    const void *, void *, size_t))aSyscall[84].pCurrent)1161 1162}; /* End of the overrideable system calls */1163 1164/*1165** This is the xSetSystemCall() method of sqlite3_vfs for all of the1166** "win32" VFSes.  Return SQLITE_OK upon successfully updating the1167** system call pointer, or SQLITE_NOTFOUND if there is no configurable1168** system call named zName.1169*/1170static int winSetSystemCall(1171  sqlite3_vfs *pNotUsed,        /* The VFS pointer.  Not used */1172  const char *zName,            /* Name of system call to override */1173  sqlite3_syscall_ptr pNewFunc  /* Pointer to new system call value */1174){1175  unsigned int i;1176  int rc = SQLITE_NOTFOUND;1177 1178  UNUSED_PARAMETER(pNotUsed);1179  if( zName==0 ){1180    /* If no zName is given, restore all system calls to their default1181    ** settings and return NULL1182    */1183    rc = SQLITE_OK;1184    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){1185      if( aSyscall[i].pDefault ){1186        aSyscall[i].pCurrent = aSyscall[i].pDefault;1187      }1188    }1189  }else{1190    /* If zName is specified, operate on only the one system call1191    ** specified.1192    */1193    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){1194      if( strcmp(zName, aSyscall[i].zName)==0 ){1195        if( aSyscall[i].pDefault==0 ){1196          aSyscall[i].pDefault = aSyscall[i].pCurrent;1197        }1198        rc = SQLITE_OK;1199        if( pNewFunc==0 ) pNewFunc = aSyscall[i].pDefault;1200        aSyscall[i].pCurrent = pNewFunc;

Showing the first 1,200 of 6518 lines. Download the file for the rest.