/ Check-in [091aa5f1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge in the fix for the InterlockedCompareExchange() build issue.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1: 091aa5f1047f0ec984a69ab1f356c1960813b77b
User & Date: drh 2014-08-06 03:16:56
Context
2014-08-06
11:49
Fix an obsolete comment in the func.c source file. No changes to code. check-in: 7a145c94 user: drh tags: sessions
03:16
Merge in the fix for the InterlockedCompareExchange() build issue. check-in: 091aa5f1 user: drh tags: sessions
03:06
In the Win32 VFS, work around InterlockedCompareExchange() being a macro on some platforms (e.g. x64). check-in: 7be244ce user: mistachkin tags: trunk
01:25
Merge the latest 3.8.6 beta changes from trunk. check-in: 68a6d5e2 user: drh tags: sessions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

   200    200   WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID);
   201    201   #endif /* SQLITE_WIN32_FILEMAPPING_API && !defined(SQLITE_OMIT_WAL) */
   202    202   
   203    203   /*
   204    204   ** Some Microsoft compilers lack this definition.
   205    205   */
   206    206   #ifndef INVALID_FILE_ATTRIBUTES
   207         -# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) 
          207  +# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
   208    208   #endif
   209    209   
   210    210   #ifndef FILE_FLAG_MASK
   211    211   # define FILE_FLAG_MASK          (0xFF3C0000)
   212    212   #endif
   213    213   
   214    214   #ifndef FILE_ATTRIBUTE_MASK
................................................................................
   250    250   #ifndef SQLITE_OMIT_WAL
   251    251     winShm *pShm;           /* Instance of shared memory on this file */
   252    252   #endif
   253    253     const char *zPath;      /* Full pathname of this file */
   254    254     int szChunk;            /* Chunk size configured by FCNTL_CHUNK_SIZE */
   255    255   #if SQLITE_OS_WINCE
   256    256     LPWSTR zDeleteOnClose;  /* Name of file to delete when closing */
   257         -  HANDLE hMutex;          /* Mutex used to control access to shared lock */  
          257  +  HANDLE hMutex;          /* Mutex used to control access to shared lock */
   258    258     HANDLE hShared;         /* Shared memory segment used for locking */
   259    259     winceLock local;        /* Locks obtained by this instance of winFile */
   260    260     winceLock *shared;      /* Global shared lock memory for the file  */
   261    261   #endif
   262    262   #if SQLITE_MAX_MMAP_SIZE>0
   263    263     int nFetchOut;                /* Number of outstanding xFetch references */
   264    264     HANDLE hMap;                  /* Handle for accessing memory mapping */
................................................................................
  1043   1043   #else
  1044   1044     { "CreateFileMappingFromApp", (SYSCALL)0,                      0 },
  1045   1045   #endif
  1046   1046   
  1047   1047   #define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \
  1048   1048           LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent)
  1049   1049   
         1050  +/*
         1051  +** NOTE: On some sub-platforms, the InterlockedCompareExchange "function"
         1052  +**       is really just a macro that uses a compiler intrinsic (e.g. x64).
         1053  +*/
         1054  +
         1055  +#if defined(InterlockedCompareExchange)
         1056  +#define osInterlockedCompareExchange InterlockedCompareExchange
         1057  +#else
  1050   1058     { "InterlockedCompareExchange", (SYSCALL)InterlockedCompareExchange, 0 },
  1051   1059   
  1052   1060   #define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG volatile*, \
  1053   1061           LONG,LONG))aSyscall[76].pCurrent)
         1062  +#endif /* defined(InterlockedCompareExchange) */
  1054   1063   
  1055   1064   }; /* End of the overrideable system calls */
  1056   1065   
  1057   1066   /*
  1058   1067   ** This is the xSetSystemCall() method of sqlite3_vfs for all of the
  1059   1068   ** "win32" VFSes.  Return SQLITE_OK opon successfully updating the
  1060   1069   ** system call pointer, or SQLITE_NOTFOUND if there is no configurable
................................................................................
  1528   1537   
  1529   1538   void sqlite3MemSetDefault(void){
  1530   1539     sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetWin32());
  1531   1540   }
  1532   1541   #endif /* SQLITE_WIN32_MALLOC */
  1533   1542   
  1534   1543   /*
  1535         -** Convert a UTF-8 string to Microsoft Unicode (UTF-16?). 
         1544  +** Convert a UTF-8 string to Microsoft Unicode (UTF-16?).
  1536   1545   **
  1537   1546   ** Space to hold the returned string is obtained from malloc.
  1538   1547   */
  1539   1548   static LPWSTR winUtf8ToUnicode(const char *zFilename){
  1540   1549     int nChar;
  1541   1550     LPWSTR zWideFilename;
  1542   1551   
................................................................................
  1581   1590     }
  1582   1591     return zFilename;
  1583   1592   }
  1584   1593   
  1585   1594   /*
  1586   1595   ** Convert an ANSI string to Microsoft Unicode, based on the
  1587   1596   ** current codepage settings for file apis.
  1588         -** 
         1597  +**
  1589   1598   ** Space to hold the returned string is obtained
  1590   1599   ** from sqlite3_malloc.
  1591   1600   */
  1592   1601   static LPWSTR winMbcsToUnicode(const char *zFilename){
  1593   1602     int nByte;
  1594   1603     LPWSTR zMbcsFilename;
  1595   1604     int codepage = osAreFileApisANSI() ? CP_ACP : CP_OEMCP;
................................................................................
  1655   1664     }
  1656   1665     zFilenameUtf8 = winUnicodeToUtf8(zTmpWide);
  1657   1666     sqlite3_free(zTmpWide);
  1658   1667     return zFilenameUtf8;
  1659   1668   }
  1660   1669   
  1661   1670   /*
  1662         -** Convert UTF-8 to multibyte character string.  Space to hold the 
         1671  +** Convert UTF-8 to multibyte character string.  Space to hold the
  1663   1672   ** returned string is obtained from sqlite3_malloc().
  1664   1673   */
  1665   1674   char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){
  1666   1675     char *zFilenameMbcs;
  1667   1676     LPWSTR zTmpWide;
  1668   1677   
  1669   1678     zTmpWide = winUtf8ToUnicode(zFilename);
................................................................................
  1795   1804   /*
  1796   1805   **
  1797   1806   ** This function - winLogErrorAtLine() - is only ever called via the macro
  1798   1807   ** winLogError().
  1799   1808   **
  1800   1809   ** This routine is invoked after an error occurs in an OS function.
  1801   1810   ** It logs a message using sqlite3_log() containing the current value of
  1802         -** error code and, if possible, the human-readable equivalent from 
         1811  +** error code and, if possible, the human-readable equivalent from
  1803   1812   ** FormatMessage.
  1804   1813   **
  1805   1814   ** The first argument passed to the macro should be the error code that
  1806         -** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). 
         1815  +** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN).
  1807   1816   ** The two subsequent arguments should be the name of the OS function that
  1808   1817   ** failed and the associated file-system path, if any.
  1809   1818   */
  1810   1819   #define winLogError(a,b,c,d)   winLogErrorAtLine(a,b,c,d,__LINE__)
  1811   1820   static int winLogErrorAtLine(
  1812   1821     int errcode,                    /* SQLite error code */
  1813   1822     DWORD lastErrno,                /* Win32 last error */
................................................................................
  1830   1839     );
  1831   1840   
  1832   1841     return errcode;
  1833   1842   }
  1834   1843   
  1835   1844   /*
  1836   1845   ** The number of times that a ReadFile(), WriteFile(), and DeleteFile()
  1837         -** will be retried following a locking error - probably caused by 
         1846  +** will be retried following a locking error - probably caused by
  1838   1847   ** antivirus software.  Also the initial delay before the first retry.
  1839   1848   ** The delay increases linearly with each retry.
  1840   1849   */
  1841   1850   #ifndef SQLITE_WIN32_IOERR_RETRY
  1842   1851   # define SQLITE_WIN32_IOERR_RETRY 10
  1843   1852   #endif
  1844   1853   #ifndef SQLITE_WIN32_IOERR_RETRY_DELAY
