fix zig builtin compilation and warnings

This commit is contained in:
Brendan Hansknecht 2024-07-06 22:00:12 -07:00
parent 669daad33d
commit 6b761f6f81
No known key found for this signature in database
GPG key ID: 0EA784685083E75B
2 changed files with 9 additions and 9 deletions

View file

@ -98,7 +98,7 @@ fn generateObjectFile(
const obj_file = obj.getEmittedBin();
var suffix =
const suffix =
if (target.os_tag == .windows)
"obj"
else

View file

@ -89,7 +89,7 @@ pub const RocList = extern struct {
return RocList.empty();
}
var list = allocate(@alignOf(T), slice.len, @sizeOf(T), elements_refcounted);
const list = allocate(@alignOf(T), slice.len, @sizeOf(T), elements_refcounted);
if (slice.len > 0) {
const dest = list.bytes orelse unreachable;
@ -221,7 +221,7 @@ pub const RocList = extern struct {
}
// unfortunately, we have to clone
var new_list = RocList.allocate(alignment, self.length, element_width, elements_refcounted);
const new_list = RocList.allocate(alignment, self.length, element_width, elements_refcounted);
var old_bytes: [*]u8 = @as([*]u8, @ptrCast(self.bytes));
var new_bytes: [*]u8 = @as([*]u8, @ptrCast(new_list.bytes));
@ -613,7 +613,7 @@ pub fn listReleaseExcessCapacity(
// If the list is unique, we can avoid incrementing and decrementing the live items.
// We can just decrement the dead elements and free the old list.
// This pattern is also like true in other locations like listConcat and listDropAt.
var output = RocList.allocateExact(alignment, old_length, element_width, elements_refcounted);
const output = RocList.allocateExact(alignment, old_length, element_width, elements_refcounted);
if (list.bytes) |source_ptr| {
const dest_ptr = output.bytes orelse unreachable;
@ -970,7 +970,7 @@ fn swap(width_initial: usize, p1: [*]u8, p2: [*]u8) void {
var ptr2 = p2;
var buffer_actual: [threshold]u8 = undefined;
var buffer: [*]u8 = buffer_actual[0..];
const buffer: [*]u8 = buffer_actual[0..];
while (true) {
if (width < threshold) {
@ -988,8 +988,8 @@ fn swap(width_initial: usize, p1: [*]u8, p2: [*]u8) void {
}
fn swapElements(source_ptr: [*]u8, element_width: usize, index_1: usize, index_2: usize) void {
var element_at_i = source_ptr + (index_1 * element_width);
var element_at_j = source_ptr + (index_2 * element_width);
const element_at_i = source_ptr + (index_1 * element_width);
const element_at_j = source_ptr + (index_2 * element_width);
return swap(element_width, element_at_i, element_at_j);
}
@ -1187,7 +1187,7 @@ fn rcNone(_: ?[*]u8) callconv(.C) void {}
test "listConcat: non-unique with unique overlapping" {
var nonUnique = RocList.fromSlice(u8, ([_]u8{1})[0..], false);
var bytes: [*]u8 = @as([*]u8, @ptrCast(nonUnique.bytes));
const bytes: [*]u8 = @as([*]u8, @ptrCast(nonUnique.bytes));
const ptr_width = @sizeOf(usize);
const refcount_ptr = @as([*]isize, @ptrCast(@as([*]align(ptr_width) u8, @alignCast(bytes)) - ptr_width));
utils.increfRcPtrC(&refcount_ptr[0], 1);
@ -1213,7 +1213,7 @@ pub fn listConcatUtf8(
const combined_length = list.len() + string.len();
// List U8 has alignment 1 and element_width 1
var result = list.reallocate(1, combined_length, 1);
const result = list.reallocate(1, combined_length, 1, false, &rcNone);
// We just allocated combined_length, which is > 0 because string.len() > 0
var bytes = result.bytes orelse unreachable;
@memcpy(bytes[list.len()..combined_length], string.asU8ptr()[0..string.len()]);