1 /* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */ 2 /* 3 * Copyright (C) 2018 HUAWEI, Inc. 4 * http://www.huawei.com/ 5 * Created by Li Guifu <[email protected]> 6 */ 7 #ifndef __EROFS_ERR_H 8 #define __EROFS_ERR_H 9 10 #ifdef __cplusplus 11 extern "C" 12 { 13 #endif 14 15 #include <errno.h> 16 17 #define MAX_ERRNO (4095) 18 #define IS_ERR_VALUE(x) \ 19 ((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO) 20 ERR_PTR(long error)21static inline void *ERR_PTR(long error) 22 { 23 return (void *)error; 24 } 25 IS_ERR(const void * ptr)26static inline int IS_ERR(const void *ptr) 27 { 28 return IS_ERR_VALUE((unsigned long)ptr); 29 } 30 PTR_ERR(const void * ptr)31static inline long PTR_ERR(const void *ptr) 32 { 33 return (long) ptr; 34 } 35 ERR_CAST(const void * ptr)36static inline void * ERR_CAST(const void *ptr) 37 { 38 /* cast away the const */ 39 return (void *) ptr; 40 } 41 42 #ifdef __cplusplus 43 } 44 #endif 45 46 #endif 47