................................................................................
  1905   1914   }
  1906   1915   
  1907   1916   /*
  1908   1917   ** Log a I/O error retry episode.
  1909   1918   */
  1910   1919   static void winLogIoerr(int nRetry){
  1911   1920     if( nRetry ){
  1912         -    sqlite3_log(SQLITE_IOERR, 
         1921  +    sqlite3_log(SQLITE_IOERR,
  1913   1922         "delayed %dms for lock/sharing conflict",
  1914   1923         winIoerrRetryDelay*nRetry*(nRetry+1)/2
  1915   1924       );
  1916   1925     }
  1917   1926   }
  1918   1927   
  1919   1928   #if SQLITE_OS_WINCE
................................................................................
  1999   2008       sqlite3_free(zName);
  2000   2009       return winLogError(SQLITE_IOERR, pFile->lastErrno,
  2001   2010                          "winceCreateLock1", zFilename);
  2002   2011     }
  2003   2012   
  2004   2013     /* Acquire the mutex before continuing */
  2005   2014     winceMutexAcquire(pFile->hMutex);
  2006         -  
  2007         -  /* Since the names of named mutexes, semaphores, file mappings etc are 
         2015  +
         2016  +  /* Since the names of named mutexes, semaphores, file mappings etc are
  2008   2017     ** case-sensitive, take advantage of that by uppercasing the mutex name
  2009   2018     ** and using that as the shared filemapping name.
  2010   2019     */
  2011   2020     osCharUpperW(zName);
  2012   2021     pFile->hShared = osCreateFileMappingW(INVALID_HANDLE_VALUE, NULL,
  2013   2022                                           PAGE_READWRITE, 0, sizeof(winceLock),
  2014         -                                        zName);  
         2023  +                                        zName);
  2015   2024   
  2016         -  /* Set a flag that indicates we're the first to create the memory so it 
         2025  +  /* Set a flag that indicates we're the first to create the memory so it
  2017   2026     ** must be zero-initialized */
  2018   2027     lastErrno = osGetLastError();
  2019   2028     if (lastErrno == ERROR_ALREADY_EXISTS){
  2020   2029       bInit = FALSE;
  2021   2030     }
  2022   2031   
  2023   2032     sqlite3_free(zName);
  2024   2033   
  2025   2034     /* If we succeeded in making the shared memory handle, map it. */
  2026   2035     if( pFile->hShared ){
  2027         -    pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared, 
         2036  +    pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared,
  2028   2037                FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock));
  2029   2038       /* If mapping failed, close the shared memory handle and erase it */
  2030   2039       if( !pFile->shared ){
  2031   2040         pFile->lastErrno = osGetLastError();
  2032   2041         winLogError(SQLITE_IOERR, pFile->lastErrno,
  2033   2042                     "winceCreateLock2", zFilename);
  2034   2043         bLogged = TRUE;
................................................................................
  2046   2055         bLogged = TRUE;
  2047   2056       }
  2048   2057       winceMutexRelease(pFile->hMutex);
  2049   2058       osCloseHandle(pFile->hMutex);
  2050   2059       pFile->hMutex = NULL;
  2051   2060       return SQLITE_IOERR;
  2052   2061     }
  2053         -  
         2062  +
  2054   2063     /* Initialize the shared memory if we're supposed to */
  2055   2064     if( bInit ){
  2056   2065       memset(pFile->shared, 0, sizeof(winceLock));
  2057   2066     }
  2058   2067   
  2059   2068     winceMutexRelease(pFile->hMutex);
  2060   2069     return SQLITE_OK;
