PageRenderTime 48ms CodeModel.GetById 39ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/vm/mach_signal.hpp

http://github.com/abeaumont/factor
C++ Header | 83 lines | 47 code | 8 blank | 28 comment | 0 complexity | 95665244b2391b3067c5604ebd0df4da MD5 | raw file
 1/* Fault handler information.  MacOSX version.
 2Copyright (C) 1993-1999, 2002-2003  Bruno Haible <clisp.org at bruno>
 3Copyright (C) 2003  Paolo Bonzini <gnu.org at bonzini>
 4
 5Used under BSD license with permission from Paolo Bonzini and Bruno Haible,
 62005-03-10:
 7
 8http://sourceforge.net/mailarchive/message.php?msg_name=200503102200.32002.bruno%40clisp.org
 9
10Modified for Factor by Slava Pestov */
11#include <stdio.h>
12#include <stdlib.h>
13#include <errno.h>
14#include <signal.h>
15
16#include <mach/mach.h>
17#include <mach/mach_error.h>
18#include <mach/thread_status.h>
19#include <mach/exception.h>
20#include <mach/task.h>
21#include <pthread.h>
22
23/* This is not defined in any header, although documented.  */
24
25/* http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/exc_server.html says:
26   The exc_server function is the MIG generated server handling function
27   to handle messages from the kernel relating to the occurrence of an
28   exception in a thread. Such messages are delivered to the exception port
29   set via thread_set_exception_ports or task_set_exception_ports. When an
30   exception occurs in a thread, the thread sends an exception message to its
31   exception port, blocking in the kernel waiting for the receipt of a reply.
32   The exc_server function performs all necessary argument handling for this
33   kernel message and calls catch_exception_raise, catch_exception_raise_state
34   or catch_exception_raise_state_identity, which should handle the exception.
35   If the called routine returns KERN_SUCCESS, a reply message will be sent,
36   allowing the thread to continue from the point of the exception; otherwise,
37   no reply message is sent and the called routine must have dealt with the
38   exception thread directly.  */
39extern "C" boolean_t exc_server (mach_msg_header_t *request_msg, mach_msg_header_t *reply_msg);
40
41/* http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/catch_exception_raise.html
42   These functions are defined in this file, and called by exc_server.
43   FIXME: What needs to be done when this code is put into a shared library? */
44extern "C"
45kern_return_t
46catch_exception_raise (mach_port_t exception_port,
47		       mach_port_t thread,
48		       mach_port_t task,
49		       exception_type_t exception,
50		       exception_data_t code,
51		       mach_msg_type_number_t code_count);
52extern "C"
53kern_return_t
54catch_exception_raise_state (mach_port_t exception_port,
55			     exception_type_t exception,
56			     exception_data_t code,
57			     mach_msg_type_number_t code_count,
58			     thread_state_flavor_t *flavor,
59			     thread_state_t in_state,
60			     mach_msg_type_number_t in_state_count,
61			     thread_state_t out_state,
62			     mach_msg_type_number_t *out_state_count);
63
64extern "C"
65kern_return_t
66catch_exception_raise_state_identity (mach_port_t exception_port,
67				      mach_port_t thread,
68				      mach_port_t task,
69				      exception_type_t exception,
70				      exception_data_t code,
71				      mach_msg_type_number_t codeCnt,
72				      thread_state_flavor_t *flavor,
73				      thread_state_t in_state,
74				      mach_msg_type_number_t in_state_count,
75				      thread_state_t out_state,
76				      mach_msg_type_number_t *out_state_count);
77
78namespace factor
79{
80
81void mach_initialize ();
82
83}