sh-signal.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // sh-signal.h - Catch runtime signals and turn them into exceptions
  2. // on a SuperH based Linux system.
  3. /* Copyright (C) 2004, 2006 Free Software Foundation
  4. This file is part of libgcj.
  5. This software is copyrighted work licensed under the terms of the
  6. Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
  7. details. */
  8. #ifndef JAVA_SIGNAL_H
  9. #define JAVA_SIGNAL_H 1
  10. #include <signal.h>
  11. #include <sys/syscall.h>
  12. #define HANDLE_SEGV 1
  13. #define HANDLE_FPE 1
  14. /* The third parameter to the signal handler points to something with
  15. * this structure defined in asm/ucontext.h, but the name clashes with
  16. * struct ucontext from sys/ucontext.h so this private copy is used. */
  17. typedef struct _sig_ucontext {
  18. unsigned long uc_flags;
  19. struct _sig_ucontext *uc_link;
  20. stack_t uc_stack;
  21. struct sigcontext uc_mcontext;
  22. sigset_t uc_sigmask;
  23. } sig_ucontext_t;
  24. #define SIGNAL_HANDLER(_name) \
  25. static void _name (int , siginfo_t *, sig_ucontext_t *_uc)
  26. #define MAKE_THROW_FRAME(_exception)
  27. /* For an explanation why we cannot simply use sigaction to
  28. install the handlers, see i386-signal.h. */
  29. /* We use kernel_old_sigaction here because we're calling the kernel
  30. directly rather than via glibc. The sigaction structure that the
  31. syscall uses is a different shape from the one in userland and not
  32. visible to us in a header file so we define it here. */
  33. struct kernel_old_sigaction {
  34. void (*k_sa_handler) (int, siginfo_t *, sig_ucontext_t *);
  35. unsigned long k_sa_mask;
  36. unsigned long k_sa_flags;
  37. void (*k_sa_restorer) (void);
  38. };
  39. #define INIT_SEGV \
  40. do \
  41. { \
  42. struct kernel_old_sigaction kact; \
  43. kact.k_sa_handler = catch_segv; \
  44. kact.k_sa_mask = 0; \
  45. kact.k_sa_flags = SA_SIGINFO | SA_NODEFER; \
  46. syscall (SYS_sigaction, SIGSEGV, &kact, NULL); \
  47. } \
  48. while (0)
  49. #define INIT_FPE \
  50. do \
  51. { \
  52. struct kernel_old_sigaction kact; \
  53. kact.k_sa_handler = catch_fpe; \
  54. kact.k_sa_mask = 0; \
  55. kact.k_sa_flags = SA_SIGINFO | SA_NODEFER; \
  56. syscall (SYS_sigaction, SIGFPE, &kact, NULL); \
  57. } \
  58. while (0)
  59. #endif /* JAVA_SIGNAL_H */