From f8ef71560867f2ef7124c0d55910dd405b34b20e Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Mon, 14 Jul 2025 13:55:15 +0100 Subject: [PATCH] tiles: Make TiFree() easier to inline for compiler Removal of unnecessary function call indirection into TileStoreFree() since TiFree() is has multiple implementation already and we can customize TiFree() directly as required. Move the function definitions into the tile.h to they are visible to compiler during code generation to consider inline potential. This has made global 'Tile *TileStoreFreeList' more visible. --- tiles/tile.c | 39 ++------------------------------------- tiles/tile.h | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/tiles/tile.c b/tiles/tile.c index 467093fe..696fff76 100644 --- a/tiles/tile.c +++ b/tiles/tile.c @@ -61,7 +61,7 @@ global const Rect TiPlaneRect = { {MINFINITY+2, MINFINITY+2}, {INFINITY-2, INFIN #ifdef HAVE_SYS_MMAN_H -static Tile *TileStoreFreeList = NULL; +Tile *TileStoreFreeList = NULL; /* The new Tile Allocation scheme (Magic 8.0) */ @@ -788,21 +788,6 @@ TiAlloc(void) return newtile; } -static void -TileStoreFree( - Tile *ptr) -{ - ptr->ti_client = PTR2CD(TileStoreFreeList); - TileStoreFreeList = ptr; -} - -void -TiFree( - Tile *tp) -{ - TileStoreFree(tp); -} - #else /* @@ -826,31 +811,11 @@ TiAlloc(void) TiSetBody(newtile, 0); return newtile; } - -/* - * -------------------------------------------------------------------- - * - * TiFree --- - * - * Release memory allocation for tiles - * - * Results: - * None. - * - * -------------------------------------------------------------------- - */ - -void -TiFree( - Tile *tp) -{ - freeMagic((char *)tp); -} - #endif /* !HAVE_SYS_MMAN_H */ #ifdef __GNUC_STDC_INLINE__ /* Use of 'extern inline' force an emit of inline code at a symbol */ +extern inline void TiFree(Tile *tile); extern inline void TiFreeIf(Tile *tile); extern inline void TiFree1(Tile **delay1, Tile *tile); extern inline void TiJoinX1(Tile **delay1, Tile *tile1, Tile *tile2, Plane *plane); diff --git a/tiles/tile.h b/tiles/tile.h index 89b3fe0a..a4d63525 100644 --- a/tiles/tile.h +++ b/tiles/tile.h @@ -247,10 +247,41 @@ extern Tile *TiSrPoint(Tile *hint, Plane *plane, const Point *point); #define TiSetClientPTR(tp,cd) ((tp)->ti_client = PTR2CD((cd))) extern Tile *TiAlloc(void); -extern void TiFree(Tile *tile); #ifdef __GNUC_STDC_INLINE__ + /* Provide compiler visibility of STDC 'inline' semantics */ + +#ifdef HAVE_SYS_MMAN_H +extern Tile *TileStoreFreeList; + +inline void +TiFree(Tile *tile) +{ + tile->ti_client = PTR2CD(TileStoreFreeList); + TileStoreFreeList = tile; +} +#else +/* + * -------------------------------------------------------------------- + * + * TiFree --- + * + * Release memory allocation for tiles + * + * Results: + * None. + * + * -------------------------------------------------------------------- + */ + +inline void +TiFree(Tile *tile) +{ + freeMagic((char *)tile); +} +#endif + inline void TiFreeIf(Tile *tile) { @@ -280,6 +311,7 @@ TiJoinY1(Tile **delay1, Tile *tile1, Tile *tile2, Plane *plane) } #else /* To support older compilers (that don't auto emit based on -O level) */ +extern void TiFree(Tile *tile); extern void TiFreeIf(Tile *tile); extern void TiFree1(Tile **delay1, Tile *tile); extern void TiJoinX1(Tile **delay1, Tile *tile1, Tile *tile2, Plane *plane);