shithub: mc

Download patch

ref: 24e9cd439c9024f7140c13f544f885d0301c2b9a
parent: 02b049f149999981a2993939750a0f3739fd4dce
parent: f26f3e1bf47dc0603f14f8ee31326456fcb45bb5
author: Ori Bernstein <[email protected]>
date: Mon May 26 08:58:41 EDT 2014

Merge branch 'master' of git+ssh://mimir.eigenstate.org/git/ori/mc

--- a/6/isel.c
+++ b/6/isel.c
@@ -115,7 +115,7 @@
                 rip = locphysreg(Rrip);
                 l = locmeml(htget(s->globls, n), rip, NULL, mode(n));
             } else if (hthas(s->stkoff, n)) {
-                stkoff = (ssize_t)htget(s->stkoff, n);
+                stkoff = ptoi(htget(s->stkoff, n));
                 l = locmem(-stkoff, locphysreg(Rrbp), NULL, mode(n));
             }  else {
                 if (!hthas(s->reglocs, n))
--- a/6/ra.c
+++ b/6/ra.c
@@ -950,7 +950,7 @@
 {
     size_t stkoff;
 
-    stkoff = (size_t)htget(s->spillslots, (void*)reg);
+    stkoff = ptoi(htget(s->spillslots, itop(reg)));
     return locmem(-stkoff, locphysreg(Rrbp), NULL, locmap[reg]->mode);
 }
 
@@ -1081,7 +1081,7 @@
         locprint(stdout, l, 'x');
         printf(" to %zd(%%rbp)\n", s->stksz->lit);
     }
-    htput(s->spillslots, (void *)l->reg.id, (void *)s->stksz->lit);
+    htput(s->spillslots, itop(l->reg.id), itop(s->stksz->lit));
 }
 
 /* 
--- a/6/simp.c
+++ b/6/simp.c
@@ -1478,7 +1478,7 @@
         dump(n, stdout);
         printf("declared at %zd, size = %zd\n", s->stksz, size(n));
     }
-    htput(s->stkoff, n, (void*)s->stksz);
+    htput(s->stkoff, n, itop(s->stksz));
 }
 
 static void declarearg(Simp *s, Node *n)
@@ -1485,7 +1485,7 @@
 {
     assert(n->type == Ndecl || (n->type == Nexpr && exprop(n) == Ovar));
     s->argsz = align(s->argsz, min(size(n), Ptrsz));
-    htput(s->stkoff, n, (void*)-(s->argsz + 2*Ptrsz));
+    htput(s->stkoff, n, itop(-(s->argsz + 2*Ptrsz)));
     if (debugopt['i']) {
         dump(n, stdout);
         printf("declared at %zd\n", -(s->argsz + 2*Ptrsz));
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -523,6 +523,8 @@
 vlong host64(byte buf[8]);
 void be32(long v, byte buf[4]);
 long host32(byte buf[4]);
+static inline intptr_t ptoi(void *p) {return (intptr_t)p;}
+static inline void* itop(intptr_t i) {return (void*)i;}
 
 void wrbuf(FILE *fd, void *buf, size_t sz);
 void rdbuf(FILE *fd, void *buf, size_t sz);
--- a/parse/use.c
+++ b/parse/use.c
@@ -282,7 +282,7 @@
         *dest = mktype(-1, tid & ~Builtinmask);
     } else {
         lappend(&typefixdest, &ntypefixdest, dest);
-        lappend(&typefixid, &ntypefixid, (void*)tid);
+        lappend(&typefixid, &ntypefixid, itop(tid));
     }
 }
 
@@ -307,7 +307,7 @@
         ty->traits = mkbs();
         for (i = 0; i < n; i++) {
             v = rdint(fd);
-            tr = htget(trmap, (void*)v);
+            tr = htget(trmap, itop(v));
             settrait(ty, tr);
         }
     }
@@ -382,7 +382,7 @@
     n = rdint(fd);
     for (i = 0; i < n; i++)
         lappend(&tr->funcs, &tr->nfuncs, rdsym(fd, tr));
-    htput(trmap, (void*)uid, tr);
+    htput(trmap, itop(uid), tr);
     return tr;
 }
 
@@ -645,7 +645,7 @@
         case Nimpl:
             n->impl.traitname = unpickle(fd);
             i = rdint(fd);
-            n->impl.trait = htget(trmap, (void*)i);
+            n->impl.trait = htget(trmap, itop(i));
             rdtype(fd, &n->impl.type);
             n->impl.ndecls = rdint(fd);
             n->impl.decls = zalloc(sizeof(Node *)*n->impl.ndecls);
@@ -694,7 +694,7 @@
      * depended on when we do type inference.
      */
     for (i = 0; i < ntypefixdest; i++) {
-        t = htget(tidmap, (void*)typefixid[i]);
+        t = htget(tidmap, itop(typefixid[i]));
         if (!t)
             die("Unable to find type for id %zd\n", i);
         if (t->type == Tyname && !t->issynth) {
@@ -705,11 +705,11 @@
         }
         *typefixdest[i] = t;
         if (!*typefixdest[i])
-            die("Couldn't find type %d\n", (int)typefixid[i]);
+            die("Couldn't find type %zd\n", typefixid[i]);
     }
     /* check for duplicate type definitions */
     for (i = 0; i < ntypefixdest; i++) {
-        t = htget(tidmap, (void*)typefixid[i]);
+        t = htget(tidmap, itop(typefixid[i]));
         if (t->type != Tyname || t->issynth)
             continue;
         old = htget(tydedup, t->name);
@@ -766,7 +766,7 @@
     trmap = mkht(ptrhash, ptreq);
     /* builtin traits */
     for (i = 0; i < Ntraits; i++)
-        htput(trmap, (void*)i, traittab[i]);
+        htput(trmap, itop(i), traittab[i]);
     while ((c = fgetc(f)) != EOF) {
         switch(c) {
             case 'L':
@@ -792,7 +792,7 @@
             case 'T':
                 tid = rdint(f);
                 ty = tyunpickle(f);
-                htput(tidmap, (void*)tid, ty);
+                htput(tidmap, itop(tid), ty);
                 /* fix up types */
                 if (ty->type == Tyname) {
                     if (ty->issynth)