aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-11-19 07:39:31 +0000
committerstephan <stephan@noemail.net>2022-11-19 07:39:31 +0000
commit9a92d53cf5f3aa0452d7a9638c0b15f4c87d83ad (patch)
tree4df0ffe556437c95e3835f9c7c116256e961383d /src
parent8cfd2c3eeb6d34d3481aadf20d8eb5f5a5c793be (diff)
downloadsqlite-9a92d53cf5f3aa0452d7a9638c0b15f4c87d83ad.tar.gz
sqlite-9a92d53cf5f3aa0452d7a9638c0b15f4c87d83ad.zip
Account for lack of mmap(), getpid(), and shared memory APIs in wasi.
FossilOrigin-Name: 80ff026fb4b2203eea53d4930c1e9bb138db951fb408739c7d5c776fb397b665
Diffstat (limited to 'src')
-rw-r--r--src/os_unix.c17
-rw-r--r--src/sqlite.h.in7
2 files changed, 17 insertions, 7 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index a32c68d66..af22d3cf8 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -95,7 +95,8 @@
#include <time.h>
#include <sys/time.h> /* amalgamator: keep */
#include <errno.h>
-#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
+#if (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) \
+ && !defined(SQLITE_WASI)
# include <sys/mman.h>
#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 9ff5163b1..1a1ef3c14 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