Re: [PATCH 1/9] kernel: export sound/core/pcm_timer.c gcd implementation
From: Geert Uytterhoeven
Date: Tue Jun 02 2009 - 03:15:41 EST
On Tue, Jun 2, 2009 at 06:50, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Mon, 1 Jun 2009 13:57:09 +0200 Florian Fainelli <florian@xxxxxxxxxxx> 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?
Well, `gcd' is a quite common acronym, probably almost as well known as `min'
and `max'...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
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/