/ Check-in [7e669d9b]
Login

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

Overview
Comment:Initial work on porting lsmtest to Win32.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | lsm-vtab
Files: files | file ages | folders
SHA3-256:7e669d9bfab237ff7ece821cf95cfd3bb753b1882b9a86044b7d4579808aecf4
User & Date: mistachkin 2017-06-27 22:27:54
Context
2017-06-27
22:33
Improve a local variable name. check-in: d0f6973d user: mistachkin tags: lsm-vtab
22:27
Initial work on porting lsmtest to Win32. check-in: 7e669d9b user: mistachkin tags: lsm-vtab
18:15
Implement xFullpath for lsm1 on Win32. check-in: dbe9c8aa user: mistachkin tags: lsm-vtab
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/lsm1/Makefile.

    33     33                $(LSMDIR)/lsm-test/lsmtest5.c $(LSMDIR)/lsm-test/lsmtest6.c     \
    34     34                $(LSMDIR)/lsm-test/lsmtest7.c $(LSMDIR)/lsm-test/lsmtest8.c     \
    35     35                $(LSMDIR)/lsm-test/lsmtest9.c                                   \
    36     36                $(LSMDIR)/lsm-test/lsmtest_datasource.c \
    37     37                $(LSMDIR)/lsm-test/lsmtest_func.c $(LSMDIR)/lsm-test/lsmtest_io.c  \
    38     38                $(LSMDIR)/lsm-test/lsmtest_main.c $(LSMDIR)/lsm-test/lsmtest_mem.c \
    39     39                $(LSMDIR)/lsm-test/lsmtest_tdb.c $(LSMDIR)/lsm-test/lsmtest_tdb3.c \
    40         -             $(LSMDIR)/lsm-test/lsmtest_util.c
           40  +             $(LSMDIR)/lsm-test/lsmtest_util.c $(LSMDIR)/lsm-test/lsmtest_win32.c
    41     41   
    42     42   
    43     43   # all: lsm.so
    44     44   
    45     45   LSMOPTS = -DLSM_MUTEX_PTHREADS=1 -I$(LSMDIR)
    46     46   
    47     47   lsm.so:	$(LSMOBJ)

Changes to ext/lsm1/Makefile.msc.

    33     33                $(LSMDIR)\lsm-test\lsmtest5.c $(LSMDIR)\lsm-test\lsmtest6.c     \
    34     34                $(LSMDIR)\lsm-test\lsmtest7.c $(LSMDIR)\lsm-test\lsmtest8.c     \
    35     35                $(LSMDIR)\lsm-test\lsmtest9.c                                   \
    36     36                $(LSMDIR)\lsm-test\lsmtest_datasource.c \
    37     37                $(LSMDIR)\lsm-test\lsmtest_func.c $(LSMDIR)\lsm-test\lsmtest_io.c  \
    38     38                $(LSMDIR)\lsm-test\lsmtest_main.c $(LSMDIR)\lsm-test\lsmtest_mem.c \
    39     39                $(LSMDIR)\lsm-test\lsmtest_tdb.c $(LSMDIR)\lsm-test\lsmtest_tdb3.c \
    40         -             $(LSMDIR)\lsm-test\lsmtest_util.c
           40  +             $(LSMDIR)\lsm-test\lsmtest_util.c $(LSMDIR)\lsm-test\lsmtest_win32.c
    41     41   
    42     42   # all: lsm.dll
    43     43   
    44     44   LSMOPTS = -DLSM_MUTEX_WIN32=1 -I$(LSMDIR)
    45     45   
    46     46   lsm_ckpt.lo:	$(LSMDIR)\lsm_ckpt.c $(LSMHDR) $(SQLITE3H)
    47     47   	$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\lsm_ckpt.c
