Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at for-next 28 lines 592 B view raw
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#define __STR(x) #x 9 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__ */