................................................................................
  2084   2093       }
  2085   2094   
  2086   2095       /* De-reference and close our copy of the shared memory handle */
  2087   2096       osUnmapViewOfFile(pFile->shared);
  2088   2097       osCloseHandle(pFile->hShared);
  2089   2098   
  2090   2099       /* Done with the mutex */
  2091         -    winceMutexRelease(pFile->hMutex);    
         2100  +    winceMutexRelease(pFile->hMutex);
  2092   2101       osCloseHandle(pFile->hMutex);
  2093   2102       pFile->hMutex = NULL;
  2094   2103     }
  2095   2104   }
  2096   2105   
  2097         -/* 
         2106  +/*
  2098   2107   ** An implementation of the LockFile() API of Windows for CE
  2099   2108   */
  2100   2109   static BOOL winceLockFile(
  2101   2110     LPHANDLE phFile,
  2102   2111     DWORD dwFileOffsetLow,
  2103   2112     DWORD dwFileOffsetHigh,
  2104   2113     DWORD nNumberOfBytesToLockLow,
................................................................................
  2301   2310   ** Some Microsoft compilers lack this definition.
  2302   2311   */
  2303   2312   #ifndef INVALID_SET_FILE_POINTER
  2304   2313   # define INVALID_SET_FILE_POINTER ((DWORD)-1)
  2305   2314   #endif
  2306   2315   
  2307   2316   /*
  2308         -** Move the current position of the file handle passed as the first 
  2309         -** argument to offset iOffset within the file. If successful, return 0. 
         2317  +** Move the current position of the file handle passed as the first
         2318  +** argument to offset iOffset within the file. If successful, return 0.
  2310   2319   ** Otherwise, set pFile->lastErrno and return non-zero.
  2311   2320   */
  2312   2321   static int winSeekFile(winFile *pFile, sqlite3_int64 iOffset){
  2313   2322   #if !SQLITE_OS_WINRT
  2314   2323     LONG upperBits;                 /* Most sig. 32 bits of new offset */
  2315   2324     LONG lowerBits;                 /* Least sig. 32 bits of new offset */
  2316   2325     DWORD dwRet;                    /* Value returned by SetFilePointer() */
................................................................................
  2317   2326     DWORD lastErrno;                /* Value returned by GetLastError() */
  2318   2327   
  2319   2328     OSTRACE(("SEEK file=%p, offset=%lld\n", pFile->h, iOffset));
  2320   2329   
  2321   2330     upperBits = (LONG)((iOffset>>32) & 0x7fffffff);
  2322   2331     lowerBits = (LONG)(iOffset & 0xffffffff);
  2323   2332   
  2324         -  /* API oddity: If successful, SetFilePointer() returns a dword 
         2333  +  /* API oddity: If successful, SetFilePointer() returns a dword
  2325   2334     ** containing the lower 32-bits of the new file-offset. Or, if it fails,
  2326         -  ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, 
  2327         -  ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine 
  2328         -  ** whether an error has actually occurred, it is also necessary to call 
         2335  +  ** it returns INVALID_SET_FILE_POINTER. However according to MSDN,
         2336  +  ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine
         2337  +  ** whether an error has actually occurred, it is also necessary to call
  2329   2338     ** GetLastError().
  2330   2339     */
  2331   2340     dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
  2332   2341   
  2333   2342     if( (dwRet==INVALID_SET_FILE_POINTER
  2334   2343         && ((lastErrno = osGetLastError())!=NO_ERROR)) ){
  2335   2344       pFile->lastErrno = lastErrno;
................................................................................
  2404   2413   #if SQLITE_OS_WINCE
  2405   2414   #define WINCE_DELETION_ATTEMPTS 3
  2406   2415     winceDestroyLock(pFile);
  2407   2416     if( pFile->zDeleteOnClose ){
  2408   2417       int cnt = 0;
  2409   2418       while(
  2410   2419              osDeleteFileW(pFile->zDeleteOnClose)==0
  2411         -        && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff 
         2420  +        && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff
  2412   2421           && cnt++ < WINCE_DELETION_ATTEMPTS
  2413   2422       ){
  2414   2423          sqlite3_win32_sleep(100);  /* Wait a little before trying again */
  2415   2424       }
  2416   2425       sqlite3_free(pFile->zDeleteOnClose);
  2417   2426     }
  2418   2427   #endif
................................................................................
  3252   3261   */
  3253   3262   static int winDeviceCharacteristics(sqlite3_file *id){
  3254   3263     winFile *p = (winFile*)id;
  3255   3264     return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |
  3256   3265            ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0);
  3257   3266   }
  3258   3267   
  3259         -/* 
         3268  +/*
  3260   3269   ** Windows will only let you create file view mappings
  3261   3270   ** on allocation size granularity boundaries.
  3262   3271   ** During sqlite3_os_init() we do a GetSystemInfo()
  3263   3272   ** to get the granularity size.
  3264   3273   */
  3265   3274   static SYSTEM_INFO winSysInfo;
  3266   3275   
  3267   3276   #ifndef SQLITE_OMIT_WAL
  3268   3277   
  3269   3278   /*
  3270   3279   ** Helper functions to obtain and relinquish the global mutex. The
  3271         -** global mutex is used to protect the winLockInfo objects used by 
         3280  +** global mutex is used to protect the winLockInfo objects used by
  3272   3281   ** this file, all of which may be shared by multiple threads.
  3273   3282   **
  3274         -** Function winShmMutexHeld() is used to assert() that the global mutex 
  3275         -** is held when required. This function is only used as part of assert() 
         3283  +** Function winShmMutexHeld() is used to assert() that the global mutex
         3284  +** is held when required. This function is only used as part of assert()
  3276   3285   ** statements. e.g.
  3277   3286   **
  3278   3287   **   winShmEnterMutex()
  3279   3288   **     assert( winShmMutexHeld() );
  3280   3289   **   winShmLeaveMutex()
  3281   3290   */
  3282   3291   static void winShmEnterMutex(void){
................................................................................
  3298   3307   ** point to a single instance of this object.  In other words, each
  3299   3308   ** log-summary is opened only once per process.
  3300   3309   **
  3301   3310   ** winShmMutexHeld() must be true when creating or destroying
  3302   3311   ** this object or while reading or writing the following fields:
  3303   3312   **
  3304   3313   **      nRef
  3305         -**      pNext 
         3314  +**      pNext
  3306   3315   **
  3307   3316   ** The following fields are read-only after the object is created:
  3308         -** 
         3317  +**
  3309   3318   **      fid
  3310   3319   **      zFilename
  3311   3320   **
  3312   3321   ** Either winShmNode.mutex must be held or winShmNode.nRef==0 and
  3313   3322   ** winShmMutexHeld() is true when reading or writing any other field
  3314   3323   ** in this structure.
  3315   3324   **
................................................................................
  3397   3406       rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);
  3398   3407     }else{
  3399   3408       /* Initialize the locking parameters */
  3400   3409       DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;
  3401   3410       if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
  3402   3411       rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);
  3403   3412     }
  3404         -  
         3413  +
  3405   3414     if( rc!= 0 ){
  3406   3415       rc = SQLITE_OK;
  3407   3416     }else{
  3408   3417       pFile->lastErrno =  osGetLastError();
  3409   3418       rc = SQLITE_BUSY;
  3410   3419     }
  3411   3420   
