ref: 6045e24445b89f8e72e400574835ea8bb7d39673
parent: 3cc27c015d4354faed21058af35cf7e4a79839dd
parent: f9e53bfe1fc4d0177764550872b4fd6bee679205
author: Ori Bernstein <[email protected]>
date: Thu Jun 12 05:32:42 EDT 2014
Merge https://github.com/oridb/mc
--- a/6/ra.c
+++ b/6/ra.c
@@ -362,6 +362,12 @@
l->list = wl;
}
+static void wldel(Isel *s, Loc ***wl, size_t *nwl, size_t idx)
+{
+ (*wl)[idx]->list = NULL;
+ ldel(wl, nwl, idx);
+}
+
static void wlputset(Bitset *bs, regid r)
{
bsput(bs, r);
@@ -547,8 +553,9 @@
continue;
else if (!istrivial(s, i))
wlput(&s->wlspill, &s->nwlspill, locmap[i]);
- else if (moverelated(s, i))
+ else if (moverelated(s, i)) {
wlput(&s->wlfreeze, &s->nwlfreeze, locmap[i]);
+ }
else
wlput(&s->wlsimp, &s->nwlsimp, locmap[i]);
locmap[i]->reg.colour = 0;
@@ -605,7 +612,7 @@
*/
found = wlfind(s->wlspill, s->nwlspill, m, &idx);
if (found)
- ldel(&s->wlspill, &s->nwlspill, idx);
+ wldel(s, &s->wlspill, &s->nwlspill, idx);
if (moverelated(s, m)) {
if (!found)
assert(wlfind(s->wlfreeze, s->nwlfreeze, m, &idx));
@@ -656,8 +663,9 @@
if (!istrivial(s, u))
return;
- assert(wlfind(s->wlfreeze, s->nwlfreeze, u, &i));
- ldel(&s->wlfreeze, &s->nwlfreeze, i);
+ assert(locmap[u]->list == &s->wlfreeze || locmap[u]->list == &s->wlsimp);
+ if (wlfind(s->wlfreeze, s->nwlfreeze, u, &i))
+ wldel(s, &s->wlfreeze, &s->nwlfreeze, i);
wlput(&s->wlsimp, &s->nwlsimp, locmap[u]);
}
@@ -720,9 +728,9 @@
if (debugopt['r'] > 2)
printedge(stdout, "combining:", u, v);
if (wlfind(s->wlfreeze, s->nwlfreeze, v, &idx))
- ldel(&s->wlfreeze, &s->nwlfreeze, idx);
+ wldel(s, &s->wlfreeze, &s->nwlfreeze, idx);
else if (wlfind(s->wlspill, s->nwlspill, v, &idx)) {
- ldel(&s->wlspill, &s->nwlspill, idx);
+ wldel(s, &s->wlspill, &s->nwlspill, idx);
}
wlputset(s->coalesced, v);
s->aliasmap[v] = locmap[u];
@@ -750,7 +758,7 @@
decdegree(s, t);
}
if (!istrivial(s, u) && wlfind(s->wlfreeze, s->nwlfreeze, u, &idx)) {
- ldel(&s->wlfreeze, &s->nwlfreeze, idx);
+ wldel(s, &s->wlfreeze, &s->nwlfreeze, idx);
wlput(&s->wlspill, &s->nwlspill, locmap[u]);
}
}
@@ -822,7 +830,7 @@
if (!nodemoves(s, v->reg.id, NULL) && istrivial(s, v->reg.id)) {
if (!wlfind(s->wlfreeze, s->nwlfreeze, v->reg.id, &idx))
die("Reg %zd not in freeze wl\n", v->reg.id);
- ldel(&s->wlfreeze, &s->nwlfreeze, idx);
+ wldel(s, &s->wlfreeze, &s->nwlfreeze, idx);
wlput(&s->wlsimp, &s->nwlsimp, v);
}
@@ -851,7 +859,7 @@
if (!bshas(s->shouldspill, s->wlspill[i]->reg.id))
continue;
m = s->wlspill[i];
- ldel(&s->wlspill, &s->nwlspill, i);
+ wldel(s, &s->wlspill, &s->nwlspill, i);
break;
}
if (!m) {
@@ -861,7 +869,7 @@
continue;
}
m = s->wlspill[i];
- ldel(&s->wlspill, &s->nwlspill, i);
+ wldel(s, &s->wlspill, &s->nwlspill, i);
break;
}
}
--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -18,6 +18,7 @@
hasprefix.myr \
hassuffix.myr \
htab.myr \
+ ifreq.myr \
intparse.myr \
ipparse.myr \
mk.myr \
@@ -60,6 +61,9 @@
sys.myr: sys-$(SYS).myr
cp sys-$(SYS).myr sys.myr
+
+ifreq.myr: ifreq-$(SYS).myr
+ cp ifreq-$(SYS).myr ifreq.myr
waitstatus.myr: waitstatus-$(SYS).myr
cp waitstatus-$(SYS).myr waitstatus.myr
--- /dev/null
+++ b/libstd/ifreq-linux.myr
@@ -1,0 +1,65 @@
+pkg std
+ const Ifnamesize = 16
+
+ type ifreq_addr = struct
+ name : byte[Ifnamesz]
+ addr : sockaddr
+ ;;
+
+ type ifreq_dstaddr = struct
+ name : byte[Ifnamesz]
+ dstaddr : sockaddr
+ ;;
+
+ type ifreq_broadaddr = struct
+ name : byte[Ifnamesz]
+ broadaddr : sockaddr
+ ;;
+
+ type ifreq_netmask = struct
+ name : byte[Ifnamesz]
+ netmask : sockaddr
+ ;;
+
+
+ type ifreq_hwaddr = struct
+ name : byte[Ifnamesz]
+ hwaddr : sockaddr
+ ;;
+
+ type ifreq_flags = struct
+ name : byte[Ifnamesz]
+ flags : int16
+ ;;
+
+ type ifreq_ifindex = struct
+ name : byte[Ifnamesz]
+ index : int32
+ ;;
+
+ type ifreq_metric = struct
+ name : byte[Ifnamesz]
+ metric : int32
+ ;;
+
+
+ type ifreq_mtu = struct
+ name : byte[Ifnamesz]
+ mtu : int32
+ ;;
+
+ type ifreq_slave = struct
+ name : byte[Ifnamesz]
+ slave : byte[Ifnamesz]
+ ;;
+
+ type ifreq_newname = struct
+ name : byte[Ifnamesz]
+ newname : byte[Ifnamesz]
+ ;;
+
+ type ifreq_data = struct
+ name : byte[Ifnamesz]
+ data : void#
+ ;;
+;;
--- a/libstd/sys-linux.myr
+++ b/libstd/sys-linux.myr
@@ -43,24 +43,25 @@
;;
type statbuf = struct
- dev : uint
- ino : uint
- mode : uint16
- nlink : uint16
- uid : uint16
- gid : uint16
- rdev : uint
- size : uint
- blksize : uint
- blocks : uint
- atime : uint
- atimens : uint
- mtime : uint
- mtimens : uint
- ctime : uint
- ctimens : uint
- _unused1: uint
- _unused2: uint
+ dev : uint64
+ __inotrunc : uint32
+ __pad0 : uint32
+ mode : uint32
+ nlink : uint32
+ uid : uint32
+ gid : uint32
+ rdev : uint64
+ __pad1 : uint32
+ size : uint64
+ blksize : uint32
+ blocks : uint64
+ atime : uint64
+ atimens : uint64
+ mtime : uint64
+ mtimens : uint64
+ ctime : uint64
+ ctimens : uint64
+ ino : uint64
;;
type utsname = struct
@@ -557,7 +558,7 @@
}
/* fd manipulation */
-const open = {path, opts; -> syscall(Sysopen, cstring(path), 0o644, mode) castto(fd)}
+const open = {path, opts; -> syscall(Sysopen, cstring(path), opts, 0o777) castto(fd)}
const openmode = {path, opts, mode; -> syscall(Sysopen, cstring(path), opts, mode) castto(fd)}
const close = {fd; -> syscall(Sysclose, fd)}
const creat = {path, mode; -> syscall(Syscreat, cstring(path), mode) castto(fd)}
--- a/libstd/sys-osx.myr
+++ b/libstd/sys-osx.myr
@@ -593,7 +593,7 @@
/* fd manipulation */
-const open = {path, opts; -> syscall(Sysopen, cstring(path), opts, 0o644) castto(fd)}
+const open = {path, opts; -> syscall(Sysopen, cstring(path), opts, 0o777) castto(fd)}
const openmode = {path, opts, mode; -> syscall(Sysopen, cstring(path), opts, mode) castto(fd)}
const close = {fd; -> syscall(Sysclose, fd)}
const creat = {path, mode; -> openmode(path, Ocreat | Otrunc | Owronly, mode) castto(fd)}
--- a/parse/tok.c
+++ b/parse/tok.c
@@ -623,10 +623,16 @@
int c;
int isfloat;
int unsignedval;
+ /* because we allow '_' in numbers, and strtod/stroull don't, we
+ * need a buffer that holds the number without '_'.
+ */
+ char buf[128];
+ size_t nbuf;
t = NULL;
isfloat = 0;
start = fidx;
+ nbuf = 0;
for (c = peek(); isxdigit(c) || c == '.' || c == '_'; c = peek()) {
next();
if (c == '_')
@@ -635,17 +641,23 @@
isfloat = 1;
else if (hexval(c) < 0 || hexval(c) > base)
fatal(line, "Integer digit '%c' outside of base %d", c, base);
+ if (nbuf >= sizeof buf) {
+ buf[nbuf] = '\0';
+ fatal(line, "number %s... too long to represent", buf);
+ }
+ buf[nbuf++] = c;
}
+ buf[nbuf] = '\0';
/* we only support base 10 floats */
if (isfloat && base == 10) {
t = mktok(Tfloatlit);
t->str = strdupn(&fbuf[start], fidx - start);
- t->fltval = strtod(t->str, NULL);
+ t->fltval = strtod(buf, NULL);
} else {
t = mktok(Tintlit);
t->str = strdupn(&fbuf[start], fidx - start);
- t->intval = strtoull(t->str, NULL, base);
+ t->intval = strtoull(buf, NULL, base);
/* check suffixes:
* u -> unsigned
* l -> 64 bit