From 996b292a80db5042c49e7edd6c9090a96253880a Mon Sep 17 00:00:00 2001 From: Andreas Wendleder Date: Wed, 10 Jun 2026 03:49:15 +0200 Subject: [PATCH] garouter: convert K&R function definitions to ANSI C Convert the old-style (K&R) function definitions in garouter/ to ANSI C prototypes, formatted in the project's convention: the return type on its own line and each parameter on its own line, indented four spaces, with the original parameter comments retained. Updates garouter.h. Callbacks passed to generic function-pointer parameters (RtrStemProcessAll, the split-paint-plane hook) are cast to the expected pointer type at the call sites. Builds cleanly under GCC 16 / C23 (with the -std=gnu17 build change). Co-Authored-By: Claude Opus 4.8 --- garouter/gaChannel.c | 58 +++++++++++---------- garouter/gaMain.c | 22 ++++---- garouter/gaSimple.c | 36 ++++++------- garouter/gaStem.c | 120 ++++++++++++++++++++++--------------------- garouter/gaTest.c | 32 ++++++------ garouter/garouter.h | 2 +- 6 files changed, 138 insertions(+), 132 deletions(-) diff --git a/garouter/gaChannel.c b/garouter/gaChannel.c index d1ea44cf..0df48805 100644 --- a/garouter/gaChannel.c +++ b/garouter/gaChannel.c @@ -154,9 +154,9 @@ GAClearChannels() */ bool -GADefineChannel(chanType, r) - int chanType; - Rect *r; +GADefineChannel( + int chanType, + Rect *r) { int length, width, halfGrid = RtrGridSpacing / 2; GCRChannel *ch; @@ -257,10 +257,10 @@ GADefineChannel(chanType, r) */ void -gaChannelInit(list, routeUse, netList) - GCRChannel *list; /* List of channels to process */ - CellUse *routeUse; /* Cell being routed (searched for obstacles) */ - NLNetList *netList; /* Netlist being routed */ +gaChannelInit( + GCRChannel *list, /* List of channels to process */ + CellUse *routeUse, /* Cell being routed (searched for obstacles) */ + NLNetList *netList) /* Netlist being routed */ { GCRChannel *ch; @@ -356,8 +356,8 @@ gaChannelInit(list, routeUse, netList) } void -gaChannelStats(list) - GCRChannel *list; +gaChannelStats( + GCRChannel *list) { GCRChannel *ch; int *tot, *clear, numTot, numClear; @@ -407,10 +407,11 @@ gaChannelStats(list) } void -gaPinStats(pins, nPins, pTot, pClear) - GCRPin *pins; - int nPins; - int *pTot, *pClear; +gaPinStats( + GCRPin *pins, + int nPins, + int *pTot, + int *pClear) { GCRPin *pin, *pend; @@ -449,8 +450,8 @@ gaPinStats(pins, nPins, pTot, pClear) */ void -gaPropagateBlockages(list) - GCRChannel *list; +gaPropagateBlockages( + GCRChannel *list) { GCRChannel *ch; bool changed; @@ -482,10 +483,10 @@ gaPropagateBlockages(list) */ int -gaSetClient(tile, dinfo, cdata) - Tile *tile; - TileType dinfo; /* (unused) */ - ClientData cdata; +gaSetClient( + Tile *tile, + TileType dinfo, /* (unused) */ + ClientData cdata) { tile->ti_client = (ClientData) cdata; return (0); @@ -512,10 +513,10 @@ gaSetClient(tile, dinfo, cdata) */ int -gaSplitTile(tile, dinfo, r) - Tile *tile; - TileType dinfo; /* (unused) */ - Rect *r; +gaSplitTile( + Tile *tile, + TileType dinfo, /* (unused) */ + Rect *r) { Tile *tp; ASSERT(TiGetType(tile) == TT_SPACE, "gaSplitTile"); @@ -574,9 +575,9 @@ gaSplitTile(tile, dinfo, r) */ void -gaInitRiverBlockages(routeUse, ch) - CellUse *routeUse; - GCRChannel *ch; +gaInitRiverBlockages( + CellUse *routeUse, + GCRChannel *ch) { GCRPin *p1, *p2; int n, nPins, coord; @@ -634,7 +635,10 @@ gaInitRiverBlockages(routeUse, ch) } int -gaAlwaysOne(Tile *tile, TileType dinfo, ClientData clientdata) +gaAlwaysOne( + Tile *tile, + TileType dinfo, + ClientData clientdata) { return (1); } diff --git a/garouter/gaMain.c b/garouter/gaMain.c index 07c9bc4d..a62185c5 100644 --- a/garouter/gaMain.c +++ b/garouter/gaMain.c @@ -258,9 +258,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ */ int -GARouteCmd(routeUse, netListName) - CellUse *routeUse; - char *netListName; +GARouteCmd( + CellUse *routeUse, + char *netListName) { int errs = -1; NLNetList netList; @@ -329,10 +329,10 @@ done: */ int -GARoute(list, routeUse, netList) - GCRChannel *list; /* List of channels */ - CellUse *routeUse; /* Cell being routed */ - NLNetList *netList; /* List of nets to route */ +GARoute( + GCRChannel *list, /* List of channels */ + CellUse *routeUse, /* Cell being routed */ + NLNetList *netList) /* List of nets to route */ { int feedCount = DBWFeedbackCount, errs; GCRChannel *ch; @@ -432,10 +432,10 @@ done: */ int -gaBuildNetList(netListName, routeUse, netList) - char *netListName; - CellUse *routeUse; - NLNetList *netList; +gaBuildNetList( + char *netListName, + CellUse *routeUse, + NLNetList *netList) { CellDef *routeDef = routeUse->cu_def; int numNets; diff --git a/garouter/gaSimple.c b/garouter/gaSimple.c index c3b82e93..851065c4 100644 --- a/garouter/gaSimple.c +++ b/garouter/gaSimple.c @@ -84,12 +84,12 @@ extern int gaContactClear; */ bool -gaStemSimpleInit(routeUse, term, pinPoint, pinSide, simple) - CellUse *routeUse; /* Search this cell for obstacles */ - NLTermLoc *term; /* Route from term->nloc_rect */ - Point *pinPoint; /* Crossing point to reach */ - int pinSide; /* Direction of pin from term. */ - SimpleStem *simple; /* Fill this in */ +gaStemSimpleInit( + CellUse *routeUse, /* Search this cell for obstacles */ + NLTermLoc *term, /* Route from term->nloc_rect */ + Point *pinPoint, /* Crossing point to reach */ + int pinSide, /* Direction of pin from term. */ + SimpleStem *simple) /* Fill this in */ { SimpleWire *sMetal = &simple->ss_metalWire; @@ -530,10 +530,10 @@ gaStemSimpleInit(routeUse, term, pinPoint, pinSide, simple) */ bool -gaIsClear(use, r, mask) - CellUse *use; - Rect *r; - TileTypeBitMask *mask; +gaIsClear( + CellUse *use, + Rect *r, + TileTypeBitMask *mask) { int gaIsClearFunc(); SearchContext scx; @@ -572,10 +572,10 @@ gaIsClear(use, r, mask) */ int -gaIsClearFunc(tile, dinfo, cxp) - Tile *tile; - TileType dinfo; - TreeContext *cxp; +gaIsClearFunc( + Tile *tile, + TileType dinfo, + TreeContext *cxp) { return 1; } @@ -600,10 +600,10 @@ gaIsClearFunc(tile, dinfo, cxp) */ bool -gaStemSimpleRoute(simple, pinLayer, def) - SimpleStem *simple; /* Describes the route */ - TileType pinLayer; /* Connect to pin on this layer */ - CellDef *def; /* If non-NULL, paint to this def */ +gaStemSimpleRoute( + SimpleStem *simple, /* Describes the route */ + TileType pinLayer, /* Connect to pin on this layer */ + CellDef *def) /* If non-NULL, paint to this def */ { SimpleWire *wPin, *wOther; diff --git a/garouter/gaStem.c b/garouter/gaStem.c index 88ddaf00..e4941edd 100644 --- a/garouter/gaStem.c +++ b/garouter/gaStem.c @@ -83,12 +83,12 @@ int gaNumSimplePaint, gaNumMazePaint, gaNumExtPaint; /* Forward declarations */ int gaStemContainingChannelFunc(); -bool gaStemAssign(); +bool gaStemAssign(CellUse *routeUse, bool doWarn, NLTermLoc *loc, NLTerm *term, NLNet *net, NLNetList *netList); int gaStemGridRange(); void gaStemPaint(); bool gaStemNetClear(); bool gaStemInternalFunc(); -bool gaStemInternal(); +bool gaStemInternal(CellUse *routeUse, bool doWarn, NLTermLoc *loc, NLNet *net, GCRChannel *ch, NLNetList *netList); bool gaStemGrow(); @@ -120,9 +120,9 @@ bool gaStemGrow(); */ void -gaStemAssignAll(routeUse, netList) - CellUse *routeUse; - NLNetList *netList; +gaStemAssignAll( + CellUse *routeUse, + NLNetList *netList) { TileType t; @@ -165,7 +165,7 @@ gaStemAssignAll(routeUse, netList) gaMaxBelow = RtrContactOffset; /* Assign the stems (gaStemAssign() does the real work) */ - RtrStemProcessAll(routeUse, netList, GAStemWarn, gaStemAssign); + RtrStemProcessAll(routeUse, netList, GAStemWarn, (bool (*)()) gaStemAssign); if (DebugIsSet(gaDebugID, gaDebVerbose)) { @@ -206,13 +206,13 @@ gaStemAssignAll(routeUse, netList) */ bool -gaStemAssign(routeUse, doWarn, loc, term, net, netList) - CellUse *routeUse; /* Cell being routed */ - bool doWarn; /* If TRUE, leave feedback for each error */ - NLTermLoc *loc; /* Location considered */ - NLTerm *term; /* Terminal of which loc is a location */ - NLNet *net; /* Net to which it belongs */ - NLNetList *netList; /* Netlist (searched for blocking terminals) */ +gaStemAssign( + CellUse *routeUse, /* Cell being routed */ + bool doWarn, /* If TRUE, leave feedback for each error */ + NLTermLoc *loc, /* Location considered */ + NLTerm *term, /* Terminal of which loc is a location */ + NLNet *net, /* Net to which it belongs */ + NLNetList *netList) /* Netlist (searched for blocking terminals) */ { GCRChannel *ch; @@ -276,10 +276,10 @@ fail: */ GCRChannel * -gaStemContainingChannel(routeUse, doWarn, loc) - CellUse *routeUse; /* For errors */ - bool doWarn; /* If TRUE, leave feedback if error */ - NLTermLoc *loc; /* Find a channel for this terminal */ +gaStemContainingChannel( + CellUse *routeUse, /* For errors */ + bool doWarn, /* If TRUE, leave feedback if error */ + NLTermLoc *loc) /* Find a channel for this terminal */ { GCRChannel *ch; Rect area; @@ -342,10 +342,10 @@ overlap: */ int -gaStemContainingChannelFunc(tile, dinfo, pCh) - Tile *tile; - TileType dinfo; /* (unused) */ - GCRChannel **pCh; +gaStemContainingChannelFunc( + Tile *tile, + TileType dinfo, /* (unused) */ + GCRChannel **pCh) { GCRChannel *ch; @@ -386,8 +386,8 @@ gaStemContainingChannelFunc(tile, dinfo, pCh) */ bool -gaStemGrow(area) - Rect *area; +gaStemGrow( + Rect *area) { Rect r; GCRChannel *ch; @@ -445,13 +445,13 @@ gaStemGrow(area) */ bool -gaStemInternal(routeUse, doWarn, loc, net, ch, netList) - CellUse *routeUse; /* Cell being routed */ - bool doWarn; /* If TRUE, leave feedback on all errors */ - NLTermLoc *loc; /* Terminal being processed */ - NLNet *net; /* Used for marking pins */ - GCRChannel *ch; /* Channel containing loc */ - NLNetList *netList; /* Netlist (searched for blocking terminals) */ +gaStemInternal( + CellUse *routeUse, /* Cell being routed */ + bool doWarn, /* If TRUE, leave feedback on all errors */ + NLTermLoc *loc, /* Terminal being processed */ + NLNet *net, /* Used for marking pins */ + GCRChannel *ch, /* Channel containing loc */ + NLNetList *netList) /* Netlist (searched for blocking terminals) */ { int min, max, start, lo, hi; @@ -519,13 +519,13 @@ gaStemInternal(routeUse, doWarn, loc, net, ch, netList) */ bool -gaStemInternalFunc(routeUse, loc, net, ch, gridLine, netList) - CellUse *routeUse; - NLTermLoc *loc; - NLNet *net; - GCRChannel *ch; - int gridLine; - NLNetList *netList; +gaStemInternalFunc( + CellUse *routeUse, + NLTermLoc *loc, + NLNet *net, + GCRChannel *ch, + int gridLine, + NLNetList *netList) { GCRPin *pin1, *pin2; NLTermLoc *loc2; @@ -642,13 +642,13 @@ gaStemInternalFunc(routeUse, loc, net, ch, gridLine, netList) */ GCRPin * -gaStemCheckPin(routeUse, terminalLoc, ch, side, gridPoint, netList) - CellUse *routeUse; /* Cell being routed */ - NLTermLoc *terminalLoc; /* Terminal */ - GCRChannel *ch; /* Channel whose pin we are to use */ - int side; /* Direction 'gridPoint' lies relative to 'loc' */ - Point *gridPoint; /* Crossing point to use */ - NLNetList *netList; /* Searched for obstructing terminals */ +gaStemCheckPin( + CellUse *routeUse, /* Cell being routed */ + NLTermLoc *terminalLoc, /* Terminal */ + GCRChannel *ch, /* Channel whose pin we are to use */ + int side, /* Direction 'gridPoint' lies relative to 'loc' */ + Point *gridPoint, /* Crossing point to use */ + NLNetList *netList) /* Searched for obstructing terminals */ { TileTypeBitMask destMask; GCRPin *pin; @@ -785,11 +785,11 @@ hardway: */ bool -gaStemNetClear(termArea, point, side, netList) - Rect *termArea; /* Area of the starting terminal */ - Point *point; /* Crossing point where we want to end up */ - int side; /* Direction of point relative to termArea */ - NLNetList *netList; /* Netlist to check for terminals to avoid */ +gaStemNetClear( + Rect *termArea, /* Area of the starting terminal */ + Point *point, /* Crossing point where we want to end up */ + int side, /* Direction of point relative to termArea */ + NLNetList *netList) /* Netlist to check for terminals to avoid */ { int min, max, start, type, grid; NLTermLoc *loc; @@ -883,10 +883,12 @@ gaStemNetClear(termArea, point, side, netList) */ int -gaStemGridRange(type, r, pMinGrid, pMaxGrid, pStart) - int type; - Rect *r; - int *pMinGrid, *pMaxGrid, *pStart; +gaStemGridRange( + int type, + Rect *r, + int *pMinGrid, + int *pMaxGrid, + int *pStart) { int min, max, start; @@ -948,9 +950,9 @@ gaStemGridRange(type, r, pMinGrid, pMaxGrid, pStart) */ void -gaStemPaintAll(routeUse, netList) - CellUse *routeUse; - NLNetList *netList; +gaStemPaintAll( + CellUse *routeUse, + NLNetList *netList) { NLTermLoc *loc; NLTerm *term; @@ -1008,9 +1010,9 @@ out: */ void -gaStemPaint(routeUse, terminalLoc) - CellUse *routeUse; - NLTermLoc *terminalLoc; +gaStemPaint( + CellUse *routeUse, + NLTermLoc *terminalLoc) { TileTypeBitMask terminalLayerMask; /* Possible layers for stem at terminal */ diff --git a/garouter/gaTest.c b/garouter/gaTest.c index 6fbb020f..8bcfa876 100644 --- a/garouter/gaTest.c +++ b/garouter/gaTest.c @@ -87,9 +87,9 @@ void GAInit(); */ void -GATest(w, cmd) - MagWindow *w; - TxCommand *cmd; +GATest( + MagWindow *w, + TxCommand *cmd) { int n; typedef enum { CLRDEBUG, SETDEBUG, SHOWDEBUG} cmdType; @@ -159,12 +159,12 @@ badCmd: */ void -GAGenChans(chanType, area, f) - int chanType; - Rect *area; - FILE *f; +GAGenChans( + int chanType, + Rect *area, + FILE *f) { - extern int DBPaintPlane0(), DBPaintPlaneVert(); + extern int DBPaintPlane0(Plane *plane, Rect *area, const PaintResultType *resultTbl, PaintUndoInfo *undo, unsigned char method), DBPaintPlaneVert(); int gaSplitFunc(), gaSplitOut(); static CellDef *genDef = (CellDef *) NULL; static CellUse *genUse = (CellUse *) NULL; @@ -185,7 +185,7 @@ GAGenChans(chanType, area, f) switch (chanType) { case CHAN_HRIVER: - gaSplitPaintPlane = DBPaintPlane0; + gaSplitPaintPlane = (int (*)()) DBPaintPlane0; area->r_ytop = RTR_GRIDDOWN(area->r_ytop - halfUp, RtrOrigin.p_y) + halfUp; area->r_ybot = RTR_GRIDUP(area->r_ybot + halfDown, RtrOrigin.p_y) @@ -254,10 +254,10 @@ GAGenChans(chanType, area, f) */ int -gaSplitOut(tile, dinfo, f) - Tile *tile; - TileType dinfo; /* (unused) */ - FILE *f; +gaSplitOut( + Tile *tile, + TileType dinfo, /* (unused) */ + FILE *f) { Rect r; @@ -303,9 +303,9 @@ gaSplitOut(tile, dinfo, f) */ int -gaSplitFunc(scx, plane) - SearchContext *scx; - Plane *plane; +gaSplitFunc( + SearchContext *scx, + Plane *plane) { int halfUp, halfDown; CellDef *def = scx->scx_use->cu_def; diff --git a/garouter/garouter.h b/garouter/garouter.h index c1a27619..3ae859ea 100644 --- a/garouter/garouter.h +++ b/garouter/garouter.h @@ -86,7 +86,7 @@ extern ClientData gaDebugID; /* Our identity with the debugging module */ #include "gaDebug.h" /* Can add flags without total recompile */ /* Internal procedures */ -extern GCRChannel *gaStemContainingChannel(); +extern GCRChannel *gaStemContainingChannel(CellUse *routeUse, bool doWarn, NLTermLoc *loc); extern GCRPin *gaStemCheckPin(); extern int gaAlwaysOne(); extern bool gaMazeRoute(CellUse *routeUse, NLTermLoc *terminalLoc, Point *pinPoint,