[lttng-dev] [PATCH lttng-modules 1/2] Fix: Add Fedora version macros

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Tue Feb 20 12:33:54 EST 2018


Merged into master, 2.10, 2.9, thanks!

Mathieu

----- On Feb 20, 2018, at 12:10 PM, Michael Jeanson mjeanson at efficios.com wrote:

> From: Loïc Gelle <loic.gelle at polymtl.ca>
> 
> Signed-off-by: Loïc Gelle <loic.gelle at polymtl.ca>
> Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
> ---
> Kbuild.common          |  6 ++++++
> abi-fedora-version.sh  | 21 +++++++++++++++++++++
> lttng-kernel-version.h | 19 +++++++++++++++++++
> 3 files changed, 46 insertions(+)
> create mode 100755 abi-fedora-version.sh
> 
> diff --git a/Kbuild.common b/Kbuild.common
> index 16c62ab..c0d5409 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 0000000..52dd044
> --- /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 387aa0a..2b63a5d 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) \
> --
> 2.7.4

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com


More information about the lttng-dev mailing list