CVS: winex/dlls/ntdll signal_i386.c,1.44,1.45
[email protected] 27 Jun 2007 11:50:01 -0000
Newsgroups
gmane.comp.emulators.winex.cvs
Message-ID
<[email protected] >
Subject: winex/dlls/ntdll signal_i386.c,1.44,1.45Update of /var/lib/cvsd/cvsroot/winex/dlls/ntdll
In directory agravaine:/tmp/cvs-serv22105/dlls/ntdll
Modified Files:
signal_i386.c
Log Message:
- various changes & configure checks to build on Leopard (MacOS X 10.5)
Index: signal_i386.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/ntdll/signal_i386.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- signal_i386.c 30 Mar 2007 15:55:45 -0000 1.44
+++ signal_i386.c 27 Jun 2007 11:49:59 -0000 1.45
@@ -54,8 +54,13 @@
extern void __wine_ret_to_32_regs( CONTEXT *context ) WINE_NORETURN;
#ifdef HAVE_SIGALTSTACK
+#ifdef SIGALTSTACK_TAKES_STACK_T
+static int wine_sigaltstack( const stack_t *new,
+ stack_t *old )
+#else
static int wine_sigaltstack( const struct sigaltstack *new,
struct sigaltstack *old )
+#endif
{
int ret;
@@ -254,7 +259,6 @@
#endif /* __EMX__ */
#ifdef __APPLE__
-# include <sys/types.h>
# include <sys/ucontext.h>
# include <signal.h>
# include <mach/mach.h>
@@ -272,29 +276,35 @@
/* NOTE - if you add or change any of these, check build_fake_signal_context()
and friend to make sure it's implemented in our mach exceptions */
-#define EAX_sig(context) ((context)->uc_mcontext->ss.eax)
-#define EBX_sig(context) ((context)->uc_mcontext->ss.ebx)
-#define ECX_sig(context) ((context)->uc_mcontext->ss.ecx)
-#define EDX_sig(context) ((context)->uc_mcontext->ss.edx)
-#define ESI_sig(context) ((context)->uc_mcontext->ss.esi)
-#define EDI_sig(context) ((context)->uc_mcontext->ss.edi)
-#define EBP_sig(context) ((context)->uc_mcontext->ss.ebp)
+#ifdef MACH_X86_STATE_NEEDS_PREFIX
+#define DREG(a) __##a
+#else
+#define DREG(a) a
+#endif
-#define CS_sig(context) ((context)->uc_mcontext->ss.cs)
-#define DS_sig(context) ((context)->uc_mcontext->ss.ds)
-#define ES_sig(context) ((context)->uc_mcontext->ss.es)
-#define SS_sig(context) ((context)->uc_mcontext->ss.ss)
+#define EAX_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(eax))
+#define EBX_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(ebx))
+#define ECX_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(ecx))
+#define EDX_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(edx))
+#define ESI_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(esi))
+#define EDI_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(edi))
+#define EBP_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(ebp))
-#define FS_sig(context) ((context)->uc_mcontext->ss.fs)
-#define GS_sig(context) ((context)->uc_mcontext->ss.gs)
+#define CS_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(cs))
+#define DS_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(ds))
+#define ES_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(es))
+#define SS_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(ss))
-#define EFL_sig(context) ((context)->uc_mcontext->ss.eflags)
+#define FS_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(fs))
+#define GS_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(gs))
-#define EIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext->ss.eip))
-#define ESP_sig(context) (*((unsigned long*)&(context)->uc_mcontext->ss.esp))
-#define TRAP_sig(context) ((context)->uc_mcontext->es.trapno)
-#define ERROR_sig(context) ((context)->uc_mcontext->es.err)
-#define CR2_sig(context) ((context)->uc_mcontext->es.faultvaddr)
+#define EFL_sig(context) ((context)->uc_mcontext->DREG(ss).DREG(eflags))
+
+#define EIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext->DREG(ss).DREG(eip)))
+#define ESP_sig(context) (*((unsigned long*)&(context)->uc_mcontext->DREG(ss).DREG(esp)))
+#define TRAP_sig(context) ((context)->uc_mcontext->DREG(es).DREG(trapno))
+#define ERROR_sig(context) ((context)->uc_mcontext->DREG(es).DREG(err))
+#define CR2_sig(context) ((context)->uc_mcontext->DREG(es).DREG(faultvaddr))
#define HANDLER_DEF(name) void __dynamicstackalign name( int __signal, siginfo_t *__siginfo, SIGCONTEXT *__context )
#define HANDLER_CONTEXT (__context)
@@ -784,12 +794,12 @@
if (!thread_get_state (mach_thread_self (), x86_DEBUG_STATE32,
(thread_state_t)&debug_regs, &sc))
{
- context->Dr0 = debug_regs.dr0;
- context->Dr1 = debug_regs.dr1;
- context->Dr2 = debug_regs.dr2;
- context->Dr3 = debug_regs.dr3;
- context->Dr6 = debug_regs.dr6;
- context->Dr7 = debug_regs.dr7;
+ context->Dr0 = debug_regs.DREG(dr0);
+ context->Dr1 = debug_regs.DREG(dr1);
+ context->Dr2 = debug_regs.DREG(dr2);
+ context->Dr3 = debug_regs.DREG(dr3);
+ context->Dr6 = debug_regs.DREG(dr6);
+ context->Dr7 = debug_regs.DREG(dr7);
}
#else
CONTEXT debug_regs;
@@ -827,14 +837,14 @@
x86_debug_state32_t debug_regs;
mach_msg_type_number_t sc = x86_DEBUG_STATE32_COUNT;
- debug_regs.dr0 = context->Dr0;
- debug_regs.dr1 = context->Dr1;
- debug_regs.dr2 = context->Dr2;
- debug_regs.dr3 = context->Dr3;
- debug_regs.dr6 = context->Dr6;
- debug_regs.dr7 = context->Dr7;
- debug_regs.dr4 = 0;
- debug_regs.dr5 = 0;
+ debug_regs.DREG(dr0) = context->Dr0;
+ debug_regs.DREG(dr1) = context->Dr1;
+ debug_regs.DREG(dr2) = context->Dr2;
+ debug_regs.DREG(dr3) = context->Dr3;
+ debug_regs.DREG(dr6) = context->Dr6;
+ debug_regs.DREG(dr7) = context->Dr7;
+ debug_regs.DREG(dr4) = 0;
+ debug_regs.DREG(dr5) = 0;
if (thread_set_state (mach_thread_self (), x86_DEBUG_STATE32,
(thread_state_t)&debug_regs, sc))
@@ -1508,8 +1518,12 @@
int SIGNAL_SetupSignalStack( void )
{
#ifdef HAVE_SIGALTSTACK
-
+#ifdef SIGALTSTACK_TAKES_STACK_T
+ stack_t ss;
+#else
struct sigaltstack ss;
+#endif
+
ss.ss_sp = NtCurrentTeb()->signal_stack;
ss.ss_size = SIGNAL_STACK_SIZE;
ss.ss_flags = 0;
@@ -1532,8 +1546,11 @@
int SIGNAL_SuspendSignalStack( void )
{
#ifdef HAVE_SIGALTSTACK
-
+#ifdef SIGALTSTACK_TAKES_STACK_T
+ stack_t nosas;
+#else
struct sigaltstack nosas;
+#endif
if ( !NtCurrentTeb()->signal_stack ) return 0;
@@ -1554,46 +1571,46 @@
#ifdef __APPLE__
static void build_fake_signal_context (x86_thread_state32_t *thread_state,
- struct ucontext *context)
+ ucontext_t *context)
{
- context->uc_mcontext->ss.eax = thread_state->eax;
- context->uc_mcontext->ss.ebx = thread_state->ebx;
- context->uc_mcontext->ss.ecx = thread_state->ecx;
- context->uc_mcontext->ss.edx = thread_state->edx;
- context->uc_mcontext->ss.edi = thread_state->edi;
- context->uc_mcontext->ss.esi = thread_state->esi;
- context->uc_mcontext->ss.ebp = thread_state->ebp;
- context->uc_mcontext->ss.esp = thread_state->esp;
- context->uc_mcontext->ss.ss = thread_state->ss;
- context->uc_mcontext->ss.eflags = thread_state->eflags;
- context->uc_mcontext->ss.eip = thread_state->eip;
- context->uc_mcontext->ss.cs = thread_state->cs;
- context->uc_mcontext->ss.ds = thread_state->ds;
- context->uc_mcontext->ss.es = thread_state->es;
- context->uc_mcontext->ss.fs = thread_state->fs;
- context->uc_mcontext->ss.gs = thread_state->gs;
+ context->uc_mcontext->DREG(ss).DREG(eax) = thread_state->DREG(eax);
+ context->uc_mcontext->DREG(ss).DREG(ebx) = thread_state->DREG(ebx);
+ context->uc_mcontext->DREG(ss).DREG(ecx) = thread_state->DREG(ecx);
+ context->uc_mcontext->DREG(ss).DREG(edx) = thread_state->DREG(edx);
+ context->uc_mcontext->DREG(ss).DREG(edi) = thread_state->DREG(edi);
+ context->uc_mcontext->DREG(ss).DREG(esi) = thread_state->DREG(esi);
+ context->uc_mcontext->DREG(ss).DREG(ebp) = thread_state->DREG(ebp);
+ context->uc_mcontext->DREG(ss).DREG(esp) = thread_state->DREG(esp);
+ context->uc_mcontext->DREG(ss).DREG(ss) = thread_state->DREG(ss);
+ context->uc_mcontext->DREG(ss).DREG(eflags) = thread_state->DREG(eflags);
+ context->uc_mcontext->DREG(ss).DREG(eip) = thread_state->DREG(eip);
+ context->uc_mcontext->DREG(ss).DREG(cs) = thread_state->DREG(cs);
+ context->uc_mcontext->DREG(ss).DREG(ds) = thread_state->DREG(ds);
+ context->uc_mcontext->DREG(ss).DREG(es) = thread_state->DREG(es);
+ context->uc_mcontext->DREG(ss).DREG(fs) = thread_state->DREG(fs);
+ context->uc_mcontext->DREG(ss).DREG(gs) = thread_state->DREG(gs);
}
static void restore_from_signal_context(x86_thread_state32_t *thread_state,
- struct ucontext *context)
+ ucontext_t *context)
{
- thread_state->eax = context->uc_mcontext->ss.eax;
- thread_state->ebx = context->uc_mcontext->ss.ebx;
- thread_state->ecx = context->uc_mcontext->ss.ecx;
- thread_state->edx = context->uc_mcontext->ss.edx;
- thread_state->edi = context->uc_mcontext->ss.edi;
- thread_state->esi = context->uc_mcontext->ss.esi;
- thread_state->ebp = context->uc_mcontext->ss.ebp;
- thread_state->esp = context->uc_mcontext->ss.esp;
- thread_state->ss = context->uc_mcontext->ss.ss;
- thread_state->eflags = context->uc_mcontext->ss.eflags;
- thread_state->eip = context->uc_mcontext->ss.eip;
- thread_state->cs = context->uc_mcontext->ss.cs;
- thread_state->ds = context->uc_mcontext->ss.ds;
- thread_state->es = context->uc_mcontext->ss.es;
- thread_state->fs = context->uc_mcontext->ss.fs;
- thread_state->gs = context->uc_mcontext->ss.gs;
+ thread_state->DREG(eax) = context->uc_mcontext->DREG(ss).DREG(eax);
+ thread_state->DREG(ebx) = context->uc_mcontext->DREG(ss).DREG(ebx);
+ thread_state->DREG(ecx) = context->uc_mcontext->DREG(ss).DREG(ecx);
+ thread_state->DREG(edx) = context->uc_mcontext->DREG(ss).DREG(edx);
+ thread_state->DREG(edi) = context->uc_mcontext->DREG(ss).DREG(edi);
+ thread_state->DREG(esi) = context->uc_mcontext->DREG(ss).DREG(esi);
+ thread_state->DREG(ebp) = context->uc_mcontext->DREG(ss).DREG(ebp);
+ thread_state->DREG(esp) = context->uc_mcontext->DREG(ss).DREG(esp);
+ thread_state->DREG(ss) = context->uc_mcontext->DREG(ss).DREG(ss);
+ thread_state->DREG(eflags) = context->uc_mcontext->DREG(ss).DREG(eflags);
+ thread_state->DREG(eip) = context->uc_mcontext->DREG(ss).DREG(eip);
+ thread_state->DREG(cs) = context->uc_mcontext->DREG(ss).DREG(cs);
+ thread_state->DREG(ds) = context->uc_mcontext->DREG(ss).DREG(ds);
+ thread_state->DREG(es) = context->uc_mcontext->DREG(ss).DREG(es);
+ thread_state->DREG(fs) = context->uc_mcontext->DREG(ss).DREG(fs);
+ thread_state->DREG(gs) = context->uc_mcontext->DREG(ss).DREG(gs);
}
@@ -1637,8 +1654,8 @@
{
mach_msg_type_number_t sc = x86_EXCEPTION_STATE32_COUNT;
kern_return_t res;
- struct ucontext ucontext;
- struct mcontext uc_mcontext;
+ ucontext_t ucontext;
+ mcontext_t uc_mcontext;
x86_thread_state32_t x86State;
if ((OldStateCount * sizeof (natural_t)) < sizeof (x86_thread_state32_t))
@@ -1654,14 +1671,15 @@
}
x86State = *(x86_thread_state32_t *)OldState;
- memset (&uc_mcontext, 0, sizeof (uc_mcontext));
+ uc_mcontext = alloca (sizeof (*uc_mcontext));
+ memset (uc_mcontext, 0, sizeof (*uc_mcontext));
memset (&ucontext, 0, sizeof (ucontext));
- ucontext.uc_mcontext = &uc_mcontext;
+ ucontext.uc_mcontext = uc_mcontext;
build_fake_signal_context (&x86State, &ucontext);
res = thread_get_state (ExceptionThread, x86_EXCEPTION_STATE32,
- (thread_state_t)&uc_mcontext.es, &sc);
+ (thread_state_t)&uc_mcontext->DREG(es), &sc);
if (res)
fprintf (stderr,
"thread_get_state x86_EXCEPTION_STATE32 failed! res: 0x%x\n",