exc2signal.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Translate Mach exception codes into signal numbers. Stub version.
  2. Copyright (C) 1991-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include <hurd.h>
  16. #include <hurd/signal.h>
  17. /* This file must be modified with machine-dependent details. */
  18. #error "need to write sysdeps/mach/hurd/MACHINE/exc2signal.c"
  19. /* Translate the Mach exception codes, as received in an `exception_raise' RPC,
  20. into a signal number and signal subcode. */
  21. void
  22. _hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
  23. {
  24. detail->error = 0;
  25. switch (detail->exc)
  26. {
  27. default:
  28. *signo = SIGIOT;
  29. detail->code = detail->exc;
  30. break;
  31. case EXC_BAD_ACCESS:
  32. if (detail->exc_code == KERN_PROTECTION_FAILURE)
  33. *signo = SIGSEGV;
  34. else
  35. *signo = SIGBUS;
  36. detail->code = detail->exc_subcode;
  37. detail->error = detail->exc_code;
  38. break;
  39. case EXC_BAD_INSTRUCTION:
  40. *signo = SIGILL;
  41. detail->code = 0;
  42. break;
  43. case EXC_ARITHMETIC:
  44. *signo = SIGFPE;
  45. detail->code = 0;
  46. break;
  47. case EXC_EMULATION:
  48. case EXC_SOFTWARE:
  49. *signo = SIGEMT;
  50. detail->code = 0;
  51. break;
  52. case EXC_BREAKPOINT:
  53. *signo = SIGTRAP;
  54. detail->code = 0;
  55. break;
  56. }
  57. }
  58. libc_hidden_def (_hurd_exception2signal)