xref: /linux/tools/testing/selftests/bpf/progs/err.h (revision 84b9b44b)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ERR_H__
3 #define __ERR_H__
4 
5 #define MAX_ERRNO 4095
6 #define IS_ERR_VALUE(x) (unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO
7 
8 static inline int IS_ERR_OR_NULL(const void *ptr)
9 {
10 	return !ptr || IS_ERR_VALUE((unsigned long)ptr);
11 }
12 
13 static inline long PTR_ERR(const void *ptr)
14 {
15 	return (long) ptr;
16 }
17 
18 #endif /* __ERR_H__ */
19