error.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // POSIX-specific error handling and diagnostic utilities
  2. //
  3. // Platform: ISO C++ 98/11 - POSIX
  4. // $Id$
  5. //
  6. // (c) __vic 2013
  7. #ifndef __VIC_POSIX_ERROR_H
  8. #define __VIC_POSIX_ERROR_H
  9. #include<__vic/defs.h>
  10. #include<cerrno>
  11. namespace __vic { namespace posix {
  12. #if defined(ESTALE) && ESTALE != ENOENT
  13. // ESTALE - Stale NFS file handle
  14. #define __VIC_CASE_ENOENT case ENOENT: case ESTALE:
  15. #else
  16. #define __VIC_CASE_ENOENT case ENOENT:
  17. #endif
  18. #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
  19. #define __VIC_CASE_EAGAIN case EAGAIN: case EWOULDBLOCK:
  20. #else
  21. #define __VIC_CASE_EAGAIN case EAGAIN:
  22. #endif
  23. //----------------------------------------------------------------------------
  24. inline bool is_ENOENT(int err_no)
  25. {
  26. switch(err_no) { __VIC_CASE_ENOENT return true; }
  27. return false;
  28. }
  29. //----------------------------------------------------------------------------
  30. inline bool is_EAGAIN(int err_no)
  31. {
  32. switch(err_no) { __VIC_CASE_EAGAIN return true; }
  33. return false;
  34. }
  35. //----------------------------------------------------------------------------
  36. }} // namespace
  37. #endif // header guard