Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/core/sqlite/src/patches/00-syscall.patch
1067 views
1
diff --git a/src/os_unix.c b/src/os_unix.c
2
index b933de3..61490f2 100644
3
--- a/src/os_unix.c
4
+++ b/src/os_unix.c
5
@@ -549,6 +549,67 @@ static struct unix_syscall {
6
7
}; /* End of the overrideable system calls */
8
9
+// WebAssembly note: these overrideable system calls are not possible with
10
+// webassembly **with performance** since you'll just get the error
11
+// "null function or function signature mismatch" since WASM doesn't allow
12
+// incompatible signatures with functions. I think emscripten/pyodide gets
13
+// around this by proxying the call through Javascript, rather than using
14
+// a direct function pointer from the WASM function pointer table. However,
15
+// in my benchmarks, that can be a 100x performance penalty, so not a good option.
16
+// We don't need overrideable system calls anyways, so we just undo the above.
17
+
18
+#undef osOpen
19
+#define osOpen open
20
+#undef osClose
21
+#define osClose close
22
+#undef osAccess
23
+#define osAccess access
24
+#undef osGetcwd
25
+#define osGetcwd getcwd
26
+#undef osStat
27
+#define osStat stat
28
+#undef osFstat
29
+#define osFstat fstat
30
+#undef osFtruncate
31
+#define osFtruncate ftruncate
32
+#undef osFcntl
33
+#define osFcntl fcntl
34
+#undef osRead
35
+#define osRead read
36
+#undef osPread
37
+#define osPread pread
38
+#undef osPread64
39
+#define osPread64 pread64
40
+#undef osWrite
41
+#define osWrite write
42
+#undef osPwrite
43
+#define osPwrite pwrite
44
+#undef osPwrite64
45
+#define osPwrite64 pwrite64
46
+#undef osFchmod
47
+#define osFchmod fchmod
48
+#undef osFallocate
49
+#define osFallocate fallocate
50
+#undef osUnlink
51
+#define osUnlink unlink
52
+#undef osOpendirectory
53
+#define osOpendirectory openDirectory
54
+#undef osMkdir
55
+#define osMkdir mkdir
56
+#undef osRmdir
57
+#define osRmdir rmdir
58
+#undef osFchown
59
+#define osFchown fchown
60
+#undef osGeteuid
61
+#define osGeteuid geteuid
62
+#undef osReadlink
63
+#define osReadlink readlink
64
+#undef osLstat
65
+#define osLstat lstat
66
+#undef osIoctl
67
+#define osIoctl ioctl
68
+
69
+
70
71