................................................................................
    85     85   lsm_vtab.lo:	$(LSMDIR)\lsm_vtab.c $(LSMHDR) $(SQLITE3H)
    86     86   	$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\lsm_vtab.c
    87     87   
    88     88   lsm.dll:	$(LSMOBJ)
    89     89   	$(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /OUT:$@ $(LSMOBJ)
    90     90   
    91     91   lsmtest.exe: $(LSMOBJ) $(LSMTESTSRC) $(LSMTESTHDR) $(LIBOBJS1)
    92         -	# $(LTCOMPILE) -c $(TOP)\lsm-test\lsmtest_tdb2.cc
    93         -	$(LTCOMPILE) $(LSMOPTS) $(LSMTESTSRC) $(LSMOBJ) $(LIBOBJS1) -Fe$@
           92  +	$(LTLINK) $(LSMOPTS) $(LSMTESTSRC) /link $(LSMOBJ) $(LIBOBJS1)

Changes to ext/lsm1/lsm-test/lsmtest.h.

    10     10   #include <stdlib.h>
    11     11   #include <string.h>
    12     12   #include <stdio.h>
    13     13   
    14     14   #ifdef __cplusplus
    15     15   extern "C" {
    16     16   #endif
           17  +
           18  +#ifdef _WIN32
           19  +# include "windows.h"
           20  +# define gettimeofday win32GetTimeOfDay
           21  +# define F_OK  (0)
           22  +# define sleep(sec) Sleep(1000 * (sec))
           23  +# define usleep(usec) Sleep((usec) / 1000)
           24  +# ifdef _MSC_VER
           25  +#  include <io.h>
           26  +#  define snprintf _snprintf
           27  +#  define fsync(fd) FlushFileBuffers((HANDLE)_get_osfhandle((fd)))
           28  +#  define fdatasync(fd) FlushFileBuffers((HANDLE)_get_osfhandle((fd)))
           29  +#  define __va_copy(dst,src) ((dst) = (src))
           30  +#  define ftruncate(fd,sz) (_chsize_s((fd), (sz))==0)
           31  +# else
           32  +#  error Unsupported C compiler for Windows.
           33  +# endif
           34  +int win32GetTimeOfDay(struct timeval *, void *);
           35  +#endif
    17     36   
    18     37   #ifndef _LSM_INT_H
    19     38   typedef unsigned int  u32;
    20     39   typedef unsigned char u8;
    21     40   typedef long long int i64;
    22     41   typedef unsigned long long int u64;
    23     42   #endif

Changes to ext/lsm1/lsm-test/lsmtest6.c.

   236    236       lsm_csr_close(pCsr);
   237    237       *pRc = rc;
   238    238     }
   239    239   }
   240    240   
   241    241   #define LSMTEST6_TESTDB "testdb.lsm" 
   242    242   
   243         -#include <unistd.h>
          243  +#ifndef _WIN32
          244  +# include <unistd.h>
          245  +#endif
   244    246   #include <sys/types.h>
   245    247   #include <sys/stat.h>
   246    248   #include <fcntl.h>
   247    249   
   248    250   void testDeleteLsmdb(const char *zFile){
   249    251     char *zLog = testMallocPrintf("%s-log", zFile);
   250    252     char *zShm = testMallocPrintf("%s-shm", zFile);

Changes to ext/lsm1/lsm-test/lsmtest_io.c.

    54     54   */
    55     55   
    56     56   #include "lsmtest.h"
    57     57   
    58     58   #include <sys/types.h>
    59     59   #include <sys/stat.h>
    60     60   #include <fcntl.h>
    61         -#include <unistd.h>
           61  +#ifndef _WIN32
           62  +# include <unistd.h>
           63  +#endif
    62     64   #include <ctype.h>
    63     65   
    64     66   typedef struct IoContext IoContext;
    65     67   
    66     68   struct IoContext {
    67     69     int fd;
    68     70     int nWrite;

Changes to ext/lsm1/lsm-test/lsmtest_main.c.

     4      4   #include "stdio.h"
     5      5   #include "assert.h"
     6      6   #include "string.h"
     7      7   #include "stdlib.h"
     8      8   
     9      9   #include <sqlite3.h>
    10     10   
    11         -#include <unistd.h>
           11  +#ifndef _WIN32
           12  +# include <unistd.h>
           13  +#endif
    12     14   #include <sys/types.h>
    13     15   #include <sys/stat.h>
    14     16   #include <fcntl.h>
    15     17   #include <errno.h>
    16     18   
    17     19   
    18     20   void test_failed(){ 

Changes to ext/lsm1/lsm-test/lsmtest_tdb.c.

    10     10   #include "lsm.h"
    11     11   
    12     12   #include "lsmtest.h"
    13     13   
    14     14   #include <stdlib.h>
    15     15   #include <string.h>
    16     16   #include <assert.h>
    17         -#include <unistd.h>
           17  +#ifndef _WIN32
           18  +# include <unistd.h>
           19  +#endif
    18     20   #include <stdio.h>
    19     21   
    20     22   
    21     23   typedef struct SqlDb SqlDb;
    22     24   
    23     25   static int error_transaction_function(TestDb *p, int iLevel){ 
    24     26     unused_parameter(p);

Changes to ext/lsm1/lsm-test/lsmtest_tdb3.c.

     2      2   #include "lsmtest_tdb.h"
     3      3   #include "lsm.h"
     4      4   #include "lsmtest.h"
     5      5   
     6      6   #include <stdlib.h>
     7      7   #include <string.h>
     8      8   #include <assert.h>
     9         -#include <unistd.h>
            9  +#ifndef _WIN32
           10  +# include <unistd.h>
           11  +#endif
    10     12   #include <stdio.h>
    11     13   
    12         -#include <sys/time.h>
           14  +#ifndef _WIN32
           15  +# include <sys/time.h>
           16  +#endif
    13     17   
    14     18   typedef struct LsmDb LsmDb;
    15     19   typedef struct LsmWorker LsmWorker;
    16     20   typedef struct LsmFile LsmFile;
    17     21   
    18     22   #define LSMTEST_DFLT_MT_MAX_CKPT (8*1024)
    19     23   #define LSMTEST_DFLT_MT_MIN_CKPT (2*1024)

Changes to ext/lsm1/lsm-test/lsmtest_util.c.

     1      1   
            2  +#include "lsmtest.h"
     2      3   #include <stdarg.h>
     3      4   #include <stdio.h>
     4      5   #include <string.h>
     5         -#include <sys/time.h>
            6  +#ifndef _WIN32
            7  +# include <sys/time.h>
            8  +#endif
     6      9   
     7     10   /*
     8     11   ** Global variables used within this module.
     9     12   */
    10     13   static struct TestutilGlobal {
    11     14     char **argv;
    12     15     int argc;

Added ext/lsm1/lsm-test/lsmtest_win32.c.

            1  +
            2  +#include "lsmtest.h"
            3  +
            4  +#ifdef _WIN32
            5  +
            6  +#define TICKS_PER_SECOND      (10000000)
            7  +#define TICKS_PER_MICROSECOND (10)
            8  +#define TICKS_UNIX_EPOCH      (116444736000000000LL)
            9  +
           10  +int win32GetTimeOfDay(
           11  +  struct timeval *tp,
           12  +  void *tzp
           13  +){
           14  +  FILETIME fileTime;
           15  +  ULARGE_INTEGER largeInteger;
           16  +  ULONGLONG temp;
           17  +
           18  +  unused_parameter(tzp);
           19  +  memset(&fileTime, 0, sizeof(FILETIME));
           20  +  GetSystemTimeAsFileTime(&fileTime);
           21  +  memset(&largeInteger, 0, sizeof(ULARGE_INTEGER));
           22  +  largeInteger.LowPart = fileTime.dwLowDateTime;
           23  +  largeInteger.HighPart = fileTime.dwHighDateTime;
           24  +  temp = largeInteger.QuadPart - TICKS_UNIX_EPOCH;
           25  +  tp->tv_sec = (long)(temp / TICKS_PER_SECOND);
           26  +  temp -= ((ULONGLONG)tp->tv_sec * TICKS_PER_SECOND);
           27  +  tp->tv_usec = (long)(temp / TICKS_PER_MICROSECOND);
           28  +  return 0;
           29  +}
           30  +#endif

Changes to ext/lsm1/lsmInt.h.

    20     20   
    21     21   #include <stdarg.h>
    22     22   #include <stdlib.h>
    23     23   #include <stdio.h>
    24     24   #include <ctype.h>
    25     25   
    26     26   #ifdef _WIN32
    27         -# define snprintf _snprintf
           27  +# ifdef _MSC_VER
           28  +#  define snprintf _snprintf
           29  +# endif
    28     30   #else
    29     31   # include <unistd.h>
    30     32   #endif
    31     33   
    32     34   #ifdef NDEBUG
    33     35   # ifdef LSM_DEBUG_EXPENSIVE
    34     36   #  undef LSM_DEBUG_EXPENSIVE