................................................................................
  3493   3502     pNew = sqlite3MallocZero( sizeof(*pShmNode) + nName + 17 );
  3494   3503     if( pNew==0 ){
  3495   3504       sqlite3_free(p);
  3496   3505       return SQLITE_IOERR_NOMEM;
  3497   3506     }
  3498   3507     pNew->zFilename = (char*)&pNew[1];
  3499   3508     sqlite3_snprintf(nName+15, pNew->zFilename, "%s-shm", pDbFd->zPath);
  3500         -  sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename); 
         3509  +  sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename);
  3501   3510   
  3502   3511     /* Look to see if there is an existing winShmNode that can be used.
  3503   3512     ** If no matching winShmNode currently exists, create a new one.
  3504   3513     */
  3505   3514     winShmEnterMutex();
  3506   3515     for(pShmNode = winShmNodeList; pShmNode; pShmNode=pShmNode->pNext){
  3507   3516       /* TBD need to come up with better match here.  Perhaps
................................................................................
  3530   3539                    SQLITE_OPEN_WAL | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
  3531   3540                    0);
  3532   3541       if( SQLITE_OK!=rc ){
  3533   3542         goto shm_open_err;
  3534   3543       }
  3535   3544   
  3536   3545       /* Check to see if another process is holding the dead-man switch.
  3537         -    ** If not, truncate the file to zero length. 
         3546  +    ** If not, truncate the file to zero length.
  3538   3547       */
  3539   3548       if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
  3540   3549         rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
  3541   3550         if( rc!=SQLITE_OK ){
  3542   3551           rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),
  3543   3552                            "winOpenShm", pDbFd->zPath);
  3544   3553         }
................................................................................
  3559   3568     pDbFd->pShm = p;
  3560   3569     winShmLeaveMutex();
  3561   3570   
  3562   3571     /* The reference count on pShmNode has already been incremented under
  3563   3572     ** the cover of the winShmEnterMutex() mutex and the pointer from the
  3564   3573     ** new (struct winShm) object to the pShmNode has been set. All that is
  3565   3574     ** left to do is to link the new object into the linked list starting
  3566         -  ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex 
         3575  +  ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex
  3567   3576     ** mutex.
  3568   3577     */
  3569   3578     sqlite3_mutex_enter(pShmNode->mutex);
  3570   3579     p->pNext = pShmNode->pFirst;
  3571   3580     pShmNode->pFirst = p;
  3572   3581     sqlite3_mutex_leave(pShmNode->mutex);
  3573   3582     return SQLITE_OK;
