Remove C++ dependency from wasmtime (#1365)
* Remove C++ dependency from `wasmtime` This commit removes the last wads of C++ that we have in wasmtime, meaning that building wasmtime no longer requires a C++ compiler. It still does require a C toolchain for some minor purposes, but hopefully we can remove that over time too! The motivation for doing this is to consolidate all our signal-handling code into one location in one language so you don't have to keep crossing back and forth when understanding what's going on. This also allows us to remove some extra cruft that wasn't necessary from the C++ original implementation. Additionally this should also make building wasmtime a bit more portable since it's often easier to acquire a C toolchain than it is to acquire a C++ toolchain. (e.g. if you're cross-compiling to a musl target) * Typos
This commit is contained in:
28
crates/runtime/src/helpers.c
Normal file
28
crates/runtime/src/helpers.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <setjmp.h>
|
||||
|
||||
int RegisterSetjmp(
|
||||
void **buf_storage,
|
||||
void (*body)(void*),
|
||||
void *payload) {
|
||||
jmp_buf buf;
|
||||
if (setjmp(buf) != 0) {
|
||||
return 0;
|
||||
}
|
||||
*buf_storage = &buf;
|
||||
body(payload);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Unwind(void *JmpBuf) {
|
||||
jmp_buf *buf = (jmp_buf*) JmpBuf;
|
||||
longjmp(*buf, 1);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sys/ucontext.h>
|
||||
|
||||
void* GetPcFromUContext(ucontext_t *cx) {
|
||||
return (void*) cx->uc_mcontext->__ss.__rip;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user