summaryrefslogtreecommitdiffstats
path: root/headers/linux/err.h
diff options
context:
space:
mode:
Diffstat (limited to 'headers/linux/err.h')
-rw-r--r--headers/linux/err.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/headers/linux/err.h b/headers/linux/err.h
new file mode 100644
index 0000000..586a5dc
--- /dev/null
+++ b/headers/linux/err.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
+
+#ifndef __LINUX_ERR_H
+#define __LINUX_ERR_H
+
+#include <stdbool.h>
+#include <linux/types.h>
+#include <asm/errno.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_;
+}
+
+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