More precise alignCast (allow for 32-bit targets)

This commit is contained in:
Brian Carroll 2021-12-13 16:09:55 +00:00
parent 457041a314
commit 3c74acafa4
4 changed files with 7 additions and 7 deletions

View file

@ -36,7 +36,7 @@ pub const RocList = extern struct {
}
// otherwise, check if the refcount is one
const ptr: [*]usize = @ptrCast([*]usize, @alignCast(8, self.bytes));
const ptr: [*]usize = @ptrCast([*]usize, @alignCast(@alignOf(usize), self.bytes));
return (ptr - 1)[0] == utils.REFCOUNT_ONE;
}
@ -1282,7 +1282,7 @@ pub fn listSet(
// `if inBounds then LowLevelListGet input index item else input`
// so we don't do a bounds check here. Hence, the list is also non-empty,
// because inserting into an empty list is always out of bounds
const ptr: [*]usize = @ptrCast([*]usize, @alignCast(8, bytes));
const ptr: [*]usize = @ptrCast([*]usize, @alignCast(@alignOf(usize), bytes));
if ((ptr - 1)[0] == utils.REFCOUNT_ONE) {
return listSetInPlaceHelp(bytes, index, element, element_width, dec);