Re: [PATCH] atomic64_test: Simplify the #ifdef foratomic64_dec_if_positive() test

From: Andrew Morton
Date: Wed Jul 18 2012 - 18:10:36 EST


On Tue, 17 Jul 2012 18:10:48 +0100
Catalin Marinas <catalin.marinas@xxxxxxx> wrote:

> This patch introduces CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE and uses
> this instead of the multitude of #if defined() checks in atomic64_test.c
>
> ...
>
> --- a/lib/atomic64_test.c
> +++ b/lib/atomic64_test.c
> @@ -114,8 +114,7 @@ static __init int test_atomic64(void)
> r += one;
> BUG_ON(v.counter != r);
>
> -#if defined(CONFIG_X86) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || \
> - defined(CONFIG_S390) || defined(_ASM_GENERIC_ATOMIC64_H) || defined(CONFIG_ARM)

ugh, good riddance.

> +#ifdef CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE

The alternative way of doing this is to do

#define atomic64_dec_if_positive atomic64_dec_if_positive

in all the relevant .h files, then use #ifdef atomic64_dec_if_positive.
That's rather nice because it keeps everything in one place. otoh it
is rather unobvious trickery.

But either way is better than what we have now.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/