Fix compilation errors on Darwin.
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
# include <mach/exc.h>
|
# include <mach/exc.h>
|
||||||
# include <mach/mach.h>
|
# include <mach/mach.h>
|
||||||
|
# include <pthread.h>
|
||||||
#else
|
#else
|
||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -520,7 +521,6 @@ HandleMachException(const ExceptionRequest& request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
AutoNoteSingleThreadedRegion anstr;
|
|
||||||
AutoHandlingTrap aht;
|
AutoHandlingTrap aht;
|
||||||
if (!HandleTrap(&context)) {
|
if (!HandleTrap(&context)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -542,8 +542,8 @@ HandleMachException(const ExceptionRequest& request)
|
|||||||
|
|
||||||
static mach_port_t sMachDebugPort = MACH_PORT_NULL;
|
static mach_port_t sMachDebugPort = MACH_PORT_NULL;
|
||||||
|
|
||||||
static void
|
static void*
|
||||||
MachExceptionHandlerThread(void *arg)
|
MachExceptionHandlerThread(void* arg)
|
||||||
{
|
{
|
||||||
// Taken from mach_exc in /usr/include/mach/mach_exc.defs.
|
// Taken from mach_exc in /usr/include/mach/mach_exc.defs.
|
||||||
static const unsigned EXCEPTION_MSG_ID = 2405;
|
static const unsigned EXCEPTION_MSG_ID = 2405;
|
||||||
@@ -588,6 +588,8 @@ MachExceptionHandlerThread(void *arg)
|
|||||||
mach_msg(&reply.Head, MACH_SEND_MSG, sizeof(reply), 0, MACH_PORT_NULL,
|
mach_msg(&reply.Head, MACH_SEND_MSG, sizeof(reply), 0, MACH_PORT_NULL,
|
||||||
MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
|
MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // If not Windows or Mac, assume Unix
|
#else // If not Windows or Mac, assume Unix
|
||||||
@@ -769,7 +771,7 @@ EnsureDarwinMachPorts()
|
|||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
r = pthread_detach(&handlerThread);
|
r = pthread_detach(handlerThread);
|
||||||
assert(r != 0);
|
assert(r != 0);
|
||||||
|
|
||||||
// In addition to the process-wide signal handler setup, OSX needs each
|
// In addition to the process-wide signal handler setup, OSX needs each
|
||||||
@@ -781,7 +783,7 @@ EnsureDarwinMachPorts()
|
|||||||
// uses of thread-level exception ports.
|
// uses of thread-level exception ports.
|
||||||
assert(sMachDebugPort != MACH_PORT_NULL);
|
assert(sMachDebugPort != MACH_PORT_NULL);
|
||||||
thread_port_t thisThread = mach_thread_self();
|
thread_port_t thisThread = mach_thread_self();
|
||||||
kern_return_t kret = thread_set_exception_ports(thisThread,
|
kret = thread_set_exception_ports(thisThread,
|
||||||
EXC_MASK_BAD_ACCESS | EXC_MASK_BAD_INSTRUCTION,
|
EXC_MASK_BAD_ACCESS | EXC_MASK_BAD_INSTRUCTION,
|
||||||
sMachDebugPort,
|
sMachDebugPort,
|
||||||
EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES,
|
EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ EnsureEagerSignalHandlers(void);
|
|||||||
// be performed per-thread. This operation may incur some overhead and
|
// be performed per-thread. This operation may incur some overhead and
|
||||||
// so should be done only when needed to use wasm.
|
// so should be done only when needed to use wasm.
|
||||||
bool
|
bool
|
||||||
EnsureDarwinMachPorts(struct TrapContext* cx);
|
EnsureDarwinMachPorts(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ pub extern "C" fn RecordTrap(pc: *const u8, _codeSegment: *const CodeSegment) {
|
|||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Unwind() {
|
pub extern "C" fn Unwind() {
|
||||||
JMP_BUFS.with(|bufs| unsafe {
|
JMP_BUFS.with(|bufs| {
|
||||||
let buf = bufs.borrow_mut().pop().unwrap();
|
let buf = bufs.borrow_mut().pop().unwrap();
|
||||||
longjmp(&buf, 1);
|
unsafe { longjmp(&buf, 1) };
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user