ref: 28920020c79d99633a69d19f05a56e73bb3356c4
parent: f89df20e0dae4f7884cd432e9064ddb0f6e26ede
author: Ori Bernstein <[email protected]>
date: Thu Oct 24 09:43:56 EDT 2013
Be more compliant with stricter type name checking We had a bug where we used compatible-but-differing named types in the allocator. This should never have compiled, but our type checker missed it.
--- a/libstd/alloc.myr
+++ b/libstd/alloc.myr
@@ -219,7 +219,7 @@
die("Unable to mmap")
;;
- s = align(p castto(intptr), Slabsz) castto(slab#)
+ s = align(p castto(size), Slabsz) castto(slab#)
s.head = p
s.nfree = bkt.nper
/* skip past the slab header */
@@ -315,14 +315,6 @@
}
/*
-chunks are variable sizes, so we can't just
-index to get to the next one
-*/
-const nextchunk = {b, sz
- -> ((b castto(intptr)) + sz) castto(chunk#)
-}
-
-/*
aligns a size to a requested alignment.
'align' must be a power of two
*/
@@ -331,9 +323,17 @@
}
/*
+chunks are variable sizes, so we can't just
+index to get to the next one
+*/
+const nextchunk = {b, sz : size
+ -> ((b castto(intptr)) + (sz castto(intptr))) castto(chunk#)
+}
+
+/*
truncates a pointer to 'align'. 'align' must
be a power of two.
*/
const mtrunc = {m, align
- -> ((m castto(intptr)) & ~(align - 1)) castto(byte#)
+ -> ((m castto(intptr)) & ~((align castto(intptr)) - 1)) castto(byte#)
}