err.h 712 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef _LINUX_ERR_H
  2. #define _LINUX_ERR_H
  3. #include <linux/compiler.h>
  4. #include <asm/errno.h>
  5. /*
  6. * Kernel pointers have redundant information, so we can use a
  7. * scheme where we can return either an error code or a dentry
  8. * pointer with the same return value.
  9. *
  10. * This should be a per-architecture thing, to allow different
  11. * error and pointer decisions.
  12. */
  13. #define MAX_ERRNO 4095
  14. #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
  15. static inline void *ERR_PTR(long error)
  16. {
  17. return (void *) error;
  18. }
  19. static inline long PTR_ERR(const void *ptr)
  20. {
  21. return (long) ptr;
  22. }
  23. static inline long IS_ERR(const void *ptr)
  24. {
  25. return IS_ERR_VALUE((unsigned long)ptr);
  26. }
  27. #endif /* _LINUX_ERR_H */