linux-mips
[Top] [All Lists]

Re: [PATCH 1/9] kernel: export sound/core/pcm_timer.c gcd implementation

To: Florian Fainelli <florian@openwrt.org>
Subject: Re: [PATCH 1/9] kernel: export sound/core/pcm_timer.c gcd implementation
From: Andrew Morton <akpm@linux-foundation.org>
Date: Mon, 1 Jun 2009 21:50:34 -0700
Cc: linux-kernel@vger.kernel.org, Takashi Iwai <tiwai@suse.de>, linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>, Ingo Molnar <mingo@elte.hu>
In-reply-to: <200906011357.09966.florian@openwrt.org>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <200906011357.09966.florian@openwrt.org>
Sender: linux-mips-bounce@linux-mips.org
On Mon, 1 Jun 2009 13:57:09 +0200 Florian Fainelli <florian@openwrt.org> wrote:

> This patch exports the gcd implementation from
> sound/core/pcm_timer.c into include/linux/kernel.h.
> AR7 uses it in its clock routines.
> 
> ...
>
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 883cd44..878a27a 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -147,6 +147,22 @@ extern int _cond_resched(void);
>               (__x < 0) ? -__x : __x;         \
>       })
>  
> +/* Greatest common divisor */
> +static inline unsigned long gcd(unsigned long a, unsigned long b)
> +{
> +        unsigned long r;
> +        if (a < b) {
> +                r = a;
> +                a = b;
> +                b = r;
> +        }
> +        while ((r = a % b) != 0) {
> +                a = b;
> +                b = r;
> +        }
> +        return b;
> +}

a) the name's a bit sucky.   Is there some convention for this name?

b) It looks too large to be inlined.  lib/gdc.c?

b) there's an implementation of gcd() in
   net/netfilter/ipvs/ip_vs_wrr.c.  I expect that this patch broke the
   build.



<Prev in Thread] Current Thread [Next in Thread>