1 /* src/vm/jit/i386/linux/md-os.c - machine dependent i386 Linux functions
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Christian Thalinger
31 $Id: md-os.c 3759 2005-11-23 00:47:27Z twisti $
36 #define _GNU_SOURCE /* include REG_ defines from ucontext.h */
43 #include "vm/exceptions.h"
44 #include "vm/options.h"
45 #include "vm/stringlocal.h"
46 #include "vm/jit/asmpart.h"
47 #include "vm/jit/stacktrace.h"
50 /* signal_handler_sigsegv ******************************************************
52 NullPointerException signal handler for hardware null pointer check.
54 *******************************************************************************/
56 void signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
64 _uc = (ucontext_t *) _p;
65 _mc = &_uc->uc_mcontext;
67 sp = (u1 *) _mc->gregs[REG_ESP];
68 xpc = (u1 *) _mc->gregs[REG_EIP];
69 ra = xpc; /* return address is equal to xpc */
72 (ptrint) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
74 _mc->gregs[REG_ECX] = (ptrint) xpc; /* REG_ITMP2_XPC */
75 _mc->gregs[REG_EIP] = (ptrint) asm_handle_exception;
79 /* signal_handler_sigfpe *******************************************************
81 ArithmeticException signal handler for hardware divide by zero check.
83 *******************************************************************************/
85 void signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
93 _uc = (ucontext_t *) _p;
94 _mc = &_uc->uc_mcontext;
96 sp = (u1 *) _mc->gregs[REG_ESP];
97 xpc = (u1 *) _mc->gregs[REG_EIP];
98 ra = xpc; /* return address is equal to xpc */
100 _mc->gregs[REG_EAX] =
101 (ptrint) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
103 _mc->gregs[REG_ECX] = (ptrint) xpc; /* REG_ITMP2_XPC */
104 _mc->gregs[REG_EIP] = (ptrint) asm_handle_exception;
108 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
109 void thread_restartcriticalsection(ucontext_t *uc)
113 critical = thread_checkcritical((void *) uc->uc_mcontext.gregs[REG_EIP]);
116 uc->uc_mcontext.gregs[REG_EIP] = (ptrint) critical;
122 * These are local overrides for various environment variables in Emacs.
123 * Please do not remove this and leave it at the end of the file, where
124 * Emacs will automagically detect them.
125 * ---------------------------------------------------------------------
128 * indent-tabs-mode: t