gcr: convert K&R function definitions to ANSI C

Convert the old-style (K&R) function definitions in gcr/ 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 gcr.h with prototypes for the affected declarations.

Builds cleanly under GCC 16 / C23 (with the -std=gnu17 build change).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Andreas Wendleder 2026-06-10 03:49:04 +02:00
parent 1ac06cafc6
commit fc95cacba2
No known key found for this signature in database
GPG Key ID: 588785BFDFB01ABD
10 changed files with 169 additions and 162 deletions

View File

@ -358,12 +358,12 @@ extern void gcrCheckCol();
extern int gcrClass();
extern void gcrCollapse();
extern int gcrDensity();
extern void gcrDumpResult();
extern void gcrDumpResult(GCRChannel *ch, bool showResult);
extern void gcrFeasible();
extern void gcrInitCol();
extern void gcrInitCollapse();
extern int gcrLook();
extern void gcrMakeRuns();
extern int gcrLook(GCRChannel * ch, int track, bool canCover);
extern void gcrMakeRuns(GCRChannel * ch, int column, GCRNet ** list, int count, bool riseFall);
extern void gcrMarkWanted();
extern void gcrPickBest();
extern void gcrPrintCol();
@ -372,7 +372,7 @@ extern void gcrReduceRange();
extern bool gcrRiverRoute();
extern void gcrSetEndDist();
extern void gcrSetFlags();
extern void gcrShellSort();
extern void gcrShellSort(GCRNet **v, int n, bool isUp);
extern int gcrTryRun();
extern void gcrUncollapse();
extern void gcrVacate();

View File

