From 586361fa7cc762531efaf178eb3b243ccd41673d Mon Sep 17 00:00:00 2001 From: drh <> Date: Wed, 10 Sep 2025 14:28:07 +0000 Subject: [PATCH] The GetSystemTimePreciseAsFileTime() API does not exist on 32-bit windows. Adjust [c5dbe93114d318fe] so that it works with this limitation. FossilOrigin-Name: 61d9e204c5801a94811fdb0afe2c04f9814e08f2e141afa6dbda0fa45f026f70 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c.in | 26 ++++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index df22ac8076..f65fb0262a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sallow\sthe\slocal_getline()\sfunction\sin\sthe\sCLI\sto\sallocate\smore\nmemory\sthan\scan\sbe\scounted\susing\sa\s32-bit\sinteger,\sthus\slimiting\sthe\nlength\sof\san\sinput\sline\sto\sabout\sone\sgigabyte.\n[forum:/forumpost/c83b9affa2|Forum\spost\sc83b9affa2]. -D 2025-09-09T10:28:06.692 +C The\sGetSystemTimePreciseAsFileTime()\sAPI\sdoes\snot\sexist\son\s32-bit\swindows.\nAdjust\s[c5dbe93114d318fe]\sso\sthat\sit\sworks\swith\sthis\slimitation. +D 2025-09-10T14:28:07.926 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -742,7 +742,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c f8d1d011aba0964ff1bdccd049d4d2c2fec217efd90d202a4bb775e926b2c25d F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c b95181711d59c36d9789e67f76c4cfec64b99f9629a50be5e6566e117b87d957 -F src/shell.c.in 7f768dd5330d3ee76dbe1e662e66288350ec609a767f95f54ae81a5ae29e8834 +F src/shell.c.in 69b2526fe5f074c7493bdc1fa93fc9f198088c4f5e1707b129f4864054cb80dd F src/sqlite.h.in 79dd3963888543f3120536608bf51024c93c7eb163a255098ffd569710189781 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479 F src/sqlite3ext.h 0bfd049bb2088cc44c2ad54f2079d1c6e43091a4e1ce8868779b75f6c1484f1e @@ -2174,8 +2174,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 4384ad8918801780f2660817dead919020423eb94aa880fff9b04f2d5f5d932f -R 3b3a3ca2d8f4756b389edcf626eb6983 +P 0f31711591c56f3896fb6f092752fb82c4ea646bf8e5838dfbe55302994ea091 +R 92f5496970f9c5f8107276d283e96509 U drh -Z 26ebd0e9d41736761228599c89751b0d +Z d1a933d782194f41c167cb8645e06e10 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 71ee003fd5..e801538531 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0f31711591c56f3896fb6f092752fb82c4ea646bf8e5838dfbe55302994ea091 +61d9e204c5801a94811fdb0afe2c04f9814e08f2e141afa6dbda0fa45f026f70 diff --git a/src/shell.c.in b/src/shell.c.in index ebd6cad420..5eadb31369 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -274,7 +274,7 @@ static int cli_strncmp(const char *a, const char *b, size_t n){ ** Unix epoch (1970-01-01T00:00:00Z) */ static sqlite3_int64 timeOfDay(void){ -#if defined(_WIN32) +#if defined(_WIN64) sqlite3_uint64 t; FILETIME tm; GetSystemTimePreciseAsFileTime(&tm); @@ -282,6 +282,19 @@ static sqlite3_int64 timeOfDay(void){ t += 116444736000000000LL; t /= 10; return t; +#elif defined(_WIN32) + static sqlite3_vfs *clockVfs = 0; + sqlite3_int64 t; + if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0); + if( clockVfs==0 ) return 0; /* Never actually happens */ + if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){ + clockVfs->xCurrentTimeInt64(clockVfs, &t); + }else{ + double r; + clockVfs->xCurrentTime(clockVfs, &r); + t = (sqlite3_int64)(r*86400000.0); + } + return t*1000; #else struct timeval sNow; (void)gettimeofday(&sNow,0); @@ -331,7 +344,7 @@ static void endTimer(FILE *out){ sqlite3_int64 iEnd = timeOfDay(); struct rusage sEnd; getrusage(RUSAGE_SELF, &sEnd); - sqlite3_fprintf(out, "Run Time: real %.6f user %f sys %f\n", + sqlite3_fprintf(out, "Run Time: real %.6f user %.6f sys %.6f\n", (iEnd - iBegin)*0.000001, timeDiff(&sBegin.ru_utime, &sEnd.ru_utime), timeDiff(&sBegin.ru_stime, &sEnd.ru_stime)); @@ -410,10 +423,19 @@ static void endTimer(FILE *out){ FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd; sqlite3_int64 ftWallEnd = timeOfDay(); getProcessTimesAddr(hProcess,&ftCreation,&ftExit,&ftKernelEnd,&ftUserEnd); +#ifdef _WIN64 + /* microsecond precision on 64-bit windows */ sqlite3_fprintf(out, "Run Time: real %.6f user %f sys %f\n", (ftWallEnd - ftWallBegin)*0.000001, timeDiff(&ftUserBegin, &ftUserEnd), timeDiff(&ftKernelBegin, &ftKernelEnd)); +#else + /* millisecond precisino on 32-bit windows */ + sqlite3_fprintf(out, "Run Time: real %.3f user %.3f sys %.3f\n", + (ftWallEnd - ftWallBegin)*0.000001, + timeDiff(&ftUserBegin, &ftUserEnd), + timeDiff(&ftKernelBegin, &ftKernelEnd)); +#endif } } -- 2.47.3