]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Use WaitForSingleObjectEx() as a substitute for Sleep on winRT.
authordrh <drh@noemail.net>
Thu, 1 Mar 2012 21:19:39 +0000 (21:19 +0000)
committerdrh <drh@noemail.net>
Thu, 1 Mar 2012 21:19:39 +0000 (21:19 +0000)
FossilOrigin-Name: bf897be0daa2f7e16f63b78849ffb76ce02d48f1

Makefile.msc
manifest
manifest.uuid
src/os_win.c

index 84efa4f58f97fccbf145f1f315bdeaee57a1112b..06677c98e4be463157b079fcd35ac10c3e97e8cd 100644 (file)
@@ -47,7 +47,7 @@ BCC = cl.exe
 # will run on the target platform.  (BCC and TCC are usually the
 # same unless your are cross-compiling.)
 #
-TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -DSQLITE_OS_WINRT=1 -I. -I$(TOP)\src -fp:precise
+TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -DSQLITE_OS_WINRT=0 -I. -I$(TOP)\src -fp:precise
 
 # The mksqlite3c.tcl and mksqlite3h.tcl scripts will pull in 
 # any extension header files by default.  For non-amalgamation
index 053f4b53914403184929ee7386e9501a4d16240d..983a310380c6b37cb51903b1ae095f17316142b0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,9 +1,9 @@
-C Add\srecognition\sof\sthe\sSQLITE_OS_WINRT\scompile-time\soption.\s\s\nUse\sInitializeCriticalSectionEx()\sunder\swinRT.
-D 2012-03-01T20:05:41.277
+C Use\sWaitForSingleObjectEx()\sas\sa\ssubstitute\sfor\sSleep\son\swinRT.
+D 2012-03-01T21:19:39.132
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
-F Makefile.msc 0e67f253439ebc333b7b49f373d5932a93209c6a
+F Makefile.msc 2aa54dceaafea890a19cd7f06ac7c168aff669d8
 F Makefile.vxworks 1deb39c8bb047296c30161ffa10c1b5423e632f9
 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6
 F VERSION bb4c2a86abe53ea3c1d6ea515b69a426040e2414
@@ -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 5ac061ae1326a71500cee578ed0fd9113b4f6a37
+F src/os_win.c b9c36459cf8f37d16a24f35cca934c21d74f0e5b
 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 718905367ff3f86a449c2c27f724089ba31dea3a
-R 465a0789e63e9500d164032936751907
+P 8b7ca8a09f7b69db1fe766616cba0307e681a6f3
+R 8f274d295cc98eee7dadf7a129e9b0df
 U drh
-Z 36d2e47a7d135f112024e54b1ccd201a
+Z a00ee944783dbe7653fdca656eaa2c07
index 4e41b5c0e4844de5ad16b5deeca8b5e89466e637..aee07f3b30bf6f7a8c9e03ef3de8ad177615fea0 100644 (file)
@@ -1 +1 @@
-8b7ca8a09f7b69db1fe766616cba0307e681a6f3
\ No newline at end of file
+bf897be0daa2f7e16f63b78849ffb76ce02d48f1
\ No newline at end of file
index 8b86c7ed59f6e6ca5561540b0f939d671bfbd9fa..9730e6bda920650559c8df3a14ea352771138b70 100644 (file)
@@ -168,17 +168,11 @@ int sqlite3_os_type = 0;
 static int sqlite3_os_type = 0;
 #endif
 
-/*
-** Many system calls are accessed through pointer-to-functions so that
-** they may be overridden at runtime to facilitate fault injection during
-** testing and sandboxing.  The following array holds the names and pointers
-** to all overrideable system calls.
-*/
-#if !SQLITE_OS_WINCE
+#if !SQLITE_OS_WINCE || SQLITE_OS_WINRT
 #  define SQLITE_WIN32_HAS_ANSI
 #endif
 
-#if SQLITE_OS_WINCE || SQLITE_OS_WINNT
+#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT
 #  define SQLITE_WIN32_HAS_WIDE
 #endif
 
@@ -207,6 +201,12 @@ static int sqlite3_os_type = 0;
 #  define osLockFileEx              LockFileEx
 #endif
 
