/ Check-in [39759a55]
Login

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

Overview
Comment:Cleanup localtime() support for Windows CE.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | winCeLocalTime
Files: files | file ages | folders
SHA1: 39759a553208d8ef72964bdd539a0883e1d99cf6
User & Date: mistachkin 2016-01-23 01:54:15
Context
2016-04-05
17:59
Merge updates from trunk. check-in: 00990020 user: mistachkin tags: winCeLocalTime
2016-01-23
01:54
Cleanup localtime() support for Windows CE. check-in: 39759a55 user: mistachkin tags: winCeLocalTime
00:07
More work on the MSVC build. check-in: a79c46bc user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/date.c.

   414    414   */
   415    415   static void clearYMD_HMS_TZ(DateTime *p){
   416    416     p->validYMD = 0;
   417    417     p->validHMS = 0;
   418    418     p->validTZ = 0;
   419    419   }
   420    420   
          421  +#ifndef SQLITE_OMIT_LOCALTIME
   421    422   /*
   422    423   ** On recent Windows platforms, the localtime_s() function is available
   423    424   ** as part of the "Secure CRT". It is essentially equivalent to 
   424    425   ** localtime_r() available under most POSIX platforms, except that the 
   425    426   ** order of the parameters is reversed.
   426    427   **
   427    428   ** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx.
................................................................................
   432    433   */
   433    434   #if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S \
   434    435       && defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
   435    436   #undef  HAVE_LOCALTIME_S
   436    437   #define HAVE_LOCALTIME_S 1
   437    438   #endif
   438    439   
   439         -#ifndef SQLITE_OMIT_LOCALTIME
   440    440   /*
   441    441   ** The following routine implements the rough equivalent of localtime_r()
   442    442   ** using whatever operating-system specific localtime facility that
   443    443   ** is available.  This routine returns 0 on success and
   444    444   ** non-zero on any kind of error.
   445    445   **
   446    446   ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this

Changes to src/os_win.c.

  1982   1982       sqlite3_log(SQLITE_NOTICE,
  1983   1983         "delayed %dms for lock/sharing conflict at line %d",
  1984   1984         winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno
  1985   1985       );
  1986   1986     }
  1987   1987   }
  1988   1988   
  1989         -#if SQLITE_OS_WINCE
  1990         -/*************************************************************************
  1991         -** This section contains code for WinCE only.
         1989  +/*
         1990  +** This #if cannot use SQLITE_OS_WINCE because the corresponding section
         1991  +** in "sqliteInt.h" does not use it.
  1992   1992   */
  1993         -#if !defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API
         1993  +#if defined(_WIN32_WCE) && \
         1994  +    (!defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API)
  1994   1995   /*
  1995   1996   ** The MSVC CRT on Windows CE may not have a localtime() function.  So
  1996   1997   ** create a substitute.
  1997   1998   */
  1998         -#include <time.h>
  1999   1999   struct tm *__cdecl localtime(const time_t *t)
  2000   2000   {
  2001   2001     static struct tm y;
  2002   2002     FILETIME uTm, lTm;
  2003   2003     SYSTEMTIME pTm;
  2004   2004     sqlite3_int64 t64;
  2005   2005     t64 = *t;
................................................................................
  2015   2015     y.tm_hour = pTm.wHour;
  2016   2016     y.tm_min = pTm.wMinute;
  2017   2017     y.tm_sec = pTm.wSecond;
  2018   2018     return &y;
  2019   2019   }
  2020   2020   #endif
  2021   2021   
         2022  +#if SQLITE_OS_WINCE
         2023  +/*************************************************************************
         2024  +** This section contains code for WinCE only.
         2025  +*/
  2022   2026   #define HANDLE_TO_WINFILE(a) (winFile*)&((char*)a)[-(int)offsetof(winFile,h)]
  2023   2027   
  2024   2028   /*
  2025   2029   ** Acquire a lock on the handle h
  2026   2030   */
  2027   2031   static void winceMutexAcquire(HANDLE h){
  2028   2032      DWORD dwErr;

Changes to src/sqliteInt.h.

   214    214   #      pragma intrinsic(_ReadWriteBarrier)
   215    215   #    else
   216    216   #      include <cmnintrin.h>
   217    217   #    endif
   218    218   #  endif
   219    219   #endif
   220    220   
          221  +/*
          222  +** The MSVC CRT on Windows CE may not have a localtime() function.  So
          223  +** declare a substitute.  The function itself is defined in "os_win.c".
          224  +*/
          225  +#if defined(_WIN32_WCE) && \
          226  +    (!defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API)
          227  +#  include <time.h>
          228  +struct tm *__cdecl localtime(const time_t *);
          229  +#endif
          230  +
   221    231   /*
   222    232   ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
   223    233   ** 0 means mutexes are permanently disable and the library is never
   224    234   ** threadsafe.  1 means the library is serialized which is the highest
   225    235   ** level of threadsafety.  2 means the library is multithreaded - multiple
   226    236   ** threads can use SQLite as long as no two threads try to use the same
   227    237   ** database connection at the same time.