lef: constify strings in data structures of lef module

This commit is contained in:
Darryl L. Miles 2025-01-04 09:05:56 +00:00 committed by Tim Edwards
parent ed87c3a98b
commit 451dab4b9b
6 changed files with 27 additions and 25 deletions

View File

@ -1960,7 +1960,7 @@ DefReadVias(
lefl->info.via.cell = (CellDef *)NULL; lefl->info.via.cell = (CellDef *)NULL;
lefl->info.via.lr = (LinkedRect *)NULL; lefl->info.via.lr = (LinkedRect *)NULL;
HashSetValue(he, lefl); HashSetValue(he, lefl);
lefl->canonName = (char *)he->h_key.h_name; lefl->canonName = (const char *)he->h_key.h_name;
} }
else else
{ {

View File

@ -62,7 +62,7 @@ typedef struct {
typedef struct { typedef struct {
CellDef *def; CellDef *def;
int nlayers; int nlayers;
char **baseNames; const char **baseNames;
TileTypeBitMask *blockMasks; TileTypeBitMask *blockMasks;
LinkedRect **blockData; LinkedRect **blockData;
} DefObsData; } DefObsData;
@ -79,7 +79,7 @@ typedef struct {
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
char *defGetType(TileType ttype, lefLayer **lefptr, bool do_vias); /* Forward declaration */ const char *defGetType(TileType ttype, lefLayer **lefptr, bool do_vias); /* Forward declaration */
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
@ -934,7 +934,8 @@ defNetGeometryFunc(
int routeWidth, w, h, midlinex2, topClip, botClip; int routeWidth, w, h, midlinex2, topClip, botClip;
float x1, y1, x2, y2, extlen; float x1, y1, x2, y2, extlen;
lefLayer *lefType, *lefl; lefLayer *lefType, *lefl;
char *lefName, viaName[128], posstr[24]; const char *lefName;
char viaName[128], posstr[24];
LefRules *lastruleset = defdata->ruleset; LefRules *lastruleset = defdata->ruleset;
HashEntry *he; HashEntry *he;
HashTable *defViaTable = defdata->defViaTable; HashTable *defViaTable = defdata->defViaTable;
@ -1456,7 +1457,7 @@ defNetGeometryFunc(
if (orient == GEO_CENTER) if (orient == GEO_CENTER)
{ {
char *rName; const char *rName;
/* Type can be zero (space) if the first tile */ /* Type can be zero (space) if the first tile */
/* encountered is a via. If so, use the 1st */ /* encountered is a via. If so, use the 1st */
@ -1712,7 +1713,8 @@ defCountViaFunc(
TileType ttype = TiGetType(tile), ctype, rtype; TileType ttype = TiGetType(tile), ctype, rtype;
TileTypeBitMask *rmask, *rmask2; TileTypeBitMask *rmask, *rmask2;
Tile *tp; Tile *tp;
char *lname, vname[100], posstr[24]; const char *lname;
char vname[100], posstr[24];
Rect r, r2, rorig; Rect r, r2, rorig;
int w, h, offx, offy, sdist, lorient, horient; int w, h, offx, offy, sdist, lorient, horient;
int ldist, hdist, sldist, shdist, pNum; int ldist, hdist, sldist, shdist, pNum;
@ -1933,7 +1935,7 @@ defCountViaFunc(
lefl->info.via.lr = (LinkedRect *)NULL; lefl->info.via.lr = (LinkedRect *)NULL;
lefl->refCnt = 0; /* These entries will be removed after writing */ lefl->refCnt = 0; /* These entries will be removed after writing */
HashSetValue(he, lefl); HashSetValue(he, lefl);
lefl->canonName = (char *)he->h_key.h_name; lefl->canonName = (const char *)he->h_key.h_name;
if ((sldist > 0) || (ldist > 0)) if ((sldist > 0) || (ldist > 0))
{ {
@ -2015,7 +2017,7 @@ defCountViaFunc(
*------------------------------------------------------------ *------------------------------------------------------------
*/ */
char * const char *
defGetType( defGetType(
TileType ttype, TileType ttype,
lefLayer **lefptr, lefLayer **lefptr,
@ -2100,7 +2102,7 @@ defWriteVias(
while ((he = HashNext(&LefInfo, &hs))) while ((he = HashNext(&LefInfo, &hs)))
{ {
int size, sep, border; int size, sep, border;
char *us1, *us2; const char *us1, *us2;
lefl = (lefLayer *)HashGetValue(he); lefl = (lefLayer *)HashGetValue(he);
if (!lefl) continue; if (!lefl) continue;
@ -2497,7 +2499,7 @@ defWriteBlockages(
if ((lefl != NULL) && ((lefl->lefClass == CLASS_ROUTE) || if ((lefl != NULL) && ((lefl->lefClass == CLASS_ROUTE) ||
(lefl->lefClass == CLASS_VIA))) (lefl->lefClass == CLASS_VIA)))
{ {
char *llayer; const char *llayer;
if (lefl->lefClass == CLASS_ROUTE) if (lefl->lefClass == CLASS_ROUTE)
llayer = lefl->canonName; llayer = lefl->canonName;
else else
@ -2876,7 +2878,7 @@ defMakeInverseLayerMap(
LefMapping *lefMagicToLefLayer; LefMapping *lefMagicToLefLayer;
lefLayer *lefl; lefLayer *lefl;
TileType i; TileType i;
char *lefname; const char *lefname;
lefMagicToLefLayer = (LefMapping *)mallocMagic(DBNumTypes lefMagicToLefLayer = (LefMapping *)mallocMagic(DBNumTypes
* sizeof(LefMapping)); * sizeof(LefMapping));

View File

@ -85,7 +85,7 @@ typedef struct {
TileType type; /* magic tile type, or -1 for none */ TileType type; /* magic tile type, or -1 for none */
TileType obsType; /* magic type to use if this is an obstruction */ TileType obsType; /* magic type to use if this is an obstruction */
short refCnt; /* reference count for memory deallocation */ short refCnt; /* reference count for memory deallocation */
char * canonName; /* name to use when writing LEF output */ const char * canonName; /* name to use when writing LEF output */
unsigned char lefClass; /* is this a via, route, or masterslice layer */ unsigned char lefClass; /* is this a via, route, or masterslice layer */
union { union {
lefRoute route; /* for route layers */ lefRoute route; /* for route layers */
@ -97,7 +97,7 @@ typedef struct {
/* layer corresponding to a magic tile type. */ /* layer corresponding to a magic tile type. */
typedef struct { typedef struct {
char *lefName; /* Primary name of LEF layer */ const char *lefName; /* Primary name of LEF layer */
lefLayer *lefInfo; /* Pointer to information about the layer */ lefLayer *lefInfo; /* Pointer to information about the layer */
} LefMapping; } LefMapping;
@ -114,7 +114,7 @@ typedef struct _lefRule {
/* Structure to hold nondefault rules required by nets */ /* Structure to hold nondefault rules required by nets */
typedef struct { typedef struct {
char *name; const char *name;
lefRule *rule; lefRule *rule;
} LefRules; } LefRules;
@ -129,7 +129,7 @@ typedef struct {
/* Linked string structure used to maintain list of nets to ignore */ /* Linked string structure used to maintain list of nets to ignore */
typedef struct _linkedNetName { typedef struct _linkedNetName {
char *lnn_name; const char *lnn_name;
struct _linkedNetName *lnn_next; struct _linkedNetName *lnn_next;
} linkedNetName; } linkedNetName;

View File

@ -639,7 +639,7 @@ LefRedefined(
const char *redefname) const char *redefname)
{ {
lefLayer *slef, *newlefl; lefLayer *slef, *newlefl;
char *altName; const char *altName;
LinkedRect *viaLR; LinkedRect *viaLR;
HashSearch hs; HashSearch hs;
HashEntry *he; HashEntry *he;
@ -659,8 +659,8 @@ LefRedefined(
if (slef == lefl) if (slef == lefl)
records++; records++;
if (altName == NULL) if (altName == NULL)
if (strcmp((char *)he->h_key.h_name, redefname)) if (strcmp((const char *)he->h_key.h_name, redefname))
altName = (char *)he->h_key.h_name; altName = (const char *)he->h_key.h_name;
} }
if (records == 1) if (records == 1)
{ {
@ -676,7 +676,7 @@ LefRedefined(
he = HashFind(&LefInfo, redefname); he = HashFind(&LefInfo, redefname);
newlefl = (lefLayer *)mallocMagic(sizeof(lefLayer)); newlefl = (lefLayer *)mallocMagic(sizeof(lefLayer));
newlefl->refCnt = 1; newlefl->refCnt = 1;
newlefl->canonName = (char *)he->h_key.h_name; newlefl->canonName = (const char *)he->h_key.h_name;
HashSetValue(he, newlefl); HashSetValue(he, newlefl);
/* If the canonical name of the original entry */ /* If the canonical name of the original entry */
@ -1960,7 +1960,7 @@ LefReadNonDefaultRule(
lefl->info.via.lr = (LinkedRect *)NULL; lefl->info.via.lr = (LinkedRect *)NULL;
HashSetValue(he, lefl); HashSetValue(he, lefl);
LefReadLayerSection(f, tsave, keyword, lefl); LefReadLayerSection(f, tsave, keyword, lefl);
lefl->canonName = (char *)he->h_key.h_name; lefl->canonName = (const char *)he->h_key.h_name;
} }
goto newrule; goto newrule;
@ -3007,7 +3007,7 @@ LefRead(
lefl->info.via.lr = (LinkedRect *)NULL; lefl->info.via.lr = (LinkedRect *)NULL;
HashSetValue(he, lefl); HashSetValue(he, lefl);
LefReadLayerSection(f, tsave, keyword, lefl); LefReadLayerSection(f, tsave, keyword, lefl);
lefl->canonName = (char *)he->h_key.h_name; lefl->canonName = (const char *)he->h_key.h_name;
} }
else if (keyword == LEF_SECTION_VIARULE) else if (keyword == LEF_SECTION_VIARULE)
/* If we've already seen this via, don't reprocess. */ /* If we've already seen this via, don't reprocess. */
@ -3064,7 +3064,7 @@ LefRead(
lefl->refCnt = 1; lefl->refCnt = 1;
lefl->lefClass = (DBIsContact(mtype)) ? CLASS_VIA : CLASS_ROUTE; lefl->lefClass = (DBIsContact(mtype)) ? CLASS_VIA : CLASS_ROUTE;
HashSetValue(he, lefl); HashSetValue(he, lefl);
lefl->canonName = (char *)he->h_key.h_name; lefl->canonName = (const char *)he->h_key.h_name;
} }
} }
else else

View File

@ -317,7 +317,7 @@ LefTechLine(
else else
newlefl->type = mtype; newlefl->type = mtype;
} }
newlefl->canonName = (char *)he->h_key.h_name; newlefl->canonName = (const char *)he->h_key.h_name;
/* "isObstruction" records whether the type is an */ /* "isObstruction" records whether the type is an */
/* obstruction or not. So recast the option to a route */ /* obstruction or not. So recast the option to a route */

View File

@ -308,7 +308,7 @@ lefWriteHeader(
/* NOTE: Type (e.g., "STRING") may be kept in hash value. */ /* NOTE: Type (e.g., "STRING") may be kept in hash value. */
/* This has not been implemented; only string types are supported */ /* This has not been implemented; only string types are supported */
fprintf(f, IN0 "MACRO %s STRING ;\n", (char *)he->h_key.h_name); fprintf(f, IN0 "MACRO %s STRING ;\n", (const char *)he->h_key.h_name);
} }
if (nprops > 0) fprintf(f, "END PROPERTYDEFINITIONS\n\n"); if (nprops > 0) fprintf(f, "END PROPERTYDEFINITIONS\n\n");
@ -323,7 +323,7 @@ lefWriteHeader(
char *propvalue; char *propvalue;
Rect boundary; Rect boundary;
siteDef = DBCellLookDef((char *)he->h_key.h_name); siteDef = DBCellLookDef((const char *)he->h_key.h_name);
if (siteDef) if (siteDef)
{ {
fprintf(f, "SITE %s\n", siteDef->cd_name); fprintf(f, "SITE %s\n", siteDef->cd_name);