@ -60,12 +60,12 @@ void gcrEvalPat();
*/
void
gcrCollapse(col, width, bot, top, freed)
GCRColEl ** col;
int width;
int bot;
int top;
int freed;
gcrCollapse(
GCRColEl ** col,
int width,
int bot,
int top,
int freed)
{
int i, to;
GCRNet * net;
@ -139,8 +139,8 @@ gcrCollapse(col, width, bot, top, freed)
*/
void
gcrInitCollapse(size)
int size; /* Number of tracks in column. */
gcrInitCollapse(
int size) /* Number of tracks in column. */
{
gcrBestFreed = 0;
gcrSplitNets = -1;
@ -176,12 +176,12 @@ gcrInitCollapse(size)
*/
void
gcrEvalPat(col, freed, size)
GCRColEl ** col; /* Describes column in which to collapse. */
int freed; /* We've already found a set of collapsing
gcrEvalPat(
GCRColEl ** col, /* Describes column in which to collapse. */
int freed, /* We've already found a set of collapsing
* jogs that frees at least this many tracks.
*/
int size; /* Number of tracks in column. */
int size) /* Number of tracks in column. */
{
int i, n, newDist, oldWiring, newWiring;
@ -266,10 +266,10 @@ gcrEvalPat(col, freed, size)
*/
int
gcrNextSplit(col, size, i)
GCRColEl * col;
int size;
int i;
gcrNextSplit(
GCRColEl * col,
int size,
int i)
{
for(i++; i<size/2; i++)
if( ((col[i].gcr_hi!= EMPTY)&&(col[i].gcr_lo== EMPTY)) ||
@ -294,8 +294,8 @@ gcrNextSplit(col, size, i)
*/
void
gcrPickBest(ch)
GCRChannel * ch;
gcrPickBest(
GCRChannel * ch)
{
ASSERT(gcrBestCol!=(GCRColEl *) NULL, "gcrPickBest");
ASSERT(ch->gcr_lCol==(GCRColEl *) NULL, "gcrPickBest");
@ -321,9 +321,9 @@ gcrPickBest(ch)
*/
void
gcrReduceRange(col, width)
GCRColEl * col;
int width;
gcrReduceRange(
GCRColEl * col,
int width)
{
int i, j;
int farthest;

View File

@ -41,7 +41,7 @@ bool GcrShowMap = FALSE;
int gcrStandalone=FALSE; /*Flag to control standalone/integrated operation*/
/* Forward declarations */
void gcrDumpResult();
void gcrDumpResult(GCRChannel *ch, bool showResult);
void gcrStats();
void gcrShowMap();
bool gcrMakeChannel();
@ -67,8 +67,8 @@ void gcrPrintCol(GCRChannel *, int, int);
*/
GCRChannel *
GCRRouteFromFile(fname)
char *fname;
GCRRouteFromFile(
char *fname)
{
static Point initOrigin = { 0, 0 };
struct tms tbuf1, tbuf2;
@ -131,9 +131,9 @@ GCRRouteFromFile(fname)
*/
bool
gcrMakeChannel(ch, fp)
GCRChannel *ch;
FILE *fp;
gcrMakeChannel(
GCRChannel *ch,
FILE *fp)
{
GCRPin *gcrMakePinLR();
unsigned lenWds, widWds;
@ -238,9 +238,10 @@ gcrMakeChannel(ch, fp)
}
GCRPin *
gcrMakePinLR(fp, x, size)
FILE *fp;
int x, size;
gcrMakePinLR(
FILE *fp,
int x,
int size)
{
GCRPin *result;
int i;
@ -281,8 +282,8 @@ gcrMakePinLR(fp, x, size)
*/
void
gcrSaveChannel(ch)
GCRChannel *ch;
gcrSaveChannel(
GCRChannel *ch)
{
FILE *fp;
char name[128];
@ -367,9 +368,9 @@ gcrSaveChannel(ch)
*/
void
gcrPrDensity(ch, chanDensity)
GCRChannel *ch;
int chanDensity;
gcrPrDensity(
GCRChannel *ch,
int chanDensity)
{
int i, diff;
char name[256];
@ -444,8 +445,8 @@ gcrPrDensity(ch, chanDensity)
*/
void
gcrDumpPins(ch)
GCRChannel *ch;
gcrDumpPins(
GCRChannel *ch)
{
int i;
GCRPin * pinArray;
@ -501,9 +502,9 @@ gcrDumpPins(ch)
*/
void
gcrDumpPinList(pin, dir)
GCRPin *pin;
bool dir;
gcrDumpPinList(
GCRPin *pin,
bool dir)
{
if (pin)
{
@ -532,9 +533,9 @@ gcrDumpPinList(pin, dir)
*/
void
gcrDumpCol(col, size)
GCRColEl *col;
int size;
gcrDumpCol(
GCRColEl *col,
int size)
{
int i;
@ -566,9 +567,9 @@ gcrDumpCol(col, size)
*/
void
gcrDumpResult(ch, showResult)
GCRChannel *ch;
bool showResult;
gcrDumpResult(
GCRChannel *ch,
bool showResult)
{
int j;
@ -791,8 +792,8 @@ void gcrPrintCol(ch, i, showResult)
*/
void
gcrStats(ch)
GCRChannel * ch;
gcrStats(
GCRChannel * ch)
{
int wireLength=0, viaCount=0, row, col;
short **res, mask, code, code2;
@ -872,10 +873,10 @@ gcrStats(ch)
*/
void
gcrCheckCol(ch, c, where)
GCRChannel *ch;
int c;
char *where;
gcrCheckCol(
GCRChannel *ch,
int c,
char *where)
{
int i, j;
GCRColEl * col;
@ -965,8 +966,8 @@ gcrCheckCol(ch, c, where)
*/
void
gcrShowMap(ch)
GCRChannel * ch;
gcrShowMap(
GCRChannel * ch)
{
int i, j, field;
short ** res;

View File

@ -47,9 +47,10 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*/
void
gcrWanted(ch, track, column)
GCRChannel *ch;
int track, column;
gcrWanted(
GCRChannel *ch,
int track,
int column)
{
GCRColEl *col = ch->gcr_lCol;
GCRPin *pin, *next;
@ -99,8 +100,8 @@ gcrWanted(ch, track, column)
*/
void
gcrMarkWanted(ch)
GCRChannel *ch;
gcrMarkWanted(
GCRChannel *ch)
{
GCRColEl *col = ch->gcr_lCol;
GCRPin *pin = ch->gcr_rPins;
@ -133,12 +134,13 @@ gcrMarkWanted(ch)
*/
void
gcrUncollapse(ch, col, width, bot, top, split)
GCRChannel *ch; /* Channel being processed */
GCRColEl **col;
int width; /* Size of array pointed to by *col */
int bot, top; /* Consider tracks between bot .. top inclusive */
int split; /* Somewhere between 0 and width inclusive */
gcrUncollapse(
GCRChannel *ch, /* Channel being processed */
GCRColEl **col,
int width, /* Size of array pointed to by *col */
int bot,
int top,
int split) /* Somewhere between 0 and width inclusive */
{
int i, to, type, extra, flags;
GCRColEl *newCol, *gcrCopyCol();

View File

@ -69,8 +69,8 @@ void gcrLinkPin();
*/
void
gcrSetEndDist(ch)
GCRChannel *ch; /* The channel to be routed */
gcrSetEndDist(
GCRChannel *ch) /* The channel to be routed */
{
int rightTotal, multiTotal;
GCRNet *net;
@ -118,8 +118,8 @@ gcrSetEndDist(ch)
*/
void
gcrBuildNets(ch)
GCRChannel * ch;
gcrBuildNets(
GCRChannel * ch)
{
HashTable ht;
int i;
@ -165,10 +165,10 @@ gcrBuildNets(ch)
*/
void
gcrLinkPin(pin, ht, ch)
GCRPin *pin;
HashTable *ht;
GCRChannel *ch;
gcrLinkPin(
GCRPin *pin,
HashTable *ht,
GCRChannel *ch)
{
GCRNet *net;
GCRNet *gcrNewNet();
@ -231,8 +231,8 @@ gcrLinkPin(pin, ht, ch)
*/
void
gcrUnlinkPin(pin)
GCRPin *pin;
gcrUnlinkPin(
GCRPin *pin)
{
GCRNet *net;
@ -268,8 +268,8 @@ gcrUnlinkPin(pin)
*/
int
gcrDensity(ch)
GCRChannel *ch;
gcrDensity(
GCRChannel *ch)
{
int density, i, last, maxVal;
unsigned lenWds;
@ -340,9 +340,9 @@ gcrDensity(ch)
*/
void
gcrInitCol(ch, edgeArray)
GCRChannel *ch;
GCRPin *edgeArray; /* Nets at left edge of channel if non-NULL */
gcrInitCol(
GCRChannel *ch,
GCRPin *edgeArray) /* Nets at left edge of channel if non-NULL */
{
GCRNet *net;
GCRColEl *col;

View File

@ -49,14 +49,14 @@ void gcrUnlinkTrack();
*/
bool
gcrBlocked(col, i, net, last)
GCRColEl *col; /* Current column information */
int i; /* Which element */
GCRNet *net; /* Net we're interested in processing: locations
gcrBlocked(
GCRColEl *col, /* Current column information */
int i, /* Which element */
GCRNet *net, /* Net we're interested in processing: locations
* that already contain this net aren't considered
* to be blocked; all others are.
*/
int last;
int last)
{
GCRColEl *colptr = &col[i];
@ -100,11 +100,11 @@ gcrBlocked(col, i, net, last)
*/
void
gcrMoveTrack(column, net, from, to)
GCRColEl * column;
GCRNet * net; /* Net to be assigned to a track */
int from;
int to;
gcrMoveTrack(
GCRColEl * column,
GCRNet * net, /* Net to be assigned to a track */
int from,
int to)
{
int i, last;
@ -261,9 +261,9 @@ gcrMoveTrack(column, net, from, to)
*/
void
gcrUnlinkTrack(col, toUnlink)
GCRColEl *col;
int toUnlink;
gcrUnlinkTrack(
GCRColEl *col,
int toUnlink)
{
GCRColEl *colPtr = &col[toUnlink];
@ -293,10 +293,10 @@ gcrUnlinkTrack(col, toUnlink)
*/
void
gcrShellSort(v, n, isUp)
GCRNet **v;
int n;
bool isUp;
gcrShellSort(
GCRNet **v,
int n,
bool isUp)
{
int gap, i, j, a1, a2;
GCRNet * net;
@ -343,10 +343,10 @@ gcrShellSort(v, n, isUp)
*/
bool
gcrVertClear(col, from, to)
GCRColEl * col;
int from;
int to;
gcrVertClear(
GCRColEl * col,
int from,
int to)
{
int i, flags;
GCRNet * net;
@ -393,9 +393,9 @@ gcrVertClear(col, from, to)
*/
GCRColEl *
gcrCopyCol(col, size)
GCRColEl *col;
int size;
gcrCopyCol(
GCRColEl *col,
int size)
{
GCRColEl * result;
int i, limit;
@ -425,10 +425,11 @@ gcrCopyCol(col, size)
*/
void
gcrLinkTrack(col, net, track, width)
GCRColEl *col;
GCRNet *net;
int track, width;
gcrLinkTrack(
GCRColEl *col,
GCRNet *net,
int track,
int width)
{
int i;

View File

@ -54,8 +54,8 @@ bool gcrOverCellHoriz();
*/
bool
gcrRiverRoute(ch)
GCRChannel *ch;
gcrRiverRoute(
GCRChannel *ch)
{
switch (ch->gcr_type)
{
@ -99,8 +99,8 @@ gcrRiverRoute(ch)
((pin)->gcr_pId != (GCRNet *) 0 && (pin)->gcr_pId != (GCRNet *) -1)
bool
gcrOverCellHoriz(ch)
GCRChannel *ch;
gcrOverCellHoriz(
GCRChannel *ch)
{
short **result = ch->gcr_result;
int col, row;
@ -139,8 +139,8 @@ gcrOverCellHoriz(ch)
}
bool
gcrOverCellVert(ch)
GCRChannel *ch;
gcrOverCellVert(
GCRChannel *ch)
{
short **result = ch->gcr_result;
int col, row;

View File

@ -62,8 +62,8 @@ void gcrExtend();
*/
int
GCRroute(ch)
GCRChannel *ch;
GCRroute(
GCRChannel *ch)
{
int i, density, netId;
char mesg[256];
@ -154,9 +154,9 @@ bottom:
*/
void
gcrRouteCol(ch, indx)
GCRChannel *ch;
int indx; /* Index of column being routed. */
gcrRouteCol(
GCRChannel *ch,
int indx) /* Index of column being routed. */
{
GCRNet **gcrClassify(), **list;
GCRColEl *col;
@ -228,9 +228,9 @@ gcrRouteCol(ch, indx)
*/
void
gcrExtend(ch, currentCol)
GCRChannel *ch; /* Channel being routed */
int currentCol; /* Column that has just been completed */
gcrExtend(
GCRChannel *ch, /* Channel being routed */
int currentCol) /* Column that has just been completed */
{
short *res = ch->gcr_result[currentCol];
GCRColEl *col = ch->gcr_lCol;

View File

@ -88,9 +88,9 @@ CellDef * gcrShowCell = (CellDef *) NULL;
*/
void
GCRShow(point, arg)
Point * point;
char * arg;
GCRShow(
Point * point,
char * arg)
{
GCRChannel * ch;
HashEntry * he;
@ -200,8 +200,8 @@ GCRShow(point, arg)
*/
void
gcrDumpChannel(ch)
GCRChannel * ch;
gcrDumpChannel(
GCRChannel * ch)
{
char name[32];
int track, col, netCount = 0, gcrNetName();
@ -255,10 +255,10 @@ gcrDumpChannel(ch)
}
int
gcrNetName(netNames, netCount, net)
GCRNet * netNames[];
int * netCount;
GCRNet * net;
gcrNetName(
GCRNet * netNames[],
int * netCount,
GCRNet * net)
{
int i;
for(i=0; i<= *netCount; i++)

View File

@ -32,7 +32,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
/* Forward declarations */
void gcrMakeRuns();
void gcrMakeRuns(GCRChannel * ch, int column, GCRNet ** list, int count, bool riseFall);
/*
@ -56,9 +56,9 @@ void gcrMakeRuns();
*/
void
gcrVacate(ch, column)
GCRChannel * ch;
int column;
gcrVacate(
GCRChannel * ch,
int column)
{
int i;
int to, count, gcrIsGreater();
@ -142,10 +142,10 @@ gcrVacate(ch, column)
*/
int
gcrLook(ch, track, canCover)
GCRChannel * ch;
int track;
bool canCover;
gcrLook(
GCRChannel * ch,
int track,
bool canCover)
{
int up, dn, dir, bestUp= EMPTY, bestDn= EMPTY, uplim, dnlim;
int target, upLength, dnLength;
@ -273,9 +273,9 @@ gcrLook(ch, track, canCover)
*/
GCRNet **
gcrClassify(ch, count)
GCRChannel * ch;
int * count;
gcrClassify(
GCRChannel * ch,
int * count)
{
GCRColEl * col;
GCRPin * pin, * next;
@ -355,9 +355,10 @@ gcrClassify(ch, count)
*/
int
gcrRealDist(col, i, dist)
GCRColEl * col;
int i, dist;
gcrRealDist(
GCRColEl * col,
int i,
int dist)
{
int j, last;
GCRNet * net=col[i].gcr_h;
@ -388,9 +389,9 @@ gcrRealDist(col, i, dist)
*/
int
gcrClass(net, track)
GCRNet * net;
int track;
gcrClass(
GCRNet * net,
int track)
{
GCRPin * pin, * next;
int dist;
@ -446,12 +447,12 @@ gcrClass(net, track)
*/
void
gcrMakeRuns(ch, column, list, count, riseFall)
GCRChannel * ch;
int column;
GCRNet ** list;
int count;
bool riseFall;
gcrMakeRuns(
GCRChannel * ch,
int column,
GCRNet ** list,
int count,
bool riseFall)
{
int j, from, to, runTo;
int distToTarget;
@ -526,10 +527,12 @@ gcrMakeRuns(ch, column, list, count, riseFall)
*/
int
gcrTryRun(ch, net, from, to, column)
GCRChannel * ch;
GCRNet * net;
int from, to, column;
gcrTryRun(
GCRChannel * ch,
GCRNet * net,
int from,
int to,
int column)
{
GCRColEl * col;
GCRNet * vnet, * hnet;