Blame view
include/linux/err.h
1.23 KB
1da177e4c
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#ifndef _LINUX_ERR_H #define _LINUX_ERR_H #include <linux/compiler.h> #include <asm/errno.h> /* * Kernel pointers have redundant information, so we can use a * scheme where we can return either an error code or a dentry * pointer with the same return value. * * This should be a per-architecture thing, to allow different * error and pointer decisions. */ |
fa79837d5
|
16 |
#define MAX_ERRNO 4095 |
ebba5f9fc
|
17 |
#ifndef __ASSEMBLY__ |
fa79837d5
|
18 |
#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) |
07ab67c8d
|
19 |
|
e47103b1a
|
20 |
static inline void * __must_check ERR_PTR(long error) |
1da177e4c
|
21 22 23 |
{ return (void *) error; } |
e47103b1a
|
24 |
static inline long __must_check PTR_ERR(const void *ptr) |
1da177e4c
|
25 26 27 |
{ return (long) ptr; } |
e47103b1a
|
28 |
static inline long __must_check IS_ERR(const void *ptr) |
1da177e4c
|
29 |
{ |
07ab67c8d
|
30 |
return IS_ERR_VALUE((unsigned long)ptr); |
1da177e4c
|
31 |
} |
e47103b1a
|
32 |
static inline long __must_check IS_ERR_OR_NULL(const void *ptr) |
603c4ba96
|
33 34 35 |
{ return !ptr || IS_ERR_VALUE((unsigned long)ptr); } |
d1bc8e954
|
36 37 38 39 40 41 42 |
/** * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type * @ptr: The pointer to cast. * * Explicitly cast an error-valued pointer to another pointer type in such a * way as to make it clear that's what's going on. */ |
e47103b1a
|
43 |
static inline void * __must_check ERR_CAST(const void *ptr) |
d1bc8e954
|
44 45 46 47 |
{ /* cast away the const */ return (void *) ptr; } |
ebba5f9fc
|
48 |
#endif |
1da177e4c
|
49 |
#endif /* _LINUX_ERR_H */ |