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