unix.h 974 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Part of Scheme 48 1.9. See file COPYING for notices and license.
  3. *
  4. * Authors: Richard Kelsey, Jonathan Rees, Mike Sperber
  5. */
  6. /*
  7. * Macros for retrying interrupted system calls. RETURN_NULL
  8. */
  9. #define RETRY_NULL(STATUS, CALL) \
  10. do { \
  11. STATUS = (CALL); \
  12. } while ((STATUS == NULL) && (errno == EINTR))
  13. #define RETRY_NEG(STATUS, CALL) \
  14. do { \
  15. STATUS = (CALL); \
  16. } while ((STATUS < 0) && (errno == EINTR))
  17. #define RETRY_OR_RAISE_NULL(STATUS, CALL) \
  18. do { \
  19. while (1) { \
  20. STATUS = (CALL); \
  21. if (STATUS != NULL) \
  22. break; \
  23. else if (errno != EINTR) \
  24. s48_os_error_2(call, NULL, errno, 0); } \
  25. } while (0)
  26. #define RETRY_OR_RAISE_NEG(STATUS, CALL) \
  27. do { \
  28. while (1) { \
  29. STATUS = (CALL); \
  30. if (STATUS >= 0) \
  31. break; \
  32. else if (errno != EINTR) \
  33. s48_os_error_2(call, NULL, errno, 0); } \
  34. } while (0)