From: Loïc Gelle Date: Tue, 20 Feb 2018 17:10:04 +0000 (-0500) Subject: Fix: Add Fedora version macros X-Git-Tag: v2.11.0-rc1~67 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e4838da19cb97d51313f08913594ce8ed6250bc1;p=lttng-modules.git Fix: Add Fedora version macros Signed-off-by: Loïc Gelle Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/Kbuild.common b/Kbuild.common index 16c62ab7..c0d54093 100644 --- a/Kbuild.common +++ b/Kbuild.common @@ -22,6 +22,12 @@ ifneq ($(SLE_API_VERSION), 0) ccflags-y += -DSLE_API_VERSION=$(SLE_API_VERSION) endif +FEDORA_REVISION_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/abi-fedora-version.sh $(CURDIR)) + +ifneq ($(FEDORA_REVISION_VERSION), 0) + ccflags-y += -DFEDORA_REVISION_VERSION=$(FEDORA_REVISION_VERSION) +endif + RT_PATCH_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/rt-patch-version.sh $(CURDIR)) ifneq ($(RT_PATCH_VERSION), 0) diff --git a/abi-fedora-version.sh b/abi-fedora-version.sh new file mode 100755 index 00000000..52dd0446 --- /dev/null +++ b/abi-fedora-version.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# First argument is the path to the kernel headers. +KPATH="$1" + +if [ ! -f "${KPATH}/include/generated/utsrelease.h" ]; then + echo 0 + exit 0 +fi + +# Assuming KPATH is the target kernel headers directory +UTS_RELEASE=$(sed -rn 's/^#define UTS_RELEASE "(.*)"/\1/p' "${KPATH}/include/generated/utsrelease.h") +FEDORA_VERSION=$(echo "${UTS_RELEASE}" | sed -n 's/.*\.fc\([0-9]*\)\..*/\1/p') + +if [ "x${FEDORA_VERSION}" = "x" ]; then + echo 0 + exit 0 +fi + +FEDORA_REVISION_VERSION=$(echo "${UTS_RELEASE}" | sed -n 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\-\([0-9]*\).*/\4/p') +echo "${FEDORA_REVISION_VERSION}" diff --git a/lttng-kernel-version.h b/lttng-kernel-version.h index 387aa0ab..2b63a5d3 100644 --- a/lttng-kernel-version.h +++ b/lttng-kernel-version.h @@ -115,6 +115,25 @@ LTTNG_SLE_VERSION_CODE < \ LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high)) +/* Fedora */ + +#define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \ + (((((a) << 16) + ((b) << 8) + (c)) * 10000ULL) + (d)) + +#ifdef FEDORA_REVISION_VERSION +#define LTTNG_FEDORA_VERSION_CODE \ + ((LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION) +#else +#define LTTNG_FEDORA_VERSION_CODE 0 +#endif + +#define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \ + a_high, b_high, c_high, d_high) \ + (LTTNG_FEDORA_VERSION_CODE >= \ + LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \ + LTTNG_FEDORA_VERSION_CODE < \ + LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high)) + /* RT patch */ #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \