err.h 525 B

1234567891011121314151617181920212223242526
  1. #ifndef ERR_H
  2. #define ERR_H
  3. #define MAX_ERRNO 4095
  4. #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
  5. static inline void * __must_check ERR_PTR(long error)
  6. {
  7. return (void *) error;
  8. }
  9. static inline long __must_check PTR_ERR(const void *ptr)
  10. {
  11. return (long) ptr;
  12. }
  13. static inline long __must_check IS_ERR(const void *ptr)
  14. {
  15. return IS_ERR_VALUE((unsigned long)ptr);
  16. }
  17. static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
  18. {
  19. return !ptr || IS_ERR_VALUE((unsigned long)ptr);
  20. }
  21. #endif /* ERR_H */