source: release/1.9/source/lisp-kernel/x86-exceptions.h @ 16083

Last change on this file since 16083 was 15470, checked in by gb, 7 years ago

Try to minimize Mach dependencies on Darwin; in particular, use POSIX
signal handling to handle exceptions (as is done on other *nix platforms.)

Use sigaltstack() on Darwin; it still seems to have problems, but at least
doesn't (usually) try to force all threads to use the same alt stack. (That
just never gets old somehow ...)

Lots of stuff removed; lots of (mostly small, mostly obvious) changes to
support the above.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/*
2   Copyright (C) 2005-2009 Clozure Associates
3   This file is part of Clozure CL. 
4
5   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
6   License , known as the LLGPL and distributed with Clozure CL as the
7   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
8   which is distributed with Clozure CL as the file "LGPL".  Where these
9   conflict, the preamble takes precedence. 
10
11   Clozure CL is referenced in the preamble as the "LIBRARY."
12
13   The LLGPL is also available online at
14   http://opensource.franz.com/preamble.html
15*/
16
17#ifndef X86_EXCEPTIONS_H
18#define X86_EXCEPTIONS_H 1
19
20typedef u8_t opcode, *pc;
21
22void switch_to_foreign_stack(void*, ...);
23
24#define INTN_OPCODE 0xcd
25
26#define UUO_GC_TRAP    0xc4
27#define UUO_ALLOC_TRAP 0xc5
28#define UUO_DEBUG_TRAP 0xca
29#define UUO_DEBUG_TRAP_WITH_STRING 0xcd
30#define UUO_WATCH_TRAP 0xce
31  #define WATCH_TRAP_FUNCTION_WATCH 0
32  #define WATCH_TRAP_FUNCTION_UNWATCH 1
33
34#define XUUO_OPCODE_0 0x0f
35#define XUUO_OPCODE_1 0x0b
36
37#define XUUO_TLB_TOO_SMALL 1
38#define XUUO_INTERRUPT_NOW 2
39#define XUUO_SUSPEND_NOW 3
40#define XUUO_INTERRUPT 4
41#define XUUO_SUSPEND 5
42#define XUUO_SUSPEND_ALL 6
43#define XUUO_RESUME 7
44#define XUUO_RESUME_ALL 8
45#define XUUO_KILL 9
46#define XUUO_ALLOCATE_LIST 10
47
48int callback_to_lisp (TCR *tcr, LispObj callback_macptr, ExceptionInformation *xp,
49                      natural arg1, natural arg2, natural arg3, natural arg4,
50                      natural arg5);
51
52
53void
54pc_luser_xp(ExceptionInformation*, TCR*, signed_natural*);
55
56
57typedef enum {
58  ID_unrecognized_alloc_instruction,
59  ID_load_allocptr_reg_from_tcr_save_allocptr_instruction,
60  ID_compare_allocptr_reg_to_tcr_save_allocbase_instruction,
61  ID_branch_around_alloc_trap_instruction,
62  ID_alloc_trap_instruction,
63  ID_set_allocptr_header_instruction,
64  ID_clear_tcr_save_allocptr_tag_instruction
65} alloc_instruction_id;
66
67/* sigaltstack isn't thread-specific on The World's Most Advanced OS */
68#ifdef WINDOWS
69#undef USE_SIGALTSTACK
70#else
71#define USE_SIGALTSTACK 1
72#endif
73
74#ifdef USE_SIGALTSTACK
75void setup_sigaltstack(area *);
76#ifdef DARWIN
77/* Apple's sigaltstack mechanism is still broken; a thread is considered
78to be running on the alternate signal stack until a signal handler called
79on the altstack returns.  (OSX is too advanced to look at the damned
80stack pointer ...)  We can reset a thread's notion of whether or not it's
81on the altstack by calling sigreturn with a second argument of #x80000000
82(the first argument is ignored in this case.)
83
84This is supported thru 10.8.1; hopefully, it'll be ignored if Apple ever
85fixes their sigaltstack implementation.
86
87Recall that in 10.4 and earlier, Apple's sigaltstack implementation tried
88to make all threads use the same alternate stack (whatever one was most
89recently specified in a call to sigaltstack()), so this nonsense is actually
90a step forward.  A sysctl was supported thru 10.6.8 (at least) to revert
91to this behavior, which was presumably useful to people who wanted to see
92what would happen if multiple threads ran signal handlers on the same stack
93at the same time.
94
95(Whenever I rant about this sort of thing, I feel like a political satirist
96during the Bush administration: every day new material is written for you,
97and it's much better than anything that you could invent yourself.)
98*/
99#define ResetAltStack() darwin_sigreturn(NULL, 0x80000000)
100#endif
101#endif
102
103#ifndef ResetAltStack
104#define ResetAltStack()
105#endif
106
107extern natural get_mxcsr();
108extern void set_mxcsr(natural);
109void enable_fp_exceptions(void);
110
111void callback_for_gc_notification(ExceptionInformation *xp, TCR *tcr);
112
113
114
115#endif /* X86_EXCEPTIONS_H */
116
Note: See TracBrowser for help on using the repository browser.