................................................................................
  3579   3588     sqlite3_free(p);
  3580   3589     sqlite3_free(pNew);
  3581   3590     winShmLeaveMutex();
  3582   3591     return rc;
  3583   3592   }
  3584   3593   
  3585   3594   /*
  3586         -** Close a connection to shared-memory.  Delete the underlying 
         3595  +** Close a connection to shared-memory.  Delete the underlying
  3587   3596   ** storage if deleteFlag is true.
  3588   3597   */
  3589   3598   static int winShmUnmap(
  3590   3599     sqlite3_file *fd,          /* Database holding shared memory */
  3591   3600     int deleteFlag             /* Delete after closing if true */
  3592   3601   ){
  3593   3602     winFile *pDbFd;       /* Database holding shared-memory */
................................................................................
  3668   3677         rc = SQLITE_OK;
  3669   3678       }
  3670   3679   
  3671   3680       /* Undo the local locks */
  3672   3681       if( rc==SQLITE_OK ){
  3673   3682         p->exclMask &= ~mask;
  3674   3683         p->sharedMask &= ~mask;
  3675         -    } 
         3684  +    }
  3676   3685     }else if( flags & SQLITE_SHM_SHARED ){
  3677   3686       u16 allShared = 0;  /* Union of locks held by connections other than "p" */
  3678   3687   
  3679   3688       /* Find out which shared locks are already held by sibling connections.
  3680   3689       ** If any sibling already holds an exclusive lock, go ahead and return
  3681   3690       ** SQLITE_BUSY.
  3682   3691       */
................................................................................
  3707   3716       */
  3708   3717       for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
  3709   3718         if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){
  3710   3719           rc = SQLITE_BUSY;
  3711   3720           break;
  3712   3721         }
  3713   3722       }
  3714         -  
         3723  +
  3715   3724       /* Get the exclusive locks at the system level.  Then if successful
  3716   3725       ** also mark the local connection as being locked.
  3717   3726       */
  3718   3727       if( rc==SQLITE_OK ){
  3719   3728         rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n);
  3720   3729         if( rc==SQLITE_OK ){
  3721   3730           assert( (p->sharedMask & mask)==0 );
................................................................................
  3727   3736     OSTRACE(("SHM-LOCK pid=%lu, id=%d, sharedMask=%03x, exclMask=%03x, rc=%s\n",
  3728   3737              osGetCurrentProcessId(), p->id, p->sharedMask, p->exclMask,
  3729   3738              sqlite3ErrName(rc)));
  3730   3739     return rc;
  3731   3740   }
  3732   3741   
  3733   3742   /*
  3734         -** Implement a memory barrier or memory fence on shared memory.  
         3743  +** Implement a memory barrier or memory fence on shared memory.
  3735   3744   **
  3736   3745   ** All loads and stores begun before the barrier must complete before
  3737   3746   ** any load or store begun after the barrier.
  3738   3747   */
  3739   3748   static void winShmBarrier(
  3740   3749     sqlite3_file *fd          /* Database holding the shared memory */
  3741   3750   ){
................................................................................
  3742   3751     UNUSED_PARAMETER(fd);
  3743   3752     /* MemoryBarrier(); // does not work -- do not know why not */
  3744   3753     winShmEnterMutex();
  3745   3754     winShmLeaveMutex();
  3746   3755   }
  3747   3756   
  3748   3757   /*
  3749         -** This function is called to obtain a pointer to region iRegion of the 
  3750         -** shared-memory associated with the database file fd. Shared-memory regions 
  3751         -** are numbered starting from zero. Each shared-memory region is szRegion 
         3758  +** This function is called to obtain a pointer to region iRegion of the
         3759  +** shared-memory associated with the database file fd. Shared-memory regions
         3760  +** are numbered starting from zero. Each shared-memory region is szRegion
  3752   3761   ** bytes in size.
  3753   3762   **
  3754   3763   ** If an error occurs, an error code is returned and *pp is set to NULL.
  3755   3764   **
  3756   3765   ** Otherwise, if the isWrite parameter is 0 and the requested shared-memory
  3757   3766   ** region has not been allocated (by any client, including one running in a
  3758         -** separate process), then *pp is set to NULL and SQLITE_OK returned. If 
  3759         -** isWrite is non-zero and the requested shared-memory region has not yet 
         3767  +** separate process), then *pp is set to NULL and SQLITE_OK returned. If
         3768  +** isWrite is non-zero and the requested shared-memory region has not yet
  3760   3769   ** been allocated, it is allocated by this function.
  3761   3770   **
  3762   3771   ** If the shared-memory region has already been allocated or is allocated by
  3763         -** this call as described above, then it is mapped into this processes 
  3764         -** address space (if it is not already), *pp is set to point to the mapped 
         3772  +** this call as described above, then it is mapped into this processes
         3773  +** address space (if it is not already), *pp is set to point to the mapped
  3765   3774   ** memory and SQLITE_OK returned.
  3766   3775   */
  3767   3776   static int winShmMap(
  3768   3777     sqlite3_file *fd,               /* Handle open on database file */
  3769   3778     int iRegion,                    /* Region to retrieve */
  3770   3779     int szRegion,                   /* Size of regions */
  3771   3780     int isWrite,                    /* True to extend file if necessary */
................................................................................
  3829   3838         goto shmpage_out;
  3830   3839       }
  3831   3840       pShmNode->aRegion = apNew;
  3832   3841   
  3833   3842       while( pShmNode->nRegion<=iRegion ){
  3834   3843         HANDLE hMap = NULL;         /* file-mapping handle */
  3835   3844         void *pMap = 0;             /* Mapped memory region */
  3836         -     
         3845  +
  3837   3846   #if SQLITE_OS_WINRT
  3838   3847         hMap = osCreateFileMappingFromApp(pShmNode->hFile.h,
  3839   3848             NULL, PAGE_READWRITE, nByte, NULL
  3840   3849         );
  3841   3850   #elif defined(SQLITE_WIN32_HAS_WIDE)
  3842         -      hMap = osCreateFileMappingW(pShmNode->hFile.h, 
         3851  +      hMap = osCreateFileMappingW(pShmNode->hFile.h,
  3843   3852             NULL, PAGE_READWRITE, 0, nByte, NULL
  3844   3853         );
  3845   3854   #elif defined(SQLITE_WIN32_HAS_ANSI)
  3846         -      hMap = osCreateFileMappingA(pShmNode->hFile.h, 
         3855  +      hMap = osCreateFileMappingA(pShmNode->hFile.h,
  3847   3856             NULL, PAGE_READWRITE, 0, nByte, NULL
  3848   3857         );
  3849   3858   #endif
  3850   3859         OSTRACE(("SHM-MAP-CREATE pid=%lu, region=%d, size=%d, rc=%s\n",
  3851   3860                  osGetCurrentProcessId(), pShmNode->nRegion, nByte,
  3852   3861                  hMap ? "ok" : "failed"));
  3853   3862         if( hMap ){
................................................................................
  3936   3945     OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\n",
  3937   3946              osGetCurrentProcessId(), pFile));
  3938   3947     return SQLITE_OK;
  3939   3948   }
  3940   3949   
  3941   3950   /*
  3942   3951   ** Memory map or remap the file opened by file-descriptor pFd (if the file
  3943         -** is already mapped, the existing mapping is replaced by the new). Or, if 
  3944         -** there already exists a mapping for this file, and there are still 
         3952  +** is already mapped, the existing mapping is replaced by the new). Or, if
         3953  +** there already exists a mapping for this file, and there are still
  3945   3954   ** outstanding xFetch() references to it, this function is a no-op.
  3946   3955   **
  3947         -** If parameter nByte is non-negative, then it is the requested size of 
  3948         -** the mapping to create. Otherwise, if nByte is less than zero, then the 
         3956  +** If parameter nByte is non-negative, then it is the requested size of
         3957  +** the mapping to create. Otherwise, if nByte is less than zero, then the
  3949   3958   ** requested size is the size of the file on disk. The actual size of the
  3950         -** created mapping is either the requested size or the value configured 
         3959  +** created mapping is either the requested size or the value configured
  3951   3960   ** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller.
  3952   3961   **
  3953   3962   ** SQLITE_OK is returned if no error occurs (even if the mapping is not
  3954   3963   ** recreated as a result of outstanding references) or an SQLite error
  3955   3964   ** code otherwise.
  3956   3965   */
  3957   3966   static int winMapfile(winFile *pFd, sqlite3_int64 nByte){
................................................................................
  3972   3981         return SQLITE_IOERR_FSTAT;
  3973   3982       }
  3974   3983     }
  3975   3984     if( nMap>pFd->mmapSizeMax ){
  3976   3985       nMap = pFd->mmapSizeMax;
  3977   3986     }
  3978   3987     nMap &= ~(sqlite3_int64)(winSysInfo.dwPageSize - 1);
  3979         - 
         3988  +
  3980   3989     if( nMap==0 && pFd->mmapSize>0 ){
  3981   3990       winUnmapfile(pFd);
  3982   3991     }
  3983   3992     if( nMap!=pFd->mmapSize ){
  3984   3993       void *pNew = 0;
  3985   3994       DWORD protect = PAGE_READONLY;
  3986   3995       DWORD flags = FILE_MAP_READ;
................................................................................
  4044   4053   ** iOff. The mapping must be valid for at least nAmt bytes.
  4045   4054   **
  4046   4055   ** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.
  4047   4056   ** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.
  4048   4057   ** Finally, if an error does occur, return an SQLite error code. The final
  4049   4058   ** value of *pp is undefined in this case.
  4050   4059   **
  4051         -** If this function does return a pointer, the caller must eventually 
         4060  +** If this function does return a pointer, the caller must eventually
  4052   4061   ** release the reference by calling winUnfetch().
  4053   4062   */
  4054   4063   static int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){
  4055   4064   #if SQLITE_MAX_MMAP_SIZE>0
  4056   4065     winFile *pFd = (winFile*)fd;   /* The underlying database file */
  4057   4066   #endif
  4058   4067     *pp = 0;
................................................................................
  4079   4088   
  4080   4089     OSTRACE(("FETCH pid=%lu, pFile=%p, pp=%p, *pp=%p, rc=SQLITE_OK\n",
  4081   4090              osGetCurrentProcessId(), fd, pp, *pp));
  4082   4091     return SQLITE_OK;
  4083   4092   }
  4084   4093   
  4085   4094   /*
  4086         -** If the third argument is non-NULL, then this function releases a 
         4095  +** If the third argument is non-NULL, then this function releases a
  4087   4096   ** reference obtained by an earlier call to winFetch(). The second
  4088   4097   ** argument passed to this function must be the same as the corresponding
  4089         -** argument that was passed to the winFetch() invocation. 
         4098  +** argument that was passed to the winFetch() invocation.
  4090   4099   **
  4091         -** Or, if the third argument is NULL, then this function is being called 
  4092         -** to inform the VFS layer that, according to POSIX, any existing mapping 
         4100  +** Or, if the third argument is NULL, then this function is being called
         4101  +** to inform the VFS layer that, according to POSIX, any existing mapping
  4093   4102   ** may now be invalid and should be unmapped.
  4094   4103   */
  4095   4104   static int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){
  4096   4105   #if SQLITE_MAX_MMAP_SIZE>0
  4097   4106     winFile *pFd = (winFile*)fd;   /* The underlying database file */
  4098   4107   
  4099         -  /* If p==0 (unmap the entire file) then there must be no outstanding 
         4108  +  /* If p==0 (unmap the entire file) then there must be no outstanding
  4100   4109     ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),
  4101   4110     ** then there must be at least one outstanding.  */
  4102   4111     assert( (p==0)==(pFd->nFetchOut==0) );
  4103   4112   
  4104   4113     /* If p!=0, it must match the iOff value. */
  4105   4114     assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );
  4106   4115   
