Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/aro/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ pub fn generateBuiltinMacros(comp: *Compilation) !Source {
\\#define __ORDER_PDP_ENDIAN__ 3412
\\
);
if (comp.target.cpu.arch.endian() == .Little) try w.writeAll(
if (comp.target.cpu.arch.endian() == .little) try w.writeAll(
\\#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
\\#define __LITTLE_ENDIAN__ 1
\\
Expand Down
4 changes: 2 additions & 2 deletions deps/aro/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ pub fn ldEmulationOption(target: std.Target, arm_endianness: ?std.builtin.Endian
.thumb,
.thumbeb,
=> switch (arm_endianness orelse target.cpu.arch.endian()) {
.Little => "armelf_linux_eabi",
.Big => "armelfb_linux_eabi",
.little => "armelf_linux_eabi",
.big => "armelfb_linux_eabi",
},
.aarch64 => "aarch64linux",
.aarch64_be => "aarch64linuxb",
Expand Down
4 changes: 2 additions & 2 deletions doc/langref.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -3376,11 +3376,11 @@ fn doTheTest() !void {

var ordered: [2]u8 = @bitCast(full);
switch (native_endian) {
.Big => {
.big => {
try expect(ordered[0] == 0x12);
try expect(ordered[1] == 0x34);
},
.Little => {
.little => {
try expect(ordered[0] == 0x34);
try expect(ordered[1] == 0x12);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/common.zig
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ pub fn HalveInt(comptime T: type, comptime signed_half: bool) type {
pub const HalfT = if (signed_half) HalfTS else HalfTU;

all: T,
s: if (native_endian == .Little)
s: if (native_endian == .little)
extern struct { low: HalfT, high: HalfT }
else
extern struct { high: HalfT, low: HalfT },
Expand Down
12 changes: 6 additions & 6 deletions lib/compiler_rt/fmod.zig
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ pub fn fmodq(a: f128, b: f128) callconv(.C) f128 {
const bPtr_u16: [*]u16 = @ptrCast(&bmod);

const exp_and_sign_index = comptime switch (builtin.target.cpu.arch.endian()) {
.Little => 7,
.Big => 0,
.little => 7,
.big => 0,
};
const low_index = comptime switch (builtin.target.cpu.arch.endian()) {
.Little => 0,
.Big => 1,
.little => 0,
.big => 1,
};
const high_index = comptime switch (builtin.target.cpu.arch.endian()) {
.Little => 1,
.Big => 0,
.little => 1,
.big => 0,
};

const signA = aPtr_u16[exp_and_sign_index] & 0x8000;
Expand Down
4 changes: 2 additions & 2 deletions lib/compiler_rt/udivmod.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const Log2Int = std.math.Log2Int;
const HalveInt = @import("common.zig").HalveInt;

const lo = switch (builtin.cpu.arch.endian()) {
.Big => 1,
.Little => 0,
.big => 1,
.little => 0,
};
const hi = 1 - lo;

Expand Down
4 changes: 2 additions & 2 deletions lib/compiler_rt/udivmodei4.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const endian = builtin.cpu.arch.endian();

/// Get the value of a limb.
inline fn limb(x: []const u32, i: usize) u32 {
return if (endian == .Little) x[i] else x[x.len - 1 - i];
return if (endian == .little) x[i] else x[x.len - 1 - i];
}

/// Change the value of a limb.
inline fn limb_set(x: []u32, i: usize, v: u32) void {
if (endian == .Little) {
if (endian == .little) {
x[i] = v;
} else {
x[x.len - 1 - i] = v;
Expand Down
4 changes: 2 additions & 2 deletions lib/std/Build/Step/CheckObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1624,8 +1624,8 @@ const WasmDumper = struct {
switch (opcode) {
.i32_const => try writer.print("i32.const {x}\n", .{try std.leb.readILEB128(i32, reader)}),
.i64_const => try writer.print("i64.const {x}\n", .{try std.leb.readILEB128(i64, reader)}),
.f32_const => try writer.print("f32.const {x}\n", .{@as(f32, @bitCast(try reader.readIntLittle(u32)))}),
.f64_const => try writer.print("f64.const {x}\n", .{@as(f64, @bitCast(try reader.readIntLittle(u64)))}),
.f32_const => try writer.print("f32.const {x}\n", .{@as(f32, @bitCast(try reader.readInt(u32, .little)))}),
.f64_const => try writer.print("f64.const {x}\n", .{@as(f64, @bitCast(try reader.readInt(u64, .little)))}),
.global_get => try writer.print("global.get {x}\n", .{try std.leb.readULEB128(u32, reader)}),
else => unreachable,
}
Expand Down
8 changes: 4 additions & 4 deletions lib/std/base64.zig
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ pub const Base64Encoder = struct {
var idx: usize = 0;
var out_idx: usize = 0;
while (idx + 15 < source.len) : (idx += 12) {
const bits = std.mem.readIntBig(u128, source[idx..][0..16]);
const bits = std.mem.readInt(u128, source[idx..][0..16], .big);
inline for (0..16) |i| {
dest[out_idx + i] = encoder.alphabet_chars[@truncate((bits >> (122 - i * 6)) & 0x3f)];
}
out_idx += 16;
}
while (idx + 3 < source.len) : (idx += 3) {
const bits = std.mem.readIntBig(u32, source[idx..][0..4]);
const bits = std.mem.readInt(u32, source[idx..][0..4], .big);
dest[out_idx] = encoder.alphabet_chars[(bits >> 26) & 0x3f];
dest[out_idx + 1] = encoder.alphabet_chars[(bits >> 20) & 0x3f];
dest[out_idx + 2] = encoder.alphabet_chars[(bits >> 14) & 0x3f];
Expand Down Expand Up @@ -226,7 +226,7 @@ pub const Base64Decoder = struct {
if ((new_bits & invalid_char_tst) != 0) return error.InvalidCharacter;
bits |= (new_bits << (24 * i));
}
std.mem.writeIntLittle(u128, dest[dest_idx..][0..16], bits);
std.mem.writeInt(u128, dest[dest_idx..][0..16], bits, .little);
}
while (fast_src_idx + 4 < source.len and dest_idx + 3 < dest.len) : ({
fast_src_idx += 4;
Expand All @@ -237,7 +237,7 @@ pub const Base64Decoder = struct {
bits |= decoder.fast_char_to_index[2][source[fast_src_idx + 2]];
bits |= decoder.fast_char_to_index[3][source[fast_src_idx + 3]];
if ((bits & invalid_char_tst) != 0) return error.InvalidCharacter;
std.mem.writeIntLittle(u32, dest[dest_idx..][0..4], bits);
std.mem.writeInt(u32, dest[dest_idx..][0..4], bits, .little);
}
var remaining = source[fast_src_idx..];
for (remaining, fast_src_idx..) |c, src_idx| {
Expand Down
4 changes: 2 additions & 2 deletions lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ pub const FloatMode = enum {
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
pub const Endian = enum {
Big,
Little,
big,
little,
};

/// This data structure is used by the Zig language code generation and
Expand Down
4 changes: 2 additions & 2 deletions lib/std/child_process.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ fn writeIntFd(fd: i32, value: ErrInt) !void {
.capable_io_mode = .blocking,
.intended_io_mode = .blocking,
};
file.writer().writeIntNative(u64, @as(u64, @intCast(value))) catch return error.SystemResources;
file.writer().writeInt(u64, @intCast(value), .little) catch return error.SystemResources;
}

fn readIntFd(fd: i32) !ErrInt {
Expand All @@ -1385,7 +1385,7 @@ fn readIntFd(fd: i32) !ErrInt {
.capable_io_mode = .blocking,
.intended_io_mode = .blocking,
};
return @as(ErrInt, @intCast(file.reader().readIntNative(u64) catch return error.SystemResources));
return @as(ErrInt, @intCast(file.reader().readInt(u64, .little) catch return error.SystemResources));
}

/// Caller must free result.
Expand Down
40 changes: 20 additions & 20 deletions lib/std/coff.zig
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ pub const Symbol = struct {

pub fn getNameOffset(self: Symbol) ?u32 {
if (!std.mem.eql(u8, self.name[0..4], "\x00\x00\x00\x00")) return null;
const offset = std.mem.readIntLittle(u32, self.name[4..8]);
const offset = std.mem.readInt(u32, self.name[4..8], .little);
return offset;
}
};
Expand Down Expand Up @@ -1075,7 +1075,7 @@ pub const Coff = struct {
var stream = std.io.fixedBufferStream(data);
const reader = stream.reader();
try stream.seekTo(pe_pointer_offset);
var coff_header_offset = try reader.readIntLittle(u32);
var coff_header_offset = try reader.readInt(u32, .little);
try stream.seekTo(coff_header_offset);
var buf: [4]u8 = undefined;
try reader.readNoEof(&buf);
Expand Down Expand Up @@ -1142,7 +1142,7 @@ pub const Coff = struct {
if (!mem.eql(u8, &cv_signature, "RSDS"))
return error.InvalidPEMagic;
try reader.readNoEof(self.guid[0..]);
self.age = try reader.readIntLittle(u32);
self.age = try reader.readInt(u32, .little);

// Finally read the null-terminated string.
var byte = try reader.readByte();
Expand Down Expand Up @@ -1223,7 +1223,7 @@ pub const Coff = struct {
if (coff_header.pointer_to_symbol_table == 0) return null;

const offset = coff_header.pointer_to_symbol_table + Symbol.sizeOf() * coff_header.number_of_symbols;
const size = mem.readIntLittle(u32, self.data[offset..][0..4]);
const size = mem.readInt(u32, self.data[offset..][0..4], .little);
if ((offset + size) > self.data.len) return error.InvalidStrtabSize;

return Strtab{ .buffer = self.data[offset..][0..size] };
Expand Down Expand Up @@ -1324,9 +1324,9 @@ pub const Symtab = struct {
fn asSymbol(raw: []const u8) Symbol {
return .{
.name = raw[0..8].*,
.value = mem.readIntLittle(u32, raw[8..12]),
.section_number = @as(SectionNumber, @enumFromInt(mem.readIntLittle(u16, raw[12..14]))),
.type = @as(SymType, @bitCast(mem.readIntLittle(u16, raw[14..16]))),
.value = mem.readInt(u32, raw[8..12], .little),
.section_number = @as(SectionNumber, @enumFromInt(mem.readInt(u16, raw[12..14], .little))),
.type = @as(SymType, @bitCast(mem.readInt(u16, raw[14..16], .little))),
.storage_class = @as(StorageClass, @enumFromInt(raw[16])),
.number_of_aux_symbols = raw[17],
};
Expand All @@ -1335,27 +1335,27 @@ pub const Symtab = struct {
fn asDebugInfo(raw: []const u8) DebugInfoDefinition {
return .{
.unused_1 = raw[0..4].*,
.linenumber = mem.readIntLittle(u16, raw[4..6]),
.linenumber = mem.readInt(u16, raw[4..6], .little),
.unused_2 = raw[6..12].*,
.pointer_to_next_function = mem.readIntLittle(u32, raw[12..16]),
.pointer_to_next_function = mem.readInt(u32, raw[12..16], .little),
.unused_3 = raw[16..18].*,
};
}

fn asFuncDef(raw: []const u8) FunctionDefinition {
return .{
.tag_index = mem.readIntLittle(u32, raw[0..4]),
.total_size = mem.readIntLittle(u32, raw[4..8]),
.pointer_to_linenumber = mem.readIntLittle(u32, raw[8..12]),
.pointer_to_next_function = mem.readIntLittle(u32, raw[12..16]),
.tag_index = mem.readInt(u32, raw[0..4], .little),
.total_size = mem.readInt(u32, raw[4..8], .little),
.pointer_to_linenumber = mem.readInt(u32, raw[8..12], .little),
.pointer_to_next_function = mem.readInt(u32, raw[12..16], .little),
.unused = raw[16..18].*,
};
}

fn asWeakExtDef(raw: []const u8) WeakExternalDefinition {
return .{
.tag_index = mem.readIntLittle(u32, raw[0..4]),
.flag = @as(WeakExternalFlag, @enumFromInt(mem.readIntLittle(u32, raw[4..8]))),
.tag_index = mem.readInt(u32, raw[0..4], .little),
.flag = @as(WeakExternalFlag, @enumFromInt(mem.readInt(u32, raw[4..8], .little))),
.unused = raw[8..18].*,
};
}
Expand All @@ -1368,11 +1368,11 @@ pub const Symtab = struct {

fn asSectDef(raw: []const u8) SectionDefinition {
return .{
.length = mem.readIntLittle(u32, raw[0..4]),
.number_of_relocations = mem.readIntLittle(u16, raw[4..6]),
.number_of_linenumbers = mem.readIntLittle(u16, raw[6..8]),
.checksum = mem.readIntLittle(u32, raw[8..12]),
.number = mem.readIntLittle(u16, raw[12..14]),
.length = mem.readInt(u32, raw[0..4], .little),
.number_of_relocations = mem.readInt(u16, raw[4..6], .little),
.number_of_linenumbers = mem.readInt(u16, raw[6..8], .little),
.checksum = mem.readInt(u32, raw[8..12], .little),
.number = mem.readInt(u16, raw[12..14], .little),
.selection = @as(ComdatSelection, @enumFromInt(raw[14])),
.unused = raw[15..18].*,
};
Expand Down
10 changes: 5 additions & 5 deletions lib/std/compress/gzip.zig
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ pub fn Decompress(comptime ReaderType: type) type {
const FLG = header[3];
// Modification time, as a Unix timestamp.
// If zero there's no timestamp available.
const MTIME = mem.readIntLittle(u32, header[4..8]);
const MTIME = mem.readInt(u32, header[4..8], .little);
// Extra flags
const XFL = header[8];
// Operating system where the compression took place
const OS = header[9];
_ = XFL;

const extra = if (FLG & FEXTRA != 0) blk: {
const len = try hashed_reader.readIntLittle(u16);
const len = try hashed_reader.readInt(u16, .little);
const tmp_buf = try allocator.alloc(u8, len);
errdefer allocator.free(tmp_buf);

Expand All @@ -88,7 +88,7 @@ pub fn Decompress(comptime ReaderType: type) type {
errdefer if (comment) |p| allocator.free(p);

if (FLG & FHCRC != 0) {
const hash = try source.readIntLittle(u16);
const hash = try source.readInt(u16, .little);
if (hash != @as(u16, @truncate(hasher.hasher.final())))
return error.WrongChecksum;
}
Expand Down Expand Up @@ -133,12 +133,12 @@ pub fn Decompress(comptime ReaderType: type) type {
}

// We've reached the end of stream, check if the checksum matches
const hash = try self.in_reader.readIntLittle(u32);
const hash = try self.in_reader.readInt(u32, .little);
if (hash != self.hasher.final())
return error.WrongChecksum;

// The ISIZE field is the size of the uncompressed input modulo 2^32
const input_size = try self.in_reader.readIntLittle(u32);
const input_size = try self.in_reader.readInt(u32, .little);
if (self.read_amt & 0xffffffff != input_size)
return error.CorruptedData;

Expand Down
6 changes: 3 additions & 3 deletions lib/std/compress/lzma/decode.zig
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ pub const Params = struct {
props /= 5;
const pb = @as(u3, @intCast(props));

const dict_size_provided = try reader.readIntLittle(u32);
const dict_size_provided = try reader.readInt(u32, .little);
const dict_size = @max(0x1000, dict_size_provided);

const unpacked_size = switch (options.unpacked_size) {
.read_from_header => blk: {
const unpacked_size_provided = try reader.readIntLittle(u64);
const unpacked_size_provided = try reader.readInt(u64, .little);
const marker_mandatory = unpacked_size_provided == 0xFFFF_FFFF_FFFF_FFFF;
break :blk if (marker_mandatory)
null
else
unpacked_size_provided;
},
.read_header_but_use_provided => |x| blk: {
_ = try reader.readIntLittle(u64);
_ = try reader.readInt(u64, .little);
break :blk x;
},
.use_provided => |x| x,
Expand Down
2 changes: 1 addition & 1 deletion lib/std/compress/lzma/decode/rangecoder.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub const RangeDecoder = struct {
}
return RangeDecoder{
.range = 0xFFFF_FFFF,
.code = try reader.readIntBig(u32),
.code = try reader.readInt(u32, .big),
};
}

Expand Down
6 changes: 3 additions & 3 deletions lib/std/compress/lzma2/decode.zig
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ pub const Decoder = struct {
const unpacked_size = blk: {
var tmp: u64 = status & 0x1F;
tmp <<= 16;
tmp |= try reader.readIntBig(u16);
tmp |= try reader.readInt(u16, .big);
break :blk tmp + 1;
};

const packed_size = blk: {
const tmp: u17 = try reader.readIntBig(u16);
const tmp: u17 = try reader.readInt(u16, .big);
break :blk tmp + 1;
};

Expand Down Expand Up @@ -155,7 +155,7 @@ pub const Decoder = struct {
accum: *LzAccumBuffer,
reset_dict: bool,
) !void {
const unpacked_size = @as(u17, try reader.readIntBig(u16)) + 1;
const unpacked_size = @as(u17, try reader.readInt(u16, .big)) + 1;

if (reset_dict) {
try accum.reset(writer);
Expand Down
Loading