blob: e32eff8b2a14f9f50c2ffd654acfd413d41275c0 [file] [log] [blame]
Rusty Russell61d0b5a2013-03-18 13:22:19 +10301#ifndef ERR_H
2#define ERR_H
3#define MAX_ERRNO 4095
4
5#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
6
7static inline void * __must_check ERR_PTR(long error)
8{
9 return (void *) error;
10}
11
12static inline long __must_check PTR_ERR(const void *ptr)
13{
14 return (long) ptr;
15}
16
17static inline long __must_check IS_ERR(const void *ptr)
18{
19 return IS_ERR_VALUE((unsigned long)ptr);
20}
21
22static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
23{
24 return !ptr || IS_ERR_VALUE((unsigned long)ptr);
25}
26#endif /* ERR_H */