]> gitweb.factorcode.org Git - factor.git/blob - vm/mach_signal.h
0dbcc09f33ca49520e17614c29cd65ac3f45122b
[factor.git] / vm / mach_signal.h
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
4 #include <signal.h>
5
6 #include <mach/mach.h>
7 #include <mach/mach_error.h>
8 #include <mach/thread_status.h>
9 #include <mach/exception.h>
10 #include <mach/task.h>
11 #include <pthread.h>
12
13 /* For MacOSX.  */
14 #ifndef SS_DISABLE
15 #define SS_DISABLE SA_DISABLE
16 #endif
17
18 /* This is not defined in any header, although documented.  */
19
20 /* http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/exc_server.html says:
21    The exc_server function is the MIG generated server handling function
22    to handle messages from the kernel relating to the occurrence of an
23    exception in a thread. Such messages are delivered to the exception port
24    set via thread_set_exception_ports or task_set_exception_ports. When an
25    exception occurs in a thread, the thread sends an exception message to its
26    exception port, blocking in the kernel waiting for the receipt of a reply.
27    The exc_server function performs all necessary argument handling for this
28    kernel message and calls catch_exception_raise, catch_exception_raise_state
29    or catch_exception_raise_state_identity, which should handle the exception.
30    If the called routine returns KERN_SUCCESS, a reply message will be sent,
31    allowing the thread to continue from the point of the exception; otherwise,
32    no reply message is sent and the called routine must have dealt with the
33    exception thread directly.  */
34 extern boolean_t
35        exc_server (mach_msg_header_t *request_msg,
36                    mach_msg_header_t *reply_msg);
37
38
39 /* http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/catch_exception_raise.html
40    These functions are defined in this file, and called by exc_server.
41    FIXME: What needs to be done when this code is put into a shared library? */
42 kern_return_t
43 catch_exception_raise (mach_port_t exception_port,
44                        mach_port_t thread,
45                        mach_port_t task,
46                        exception_type_t exception,
47                        exception_data_t code,
48                        mach_msg_type_number_t code_count);
49 kern_return_t
50 catch_exception_raise_state (mach_port_t exception_port,
51                              exception_type_t exception,
52                              exception_data_t code,
53                              mach_msg_type_number_t code_count,
54                              thread_state_flavor_t *flavor,
55                              thread_state_t in_state,
56                              mach_msg_type_number_t in_state_count,
57                              thread_state_t out_state,
58                              mach_msg_type_number_t *out_state_count);
59 kern_return_t
60 catch_exception_raise_state_identity (mach_port_t exception_port,
61                                       mach_port_t thread,
62                                       mach_port_t task,
63                                       exception_type_t exception,
64                                       exception_data_t code,
65                                       mach_msg_type_number_t codeCnt,
66                                       thread_state_flavor_t *flavor,
67                                       thread_state_t in_state,
68                                       mach_msg_type_number_t in_state_count,
69                                       thread_state_t out_state,
70                                       mach_msg_type_number_t *out_state_count);
71
72 int mach_initialize ();