/ Check-in [662c32af]
Login

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

Overview
Comment:Improved localtime() support for WindowsCE
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:662c32af0276a9ef4eea2d29e2523ccc44b6d128
User & Date: drh 2016-04-12 16:23:30
Context
2016-04-12
16:59
Add the --temp option to the speedtest1.c performance test program. check-in: 8053a6e2 user: drh tags: trunk
16:23
Improved localtime() support for WindowsCE check-in: 662c32af user: drh tags: trunk
16:11
Add and adjust comments. Closed-Leaf check-in: 541c6da2 user: mistachkin tags: winCeLocalTime
16:04
Add the sqlite3_snapshot_cmp() interface (available only with SQLITE_ENABLE_SNAPSHOT). check-in: 7e728965 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/date.c.

    46     46   #include "sqliteInt.h"
    47     47   #include <stdlib.h>
    48     48   #include <assert.h>
    49     49   #include <time.h>
    50     50   
    51     51   #ifndef SQLITE_OMIT_DATETIME_FUNCS
    52     52   
           53  +/*
           54  +** The MSVC CRT on Windows CE may not have a localtime() function.
           55  +** So declare a substitute.  The substitute function itself is
           56  +** defined in "os_win.c".
           57  +*/
           58  +#if !defined(SQLITE_OMIT_LOCALTIME) && defined(_WIN32_WCE) && \
           59  +    (!defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API)
           60  +struct tm *__cdecl localtime(const time_t *);
           61  +#endif
    53     62   
    54     63   /*
    55     64   ** A structure for holding a single date and time.
    56     65   */
    57     66   typedef struct DateTime DateTime;
    58     67   struct DateTime {
    59     68     sqlite3_int64 iJD; /* The julian day number times 86400000 */
................................................................................
   414    423   */
   415    424   static void clearYMD_HMS_TZ(DateTime *p){
   416    425     p->validYMD = 0;
   417    426     p->validHMS = 0;
   418    427     p->validTZ = 0;
   419    428   }
   420    429   
          430  +#ifndef SQLITE_OMIT_LOCALTIME
   421    431   /*
   422    432   ** On recent Windows platforms, the localtime_s() function is available
   423    433   ** as part of the "Secure CRT". It is essentially equivalent to 
   424    434   ** localtime_r() available under most POSIX platforms, except that the 
   425    435   ** order of the parameters is reversed.
   426    436   **
   427    437   ** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx.
................................................................................
   432    442   */
   433    443   #if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S \
   434    444       && defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
   435    445   #undef  HAVE_LOCALTIME_S
   436    446   #define HAVE_LOCALTIME_S 1
   437    447   #endif
   438    448   
   439         -#ifndef SQLITE_OMIT_LOCALTIME
   440    449   /*
   441    450   ** The following routine implements the rough equivalent of localtime_r()
   442    451   ** using whatever operating-system specific localtime facility that
   443    452   ** is available.  This routine returns 0 on success and
   444    453   ** non-zero on any kind of error.
   445    454   **
   446    455   ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this

Changes to src/os_win.c.

  2114   2114       sqlite3_log(SQLITE_NOTICE,
  2115   2115         "delayed %dms for lock/sharing conflict at line %d",
  2116   2116         winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno
  2117   2117       );
  2118   2118     }
  2119   2119   }
  2120   2120   
  2121         -#if SQLITE_OS_WINCE
  2122         -/*************************************************************************
  2123         -** This section contains code for WinCE only.
         2121  +/*
         2122  +** This #if does not rely on the SQLITE_OS_WINCE define because the
         2123  +** corresponding section in "date.c" cannot use it.
  2124   2124   */
  2125         -#if !defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API
         2125  +#if !defined(SQLITE_OMIT_LOCALTIME) && defined(_WIN32_WCE) && \
         2126  +    (!defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API)
  2126   2127   /*
  2127         -** The MSVC CRT on Windows CE may not have a localtime() function.  So
  2128         -** create a substitute.
         2128  +** The MSVC CRT on Windows CE may not have a localtime() function.
         2129  +** So define a substitute.
  2129   2130   */
  2130         -#include <time.h>
         2131  +#  include <time.h>
  2131   2132   struct tm *__cdecl localtime(const time_t *t)
  2132   2133   {
  2133   2134     static struct tm y;
  2134   2135     FILETIME uTm, lTm;
  2135   2136     SYSTEMTIME pTm;
  2136   2137     sqlite3_int64 t64;
  2137   2138     t64 = *t;
................................................................................
  2147   2148     y.tm_hour = pTm.wHour;
  2148   2149     y.tm_min = pTm.wMinute;
  2149   2150     y.tm_sec = pTm.wSecond;
  2150   2151     return &y;
  2151   2152   }
  2152   2153   #endif
  2153   2154   
         2155  +#if SQLITE_OS_WINCE
         2156  +/*************************************************************************
         2157  +** This section contains code for WinCE only.
         2158  +*/
  2154   2159   #define HANDLE_TO_WINFILE(a) (winFile*)&((char*)a)[-(int)offsetof(winFile,h)]
  2155   2160   
  2156   2161   /*
  2157   2162   ** Acquire a lock on the handle h
  2158   2163   */
  2159   2164   static void winceMutexAcquire(HANDLE h){
  2160   2165      DWORD dwErr;