err.h 640 B

12345678910111213141516171819202122232425262728293031
  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. static inline void *ERR_PTR(long error)
  14. {
  15. return (void *) error;
  16. }
  17. static inline long PTR_ERR(const void *ptr)
  18. {
  19. return (long) ptr;
  20. }
  21. static inline long IS_ERR(const void *ptr)
  22. {
  23. return unlikely((unsigned long)ptr > (unsigned long)-1000L);
  24. }
  25. #endif /* _LINUX_ERR_H */