................................................................................
  4238   4247     size_t i, j;
  4239   4248     int nPre = sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX);
  4240   4249     int nMax, nBuf, nDir, nLen;
  4241   4250     char *zBuf;
  4242   4251   
  4243   4252     /* It's odd to simulate an io-error here, but really this is just
  4244   4253     ** using the io-error infrastructure to test that SQLite handles this
  4245         -  ** function failing. 
         4254  +  ** function failing.
  4246   4255     */
  4247   4256     SimulateIOError( return SQLITE_IOERR );
  4248   4257   
  4249   4258     /* Allocate a temporary buffer to store the fully qualified file
  4250   4259     ** name for the temporary file.  If this fails, we cannot continue.
  4251   4260     */
  4252   4261     nMax = pVfs->mxPathname; nBuf = nMax + 2;
................................................................................
  4420   4429     if( !winMakeEndInDirSep(nDir+1, zBuf) ){
  4421   4430       sqlite3_free(zBuf);
  4422   4431       OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n"));
  4423   4432       return winLogError(SQLITE_ERROR, 0, "winGetTempname4", 0);
  4424   4433     }
  4425   4434   
  4426   4435     /*
  4427         -  ** Check that the output buffer is large enough for the temporary file 
         4436  +  ** Check that the output buffer is large enough for the temporary file
  4428   4437     ** name in the following format:
  4429   4438     **
  4430   4439     **   "<temporary_directory>/etilqs_XXXXXXXXXXXXXXX\0\0"
  4431   4440     **
  4432   4441     ** If not, return SQLITE_ERROR.  The number 17 is used here in order to
  4433   4442     ** account for the space used by the 15 character random suffix and the
  4434   4443     ** two trailing NUL characters.  The final directory separator character
................................................................................
  4523   4532     int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);
  4524   4533     int isCreate     = (flags & SQLITE_OPEN_CREATE);
  4525   4534     int isReadonly   = (flags & SQLITE_OPEN_READONLY);
  4526   4535     int isReadWrite  = (flags & SQLITE_OPEN_READWRITE);
  4527   4536   
  4528   4537   #ifndef NDEBUG
  4529   4538     int isOpenJournal = (isCreate && (
  4530         -        eType==SQLITE_OPEN_MASTER_JOURNAL 
  4531         -     || eType==SQLITE_OPEN_MAIN_JOURNAL 
         4539  +        eType==SQLITE_OPEN_MASTER_JOURNAL
         4540  +     || eType==SQLITE_OPEN_MAIN_JOURNAL
  4532   4541        || eType==SQLITE_OPEN_WAL
  4533   4542     ));
  4534   4543   #endif
  4535   4544   
  4536   4545     OSTRACE(("OPEN name=%s, pFile=%p, flags=%x, pOutFlags=%p\n",
  4537   4546              zUtf8Name, id, flags, pOutFlags));
  4538   4547   
  4539         -  /* Check the following statements are true: 
         4548  +  /* Check the following statements are true:
  4540   4549     **
  4541         -  **   (a) Exactly one of the READWRITE and READONLY flags must be set, and 
         4550  +  **   (a) Exactly one of the READWRITE and READONLY flags must be set, and
  4542   4551     **   (b) if CREATE is set, then READWRITE must also be set, and
  4543   4552     **   (c) if EXCLUSIVE is set, then CREATE must also be set.
  4544   4553     **   (d) if DELETEONCLOSE is set, then CREATE must also be set.
  4545   4554     */
  4546   4555     assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));
  4547   4556     assert(isCreate==0 || isReadWrite);
  4548   4557     assert(isExclusive==0 || isCreate);
  4549   4558     assert(isDelete==0 || isCreate);
  4550   4559   
  4551         -  /* The main DB, main journal, WAL file and master journal are never 
         4560  +  /* The main DB, main journal, WAL file and master journal are never
  4552   4561     ** automatically deleted. Nor are they ever temporary files.  */
  4553   4562     assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );
  4554   4563     assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );
  4555   4564     assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );
  4556   4565     assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );
  4557   4566   
  4558   4567     /* Assert that the upper layer has set one of the "file-type" flags. */
  4559         -  assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB 
  4560         -       || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL 
  4561         -       || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL 
         4568  +  assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB
         4569  +       || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL
         4570  +       || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL
  4562   4571          || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL
  4563   4572     );
  4564   4573   
  4565   4574     assert( pFile!=0 );
  4566   4575     memset(pFile, 0, sizeof(winFile));
  4567   4576     pFile->h = INVALID_HANDLE_VALUE;
  4568   4577   
