From: mistachkin Date: Fri, 2 Mar 2012 13:47:16 +0000 (+0000) Subject: Add new Win32 APIs used to the system call table. Add error handling code for SetFil... X-Git-Tag: version-3.7.13~11^2~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=75b70a2087dbb4b4f41772fe4c49309a41a52797;p=thirdparty%2Fsqlite.git Add new Win32 APIs used to the system call table. Add error handling code for SetFilePointerEx. Make sure the last error number is saved from the call to GetFileInformationByHandleEx. FossilOrigin-Name: a782d2dc3cd4ef49ed46b361cdd331be846c3d50 --- diff --git a/manifest b/manifest index 5c40cd08c1..2f9e043fbf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sall\sANSI\sAPIs\sfor\swinRT. -D 2012-03-02T00:00:47.578 +C Add\snew\sWin32\sAPIs\sused\sto\sthe\ssystem\scall\stable.\s\sAdd\serror\shandling\scode\sfor\sSetFilePointerEx.\s\sMake\ssure\sthe\slast\serror\snumber\sis\ssaved\sfrom\sthe\scall\sto\sGetFileInformationByHandleEx. +D 2012-03-02T13:47:16.837 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h c3a9db9e8e16f564e1a40cea1687dad69634262c F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1 -F src/os_win.c 5593c84adc6717f6bf5c458d1f07cc4791a934e0 +F src/os_win.c 7378d50e4f8c3dafc0c11ca99615801c84329a4d F src/pager.c 3955b62cdb5bb64559607cb474dd12a6c8e1d4a5 F src/pager.h ef1eaf8593e78f73885c1dfac27ad83bee23bdc5 F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e @@ -991,7 +991,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 119f251de77aa88cf8ff9fcc72bfbecbe6b741e3 -R 28c9f3fe3a37af201beee74056883c04 -U drh -Z 229978c984d0d009c0d2a08c187d7dfd +P cbf23b461f599d0b025c0f42dd3189cfa4e84bac +R f72d2ca1c8333360bf3d39a3248646ef +U mistachkin +Z bc3c857da09d5ea46a27e32ed356379b diff --git a/manifest.uuid b/manifest.uuid index 40c8a48a07..30bb20d31a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cbf23b461f599d0b025c0f42dd3189cfa4e84bac \ No newline at end of file +a782d2dc3cd4ef49ed46b361cdd331be846c3d50 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 5c590e2591..bc8bf3e267 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -625,6 +625,47 @@ static struct win_syscall { #define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \ LPOVERLAPPED))aSyscall[59].pCurrent) +#if !SQLITE_OS_WINCE + { "CreateEventEx", (SYSCALL)CreateEventEx, 0 }, + +#define osCreateEventEx ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCTSTR, \ + DWORD,DWORD))aSyscall[60].pCurrent) +#else + { "CreateEventEx", (SYSCALL)0, 0 }, +#endif + + { "WaitForSingleObject", (SYSCALL)WaitForSingleObject, 0 }, + +#define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \ + DWORD))aSyscall[61].pCurrent) + +#if !SQLITE_OS_WINCE + { "WaitForSingleObjectEx", (SYSCALL)WaitForSingleObjectEx, 0 }, + +#define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \ + BOOL))aSyscall[62].pCurrent) +#else + { "WaitForSingleObjectEx", (SYSCALL)0, 0 }, +#endif + +#if !SQLITE_OS_WINCE + { "SetFilePointerEx", (SYSCALL)SetFilePointerEx, 0 }, + +#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \ + PLARGE_INTEGER,DWORD))aSyscall[63].pCurrent) +#else + { "SetFilePointerEx", (SYSCALL)0, 0 }, +#endif + +#if !SQLITE_OS_WINCE + { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 }, + +#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \ + FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[64].pCurrent) +#else + { "GetFileInformationByHandleEx", (SYSCALL)0, 0 }, +#endif + }; /* End of the overrideable system calls */ /* @@ -717,7 +758,7 @@ static const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){ #if SQLITE_OS_WINRT static HANDLE sleepObj; static void portableSleep(int ms){ - WaitForSingleObjectEx(sleepObj, ms, FALSE); + osWaitForSingleObjectEx(sleepObj, ms, FALSE); } #else static void portableSleep(int ms){ @@ -1275,7 +1316,7 @@ struct tm *__cdecl localtime(const time_t *t) static void winceMutexAcquire(HANDLE h){ DWORD dwErr; do { - dwErr = WaitForSingleObject(h, INFINITE); + dwErr = osWaitForSingleObject(h, INFINITE); } while (dwErr != WAIT_OBJECT_0 && dwErr != WAIT_ABANDONED); } /* @@ -1608,9 +1649,20 @@ static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ ** windowsRT. */ static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ - LARGE_INTEGER x; + LARGE_INTEGER x; /* The new offset */ + BOOL bRet; /* Value returned by SetFilePointerEx() */ + x.QuadPart = iOffset; - return SetFilePointerEx(pFile->h, x, 0, FILE_BEGIN) ? 0 : 1; + bRet = osSetFilePointerEx(pFile->h, x, 0, FILE_BEGIN); + + if(!bRet){ + pFile->lastErrno = osGetLastError(); + winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno, + "seekWinFile", pFile->zPath); + return 1; + } + + return 0; } #endif @@ -1870,10 +1922,11 @@ static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){ #if SQLITE_OS_WINRT { FILE_STANDARD_INFO info; - if( GetFileInformationByHandleEx(pFile->h, FileStandardInfo, + if( osGetFileInformationByHandleEx(pFile->h, FileStandardInfo, &info, sizeof(info)) ){ *pSize = info.EndOfFile.QuadPart; }else{ + pFile->lastErrno = osGetLastError(); rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno, "winFileSize", pFile->zPath); } @@ -3707,10 +3760,10 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==60 ); + assert( ArraySize(aSyscall)==65 ); #if SQLITE_OS_WINRT - sleepObj = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, + sleepObj = osCreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS); #endif @@ -3727,7 +3780,7 @@ int sqlite3_os_init(void){ int sqlite3_os_end(void){ #if SQLITE_OS_WINRT - CloseHandle(sleepObj); + osCloseHandle(sleepObj); #endif return SQLITE_OK; }