+/*
+** Many system calls are accessed through pointer-to-functions so that
+** they may be overridden at runtime to facilitate fault injection during
+** testing and sandboxing.  The following array holds the names and pointers
+** to all overrideable system calls.
+*/
 static struct win_syscall {
   const char *zName;            /* Name of the sytem call */
   sqlite3_syscall_ptr pCurrent; /* Current value of the system call */
@@ -572,7 +572,11 @@ static struct win_syscall {
 #define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \
         DWORD))aSyscall[52].pCurrent)
 
+#if SQLITE_OS_WINRT
+  { "Sleep",                   (SYSCALL)0,                       0 },
+#else
   { "Sleep",                   (SYSCALL)Sleep,                   0 },
+#endif
 
 #define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[53].pCurrent)
 
@@ -698,6 +702,21 @@ static const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){
   return 0;
 }
 
+/*
+** The following routine Suspends the thread for at least ms milliseconds.  This is equivalent
+** to the win32 Sleep() interface.
+*/
+#if SQLITE_OS_WINRT
+static HANDLE sleepObj;
+static void portableSleep(int ms){
+  WaitForSingleObjectEx(sleepObj, ms, FALSE);
+}
+#else
+static void portableSleep(int ms){
+  osSleep(ms); 
+}
+#endif
+
 /*
 ** Return true (non-zero) if we are running under WinNT, Win2K, WinXP,
 ** or WinCE.  Return false (zero) for Win95, Win98, or WinME.
@@ -709,7 +728,7 @@ static const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){
 ** WinNT/2K/XP so that we will know whether or not we can safely call
 ** the LockFileEx() API.
 */
-#if SQLITE_OS_WINCE
+#if SQLITE_OS_WINCE  || SQLITE_OS_WINRT
 # define isNT()  (1)
 #else
   static int isNT(void){
@@ -1190,7 +1209,7 @@ static int retryIoerr(int *pnRetry, DWORD *pError){
   if( e==ERROR_ACCESS_DENIED ||
       e==ERROR_LOCK_VIOLATION ||
       e==ERROR_SHARING_VIOLATION ){
-    osSleep(win32IoerrRetryDelay*(1+*pnRetry));
+    portableSleep(win32IoerrRetryDelay*(1+*pnRetry));
     ++*pnRetry;
     return 1;
   }
@@ -1599,7 +1618,7 @@ static int winClose(sqlite3_file *id){
   do{
     rc = osCloseHandle(pFile->h);
     /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
-  }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (osSleep(100), 1) );
+  }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (portableSleep(100), 1) );
 #if SQLITE_OS_WINCE
 #define WINCE_DELETION_ATTEMPTS 3
   winceDestroyLock(pFile);
@@ -1610,7 +1629,7 @@ static int winClose(sqlite3_file *id){
         && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff 
         && cnt++ < WINCE_DELETION_ATTEMPTS
     ){
-       osSleep(100);  /* Wait a little before trying again */
+       portableSleep(100);  /* Wait a little before trying again */
     }
     sqlite3_free(pFile->zDeleteOnClose);
   }
@@ -1976,7 +1995,7 @@ static int winLock(sqlite3_file *id, int locktype){
       ** copy this retry logic.  It is a hack intended for Windows only.
       */
       OSTRACE(("could not get a PENDING lock. cnt=%d\n", cnt));
-      if( cnt ) osSleep(1);
+      if( cnt ) portableSleep(1);
     }
     gotPendingLock = res;
     if( !res ){
@@ -3535,7 +3554,7 @@ static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
 ** Sleep for a little while.  Return the amount of time slept.
 */
 static int winSleep(sqlite3_vfs *pVfs, int microsec){
-  osSleep((microsec+999)/1000);
+  portableSleep((microsec+999)/1000);
   UNUSED_PARAMETER(pVfs);
   return ((microsec+999)/1000)*1000;
 }
@@ -3679,6 +3698,11 @@ int sqlite3_os_init(void){
   ** correctly.  See ticket [bb3a86e890c8e96ab] */
   assert( ArraySize(aSyscall)==60 );
 
+#if SQLITE_OS_WINRT
+  sleepObj = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, 
+                                  EVENT_ALL_ACCESS);
+#endif
+
 #ifndef SQLITE_OMIT_WAL
   /* get memory map allocation granularity */
   memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
@@ -3691,6 +3715,9 @@ int sqlite3_os_init(void){
 }
 
 int sqlite3_os_end(void){ 
+#if SQLITE_OS_WINRT
+  CloseHandle(sleepObj);
+#endif
   return SQLITE_OK;
 }