posix-signal.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // posix-signal.h - Catch runtime signals and turn them into exceptions.
  2. /* Copyright (C) 1998, 1999, 2000, 2009, 2011, 2012 Free Software Foundation
  3. This file is part of libgcj.
  4. This software is copyrighted work licensed under the terms of the
  5. Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
  6. details. */
  7. #ifndef JAVA_SIGNAL_H
  8. #define JAVA_SIGNAL_H 1
  9. #include <signal.h>
  10. #define HANDLE_SEGV 1
  11. #define HANDLE_FPE 1
  12. /* Different implementations of MD_FALLBACK_FRAME_STATE_FOR either require
  13. SA_SIGINFO being set or fail if so. Cf. gcc/ada/init.c
  14. (__gnat_install_handler) for details. */
  15. #if defined __sun__ && defined __svr4__
  16. #define SA_FLAGS SA_NODEFER | SA_SIGINFO
  17. #else
  18. #error Must define SA_FLAGS.
  19. #endif
  20. #if SA_FLAGS & SA_SIGINFO
  21. #define SIGNAL_HANDLER(_name) \
  22. static void _Jv_##_name (int, \
  23. siginfo_t *_si __attribute__ ((__unused__)), \
  24. void *_uc __attribute__ ((__unused__)))
  25. #define sa_signal_handler sa_sigaction
  26. #else
  27. #define SIGNAL_HANDLER(_name) \
  28. static void _Jv_##_name (int)
  29. #define sa_signal_handler sa_handler
  30. #endif
  31. #define MAKE_THROW_FRAME(_exception)
  32. #define _INIT_SIG_HANDLER(_SIG, _ACTION) \
  33. do \
  34. { \
  35. struct sigaction act; \
  36. act.sa_signal_handler = _Jv_##_ACTION; \
  37. act.sa_flags = SA_FLAGS; \
  38. sigemptyset (&act.sa_mask); \
  39. sigaction(_SIG, &act, NULL); \
  40. } \
  41. while (0)
  42. #define INIT_SEGV _INIT_SIG_HANDLER (SIGSEGV, catch_segv)
  43. #define INIT_FPE _INIT_SIG_HANDLER (SIGFPE, catch_fpe)
  44. #endif /* JAVA_SIGNAL_H */