brintos

brintos / linux-shallow public Read only

0
0
Text · 592 B · 3852977 Raw
29 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#ifndef __ERR_H__3#define __ERR_H__4 5#define MAX_ERRNO 40956#define IS_ERR_VALUE(x) (unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO7 8#define __STR(x) #x9 10#define set_if_not_errno_or_zero(x, y)			\11({							\12	asm volatile ("if %0 s< -4095 goto +1\n"	\13		      "if %0 s<= 0 goto +1\n"		\14		      "%0 = " __STR(y) "\n"		\15		      : "+r"(x));			\16})17 18static inline int IS_ERR_OR_NULL(const void *ptr)19{20	return !ptr || IS_ERR_VALUE((unsigned long)ptr);21}22 23static inline long PTR_ERR(const void *ptr)24{25	return (long) ptr;26}27 28#endif /* __ERR_H__ */29