Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: Map coordinate cleanups.
Home

[Freeciv-Dev] Re: Map coordinate cleanups.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: <rf13@xxxxxxxxxxxxxxxxxxxxxx>
Cc: Andreas Kemnade <akemnade@xxxxxxxxxxx>, Gaute B Strokkenes <gs234@xxxxxxxxx>, <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Map coordinate cleanups.
From: Marco Colombo <marco@xxxxxx>
Date: Thu, 16 Aug 2001 13:47:28 +0200 (CEST)

On Thu, 16 Aug 2001, Raimar Falke wrote:

> >  > Maybe it is time to decide which rule freeciv should follow. I would
> >  > vote for the extra {}s.

Me too, for what it counts.
<noflames>
But I'm on the http://www.linuxhq.com/kernel/v2.4/doc/CodingStyle.html
side, so I disagree with most of the "Mini Style Guide" section in
freeciv_hackers_guide.txt.
Well, only -i2 is real horror, to tell the truth.
</noflames>

> >  >
> >  >
> >  > > -  for (inx = 0;
> >  > > -       inx < 
> > sizeof(tile_special_type_names)/sizeof(tile_special_type_names[0]);
> >  > > -       inx++) {
> >  > > -    if (type & 0x1) {
> >  > > -      return tile_special_type_names[inx];
> >  > > -    }
> >  > > +  for (i = 0; i < NUM_SPECIAL_NAMES; i++) {
> >  > > +    if (type & 0x1)
> >  > > +      return tile_special_type_names[i];
> >  > > +
> >  > >      type >>= 1;
> >  > >    }
> >  >
> >  > Could this be rewritten to use ffs(3). There is no loop needed.
> > ffs is not portable. It does not exist on mingw targets and on amigaos.
> > (without using ixemul.library (unix emulation like cygwin.dll on
> > windows))
> >
> > Or should we put a my_ffs into common/support.c?
>
> Yes it looks like a reasonable approach.

Does it sound reasonable just to call it ffs() as in:

#if !defined(HAVE_FFS)
int
ffs(int i)
{
        ...
}
#endif

My man page says ffs() is BSDish. Maybe a __USE_BSD is required with glibc.
I guess the the glibc ffs is optimized on some archs where ASM instructions
are available to perform the task. But do we really care?

Anyway, I'm not sure one should have my_* functions everytime something
useful isn't really portable... just my 0.02.

>
>       Raimar
>
>

.TM.
-- 
      ____/  ____/   /
     /      /       /                   Marco Colombo
    ___/  ___  /   /                  Technical Manager
   /          /   /                      ESI s.r.l.
 _____/ _____/  _/                     Colombo@xxxxxx




[Prev in Thread] Current Thread [Next in Thread]