[lttng-dev] [PATCH lttng-modules 1/2] Add RT patch version macros

Michael Jeanson mjeanson at efficios.com
Fri Feb 5 17:53:06 EST 2016


---
 Makefile.ABI.workarounds |  8 +++++++-
 lttng-kernel-version.h   | 17 +++++++++++++++++
 rt-patch-version.sh      | 25 +++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100755 rt-patch-version.sh

diff --git a/Makefile.ABI.workarounds b/Makefile.ABI.workarounds
index d553ee4..e8cf520 100644
--- a/Makefile.ABI.workarounds
+++ b/Makefile.ABI.workarounds
@@ -4,8 +4,14 @@
 # the kernel EXTRAVERSION to figure it out. Translate this information
 # into a define visible from the C preprocessor.
 
-DEB_API_VERSION=$(shell $(MAKEFILEDIR)/abi-debian-version.sh $(KERNELDIR))
+DEB_API_VERSION:=$(shell $(MAKEFILEDIR)/abi-debian-version.sh $(KERNELDIR))
 
 ifneq ($(DEB_API_VERSION), 0)
   ccflags-y += -DDEBIAN_API_VERSION=$(DEB_API_VERSION)
 endif
+
+RT_PATCH_VERSION:=$(shell $(MAKEFILEDIR)/rt-patch-version.sh $(KERNELDIR))
+
+ifneq ($(RT_PATCH_VERSION), 0)
+  ccflags-y += -DRT_PATCH_VERSION=$(RT_PATCH_VERSION)
+endif
diff --git a/lttng-kernel-version.h b/lttng-kernel-version.h
index f98a192..ac61739 100644
--- a/lttng-kernel-version.h
+++ b/lttng-kernel-version.h
@@ -90,4 +90,21 @@
 		LTTNG_RHEL_VERSION_CODE < \
 		LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high))
 
+#define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
+	(((a) << 24) + ((b) << 16) + ((c) << 8) + (d))
+
+#ifdef RT_PATCH_VERSION
+#define LTTNG_RT_VERSION_CODE \
+	((LINUX_VERSION_CODE << 8) + RT_PATCH_VERSION)
+#else
+#define LTTNG_RT_VERSION_CODE 	0
+#endif
+
+#define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
+		a_high, b_high, c_high, d_high) \
+	(LTTNG_RT_VERSION_CODE >= \
+		LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
+		LTTNG_RT_VERSION_CODE < \
+		LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high))
+
 #endif /* _LTTNG_KERNEL_VERSION_H */
diff --git a/rt-patch-version.sh b/rt-patch-version.sh
new file mode 100755
index 0000000..89c7755
--- /dev/null
+++ b/rt-patch-version.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# First argument is the path to the kernel headers.
+KPATH=$1
+
+VERSIONFILE=""
+
+if [ -f "${KPATH}/localversion-rt" ]; then
+	VERSIONFILE="${KPATH}/localversion-rt"
+
+elif [ -f "${KPATH}/source/localversion-rt" ]; then
+	VERSIONFILE="${KPATH}/source/localversion-rt"
+else
+	echo 0
+	exit 0
+fi
+
+RT_PATCH_VERSION=$(sed -rn 's/^-rt([0-9]+)$/\1/p' "${VERSIONFILE}")
+
+if [ "x${RT_PATCH_VERSION}" = "x" ]; then
+	echo 0
+	exit 0
+fi
+
+echo ${RT_PATCH_VERSION}
-- 
2.7.0




More information about the lttng-dev mailing list