* src/vm/jit/trap.cpp (trap_handle): Further generalized trap handling and
[cacao.git] / src / vm / jit / trap.hpp
1 /* src/vm/jit/trap.hpp - hardware traps
2
3    Copyright (C) 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5    Copyright (C) 2009 Theobroma Systems Ltd.
6
7    This file is part of CACAO.
8
9    This program is free software; you can redistribute it and/or
10    modify it under the terms of the GNU General Public License as
11    published by the Free Software Foundation; either version 2, or (at
12    your option) any later version.
13
14    This program is distributed in the hope that it will be useful, but
15    WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22    02110-1301, USA.
23
24 */
25
26
27 #ifndef _TRAP_HPP
28 #define _TRAP_HPP
29
30 #include "config.h"
31
32 #include <stdint.h>
33
34 #include "vm/options.h"
35
36 #include "vm/jit/executionstate.h"
37
38
39 /**
40  * Contains information about a decoded trap instruction.
41  */
42 typedef struct trapinfo_t {
43         int      type;   ///< Specific trap type (see md-trap.h).
44         intptr_t value;  ///< Value (numeric or address) passed with the trap.
45 } trapinfo_t;
46
47
48 /**
49  * Trap signal number defines. Use these instead of the signal
50  * numbers provided by your specific OS.
51  */
52 enum {
53         TRAP_SIGRESERVED = 0,
54         TRAP_SIGSEGV     = 1,
55         TRAP_SIGILL      = 2,
56         TRAP_SIGTRAP     = 3,
57         TRAP_SIGFPE      = 4,
58         TRAP_SIGEND
59 };
60
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66 /* Include machine dependent trap stuff. */
67
68 #include "md-trap.h"
69
70
71 /* function prototypes ********************************************************/
72
73 void trap_init(void);
74 void trap_handle(int sig, void* xpc, void* context);
75
76 bool md_trap_decode(trapinfo_t* trp, int sig, void* xpc, executionstate_t* es);
77
78 #ifdef __cplusplus
79 }
80 #endif
81
82 #endif /* _TRAP_HPP */
83
84
85 /*
86  * These are local overrides for various environment variables in Emacs.
87  * Please do not remove this and leave it at the end of the file, where
88  * Emacs will automagically detect them.
89  * ---------------------------------------------------------------------
90  * Local variables:
91  * mode: c++
92  * indent-tabs-mode: t
93  * c-basic-offset: 4
94  * tab-width: 4
95  * End:
96  * vim:noexpandtab:sw=4:ts=4:
97  */