diff options
Diffstat (limited to 'tools/virtio/linux/err.h')
-rw-r--r-- | tools/virtio/linux/err.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/virtio/linux/err.h b/tools/virtio/linux/err.h new file mode 100644 index 000000000000..e32eff8b2a14 --- /dev/null +++ b/tools/virtio/linux/err.h | |||
@@ -0,0 +1,26 @@ | |||
1 | #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 | |||
7 | static inline void * __must_check ERR_PTR(long error) | ||
8 | { | ||
9 | return (void *) error; | ||
10 | } | ||
11 | |||
12 | static inline long __must_check PTR_ERR(const void *ptr) | ||
13 | { | ||
14 | return (long) ptr; | ||
15 | } | ||
16 | |||
17 | static inline long __must_check IS_ERR(const void *ptr) | ||
18 | { | ||
19 | return IS_ERR_VALUE((unsigned long)ptr); | ||
20 | } | ||
21 | |||
22 | static 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 */ | ||