................................................................................
  4569   4578   #if SQLITE_OS_WINRT
  4570   4579     if( !zUtf8Name && !sqlite3_temp_directory ){
  4571   4580       sqlite3_log(SQLITE_ERROR,
  4572   4581           "sqlite3_temp_directory variable should be set for WinRT");
  4573   4582     }
  4574   4583   #endif
  4575   4584   
  4576         -  /* If the second argument to this function is NULL, generate a 
  4577         -  ** temporary file name to use 
         4585  +  /* If the second argument to this function is NULL, generate a
         4586  +  ** temporary file name to use
  4578   4587     */
  4579   4588     if( !zUtf8Name ){
  4580   4589       assert( isDelete && !isOpenJournal );
  4581   4590       rc = winGetTempname(pVfs, &zTmpname);
  4582   4591       if( rc!=SQLITE_OK ){
  4583   4592         OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
  4584   4593         return rc;
................................................................................
  4610   4619   
  4611   4620     if( isReadWrite ){
  4612   4621       dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
  4613   4622     }else{
  4614   4623       dwDesiredAccess = GENERIC_READ;
  4615   4624     }
  4616   4625   
  4617         -  /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is 
  4618         -  ** created. SQLite doesn't use it to indicate "exclusive access" 
         4626  +  /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is
         4627  +  ** created. SQLite doesn't use it to indicate "exclusive access"
  4619   4628     ** as it is usually understood.
  4620   4629     */
  4621   4630     if( isExclusive ){
  4622   4631       /* Creates a new file, only if it does not already exist. */
  4623   4632       /* If the file exists, it fails. */
  4624   4633       dwCreationDisposition = CREATE_NEW;
  4625   4634     }else if( isCreate ){
................................................................................
  4700   4709   
  4701   4710     if( h==INVALID_HANDLE_VALUE ){
  4702   4711       pFile->lastErrno = lastErrno;
  4703   4712       winLogError(SQLITE_CANTOPEN, pFile->lastErrno, "winOpen", zUtf8Name);
  4704   4713       sqlite3_free(zConverted);
  4705   4714       sqlite3_free(zTmpname);
  4706   4715       if( isReadWrite && !isExclusive ){
  4707         -      return winOpen(pVfs, zName, id, 
         4716  +      return winOpen(pVfs, zName, id,
  4708   4717            ((flags|SQLITE_OPEN_READONLY) &
  4709   4718                        ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)),
  4710   4719            pOutFlags);
  4711   4720       }else{
  4712   4721         return SQLITE_CANTOPEN_BKPT;
  4713   4722       }
  4714   4723     }
................................................................................
  4909   4918       return SQLITE_IOERR_NOMEM;
  4910   4919     }
  4911   4920     if( osIsNT() ){
  4912   4921       int cnt = 0;
  4913   4922       WIN32_FILE_ATTRIBUTE_DATA sAttrData;
  4914   4923       memset(&sAttrData, 0, sizeof(sAttrData));
  4915   4924       while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,
  4916         -                             GetFileExInfoStandard, 
         4925  +                             GetFileExInfoStandard,
  4917   4926                                &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){}
  4918   4927       if( rc ){
  4919   4928         /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
  4920   4929         ** as if it does not exist.
  4921   4930         */
  4922   4931         if(    flags==SQLITE_ACCESS_EXISTS
  4923         -          && sAttrData.nFileSizeHigh==0 
         4932  +          && sAttrData.nFileSizeHigh==0
  4924   4933             && sAttrData.nFileSizeLow==0 ){
  4925   4934           attr = INVALID_FILE_ATTRIBUTES;
  4926   4935         }else{
  4927   4936           attr = sAttrData.dwFileAttributes;
  4928   4937         }
  4929   4938       }else{
  4930   4939         winLogIoerr(cnt);
................................................................................
  5015   5024   */
  5016   5025   static int winFullPathname(
  5017   5026     sqlite3_vfs *pVfs,            /* Pointer to vfs object */
  5018   5027     const char *zRelative,        /* Possibly relative input path */
  5019   5028     int nFull,                    /* Size of output buffer in bytes */
  5020   5029     char *zFull                   /* Output buffer */
  5021   5030   ){
  5022         -  
         5031  +
  5023   5032   #if defined(__CYGWIN__)
  5024   5033     SimulateIOError( return SQLITE_ERROR );
  5025   5034     UNUSED_PARAMETER(nFull);
  5026   5035     assert( nFull>=pVfs->mxPathname );
  5027   5036     if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
  5028   5037       /*
  5029   5038       ** NOTE: We are dealing with a relative path name and the data
................................................................................
  5328   5337   /*
  5329   5338   ** Find the current time (in Universal Coordinated Time).  Write into *piNow
  5330   5339   ** the current time and date as a Julian Day number times 86_400_000.  In
  5331   5340   ** other words, write into *piNow the number of milliseconds since the Julian
  5332   5341   ** epoch of noon in Greenwich on November 24, 4714 B.C according to the
  5333   5342   ** proleptic Gregorian calendar.
  5334   5343   **
  5335         -** On success, return SQLITE_OK.  Return SQLITE_ERROR if the time and date 
         5344  +** On success, return SQLITE_OK.  Return SQLITE_ERROR if the time and date
  5336   5345   ** cannot be found.
  5337   5346   */
  5338   5347   static int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){
  5339         -  /* FILETIME structure is a 64-bit value representing the number of 
  5340         -     100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). 
         5348  +  /* FILETIME structure is a 64-bit value representing the number of
         5349  +     100-nanosecond intervals since January 1, 1601 (= JD 2305813.5).
  5341   5350     */
  5342   5351     FILETIME ft;
  5343   5352     static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000;
  5344   5353   #ifdef SQLITE_TEST
  5345   5354     static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;
  5346   5355   #endif
  5347   5356     /* 2^32 - to avoid use of LL and warnings in gcc */
  5348         -  static const sqlite3_int64 max32BitValue = 
         5357  +  static const sqlite3_int64 max32BitValue =
  5349   5358         (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 +
  5350   5359         (sqlite3_int64)294967296;
  5351   5360   
  5352   5361   #if SQLITE_OS_WINCE
  5353   5362     SYSTEMTIME time;
  5354   5363     osGetSystemTime(&time);
  5355   5364     /* if SystemTimeToFileTime() fails, it returns zero. */
................................................................................
  5357   5366       return SQLITE_ERROR;
  5358   5367     }
  5359   5368   #else
  5360   5369     osGetSystemTimeAsFileTime( &ft );
  5361   5370   #endif
  5362   5371   
  5363   5372     *piNow = winFiletimeEpoch +
  5364         -            ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + 
         5373  +            ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) +
  5365   5374                  (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000;
  5366   5375   
  5367   5376   #ifdef SQLITE_TEST
  5368   5377     if( sqlite3_current_time ){
  5369   5378       *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;
  5370   5379     }
  5371   5380   #endif
................................................................................
  5494   5503   
  5495   5504     sqlite3_vfs_register(&winVfs, 1);
  5496   5505   
  5497   5506   #if defined(SQLITE_WIN32_HAS_WIDE)
  5498   5507     sqlite3_vfs_register(&winLongPathVfs, 0);
  5499   5508   #endif
  5500   5509   
  5501         -  return SQLITE_OK; 
         5510  +  return SQLITE_OK;
  5502   5511   }
  5503   5512   
  5504         -int sqlite3_os_end(void){ 
         5513  +int sqlite3_os_end(void){
  5505   5514   #if SQLITE_OS_WINRT
  5506   5515     if( sleepObj!=NULL ){
  5507   5516       osCloseHandle(sleepObj);
  5508   5517       sleepObj = NULL;
  5509   5518     }
  5510   5519   #endif
  5511   5520     return SQLITE_OK;
  5512   5521   }
  5513   5522   
  5514   5523   #endif /* SQLITE_OS_WIN */