[Freeciv-Dev] (PR#9869) Bug: DDEBUG changes savegames
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9869 >
On Sun, 29 Aug 2004, Gregory Berkolaiko wrote:
> Savegames when compiled with --enable-debug are really different from the
> very beginning.
Traced first divergence to:
index_to_map_pos(x, y, myrand(map.xsize * map.ysize));
in rand_map_pos_filtered in map.c
index_to_map_pos evaluates its argument many times:
#define index_to_map_pos(pmap_x, pmap_y, index) \
(CHECK_INDEX(index), \
index_to_native_pos(pmap_x, pmap_y, index), \
native_to_map_pos(pmap_x, pmap_y, *(pmap_x), *(pmap_y)))
#ifdef DEBUG
#define CHECK_MAP_POS(x,y) assert(is_normal_map_pos((x),(y)))
#define CHECK_INDEX(index) assert((index) >= 0 && (index) < MAX_MAP_INDEX)
#else
#define CHECK_MAP_POS(x,y) ((void)0)
#define CHECK_INDEX(index) ((void)0)
#endif
#define index_to_native_pos(pnat_x, pnat_y, index) \
(*(pnat_x) = (index) % map.xsize, \
*(pnat_y) = (index) / map.xsize)
So, even when CHECK_INDEX is not defined, "index" is evaluated twice.
I am not sure which is the better way to fix this: do temporary
assignments inside index_to* functions or do it in the caller. The first
way might give more work to compiler (optimizing), the second will give
more work to us (reviewing all uses).
G.
- [Freeciv-Dev] (PR#9869) Bug: DDEBUG changes savegames,
Gregory Berkolaiko <=
- [Freeciv-Dev] Re: (PR#9869) Bug: DDEBUG changes savegames, Jason Short, 2004/08/29
- [Freeciv-Dev] Re: (PR#9869) Bug: DDEBUG changes savegames, Gregory Berkolaiko, 2004/08/30
- [Freeciv-Dev] (PR#9869) Bug: DDEBUG changes savegames, Jason Short, 2004/08/30
- [Freeciv-Dev] Re: (PR#9869) Bug: DDEBUG changes savegames, Gregory Berkolaiko, 2004/08/30
- [Freeciv-Dev] Re: (PR#9869) Bug: DDEBUG changes savegames, Gregory Berkolaiko, 2004/08/30
- [Freeciv-Dev] (PR#9869) Bug: DDEBUG changes savegames, Gregory Berkolaiko, 2004/08/31
- [Freeciv-Dev] (PR#9869) Bug: DDEBUG changes savegames, Jason Short, 2004/08/31
- [Freeciv-Dev] Re: (PR#9869) Bug: DDEBUG changes savegames, Gregory Berkolaiko, 2004/08/31
|
|