From 9a92d53cf5f3aa0452d7a9638c0b15f4c87d83ad Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 19 Nov 2022 07:39:31 +0000 Subject: [PATCH] Account for lack of mmap(), getpid(), and shared memory APIs in wasi. FossilOrigin-Name: 80ff026fb4b2203eea53d4930c1e9bb138db951fb408739c7d5c776fb397b665 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/os_unix.c | 17 +++++++++++++---- src/sqlite.h.in | 7 ++++--- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 0d31c2ee29..4663a26d69 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Preliminary\spatches\sto\sget\ssqlite3.c\sbuilding\sas-is\sin\sWASI\senvironments. -D 2022-11-19T07:17:12.124 +C Account\sfor\slack\sof\smmap(),\sgetpid(),\sand\sshared\smemory\sAPIs\sin\swasi. +D 2022-11-19T07:39:31.318 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -623,7 +623,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_kv.c 0e59600d25b72034c7666b8b7dcc527f039b5d9c16f24a7eca4c08c66f63c364 F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107 -F src/os_unix.c fc309252d6c86d7ae32e25d6413249789428aab600ffa9db050532bbe3a92ce2 +F src/os_unix.c 2d16b0e0186805306680cfad36f1efd2909683cdabd0812f0460833b24e0e66d F src/os_win.c 295fe45f18bd86f2477f4cd79f3377c6f883ceb941b1f46808665c73747f2345 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c d3122cf67f327f1e2df12d06236a3473a8099542071e257067552f42917f172d @@ -641,7 +641,7 @@ F src/resolve.c efea4e5fbecfd6d0a9071b0be0d952620991673391b6ffaaf4c277b0bb674633 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 F src/select.c 9886d6669f5787471aab6ae52af76fad90b53edb1c218fc9ed9d953363bc5184 F src/shell.c.in f5b696b44319a7c820b1b2922ce8d34fdf330337beaa6e87c0fd85c5c92bcd34 -F src/sqlite.h.in 1d18494193ea4772a4a372e05f48d3ef0a14534bc2e1c88b942b89dcd9b14e4b +F src/sqlite.h.in 5c27883b53c95c7b44ac3e63378d11fe50f18ad0ec975ae570bf2b01322438b0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c4b9fa7a7e2bcdf850cfeb4b8a91d5ec47b7a00033bc996fd2ee96cbf2741f5f F src/sqliteInt.h 1a2cec0f7682da69975eb203fef2058949051ff500445b997d8047cbd8813315 @@ -2057,11 +2057,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2e783670e10b59e67c14b0db7f4803b41790cc7730de221d54fa2d4483cfba33 -R 15320a286fec35f9e29ba0e0afc5c3c6 -T *branch * wasi-patches -T *sym-wasi-patches * -T -sym-trunk * Cancelled\sby\sbranch. +P 19c04d71bf0f2f44d5a03288cbea3f63cf4eae2fa018ac6be4ae49a321e2b2f3 +R ed76f6c019da486b38eceba46ef5c9a9 U stephan -Z 0b7069cc0349cc87f94f97d371c39591 +Z 8a0ad9bf871d09c041e33a1999bb3238 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 285b57f1df..bbfcae861c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -19c04d71bf0f2f44d5a03288cbea3f63cf4eae2fa018ac6be4ae49a321e2b2f3 \ No newline at end of file +80ff026fb4b2203eea53d4930c1e9bb138db951fb408739c7d5c776fb397b665 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index a32c68d661..af22d3cf85 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -95,7 +95,8 @@ #include #include /* amalgamator: keep */ #include -#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 +#if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \ + && !defined(SQLITE_WASI) # include #endif @@ -190,6 +191,8 @@ #ifdef SQLITE_WASI # undef HAVE_FCHMOD # undef HAVE_FCHOWN +# undef HAVE_MREMAP +# define HAVE_MREMAP 0 # ifndef SQLITE_DEFAULT_UNIX_VFS # define SQLITE_DEFAULT_UNIX_VFS "unix-dotfile" /* ^^^ should SQLITE_DEFAULT_UNIX_VFS be "unix-none"? */ @@ -214,9 +217,13 @@ # endif #endif /* SQLITE_WASI */ +#ifdef SQLITE_WASI +# define osGetpid(X) 1 +#else /* Always cast the getpid() return type for compatibility with ** kernel modules in VxWorks. */ -#define osGetpid(X) (pid_t)getpid() +# define osGetpid(X) (pid_t)getpid() +#endif /* ** Only set the lastErrno if the error code is a real error and not @@ -528,14 +535,16 @@ static struct unix_syscall { #endif #define osGeteuid ((uid_t(*)(void))aSyscall[21].pCurrent) -#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 +#if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \ + && !defined(SQLITE_WASI) { "mmap", (sqlite3_syscall_ptr)mmap, 0 }, #else { "mmap", (sqlite3_syscall_ptr)0, 0 }, #endif #define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[22].pCurrent) -#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 +#if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \ + && !defined(SQLITE_WASI) { "munmap", (sqlite3_syscall_ptr)munmap, 0 }, #else { "munmap", (sqlite3_syscall_ptr)0, 0 }, diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9ff5163b13..1a1ef3c143 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -10473,9 +10473,10 @@ int sqlite3_deserialize( #endif #if defined(__wasi__) || defined(WASM_WASI) -# ifndef SQLITE_WASI -# define SQLITE_WASI -# endif +# undef SQLITE_WASI +# define SQLITE_WASI 1 +# undef SQLITE_OMIT_WAL +# define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */ #endif #ifdef __cplusplus