mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
workaround for broken OSX ucontext
This commit is contained in:
parent
b40450ccb2
commit
d001c75524
@ -15,6 +15,7 @@
|
|||||||
#include "contextSwitch.h"
|
#include "contextSwitch.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef THREAD_SIMPLE_IMPL
|
#ifdef THREAD_SIMPLE_IMPL
|
||||||
|
|
||||||
@ -31,7 +32,11 @@ void
|
|||||||
init_thread_context(struct ThreadContext *context,
|
init_thread_context(struct ThreadContext *context,
|
||||||
unsigned char *stack, size_t stack_size,
|
unsigned char *stack, size_t stack_size,
|
||||||
ContextFunction *thread_func, void *data) {
|
ContextFunction *thread_func, void *data) {
|
||||||
getcontext(&context->_ucontext);
|
if (getcontext(&context->_ucontext) != 0) {
|
||||||
|
fprintf(stderr, "getcontext failed in init_thread_context!\n");
|
||||||
|
// Too bad for you.
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
context->_ucontext.uc_stack.ss_sp = stack;
|
context->_ucontext.uc_stack.ss_sp = stack;
|
||||||
context->_ucontext.uc_stack.ss_size = stack_size;
|
context->_ucontext.uc_stack.ss_size = stack_size;
|
||||||
@ -49,7 +54,12 @@ save_thread_context(struct ThreadContext *context,
|
|||||||
(return from setcontext). */
|
(return from setcontext). */
|
||||||
volatile int context_return = 0;
|
volatile int context_return = 0;
|
||||||
|
|
||||||
getcontext(&context->_ucontext);
|
if (getcontext(&context->_ucontext) != 0) {
|
||||||
|
fprintf(stderr, "getcontext failed!\n");
|
||||||
|
// Nothing to do here.
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
if (context_return) {
|
if (context_return) {
|
||||||
/* We have just returned from setcontext. In this case, return
|
/* We have just returned from setcontext. In this case, return
|
||||||
from the function. The stack is still good. */
|
from the function. The stack is still good. */
|
||||||
|
@ -38,6 +38,12 @@
|
|||||||
|
|
||||||
struct ThreadContext {
|
struct ThreadContext {
|
||||||
ucontext_t _ucontext;
|
ucontext_t _ucontext;
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
// Due to a bug in OSX 10.5, the system ucontext_t declaration
|
||||||
|
// doesn't reserve enough space, and we need to reserve some
|
||||||
|
// additional space to make room.
|
||||||
|
_STRUCT_MCONTEXT _extra_padding;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#else /* HAVE_UCONTEXT_H */
|
#else /* HAVE_UCONTEXT_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user