Skip to content

Commit f7cf481

Browse files
QuantumSegfaultthewilsonator
authored andcommitted
Revert "druntime: Use WASIp1 directly instead of POSIX emulation"
This reverts commit 21329a1.
1 parent d73cc72 commit f7cf481

4 files changed

Lines changed: 43 additions & 1827 deletions

File tree

druntime/src/core/internal/abort.d

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,31 @@ void abort(scope string msg, scope string filename = __FILE__, size_t line = __L
4242
}
4343
}
4444
else version (WASIp1) {
45-
import core.sys.wasi.p1 : CIOVec, fdWrite;
45+
// currently depends on wasi-libc being linked in to provide these "syscalls"
46+
// TODO: detach this from wasi-libc
47+
alias ushort __wasi_errno_t;
48+
alias int __wasi_fd_t;
49+
alias size_t __wasi_size_t;
50+
51+
extern(C) struct __wasi_ciovec_t {
52+
const(ubyte)* buf;
53+
__wasi_size_t buf_len;
54+
}
55+
56+
pragma(mangle, "__wasi_fd_write")
57+
extern(C) static __wasi_errno_t
58+
__wasi_fd_write(__wasi_fd_t fd,
59+
const __wasi_ciovec_t *iovs,
60+
size_t iovs_len, __wasi_size_t *retptr0) @nogc nothrow;
4661

4762
static void writeStr(scope const(char)[][] m...) @nogc nothrow @trusted
4863
{
4964
foreach (s; m) {
50-
CIOVec[1] iovecs;
51-
size_t bytesWritten;
52-
iovecs[0].buf = cast(const(ubyte)*)s.ptr;
53-
iovecs[0].bufLen = s.length;
54-
cast(void)fdWrite(2, iovecs[], bytesWritten);
65+
__wasi_ciovec_t iovec;
66+
__wasi_size_t ret;
67+
iovec.buf = cast(const(ubyte)*)s.ptr;
68+
iovec.buf_len = s.length;
69+
cast(void)__wasi_fd_write(2, &iovec, 1, &ret);
5570
}
5671
}
5772
} else version (WASIp2) {

0 commit comments

Comments
 (0)