Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1213894
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 01/11] tools: Add err.h with ERR_PTR PTR_ERR interface |
| Date | 2015-08-26 15:50 +0200 |
| Message-ID | <q1Jft-7l6-39@gated-at.bofh.it> (permalink) |
| References | <q1Jfs-7l6-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Adding part of the kernel's <linux/err.h> interface:
inline void * __must_check ERR_PTR(long error);
inline long __must_check PTR_ERR(__force const void *ptr);
inline bool __must_check IS_ERR(__force const void *ptr);
it will be used to propagate error through pointers
in following patches.
Link: http://lkml.kernel.org/n/tip-ufgnyf683uab69anmmrabgdf@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/include/linux/err.h | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 tools/include/linux/err.h
diff --git a/tools/include/linux/err.h b/tools/include/linux/err.h
new file mode 100644
index 000000000000..2df92df55cfe
--- /dev/null
+++ b/tools/include/linux/err.h
@@ -0,0 +1,28 @@
+#ifndef __TOOLS_LINUX_ERR_H
+#define __TOOLS_LINUX_ERR_H
+
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+#include <asm/errno.h>
+
+#define MAX_ERRNO 4095
+
+#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
+
+static inline void * __must_check ERR_PTR(long error)
+{
+ return (void *) error;
+}
+
+static inline long __must_check PTR_ERR(__force const void *ptr)
+{
+ return (long) ptr;
+}
+
+static inline bool __must_check IS_ERR(__force const void *ptr)
+{
+ return IS_ERR_VALUE((unsigned long)ptr);
+}
+
+#endif /* _LINUX_ERR_H */
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH 01/11] tools: Add err.h with ERR_PTR PTR_ERR interface Jiri Olsa <jolsa@kernel.org> - 2015-08-26 15:50 +0200
Re: [PATCH 01/11] tools: Add err.h with ERR_PTR PTR_ERR interface Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-28 18:30 +0200
Re: [PATCH 01/11] tools: Add err.h with ERR_PTR PTR_ERR interface Jiri Olsa <jolsa@redhat.com> - 2015-08-31 09:40 +0200
Re: [PATCH 01/11] tools: Add err.h with ERR_PTR PTR_ERR interface Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-31 17:30 +0200
csiph-web