| ... | @@ -1890,7 +1890,7 @@ pub const Mutable = struct { | ... | @@ -1890,7 +1890,7 @@ pub const Mutable = struct { |
| 1890 | /// if it were a field in packed memory at the provided bit offset. | 1890 | /// if it were a field in packed memory at the provided bit offset. |
| 1891 | pub fn readPackedTwosComplement( | 1891 | pub fn readPackedTwosComplement( |
| 1892 | x: *Mutable, | 1892 | x: *Mutable, |
| 1893 | bytes: []const u8, | 1893 | buffer: []const u8, |
| 1894 | bit_offset: usize, | 1894 | bit_offset: usize, |
| 1895 | bit_count: usize, | 1895 | bit_count: usize, |
| 1896 | endian: Endian, | 1896 | endian: Endian, |
| ... | @@ -1909,11 +1909,11 @@ pub const Mutable = struct { | ... | @@ -1909,11 +1909,11 @@ pub const Mutable = struct { |
| 1909 | const total_bits = bit_offset + bit_count; | 1909 | const total_bits = bit_offset + bit_count; |
| 1910 | var last_byte = switch (endian) { | 1910 | var last_byte = switch (endian) { |
| 1911 | .Little => ((total_bits + 7) / 8) - 1, | 1911 | .Little => ((total_bits + 7) / 8) - 1, |
| 1912 | .Big => bytes.len - ((total_bits + 7) / 8), | 1912 | .Big => buffer.len - ((total_bits + 7) / 8), |
| 1913 | }; | 1913 | }; |
| 1914 | | 1914 | |
| 1915 | const sign_bit = @as(u8, 1) << @intCast(u3, (total_bits - 1) % 8); | 1915 | const sign_bit = @as(u8, 1) << @intCast(u3, (total_bits - 1) % 8); |
| 1916 | positive = ((bytes[last_byte] & sign_bit) == 0); | 1916 | positive = ((buffer[last_byte] & sign_bit) == 0); |
| 1917 | } | 1917 | } |
| 1918 | | 1918 | |
| 1919 | // Copy all complete limbs | 1919 | // Copy all complete limbs |
| ... | @@ -1922,7 +1922,7 @@ pub const Mutable = struct { | ... | @@ -1922,7 +1922,7 @@ pub const Mutable = struct { |
| 1922 | var bit_index: usize = 0; | 1922 | var bit_index: usize = 0; |
| 1923 | while (limb_index < bit_count / @bitSizeOf(Limb)) : (limb_index += 1) { | 1923 | while (limb_index < bit_count / @bitSizeOf(Limb)) : (limb_index += 1) { |
| 1924 | // Read one Limb of bits | 1924 | // Read one Limb of bits |
| 1925 | var limb = mem.readPackedInt(Limb, bytes, bit_index + bit_offset, endian); | 1925 | var limb = mem.readPackedInt(Limb, buffer, bit_index + bit_offset, endian); |
| 1926 | bit_index += @bitSizeOf(Limb); | 1926 | bit_index += @bitSizeOf(Limb); |
| 1927 | | 1927 | |
| 1928 | // 2's complement (bitwise not, then add carry bit) | 1928 | // 2's complement (bitwise not, then add carry bit) |
| ... | @@ -1938,10 +1938,10 @@ pub const Mutable = struct { | ... | @@ -1938,10 +1938,10 @@ pub const Mutable = struct { |
| 1938 | if (bit_count != bit_index) { | 1938 | if (bit_count != bit_index) { |
| 1939 | // Read all remaining bits | 1939 | // Read all remaining bits |
| 1940 | var limb = switch (signedness) { | 1940 | var limb = switch (signedness) { |
| 1941 | .unsigned => mem.readVarPackedInt(Limb, bytes, bit_index + bit_offset, bit_count - bit_index, endian, .unsigned), | 1941 | .unsigned => mem.readVarPackedInt(Limb, buffer, bit_index + bit_offset, bit_count - bit_index, endian, .unsigned), |
| 1942 | .signed => b: { | 1942 | .signed => b: { |
| 1943 | const SLimb = std.meta.Int(.signed, @bitSizeOf(Limb)); | 1943 | const SLimb = std.meta.Int(.signed, @bitSizeOf(Limb)); |
| 1944 | const limb = mem.readVarPackedInt(SLimb, bytes, bit_index + bit_offset, bit_count - bit_index, endian, .signed); | 1944 | const limb = mem.readVarPackedInt(SLimb, buffer, bit_index + bit_offset, bit_count - bit_index, endian, .signed); |
| 1945 | break :b @bitCast(Limb, limb); | 1945 | break :b @bitCast(Limb, limb); |
| 1946 | }, | 1946 | }, |
| 1947 | }; | 1947 | }; |
| ... | @@ -2383,7 +2383,7 @@ pub const Const = struct { | ... | @@ -2383,7 +2383,7 @@ pub const Const = struct { |
| 2383 | /// | 2383 | /// |
| 2384 | /// This is equivalent to storing the value of an integer with `bit_count` bits as | 2384 | /// This is equivalent to storing the value of an integer with `bit_count` bits as |
| 2385 | /// if it were a field in packed memory at the provided bit offset. | 2385 | /// if it were a field in packed memory at the provided bit offset. |
| 2386 | pub fn writePackedTwosComplement(x: Const, bytes: []u8, bit_offset: usize, bit_count: usize, endian: Endian) void { | 2386 | pub fn writePackedTwosComplement(x: Const, buffer: []u8, bit_offset: usize, bit_count: usize, endian: Endian) void { |
| 2387 | assert(x.fitsInTwosComp(if (x.positive) .unsigned else .signed, bit_count)); | 2387 | assert(x.fitsInTwosComp(if (x.positive) .unsigned else .signed, bit_count)); |
| 2388 | | 2388 | |
| 2389 | // Copy all complete limbs | 2389 | // Copy all complete limbs |
| ... | @@ -2401,7 +2401,7 @@ pub const Const = struct { | ... | @@ -2401,7 +2401,7 @@ pub const Const = struct { |
| 2401 | } | 2401 | } |
| 2402 | | 2402 | |
| 2403 | // Write one Limb of bits | 2403 | // Write one Limb of bits |
| 2404 | mem.writePackedInt(Limb, bytes, bit_index + bit_offset, limb, endian); | 2404 | mem.writePackedInt(Limb, buffer, bit_index + bit_offset, limb, endian); |
| 2405 | bit_index += @bitSizeOf(Limb); | 2405 | bit_index += @bitSizeOf(Limb); |
| 2406 | } | 2406 | } |
| 2407 | | 2407 | |
| ... | @@ -2413,7 +2413,7 @@ pub const Const = struct { | ... | @@ -2413,7 +2413,7 @@ pub const Const = struct { |
| 2413 | if (!x.positive) limb = ~limb +% carry; | 2413 | if (!x.positive) limb = ~limb +% carry; |
| 2414 | | 2414 | |
| 2415 | // Write all remaining bits | 2415 | // Write all remaining bits |
| 2416 | mem.writeVarPackedInt(bytes, bit_index + bit_offset, bit_count - bit_index, limb, endian); | 2416 | mem.writeVarPackedInt(buffer, bit_index + bit_offset, bit_count - bit_index, limb, endian); |
| 2417 | } | 2417 | } |
| 2418 | } | 2418 | } |
| 2419 | | 2419 | |