Debian Codegraph @

include/linux/err.h

raw
1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
2
3 #ifndef __LINUX_ERR_H
4 #define __LINUX_ERR_H
5
6 #include <linux/types.h>
7 #include <asm/errno.h>
8
9 #define MAX_ERRNO 4095
10
11 #define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
12
13 static inline void * ERR_PTR(long error_)
14 {
15 return (void *) error_;
16 }
17
18 static inline long PTR_ERR(const void *ptr)
19 {
20 return (long) ptr;
21 }
22
23 static inline bool IS_ERR(const void *ptr)
24 {
25 return IS_ERR_VALUE((unsigned long)ptr);
26 }
27
28 static inline bool IS_ERR_OR_NULL(const void *ptr)
29 {
30 return (!ptr) || IS_ERR_VALUE((unsigned long)ptr);
31 }
32
33 static inline long PTR_ERR_OR_ZERO(const void *ptr)
34 {
35 return IS_ERR(ptr) ? PTR_ERR(ptr) : 0;
36 }
37
38 #endif