Commit fec795cd29

LemonBoy <thatlemon@gmail.com>
2019-09-09 21:57:35
Adjust the stdlib to be 32bit compatible
1 parent f50bfb9
Changed files (3)
std
std/hash/cityhash.zig
@@ -214,7 +214,7 @@ pub const CityHash64 = struct {
     }
 
     fn hashLen0To16(str: []const u8) u64 {
-        const len: u64 = @truncate(u64, str.len);
+        const len: u64 = u64(str.len);
         if (len >= 8) {
             const mul: u64 = k2 +% len *% 2;
             const a: u64 = fetch64(str.ptr) +% k2;
@@ -240,7 +240,7 @@ pub const CityHash64 = struct {
     }
 
     fn hashLen17To32(str: []const u8) u64 {
-        const len: u64 = @truncate(u64, str.len);
+        const len: u64 = u64(str.len);
         const mul: u64 = k2 +% len *% 2;
         const a: u64 = fetch64(str.ptr) *% k1;
         const b: u64 = fetch64(str.ptr + 8);
@@ -251,7 +251,7 @@ pub const CityHash64 = struct {
     }
 
     fn hashLen33To64(str: []const u8) u64 {
-        const len: u64 = @truncate(u64, str.len);
+        const len: u64 = u64(str.len);
         const mul: u64 = k2 +% len *% 2;
         const a: u64 = fetch64(str.ptr) *% k2;
         const b: u64 = fetch64(str.ptr + 8);
@@ -305,7 +305,7 @@ pub const CityHash64 = struct {
             return hashLen33To64(str);
         }
 
-        var len: u64 = @truncate(u64, str.len);
+        var len: u64 = u64(str.len);
 
         var x: u64 = fetch64(str.ptr + str.len - 40);
         var y: u64 = fetch64(str.ptr + str.len - 16) +% fetch64(str.ptr + str.len - 56);
std/hash/murmur.zig
@@ -98,9 +98,9 @@ pub const Murmur2_64 = struct {
 
     pub fn hashWithSeed(str: []const u8, seed: u64) u64 {
         const m: u64 = 0xc6a4a7935bd1e995;
-        const len = @truncate(u64, str.len);
+        const len = u64(str.len);
         var h1: u64 = seed ^ (len *% m);
-        for (@ptrCast([*]allowzero align(1) const u64, str.ptr)[0..(len >> 3)]) |v| {
+        for (@ptrCast([*]allowzero align(1) const u64, str.ptr)[0..@intCast(usize, len >> 3)]) |v| {
             var k1: u64 = v;
             if (builtin.endian == builtin.Endian.Big)
                 k1 = @byteSwap(u64, k1);
@@ -114,7 +114,7 @@ pub const Murmur2_64 = struct {
         const offset = len - rest;
         if (rest > 0) {
             var k1: u64 = 0;
-            @memcpy(@ptrCast([*]u8, &k1), @ptrCast([*]const u8, &str[offset]), rest);
+            @memcpy(@ptrCast([*]u8, &k1), @ptrCast([*]const u8, &str[@intCast(usize, offset)]), @intCast(usize, rest));
             if (builtin.endian == builtin.Endian.Big)
                 k1 = @byteSwap(u64, k1);
             h1 ^= k1;
std/os/bits/linux/arm-eabi.zig
@@ -569,3 +569,5 @@ pub const timezone = extern struct {
     tz_minuteswest: i32,
     tz_dsttime: i32,
 };
+
+pub const Elf_Symndx = u32;