pal_freebsd_error.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef PAL_FREEBSD_ERROR_H
  2. #define PAL_FREEBSD_ERROR_H
  3. #ifdef IN_PAL
  4. #include <errno.h>
  5. #include <pal_error.h>
  6. static inline __attribute__((unused)) int unix_to_pal_error(int unix_errno) {
  7. switch (unix_errno) {
  8. case ENOENT:
  9. return -PAL_ERROR_STREAMNOTEXIST;
  10. case EINTR:
  11. return -PAL_ERROR_INTERRUPTED;
  12. case EBADF:
  13. return -PAL_ERROR_BADHANDLE;
  14. case ETIMEDOUT:
  15. case EAGAIN:
  16. return -PAL_ERROR_TRYAGAIN;
  17. case ENOMEM:
  18. return -PAL_ERROR_NOMEM;
  19. case EFAULT:
  20. return -PAL_ERROR_BADADDR;
  21. case EEXIST:
  22. return -PAL_ERROR_STREAMEXIST;
  23. case ENOTDIR:
  24. return -PAL_ERROR_STREAMISFILE;
  25. case EINVAL:
  26. return -PAL_ERROR_INVAL;
  27. case ENAMETOOLONG:
  28. return -PAL_ERROR_TOOLONG;
  29. case EISDIR:
  30. return -PAL_ERROR_STREAMISDIR;
  31. default:
  32. return -PAL_ERROR_DENIED;
  33. }
  34. }
  35. #define ERESTART (-1) /* restart syscall */
  36. #endif /* IN_PAL */
  37. #endif /* PAL_FREEBSD_ERROR_H */