Make source code compile with 32 bit (but not build 32 bit code)

This commit is contained in:
gingerBill
2018-06-15 21:46:03 +01:00
parent b92a8c513e
commit ba67e474d3
8 changed files with 23 additions and 25 deletions
+2 -2
View File
@@ -64,7 +64,7 @@ murmur32 :: proc(data: []byte) -> u32 {
c2_32: u32 : 0x1b873593;
h1: u32 = 0;
nblocks := uintptr(len(data)/4);
nblocks := len(data)/4;
p := &data[0];
p1 := mem.ptr_offset(p, 4*nblocks);
@@ -187,7 +187,7 @@ murmur64 :: proc(data: []byte) -> u64 {
}
// TODO(bill): Fix this
#no_bounds_check data8 := slice_to_bytes(data32[i..])[..3];
#no_bounds_check data8 := mem.slice_to_bytes(data32[i..])[..3];
switch len {
case 3:
h2 ~= u32(data8[2]) << 16;
+1 -1
View File
@@ -235,7 +235,7 @@ pool_alloc :: proc(using pool: ^Pool, bytes: int) -> rawptr {
}
memory := current_pos;
current_pos = ptr_offset((^byte)(current_pos), uintptr(bytes));
current_pos = ptr_offset((^byte)(current_pos), bytes);
bytes_left -= bytes;
return memory;
}
+5 -5
View File
@@ -62,16 +62,16 @@ compare :: proc "contextless" (a, b: []byte) -> int {
}
compare_byte_ptrs :: proc "contextless" (a, b: ^byte, n: int) -> int {
pa :: ptr_offset;
for i in 0..uintptr(n) do switch {
for i in 0..n do switch {
case pa(a, i)^ < pa(b, i)^: return -1;
case pa(a, i)^ > pa(b, i)^: return +1;
}
return 0;
}
ptr_offset :: proc "contextless" (ptr: $P/^$T, n: uintptr) -> P {
new := uintptr(ptr) + size_of(T)*n;
return P(new);
ptr_offset :: proc "contextless" (ptr: $P/^$T, n: int) -> P {
new := int(uintptr(ptr)) + size_of(T)*n;
return P(uintptr(new));
}
ptr_sub :: proc "contextless" (a, b: $P/^$T) -> int {
@@ -143,7 +143,7 @@ allocation_header_fill :: proc(header: ^AllocationHeader, data: rawptr, size: in
ptr := cast(^uint)(ptr_offset(header, 1));
n := ptr_sub(cast(^uint)data, ptr);
for i in 0..uintptr(n) {
for i in 0..n {
ptr_offset(ptr, i)^ = ~uint(0);
}
}
+1 -1
View File
@@ -374,7 +374,7 @@ append :: proc(array: ^$T/[dynamic]$E, args: ...E, loc := #caller_location) -> i
a := (^mem.Raw_Dynamic_Array)(array);
data := (^E)(a.data);
assert(data != nil);
mem.copy(mem.ptr_offset(data, uintptr(a.len)), &args[0], size_of(E) * arg_len);
mem.copy(mem.ptr_offset(data, a.len), &args[0], size_of(E) * arg_len);
a.len += arg_len;
}
return len(array);