summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2016-12-27 15:36:01 (GMT)
committerTom Rini <trini@konsulko.com>2017-01-14 21:46:29 (GMT)
commitff90af6c73883121358251bba66245ff4da3755c (patch)
treeb529b70b7ded25b775a0affbbedbe5220872e13c /include/linux
parenta7b817699985b515b63a601b317e3e8fd413d7e9 (diff)
downloadu-boot-fsl-qoriq-ff90af6c73883121358251bba66245ff4da3755c.tar.xz
typecheck: import include/linux/typecheck.h from Linux 4.9
Copied from Linux 4.9. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/typecheck.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/linux/typecheck.h b/include/linux/typecheck.h
new file mode 100644
index 0000000..eb5b74a
--- /dev/null
+++ b/include/linux/typecheck.h
@@ -0,0 +1,24 @@
+#ifndef TYPECHECK_H_INCLUDED
+#define TYPECHECK_H_INCLUDED
+
+/*
+ * Check at compile time that something is of a particular type.
+ * Always evaluates to 1 so you may use it easily in comparisons.
+ */
+#define typecheck(type,x) \
+({ type __dummy; \
+ typeof(x) __dummy2; \
+ (void)(&__dummy == &__dummy2); \
+ 1; \
+})
+
+/*
+ * Check at compile time that 'function' is a certain type, or is a pointer
+ * to that type (needs to use typedef for the function type.)
+ */
+#define typecheck_fn(type,function) \
+({ typeof(type) __tmp = function; \
+ (void)__tmp; \
+})
+
+#endif /* TYPECHECK_H_INCLUDED */