lkml.org 
[lkml]   [2009]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 1/9] kernel: export sound/core/pcm_timer.c gcd implementation
Date
Le Tuesday 02 June 2009 06:50:34 Andrew Morton, vous avez écrit :
> 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?

We might want something better like greatest_common_divisor which is a bit
more self-explanatory ?

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

And its users select it in order not to increase the size of kernel.h, sounds
good.

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

I did forget about this. That gcd implementation only treats the a > b case.
What do you prefer, each user keeps its gcd implementation locally or we make
a lib/gcd.c for it ?

Thanks
--
Best regards, Florian Fainelli
Email : florian@openwrt.org
http://openwrt.org
-------------------------------[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2009-06-02 09:23    [from the cache]
©2003-2011 Jasper Spaans. Advertise on this site