RTimothyEdwards / qflow

Qflow full end-to-end digital synthesis flow for ASIC designs
183 stars 36 forks source link

'restrict' reserved keyword used as variable name #11

Closed just22 closed 4 years ago

just22 commented 4 years ago

Dear Tim,

In this commit you added to the gate_ struct the member restrict, which is a reserved keyword; clang is complaining with an error:

In file included from vlog2Verilog.c:22:
In file included from ./readlef.h:12:
./lef.h:174:12: error: restrict requires a pointer or reference
    u_char restrict;    // TRUE if macro cannot be right-left mirrored
    ~~~~~~~^~~~~~~~

I don't know if there are side effects with gcc, anyway I would propose the following patchs:

Index: src/vlog2Cel.c
--- src/vlog2Cel.c.orig
+++ src/vlog2Cel.c
@@ -210,7 +210,7 @@ int write_output(struct cellrec *topcell, int units, c
            fprintf(outfptr, "cell %d %s:%s\n", cellidx, inst->cellname,
            inst->instname);
        }
-       if (gateginfo->restrict == TRUE) {
+       if (gateginfo->restricted == TRUE) {
        // LEF "SYMMETRY X" translates to .cel formate "nomirror"
        fprintf(outfptr, "nomirror\n");
        }
Index: src/readlef.c
--- src/readlef.c.orig
+++ src/readlef.c
@@ -2271,7 +2271,7 @@ LefReadMacro(f, mname, oscale)
     lefMacro->last = (GATE)NULL;
     lefMacro->nodes = 0;
     lefMacro->orient = 0;
-    lefMacro->restrict = FALSE;
+    lefMacro->restricted = FALSE;
     // Allocate memory for up to 10 pins initially
     lefMacro->taps = (DSEG *)malloc(10 * sizeof(DSEG));
     lefMacro->noderec = (NODE *)malloc(10 * sizeof(NODE));
@@ -2375,10 +2375,10 @@ origin_error:
        /* 'SYMMETRY X' (but not 'X Y') indicates no left-right flipping */
        token = LefNextToken(f, TRUE);
        if (*token != '\n') {
-           if (strchr(token, 'X') != NULL) lefMacro->restrict = TRUE;
+           if (strchr(token, 'X') != NULL) lefMacro->restricted = TRUE;
            token = LefNextToken(f, TRUE);
            if (*token != '\n') {
-           if (strchr(token, 'Y') != NULL) lefMacro->restrict = FALSE;
+           if (strchr(token, 'Y') != NULL) lefMacro->restricted = FALSE;
            }
        }
        if (token && (*token != ';'))
@@ -3457,7 +3457,7 @@ LefRead(inName)
    gateginfo->placedX = 0.0;
    gateginfo->placedY = 0.0;
    gateginfo->nodes = 1;
-   gateginfo->restrict = FALSE;
+   gateginfo->restricted = FALSE;

         gateginfo->taps = (DSEG *)malloc(sizeof(DSEG));
         gateginfo->noderec = (NODE *)malloc(sizeof(NODE));
Index: src/readdef.c
--- src/readdef.c.orig
+++ src/readdef.c
@@ -1017,7 +1017,7 @@ DefReadPins(FILE *f, char *sname, float oscale, int to
        gate->node[0] = NULL;
        gate->direction[0] = PORT_CLASS_DEFAULT;
        gate->area[0] = 0.0;
-       gate->restrict = FALSE;
+       gate->restricted = FALSE;
        gate->clientdata = (void *)NULL;

        /* Now do a search through the line for "+" entries */
@@ -1433,7 +1433,7 @@ DefAddGateInstance(GATE gate)
     gate->width = gateginfo->width;   
     gate->height = gateginfo->height;   
     gate->nodes = gateginfo->nodes;   
-    gate->restrict = gateginfo->restrict;   
+    gate->restricted = gateginfo->restricted;   
     gate->obs = (DSEG)NULL;

     gate->taps = (DSEG *)malloc(gate->nodes * sizeof(DSEG));
@@ -1671,7 +1671,7 @@ DefReadComponents(FILE *f, char *sname, float oscale, 
            gate = (GATE)malloc(sizeof(struct gate_));
            gate->gatename = strdup(usename);
            gate->gatetype = gateginfo;
-           gate->restrict = FALSE;
+           gate->restricted = FALSE;
            gate->clientdata = (void *)NULL;
        }
Index: src/lef.h
--- src/lef.h.orig
+++ src/lef.h
@@ -171,7 +171,7 @@ struct gate_ {
     double placedX;                 
     double placedY;
     int orient;
-    u_char restrict;   // TRUE if macro cannot be right-left mirrored
+    u_char restricted; // TRUE if macro cannot be right-left mirrored
     void *clientdata;  // This space for rent
 };
Index: src/addspacers.c
--- src/addspacers.c.orig
+++ src/addspacers.c
@@ -585,9 +585,9 @@ generate_fill(char *fillcellname, float scale, COREBBO
            newfillinst->placedY = (double)y / (double)scale;
            newfillinst->clientdata = (void *)NULL;
            newfillinst->orient = (row) ? row->orient : orient;
-           newfillinst->restrict = testfill->gate->restrict;
+           newfillinst->restricted = testfill->gate->restricted;
            /* Flip-restricted cells must be either "N" or "FS" */
-           if ((newfillinst->restrict == TRUE) &&
+           if ((newfillinst->restricted == TRUE) &&
                (newfillinst->orient == RS)) newfillinst->orient |= RF;
            DefAddGateInstance(newfillinst);

@@ -883,11 +883,11 @@ generate_stripefill(char *VddNet, char *GndNet, char *
            newfillinst->placedX = (double)(x + totalfx) / (double)scale;
            newfillinst->placedY = (double)y / (double)scale;
            newfillinst->clientdata = (void *)NULL;
-           newfillinst->restrict = testfill->gate->restrict;
+           newfillinst->restricted = testfill->gate->restricted;
            row = DefFindRow(y);
            newfillinst->orient = (row) ? row->orient : orient;
            /* Flip-restricted cells must be either "N" or "FS" */
-           if ((newfillinst->restrict == TRUE) &&
+           if ((newfillinst->restricted == TRUE) &&
                (newfillinst->orient == RS)) newfillinst->orient |= RF;
            DefAddGateInstance(newfillinst);
RTimothyEdwards commented 4 years ago

Well, on the other hand, it's nice to know that it otherwise compiles with clang. Thanks for pointing this out. I have updated, although I opted to replace "restrict" with "nomirror", as that is more to the point, anyway (fixed on opencircuitdesign.com; it will mirror to github tonight).