From: Michael Jeanson Date: Fri, 5 Feb 2016 22:53:06 +0000 (-0500) Subject: Add RT patch version macros X-Git-Tag: v2.7.2~11 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e0577e5fc282e0260214e5c5069342a717dc4068;p=lttng-modules.git Add RT patch version macros Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/Makefile.ABI.workarounds b/Makefile.ABI.workarounds index be9f1cb5..cb46c177 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 f98a1925..ac61739b 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 00000000..89c77554 --- /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}