push c6aba86b6d7f7dbe994528d67faed47594362b60
[wine/hacks.git] / dlls / ntdll / signal_sparc.c
blob87da976dbec89308d2bac708309bf3322f038ddf
1 /*
2 * Sparc signal handling routines
4 * Copyright 1999 Ulrich Weigand
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifdef __sparc__
23 #include "config.h"
24 #include "wine/port.h"
26 #include <assert.h>
27 #include <signal.h>
28 #include <stdlib.h>
29 #ifdef HAVE_UNISTD_H
30 # include <unistd.h>
31 #endif
32 #include <stdarg.h>
33 #include <stdio.h>
34 #include <sys/ucontext.h>
36 #include "ntstatus.h"
37 #define WIN32_NO_STATUS
38 #include "windef.h"
39 #include "winternl.h"
40 #include "winnt.h"
42 #include "wine/exception.h"
43 #include "ntdll_misc.h"
45 #include "wine/debug.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(seh);
49 static pthread_key_t teb_key;
51 #define HANDLER_DEF(name) void name( int __signal, struct siginfo *__siginfo, ucontext_t *__context )
52 #define HANDLER_CONTEXT (__context)
54 typedef int (*wine_signal_handler)(unsigned int sig);
56 static wine_signal_handler handlers[256];
58 /***********************************************************************
59 * dispatch_signal
61 static inline int dispatch_signal(unsigned int sig)
63 if (handlers[sig] == NULL) return 0;
64 return handlers[sig](sig);
69 * FIXME: All this works only on Solaris for now
72 /**********************************************************************
73 * save_context
75 static void save_context( CONTEXT *context, ucontext_t *ucontext )
77 /* Special registers */
78 context->psr = ucontext->uc_mcontext.gregs[REG_PSR];
79 context->pc = ucontext->uc_mcontext.gregs[REG_PC];
80 context->npc = ucontext->uc_mcontext.gregs[REG_nPC];
81 context->y = ucontext->uc_mcontext.gregs[REG_Y];
82 context->wim = 0; /* FIXME */
83 context->tbr = 0; /* FIXME */
85 /* Global registers */
86 context->g0 = 0; /* always */
87 context->g1 = ucontext->uc_mcontext.gregs[REG_G1];
88 context->g2 = ucontext->uc_mcontext.gregs[REG_G2];
89 context->g3 = ucontext->uc_mcontext.gregs[REG_G3];
90 context->g4 = ucontext->uc_mcontext.gregs[REG_G4];
91 context->g5 = ucontext->uc_mcontext.gregs[REG_G5];
92 context->g6 = ucontext->uc_mcontext.gregs[REG_G6];
93 context->g7 = ucontext->uc_mcontext.gregs[REG_G7];
95 /* Current 'out' registers */
96 context->o0 = ucontext->uc_mcontext.gregs[REG_O0];
97 context->o1 = ucontext->uc_mcontext.gregs[REG_O1];
98 context->o2 = ucontext->uc_mcontext.gregs[REG_O2];
99 context->o3 = ucontext->uc_mcontext.gregs[REG_O3];
100 context->o4 = ucontext->uc_mcontext.gregs[REG_O4];
101 context->o5 = ucontext->uc_mcontext.gregs[REG_O5];
102 context->o6 = ucontext->uc_mcontext.gregs[REG_O6];
103 context->o7 = ucontext->uc_mcontext.gregs[REG_O7];
105 /* FIXME: what if the current register window isn't saved? */
106 if ( ucontext->uc_mcontext.gwins && ucontext->uc_mcontext.gwins->wbcnt > 0 )
108 /* Current 'local' registers from first register window */
109 context->l0 = ucontext->uc_mcontext.gwins->wbuf[0].rw_local[0];
110 context->l1 = ucontext->uc_mcontext.gwins->wbuf[0].rw_local[1];
111 context->l2 = ucontext->uc_mcontext.gwins->wbuf[0].rw_local[2];
112 context->l3 = ucontext->uc_mcontext.gwins->wbuf[0].rw_local[3];
113 context->l4 = ucontext->uc_mcontext.gwins->wbuf[0].rw_local[4];
114 context->l5 = ucontext->uc_mcontext.gwins->wbuf[0].rw_local[5];
115 context->l6 = ucontext->uc_mcontext.gwins->wbuf[0].rw_local[6];
116 context->l7 = ucontext->uc_mcontext.gwins->wbuf[0].rw_local[7];
118 /* Current 'in' registers from first register window */
119 context->i0 = ucontext->uc_mcontext.gwins->wbuf[0].rw_in[0];
120 context->i1 = ucontext->uc_mcontext.gwins->wbuf[0].rw_in[1];
121 context->i2 = ucontext->uc_mcontext.gwins->wbuf[0].rw_in[2];
122 context->i3 = ucontext->uc_mcontext.gwins->wbuf[0].rw_in[3];
123 context->i4 = ucontext->uc_mcontext.gwins->wbuf[0].rw_in[4];
124 context->i5 = ucontext->uc_mcontext.gwins->wbuf[0].rw_in[5];
125 context->i6 = ucontext->uc_mcontext.gwins->wbuf[0].rw_in[6];
126 context->i7 = ucontext->uc_mcontext.gwins->wbuf[0].rw_in[7];
130 /**********************************************************************
131 * restore_context
133 static void restore_context( CONTEXT *context, ucontext_t *ucontext )
135 /* FIXME */
138 /**********************************************************************
139 * save_fpu
141 static void save_fpu( CONTEXT *context, ucontext_t *ucontext )
143 /* FIXME */
146 /**********************************************************************
147 * restore_fpu
149 static void restore_fpu( CONTEXT *context, ucontext_t *ucontext )
151 /* FIXME */
155 /***********************************************************************
156 * RtlCaptureContext (NTDLL.@)
158 void WINAPI RtlCaptureContext( CONTEXT *context )
160 FIXME("not implemented\n");
161 memset( context, 0, sizeof(*context) );
165 /***********************************************************************
166 * set_cpu_context
168 * Set the new CPU context.
170 void set_cpu_context( const CONTEXT *context )
172 FIXME("not implemented\n");
176 /***********************************************************************
177 * copy_context
179 * Copy a register context according to the flags.
181 void copy_context( CONTEXT *to, const CONTEXT *from, DWORD flags )
183 flags &= ~CONTEXT_SPARC; /* get rid of CPU id */
184 if (flags & CONTEXT_CONTROL)
186 to->psr = from->psr;
187 to->pc = from->pc;
188 to->npc = from->npc;
189 to->y = from->y;
190 to->wim = from->wim;
191 to->tbr = from->tbr;
193 if (flags & CONTEXT_INTEGER)
195 to->g0 = from->g0;
196 to->g1 = from->g1;
197 to->g2 = from->g2;
198 to->g3 = from->g3;
199 to->g4 = from->g4;
200 to->g5 = from->g5;
201 to->g6 = from->g6;
202 to->g7 = from->g7;
203 to->o0 = from->o0;
204 to->o1 = from->o1;
205 to->o2 = from->o2;
206 to->o3 = from->o3;
207 to->o4 = from->o4;
208 to->o5 = from->o5;
209 to->o6 = from->o6;
210 to->o7 = from->o7;
211 to->l0 = from->l0;
212 to->l1 = from->l1;
213 to->l2 = from->l2;
214 to->l3 = from->l3;
215 to->l4 = from->l4;
216 to->l5 = from->l5;
217 to->l6 = from->l6;
218 to->l7 = from->l7;
219 to->i0 = from->i0;
220 to->i1 = from->i1;
221 to->i2 = from->i2;
222 to->i3 = from->i3;
223 to->i4 = from->i4;
224 to->i5 = from->i5;
225 to->i6 = from->i6;
226 to->i7 = from->i7;
228 if (flags & CONTEXT_FLOATING_POINT)
230 /* FIXME */
235 /***********************************************************************
236 * context_to_server
238 * Convert a register context to the server format.
240 NTSTATUS context_to_server( context_t *to, const CONTEXT *from )
242 DWORD flags = from->ContextFlags & ~CONTEXT_SPARC; /* get rid of CPU id */
244 memset( to, 0, sizeof(*to) );
245 to->cpu = CPU_SPARC;
247 if (flags & CONTEXT_CONTROL)
249 to->flags |= SERVER_CTX_CONTROL;
250 to->ctl.sparc_regs.psr = from->psr;
251 to->ctl.sparc_regs.pc = from->pc;
252 to->ctl.sparc_regs.npc = from->npc;
253 to->ctl.sparc_regs.y = from->y;
254 to->ctl.sparc_regs.wim = from->wim;
255 to->ctl.sparc_regs.tbr = from->tbr;
257 if (flags & CONTEXT_INTEGER)
259 to->flags |= SERVER_CTX_INTEGER;
260 to->integer.sparc_regs.g[0] = from->g0;
261 to->integer.sparc_regs.g[1] = from->g1;
262 to->integer.sparc_regs.g[2] = from->g2;
263 to->integer.sparc_regs.g[3] = from->g3;
264 to->integer.sparc_regs.g[4] = from->g4;
265 to->integer.sparc_regs.g[5] = from->g5;
266 to->integer.sparc_regs.g[6] = from->g6;
267 to->integer.sparc_regs.g[7] = from->g7;
268 to->integer.sparc_regs.o[0] = from->o0;
269 to->integer.sparc_regs.o[1] = from->o1;
270 to->integer.sparc_regs.o[2] = from->o2;
271 to->integer.sparc_regs.o[3] = from->o3;
272 to->integer.sparc_regs.o[4] = from->o4;
273 to->integer.sparc_regs.o[5] = from->o5;
274 to->integer.sparc_regs.o[6] = from->o6;
275 to->integer.sparc_regs.o[7] = from->o7;
276 to->integer.sparc_regs.l[0] = from->l0;
277 to->integer.sparc_regs.l[1] = from->l1;
278 to->integer.sparc_regs.l[2] = from->l2;
279 to->integer.sparc_regs.l[3] = from->l3;
280 to->integer.sparc_regs.l[4] = from->l4;
281 to->integer.sparc_regs.l[5] = from->l5;
282 to->integer.sparc_regs.l[6] = from->l6;
283 to->integer.sparc_regs.l[7] = from->l7;
284 to->integer.sparc_regs.i[0] = from->i0;
285 to->integer.sparc_regs.i[1] = from->i1;
286 to->integer.sparc_regs.i[2] = from->i2;
287 to->integer.sparc_regs.i[3] = from->i3;
288 to->integer.sparc_regs.i[4] = from->i4;
289 to->integer.sparc_regs.i[5] = from->i5;
290 to->integer.sparc_regs.i[6] = from->i6;
291 to->integer.sparc_regs.i[7] = from->i7;
293 if (flags & CONTEXT_FLOATING_POINT)
295 /* FIXME */
297 return STATUS_SUCCESS;
301 /***********************************************************************
302 * context_from_server
304 * Convert a register context from the server format.
306 NTSTATUS context_from_server( CONTEXT *to, const context_t *from )
308 if (from->cpu != CPU_SPARC) return STATUS_INVALID_PARAMETER;
310 to->ContextFlags = CONTEXT_SPARC;
311 if (from->flags & SERVER_CTX_CONTROL)
313 to->ContextFlags |= CONTEXT_CONTROL;
314 to->psr = from->ctl.sparc_regs.psr;
315 to->pc = from->ctl.sparc_regs.pc;
316 to->npc = from->ctl.sparc_regs.npc;
317 to->y = from->ctl.sparc_regs.y;
318 to->wim = from->ctl.sparc_regs.wim;
319 to->tbr = from->ctl.sparc_regs.tbr;
321 if (from->flags & SERVER_CTX_INTEGER)
323 to->ContextFlags |= CONTEXT_INTEGER;
324 to->g0 = from->integer.sparc_regs.g[0];
325 to->g1 = from->integer.sparc_regs.g[1];
326 to->g2 = from->integer.sparc_regs.g[2];
327 to->g3 = from->integer.sparc_regs.g[3];
328 to->g4 = from->integer.sparc_regs.g[4];
329 to->g5 = from->integer.sparc_regs.g[5];
330 to->g6 = from->integer.sparc_regs.g[6];
331 to->g7 = from->integer.sparc_regs.g[7];
332 to->o0 = from->integer.sparc_regs.o[0];
333 to->o1 = from->integer.sparc_regs.o[1];
334 to->o2 = from->integer.sparc_regs.o[2];
335 to->o3 = from->integer.sparc_regs.o[3];
336 to->o4 = from->integer.sparc_regs.o[4];
337 to->o5 = from->integer.sparc_regs.o[5];
338 to->o6 = from->integer.sparc_regs.o[6];
339 to->o7 = from->integer.sparc_regs.o[7];
340 to->l0 = from->integer.sparc_regs.l[0];
341 to->l1 = from->integer.sparc_regs.l[1];
342 to->l2 = from->integer.sparc_regs.l[2];
343 to->l3 = from->integer.sparc_regs.l[3];
344 to->l4 = from->integer.sparc_regs.l[4];
345 to->l5 = from->integer.sparc_regs.l[5];
346 to->l6 = from->integer.sparc_regs.l[6];
347 to->l7 = from->integer.sparc_regs.l[7];
348 to->i0 = from->integer.sparc_regs.i[0];
349 to->i1 = from->integer.sparc_regs.i[1];
350 to->i2 = from->integer.sparc_regs.i[2];
351 to->i3 = from->integer.sparc_regs.i[3];
352 to->i4 = from->integer.sparc_regs.i[4];
353 to->i5 = from->integer.sparc_regs.i[5];
354 to->i6 = from->integer.sparc_regs.i[6];
355 to->i7 = from->integer.sparc_regs.i[7];
357 if (from->flags & SERVER_CTX_FLOATING_POINT)
359 /* FIXME */
361 return STATUS_SUCCESS;
365 /**********************************************************************
366 * segv_handler
368 * Handler for SIGSEGV.
370 static void segv_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
372 EXCEPTION_RECORD rec;
373 CONTEXT context;
374 NTSTATUS status;
376 rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
378 /* we want the page-fault case to be fast */
379 if ( info->si_code == SEGV_ACCERR )
380 if (!(rec.ExceptionCode = virtual_handle_fault( info->si_addr, 0 ))) return;
382 save_context( &context, ucontext );
383 rec.ExceptionRecord = NULL;
384 rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
385 rec.ExceptionAddress = (LPVOID)context.pc;
386 rec.NumberParameters = 2;
387 rec.ExceptionInformation[0] = 0; /* FIXME: read/write access ? */
388 rec.ExceptionInformation[1] = (ULONG_PTR)info->si_addr;
390 status = raise_exception( &rec, &context, TRUE );
391 if (status) raise_status( status, &rec );
392 restore_context( &context, ucontext );
395 /**********************************************************************
396 * bus_handler
398 * Handler for SIGBUS.
400 static void bus_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
402 EXCEPTION_RECORD rec;
403 CONTEXT context;
404 NTSTATUS status;
406 save_context( &context, ucontext );
407 rec.ExceptionRecord = NULL;
408 rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
409 rec.ExceptionAddress = (LPVOID)context.pc;
410 rec.NumberParameters = 0;
412 if ( info->si_code == BUS_ADRALN )
413 rec.ExceptionCode = EXCEPTION_DATATYPE_MISALIGNMENT;
414 else
415 rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
417 status = raise_exception( &rec, &context, TRUE );
418 if (status) raise_status( status, &rec );
419 restore_context( &context, ucontext );
422 /**********************************************************************
423 * ill_handler
425 * Handler for SIGILL.
427 static void ill_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
429 EXCEPTION_RECORD rec;
430 CONTEXT context;
431 NTSTATUS status;
433 switch ( info->si_code )
435 default:
436 case ILL_ILLOPC:
437 case ILL_ILLOPN:
438 case ILL_ILLADR:
439 case ILL_ILLTRP:
440 rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
441 break;
443 case ILL_PRVOPC:
444 case ILL_PRVREG:
445 rec.ExceptionCode = EXCEPTION_PRIV_INSTRUCTION;
446 break;
448 case ILL_BADSTK:
449 rec.ExceptionCode = EXCEPTION_STACK_OVERFLOW;
450 break;
453 save_context( &context, ucontext );
454 rec.ExceptionRecord = NULL;
455 rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
456 rec.ExceptionAddress = (LPVOID)context.pc;
457 rec.NumberParameters = 0;
458 status = raise_exception( &rec, &context, TRUE );
459 if (status) raise_status( status, &rec );
460 restore_context( &context, ucontext );
464 /**********************************************************************
465 * trap_handler
467 * Handler for SIGTRAP.
469 static void trap_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
471 EXCEPTION_RECORD rec;
472 CONTEXT context;
473 NTSTATUS status;
475 switch ( info->si_code )
477 case TRAP_TRACE:
478 rec.ExceptionCode = EXCEPTION_SINGLE_STEP;
479 break;
480 case TRAP_BRKPT:
481 default:
482 rec.ExceptionCode = EXCEPTION_BREAKPOINT;
483 break;
486 save_context( &context, ucontext );
487 rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
488 rec.ExceptionRecord = NULL;
489 rec.ExceptionAddress = (LPVOID)context.pc;
490 rec.NumberParameters = 0;
491 status = raise_exception( &rec, &context, TRUE );
492 if (status) raise_status( status, &rec );
493 restore_context( &context, ucontext );
497 /**********************************************************************
498 * fpe_handler
500 * Handler for SIGFPE.
502 static void fpe_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
504 EXCEPTION_RECORD rec;
505 CONTEXT context;
506 NTSTATUS status;
508 switch ( info->si_code )
510 case FPE_FLTSUB:
511 rec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED;
512 break;
513 case FPE_INTDIV:
514 rec.ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO;
515 break;
516 case FPE_INTOVF:
517 rec.ExceptionCode = EXCEPTION_INT_OVERFLOW;
518 break;
519 case FPE_FLTDIV:
520 rec.ExceptionCode = EXCEPTION_FLT_DIVIDE_BY_ZERO;
521 break;
522 case FPE_FLTOVF:
523 rec.ExceptionCode = EXCEPTION_FLT_OVERFLOW;
524 break;
525 case FPE_FLTUND:
526 rec.ExceptionCode = EXCEPTION_FLT_UNDERFLOW;
527 break;
528 case FPE_FLTRES:
529 rec.ExceptionCode = EXCEPTION_FLT_INEXACT_RESULT;
530 break;
531 case FPE_FLTINV:
532 default:
533 rec.ExceptionCode = EXCEPTION_FLT_INVALID_OPERATION;
534 break;
537 save_context( &context, ucontext );
538 save_fpu( &context, ucontext );
539 rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
540 rec.ExceptionRecord = NULL;
541 rec.ExceptionAddress = (LPVOID)context.pc;
542 rec.NumberParameters = 0;
543 status = raise_exception( &rec, &context, TRUE );
544 if (status) raise_status( status, &rec );
545 restore_context( &context, ucontext );
546 restore_fpu( &context, ucontext );
550 /**********************************************************************
551 * int_handler
553 * Handler for SIGINT.
555 static void int_handler( int signal, siginfo_t *info, ucontext_t *ucontext )
557 if (!dispatch_signal(SIGINT))
559 EXCEPTION_RECORD rec;
560 CONTEXT context;
561 NTSTATUS status;
563 save_context( &context, ucontext );
564 rec.ExceptionCode = CONTROL_C_EXIT;
565 rec.ExceptionFlags = EXCEPTION_CONTINUABLE;
566 rec.ExceptionRecord = NULL;
567 rec.ExceptionAddress = (LPVOID)context.pc;
568 rec.NumberParameters = 0;
569 status = raise_exception( &rec, &context, TRUE );
570 if (status) raise_status( status, &rec );
571 restore_context( &context, ucontext );
575 /**********************************************************************
576 * abrt_handler
578 * Handler for SIGABRT.
580 static HANDLER_DEF(abrt_handler)
582 EXCEPTION_RECORD rec;
583 CONTEXT context;
584 NTSTATUS status;
586 save_context( &context, HANDLER_CONTEXT );
587 rec.ExceptionCode = EXCEPTION_WINE_ASSERTION;
588 rec.ExceptionFlags = EH_NONCONTINUABLE;
589 rec.ExceptionRecord = NULL;
590 rec.ExceptionAddress = (LPVOID)context.pc;
591 rec.NumberParameters = 0;
592 status = raise_exception( &rec, &context, TRUE );
593 if (status) raise_status( status, &rec );
594 restore_context( &context, HANDLER_CONTEXT );
598 /**********************************************************************
599 * quit_handler
601 * Handler for SIGQUIT.
603 static HANDLER_DEF(quit_handler)
605 abort_thread(0);
609 /**********************************************************************
610 * usr1_handler
612 * Handler for SIGUSR1, used to signal a thread that it got suspended.
614 static HANDLER_DEF(usr1_handler)
616 CONTEXT context;
618 save_context( &context, HANDLER_CONTEXT );
619 wait_suspend( &context );
620 restore_context( &context, HANDLER_CONTEXT );
624 /**********************************************************************
625 * get_signal_stack_total_size
627 * Retrieve the size to allocate for the signal stack, including the TEB at the bottom.
628 * Must be a power of two.
630 size_t get_signal_stack_total_size(void)
632 assert( sizeof(TEB) <= getpagesize() );
633 return getpagesize(); /* this is just for the TEB, we don't need a signal stack */
637 /***********************************************************************
638 * set_handler
640 * Set a signal handler
642 static int set_handler( int sig, void (*func)() )
644 struct sigaction sig_act;
646 sig_act.sa_sigaction = func;
647 sig_act.sa_mask = server_block_set;
648 sig_act.sa_flags = SA_SIGINFO;
650 return sigaction( sig, &sig_act, NULL );
654 /***********************************************************************
655 * __wine_set_signal_handler (NTDLL.@)
657 int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
659 if (sig > sizeof(handlers) / sizeof(handlers[0])) return -1;
660 if (handlers[sig] != NULL) return -2;
661 handlers[sig] = wsh;
662 return 0;
666 /**********************************************************************
667 * signal_init_thread
669 void signal_init_thread( TEB *teb )
671 static int init_done;
673 if (!init_done)
675 pthread_key_create( &teb_key, NULL );
676 init_done = 1;
678 pthread_setspecific( teb_key, teb );
682 /**********************************************************************
683 * signal_init_process
685 void signal_init_process(void)
687 if (set_handler( SIGINT, (void (*)())int_handler ) == -1) goto error;
688 if (set_handler( SIGFPE, (void (*)())fpe_handler ) == -1) goto error;
689 if (set_handler( SIGSEGV, (void (*)())segv_handler ) == -1) goto error;
690 if (set_handler( SIGILL, (void (*)())ill_handler ) == -1) goto error;
691 if (set_handler( SIGBUS, (void (*)())bus_handler ) == -1) goto error;
692 if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error;
693 if (set_handler( SIGABRT, (void (*)())abrt_handler ) == -1) goto error;
694 if (set_handler( SIGQUIT, (void (*)())quit_handler ) == -1) goto error;
695 if (set_handler( SIGUSR1, (void (*)())usr1_handler ) == -1) goto error;
696 /* 'ta 6' tells the kernel to synthesize any unaligned accesses this
697 process makes, instead of just signalling an error and terminating
698 the process. wine-devel did not reach a conclusion on whether
699 this is correct, because that is what x86 does, or it is harmful
700 because it could obscure problems in user code */
701 asm("ta 6"); /* 6 == ST_FIX_ALIGN defined in sys/trap.h */
702 return;
704 error:
705 perror("sigaction");
706 exit(1);
710 /**********************************************************************
711 * __wine_enter_vm86
713 void __wine_enter_vm86( CONTEXT *context )
715 MESSAGE("vm86 mode not supported on this platform\n");
718 /***********************************************************************
719 * RtlRaiseException (NTDLL.@)
721 void WINAPI RtlRaiseException( EXCEPTION_RECORD *rec )
723 CONTEXT context;
724 NTSTATUS status;
726 RtlCaptureContext( &context );
727 rec->ExceptionAddress = (void *)context.pc;
728 status = raise_exception( rec, &context, TRUE );
729 if (status) raise_status( status, rec );
732 /**********************************************************************
733 * DbgBreakPoint (NTDLL.@)
735 void WINAPI DbgBreakPoint(void)
737 kill(getpid(), SIGTRAP);
740 /**********************************************************************
741 * DbgUserBreakPoint (NTDLL.@)
743 void WINAPI DbgUserBreakPoint(void)
745 kill(getpid(), SIGTRAP);
748 /**********************************************************************
749 * NtCurrentTeb (NTDLL.@)
751 TEB * WINAPI NtCurrentTeb(void)
753 return pthread_getspecific( teb_key );
756 #endif /* __sparc__ */