add a simple Makefile to build and clean up

add missing macros, static inline functions, etc.
add README to illustrate the purpose of this repo.

Signed-off-by: Yonghong Song <yhs@fb.com>
This commit is contained in:
Yonghong Song
2018-10-09 21:45:49 -07:00
parent 66684189f0
commit 8acf2635c3
8 changed files with 189 additions and 150 deletions

View File

@@ -3,9 +3,30 @@
#ifndef __LINUX_ERR_H
#define __LINUX_ERR_H
#include <linux/types.h>
#define MAX_ERRNO 4095
#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
static inline void * ERR_PTR(long error_)
{
return (void *) error_;
return (void *) error_;
}
static inline long PTR_ERR(const void *ptr)
{
return (long) ptr;
}
static inline bool IS_ERR(const void *ptr)
{
return IS_ERR_VALUE((unsigned long)ptr);
}
static inline bool IS_ERR_OR_NULL(const void *ptr)
{
return (!ptr) || IS_ERR_VALUE((unsigned long)ptr);
}
#endif