hurdfault.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Declarations for handling faults in the signal thread.
  2. Copyright (C) 1994-2019 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. <http://www.gnu.org/licenses/>. */
  15. #ifndef _HURD_FAULT_H
  16. #define _HURD_FAULT_H
  17. #include <hurd/sigpreempt.h>
  18. #include <setjmp.h>
  19. /* Call this before code that might fault in the signal thread; SIGNO is
  20. the signal expected to possibly arrive. This behaves like setjmp: it
  21. returns zero the first time, and returns again nonzero if the signal
  22. does arrive. */
  23. #define _hurdsig_catch_fault(sigset, firstcode, lastcode) \
  24. (_hurdsig_fault_preemptor.signals = (sigset), \
  25. _hurdsig_fault_preemptor.first = (long int) (firstcode), \
  26. _hurdsig_fault_preemptor.last = (long int) (lastcode), \
  27. setjmp (_hurdsig_fault_env))
  28. /* Call this at the end of a section protected by _hurdsig_catch_fault. */
  29. #define _hurdsig_end_catch_fault() \
  30. (_hurdsig_fault_preemptor.signals = 0)
  31. extern jmp_buf _hurdsig_fault_env;
  32. extern struct hurd_signal_preemptor _hurdsig_fault_preemptor;
  33. #define _hurdsig_catch_memory_fault(object) \
  34. _hurdsig_catch_fault (sigmask (SIGSEGV) | sigmask (SIGBUS), \
  35. (object), (object) + 1)
  36. #endif /* hurdfault.h */