shithub: scc

Download patch

ref: 742a008857ece4651a448d49954a08383dc714fc
parent: ae0f567bba4dd727c7f2f72764b04e9540c36850
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Sep 24 19:11:33 EDT 2015

Remove the difference between local and global id

These difference were created long time ago to have different tables
for locals and global identifiers, but this was a stupid solution.
We are using this id now only how an identifier to find symbols
in a common hash, so this difference was creating collisions in the
table.

--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -12,8 +12,7 @@
 #define NR_SYM_HASH 64
 
 unsigned curctx;
-static unsigned short localcnt;
-static unsigned short globalcnt;
+static unsigned short counterid;
 
 static Symbol *head, *labels;
 static Symbol *htab[NR_SYM_HASH];
@@ -105,7 +104,6 @@
 	short f;
 
 	if (--curctx == GLOBALCTX) {
-		localcnt = 0;
 		for (sym = labels; sym; sym = next) {
 			next = sym->next;
 			killsym(sym);
@@ -125,7 +123,7 @@
 {
 	unsigned short id;
 
-	id = (curctx) ? ++localcnt : ++globalcnt;
+	id = ++counterid;
 	if (id == 0) {
 		die("Overflow in %s identifiers",
 		    (curctx) ? "internal" : "external");
@@ -375,6 +373,6 @@
 	 * will make faster some operations. There is no problem of memory
 	 * leakeage because this memory is not ever freed
 	 */
-	globalcnt = 0;
+	counterid = 0;
 	head = NULL;
 }