err.h 683 B

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