Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2001:
[Freeciv-Dev] Re: map_adjust_x()

[Freeciv-Dev] Re: map_adjust_x()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Thue <thue@xxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: map_adjust_x()
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: 21 Mar 2001 20:16:31 +0100

On Mon, 19 Mar 2001, thue@xxxxxxx wrote:
>> Anyone who wishes to have a closer look at these results can get
>> the following files from my web page: fast_map3.diff,
>>, civserver.cvs.fast_map.gprof.out
> Hmm; I am not that happy about the use of macros; it would be nicer
> with inline functions and then let the compiler make sure everything
> works just like a normal function call, as well as giving the
> compiler a better chance of optimizing. Normal function calls are
> also clearer to read...  Why not do something like this in the
> header file:
> /* functions as inline */
> #endif
> and then this in the .c file:
> /* functions as non-inline */
> #endif

Would it be acceptable to put something like

#define MAP_INLINE
#define MAP_INLINE static inline

MAP_INLINE int foo(int bar);

MAP_INLINE int foo(int bar)
  /* body */

in map.h ?  This avoids duplicating the function definition or
generating as many duplicate versions as there are c files including
map.h .

> As mentioned before inline functions are in the C99 standard, so it
> is not that restrictive to only optimize for that. Besides, far most
> freeciv people use gcc for compiling.

There was some concern that gcc is not as good at optimising inlined
functions as macros, though no one provided any hard numbers.  It
should be pretty easy to come up with a quick and dirty patch that
wraps an inline function around my macros and could be used to see if
there is any significant difference.  Unfortunately, I have neither
the means nor the opportunity to do so myself right now--perhaps
someone else can?

Big Gaute                     

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