1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * erofs-utils/include/erofs/err.h 4 * 5 * Copyright (C) 2018 HUAWEI, Inc. 6 * http://www.huawei.com/ 7 * Created by Li Guifu <bluce.liguifu@huawei.com> 8 */ 9 #ifndef __EROFS_ERR_H 10 #define __EROFS_ERR_H 11 12 #include <errno.h> 13 14 #define MAX_ERRNO (4095) 15 #define IS_ERR_VALUE(x) \ 16 ((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO) 17 ERR_PTR(long error)18static inline void *ERR_PTR(long error) 19 { 20 return (void *)error; 21 } 22 IS_ERR(const void * ptr)23static inline int IS_ERR(const void *ptr) 24 { 25 return IS_ERR_VALUE((unsigned long)ptr); 26 } 27 PTR_ERR(const void * ptr)28static inline long PTR_ERR(const void *ptr) 29 { 30 return (long) ptr; 31 } 32 33 #endif 34 35