aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-11-19 07:17:12 +0000
committerstephan <stephan@noemail.net>2022-11-19 07:17:12 +0000
commit8cfd2c3eeb6d34d3481aadf20d8eb5f5a5c793be (patch)
tree8f5e3b7c2744d175fe5f197a7175656f3140a3b6 /src/os_unix.c
parent27a67968af60dfa5e2146b618df149c0bcea4997 (diff)
downloadsqlite-8cfd2c3eeb6d34d3481aadf20d8eb5f5a5c793be.tar.gz
sqlite-8cfd2c3eeb6d34d3481aadf20d8eb5f5a5c793be.zip
Preliminary patches to get sqlite3.c building as-is in WASI environments.
FossilOrigin-Name: 19c04d71bf0f2f44d5a03288cbea3f63cf4eae2fa018ac6be4ae49a321e2b2f3
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c35
1 files changed, 35 insertions, 0 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