aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/os_unix.c35
-rw-r--r--src/shell.c.in4
-rw-r--r--src/sqlite.h.in6
3 files changed, 43 insertions, 2 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index c390b5188..a32c68d66 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -183,6 +183,37 @@
*/
#define SQLITE_MAX_SYMLINKS 100
+/*
+** Remove and stub certain info for WASI (WebAssembly System
+** Interface) builds.
+*/
+#ifdef SQLITE_WASI
+# undef HAVE_FCHMOD
+# undef HAVE_FCHOWN
+# ifndef SQLITE_DEFAULT_UNIX_VFS
+# define SQLITE_DEFAULT_UNIX_VFS "unix-dotfile"
+ /* ^^^ should SQLITE_DEFAULT_UNIX_VFS be "unix-none"? */
+# endif
+# ifndef F_RDLCK
+# define F_RDLCK 0
+# define F_WRLCK 1
+# define F_UNLCK 2
+# if __LONG_MAX == 0x7fffffffL
+# define F_GETLK 12
+# define F_SETLK 13
+# define F_SETLKW 14
+# else
+# define F_GETLK 5
+# define F_SETLK 6
+# define F_SETLKW 7
+# endif
+# endif
+#else /* !SQLITE_WASI */
+# ifndef HAVE_FCHMOD
+# define HAVE_FCHMOD
+# endif
+#endif /* SQLITE_WASI */
+
/* Always cast the getpid() return type for compatibility with
** kernel modules in VxWorks. */
#define osGetpid(X) (pid_t)getpid()
@@ -457,7 +488,11 @@ static struct unix_syscall {
#define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off64_t))\
aSyscall[13].pCurrent)
+#if defined(HAVE_FCHMOD)
{ "fchmod", (sqlite3_syscall_ptr)fchmod, 0 },
+#else
+ { "fchmod", (sqlite3_syscall_ptr)0, 0 },
+#endif
#define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent)
#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
diff --git a/src/shell.c.in b/src/shell.c.in
index db8d98766..36999ed44 100644
--- a/src/shell.c.in
+++ b/src/shell.c.in
@@ -111,7 +111,7 @@ typedef unsigned char u8;
#if !defined(_WIN32) && !defined(WIN32)
# include <signal.h>
-# if !defined(__RTP__) && !defined(_WRS_KERNEL)
+# if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
# include <pwd.h>
# endif
#endif
@@ -192,7 +192,7 @@ typedef unsigned char u8;
/* Make sure isatty() has a prototype. */
extern int isatty(int);
-# if !defined(__RTP__) && !defined(_WRS_KERNEL)
+# if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
/* popen and pclose are not C89 functions and so are
** sometimes omitted from the <stdio.h> header */
extern FILE *popen(const char*,const char*);
diff --git a/src/sqlite.h.in b/src/sqlite.h.in
index c2fc4e5a6..9ff5163b1 100644
--- a/src/sqlite.h.in
+++ b/src/sqlite.h.in
@@ -10472,6 +10472,12 @@ int sqlite3_deserialize(
# undef double
#endif
+#if defined(__wasi__) || defined(WASM_WASI)
+# ifndef SQLITE_WASI
+# define SQLITE_WASI
+# endif
+#endif
+
#ifdef __cplusplus
} /* End of the 'extern "C"' block */
#endif