1 /* From linux kernle source code */
9 * Kernel pointers have redundant information, so we can use a
10 * scheme where we can return either an error code or a dentry
11 * pointer with the same return value.
13 * This should be a per-architecture thing, to allow different
14 * error and pointer decisions.
16 #define MAX_ERRNO 4095
19 #define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
21 static inline void *ERR_PTR(long error
)
23 return (void *) error
;
26 static inline long PTR_ERR(const void *ptr
)
31 static inline long IS_ERR(const void *ptr
)
33 return IS_ERR_VALUE((unsigned long)ptr
);
36 static inline long IS_ERR_OR_NULL(const void *ptr
)
38 return !ptr
|| IS_ERR_VALUE((unsigned long)ptr
);
42 * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type
43 * @ptr: The pointer to cast.
45 * Explicitly cast an error-valued pointer to another pointer type in such a
46 * way as to make it clear that's what's going on.
48 static inline void *ERR_CAST(const void *ptr
)
50 /* cast away the const */
55 #endif /* _LINUX_ERR_H */