diff mbox series

[16/74] backports: define __is_constexpr() for older kernels

Message ID 20240524190906.1835c4614254.Ib82d1b3349ab6fc55b5f17dba1ada60601dcd742@changeid (mailing list archive)
State New, archived
Headers show
Series backport updates from Intel | expand

Commit Message

Johannes Berg May 24, 2024, 5:07 p.m. UTC
From: Gregory Greenman <gregory.greenman@intel.com>

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 backport/backport-include/linux/kernel.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 backport/backport-include/linux/kernel.h
diff mbox series

Patch

diff --git a/backport/backport-include/linux/kernel.h b/backport/backport-include/linux/kernel.h
new file mode 100644
index 000000000000..b59971fbc1f0
--- /dev/null
+++ b/backport/backport-include/linux/kernel.h
@@ -0,0 +1,17 @@ 
+#ifndef __BACKPORT_KERNEL_H
+#define __BACKPORT_KERNEL_H
+#include_next <linux/kernel.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_IS_LESS(4,17,0)
+/*
+ * This returns a constant expression while determining if an argument is
+ * a constant expression, most importantly without evaluating the argument.
+ * Glory to Martin Uecker <Martin.Uecker@med.uni-goettingen.de>
+ */
+#define __is_constexpr(x) \
+	(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
+
+#endif /* < 4.17.0 */
+
+#endif /* __BACKPORT_KERNEL_H */