0001
0002 #ifndef ERR_H
0003 #define ERR_H
0004 #define MAX_ERRNO 4095
0005
0006 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
0007
0008 static inline void * __must_check ERR_PTR(long error)
0009 {
0010 return (void *) error;
0011 }
0012
0013 static inline long __must_check PTR_ERR(const void *ptr)
0014 {
0015 return (long) ptr;
0016 }
0017
0018 static inline long __must_check IS_ERR(const void *ptr)
0019 {
0020 return IS_ERR_VALUE((unsigned long)ptr);
0021 }
0022
0023 static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
0024 {
0025 return !ptr || IS_ERR_VALUE((unsigned long)ptr);
0026 }
0027 #endif