diff options
| author | Eric Joldasov <bratishkaerik@getgoogleoff.me> | 2023-06-15 13:14:16 +0600 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-19 12:34:42 -0700 |
| commit | 50339f595aa6ec96760b1cd9f8d0e0bfc3f167fc (patch) | |
| tree | 9e2b95d8e111e905e00511962dfd32c8e5bb3245 /src/link | |
| parent | a6c8ee5231230947c928bbe1c6a39eb6e1bb9c5b (diff) | |
| download | zig-50339f595aa6ec96760b1cd9f8d0e0bfc3f167fc.tar.gz zig-50339f595aa6ec96760b1cd9f8d0e0bfc3f167fc.zip | |
all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/Coff.zig | 34 | ||||
| -rw-r--r-- | src/link/Dwarf.zig | 130 | ||||
| -rw-r--r-- | src/link/Elf.zig | 10 | ||||
| -rw-r--r-- | src/link/MachO/UnwindInfo.zig | 8 | ||||
| -rw-r--r-- | src/link/MachO/ZldAtom.zig | 14 | ||||
| -rw-r--r-- | src/link/MachO/dead_strip.zig | 4 | ||||
| -rw-r--r-- | src/link/MachO/eh_frame.zig | 8 | ||||
| -rw-r--r-- | src/link/MachO/thunks.zig | 2 | ||||
| -rw-r--r-- | src/link/MachO/zld.zig | 8 | ||||
| -rw-r--r-- | src/link/Plan9.zig | 2 | ||||
| -rw-r--r-- | src/link/Wasm.zig | 70 | ||||
| -rw-r--r-- | src/link/Wasm/Object.zig | 16 | ||||
| -rw-r--r-- | src/link/Wasm/Symbol.zig | 24 | ||||
| -rw-r--r-- | src/link/Wasm/types.zig | 4 |
14 files changed, 167 insertions, 167 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 202bb71e9b..e3fcc941eb 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -538,7 +538,7 @@ fn allocateAtom(self: *Coff, atom_index: Atom.Index, new_atom_size: u32, alignme defer tracy.end(); const atom = self.getAtom(atom_index); - const sect_id = @enumToInt(atom.getSymbol(self).section_number) - 1; + const sect_id = @intFromEnum(atom.getSymbol(self).section_number) - 1; const header = &self.sections.items(.header)[sect_id]; const free_list = &self.sections.items(.free_list)[sect_id]; const maybe_last_atom_index = &self.sections.items(.last_atom_index)[sect_id]; @@ -739,7 +739,7 @@ fn shrinkAtom(self: *Coff, atom_index: Atom.Index, new_block_size: u32) void { fn writeAtom(self: *Coff, atom_index: Atom.Index, code: []u8) !void { const atom = self.getAtom(atom_index); const sym = atom.getSymbol(self); - const section = self.sections.get(@enumToInt(sym.section_number) - 1); + const section = self.sections.get(@intFromEnum(sym.section_number) - 1); const file_offset = section.header.pointer_to_raw_data + sym.value - section.header.virtual_address; log.debug("writing atom for symbol {s} at file offset 0x{x} to 0x{x}", .{ @@ -769,14 +769,14 @@ fn writeAtom(self: *Coff, atom_index: Atom.Index, code: []u8) !void { if (is_hot_update_compatible) { if (self.base.child_pid) |handle| { - const slide = @ptrToInt(self.hot_state.loaded_base_address.?); + const slide = @intFromPtr(self.hot_state.loaded_base_address.?); const mem_code = try gpa.dupe(u8, code); defer gpa.free(mem_code); self.resolveRelocs(atom_index, relocs.items, mem_code, slide); const vaddr = sym.value + slide; - const pvaddr = @intToPtr(*anyopaque, vaddr); + const pvaddr = @ptrFromInt(*anyopaque, vaddr); log.debug("writing to memory at address {x}", .{vaddr}); @@ -860,9 +860,9 @@ fn writeOffsetTableEntry(self: *Coff, index: usize) !void { if (is_hot_update_compatible) { if (self.base.child_pid) |handle| { const gpa = self.base.allocator; - const slide = @ptrToInt(self.hot_state.loaded_base_address.?); + const slide = @intFromPtr(self.hot_state.loaded_base_address.?); const actual_vmaddr = vmaddr + slide; - const pvaddr = @intToPtr(*anyopaque, actual_vmaddr); + const pvaddr = @ptrFromInt(*anyopaque, actual_vmaddr); log.debug("writing GOT entry to memory at address {x}", .{actual_vmaddr}); if (build_options.enable_logging) { switch (self.ptr_width) { @@ -970,7 +970,7 @@ fn freeAtom(self: *Coff, atom_index: Atom.Index) void { const atom = self.getAtom(atom_index); const sym = atom.getSymbol(self); - const sect_id = @enumToInt(sym.section_number) - 1; + const sect_id = @intFromEnum(sym.section_number) - 1; const free_list = &self.sections.items(.free_list)[sect_id]; var already_have_free_list_node = false; { @@ -1107,7 +1107,7 @@ pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: Module.Decl.In const atom = self.getAtom(atom_index); const sym = atom.getSymbolPtr(self); try self.setSymbolName(sym, sym_name); - sym.section_number = @intToEnum(coff.SectionNumber, self.rdata_section_index.? + 1); + sym.section_number = @enumFromInt(coff.SectionNumber, self.rdata_section_index.? + 1); } const res = try codegen.generateSymbol(&self.base, decl.srcLoc(mod), tv, &code_buffer, .none, .{ @@ -1244,7 +1244,7 @@ fn updateLazySymbolAtom( const code_len = @intCast(u32, code.len); const symbol = atom.getSymbolPtr(self); try self.setSymbolName(symbol, name); - symbol.section_number = @intToEnum(coff.SectionNumber, section_index + 1); + symbol.section_number = @enumFromInt(coff.SectionNumber, section_index + 1); symbol.type = .{ .complex_type = .NULL, .base_type = .NULL }; const vaddr = try self.allocateAtom(atom_index, code_len, required_alignment); @@ -1341,7 +1341,7 @@ fn updateDeclCode(self: *Coff, decl_index: Module.Decl.Index, code: []u8, comple if (atom.size != 0) { const sym = atom.getSymbolPtr(self); try self.setSymbolName(sym, decl_name); - sym.section_number = @intToEnum(coff.SectionNumber, sect_index + 1); + sym.section_number = @enumFromInt(coff.SectionNumber, sect_index + 1); sym.type = .{ .complex_type = complex_type, .base_type = .NULL }; const capacity = atom.capacity(self); @@ -1365,7 +1365,7 @@ fn updateDeclCode(self: *Coff, decl_index: Module.Decl.Index, code: []u8, comple } else { const sym = atom.getSymbolPtr(self); try self.setSymbolName(sym, decl_name); - sym.section_number = @intToEnum(coff.SectionNumber, sect_index + 1); + sym.section_number = @enumFromInt(coff.SectionNumber, sect_index + 1); sym.type = .{ .complex_type = complex_type, .base_type = .NULL }; const vaddr = try self.allocateAtom(atom_index, code_len, required_alignment); @@ -1502,7 +1502,7 @@ pub fn updateDeclExports( const sym = self.getSymbolPtr(sym_loc); try self.setSymbolName(sym, mod.intern_pool.stringToSlice(exp.opts.name)); sym.value = decl_sym.value; - sym.section_number = @intToEnum(coff.SectionNumber, self.text_section_index.? + 1); + sym.section_number = @enumFromInt(coff.SectionNumber, self.text_section_index.? + 1); sym.type = .{ .complex_type = .FUNCTION, .base_type = .NULL }; switch (exp.opts.linkage) { @@ -1668,7 +1668,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod const atom = self.getAtom(atom_index); const sym = atom.getSymbol(self); - const section = self.sections.get(@enumToInt(sym.section_number) - 1).header; + const section = self.sections.get(@intFromEnum(sym.section_number) - 1).header; const file_offset = section.pointer_to_raw_data + sym.value - section.virtual_address; var code = std.ArrayList(u8).init(gpa); @@ -1878,7 +1878,7 @@ fn writeBaseRelocations(self: *Coff) !void { try self.base.file.?.pwriteAll(buffer.items, header.pointer_to_raw_data); - self.data_directories[@enumToInt(coff.DirectoryEntry.BASERELOC)] = .{ + self.data_directories[@intFromEnum(coff.DirectoryEntry.BASERELOC)] = .{ .virtual_address = header.virtual_address, .size = needed_size, }; @@ -2011,11 +2011,11 @@ fn writeImportTables(self: *Coff) !void { try self.base.file.?.pwriteAll(buffer.items, header.pointer_to_raw_data); - self.data_directories[@enumToInt(coff.DirectoryEntry.IMPORT)] = .{ + self.data_directories[@intFromEnum(coff.DirectoryEntry.IMPORT)] = .{ .virtual_address = header.virtual_address + iat_size, .size = dir_table_size, }; - self.data_directories[@enumToInt(coff.DirectoryEntry.IAT)] = .{ + self.data_directories[@intFromEnum(coff.DirectoryEntry.IAT)] = .{ .virtual_address = header.virtual_address, .size = iat_size, }; @@ -2469,7 +2469,7 @@ fn logSymtab(self: *Coff) void { .UNDEFINED => 0, // TODO .ABSOLUTE => unreachable, // TODO .DEBUG => unreachable, // TODO - else => @enumToInt(sym.section_number), + else => @intFromEnum(sym.section_number), }; log.debug(" %{d}: {?s} @{x} in {s}({d}), {s}", .{ sym_id, diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig index 3cb1c213e9..c9b535e7fa 100644 --- a/src/link/Dwarf.zig +++ b/src/link/Dwarf.zig @@ -171,11 +171,11 @@ pub const DeclState = struct { switch (ty.zigTypeTag(mod)) { .NoReturn => unreachable, .Void => { - try dbg_info_buffer.append(@enumToInt(AbbrevKind.pad1)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.pad1)); }, .Bool => { try dbg_info_buffer.ensureUnusedCapacity(12); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.base_type)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.base_type)); // DW.AT.encoding, DW.FORM.data1 dbg_info_buffer.appendAssumeCapacity(DW.ATE.boolean); // DW.AT.byte_size, DW.FORM.udata @@ -186,7 +186,7 @@ pub const DeclState = struct { .Int => { const info = ty.intInfo(mod); try dbg_info_buffer.ensureUnusedCapacity(12); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.base_type)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.base_type)); // DW.AT.encoding, DW.FORM.data1 dbg_info_buffer.appendAssumeCapacity(switch (info.signedness) { .signed => DW.ATE.signed, @@ -200,7 +200,7 @@ pub const DeclState = struct { .Optional => { if (ty.isPtrLikeOptional(mod)) { try dbg_info_buffer.ensureUnusedCapacity(12); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.base_type)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.base_type)); // DW.AT.encoding, DW.FORM.data1 dbg_info_buffer.appendAssumeCapacity(DW.ATE.address); // DW.AT.byte_size, DW.FORM.udata @@ -211,7 +211,7 @@ pub const DeclState = struct { // Non-pointer optionals are structs: struct { .maybe = *, .val = * } const payload_ty = ty.optionalChild(mod); // DW.AT.structure_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type)); // DW.AT.byte_size, DW.FORM.udata const abi_size = ty.abiSize(mod); try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); @@ -219,7 +219,7 @@ pub const DeclState = struct { try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(7); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("maybe"); dbg_info_buffer.appendAssumeCapacity(0); @@ -231,7 +231,7 @@ pub const DeclState = struct { try dbg_info_buffer.ensureUnusedCapacity(6); dbg_info_buffer.appendAssumeCapacity(0); // DW.AT.member - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("val"); dbg_info_buffer.appendAssumeCapacity(0); @@ -253,14 +253,14 @@ pub const DeclState = struct { const ptr_bytes = @intCast(u8, @divExact(ptr_bits, 8)); // DW.AT.structure_type try dbg_info_buffer.ensureUnusedCapacity(2); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_type)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_type)); // DW.AT.byte_size, DW.FORM.udata try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); // DW.AT.name, DW.FORM.string try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(5); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("ptr"); dbg_info_buffer.appendAssumeCapacity(0); @@ -273,7 +273,7 @@ pub const DeclState = struct { try dbg_info_buffer.ensureUnusedCapacity(6); dbg_info_buffer.appendAssumeCapacity(0); // DW.AT.member - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("len"); dbg_info_buffer.appendAssumeCapacity(0); @@ -288,7 +288,7 @@ pub const DeclState = struct { dbg_info_buffer.appendAssumeCapacity(0); } else { try dbg_info_buffer.ensureUnusedCapacity(5); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.ptr_type)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.ptr_type)); // DW.AT.type, DW.FORM.ref4 const index = dbg_info_buffer.items.len; try dbg_info_buffer.resize(index + 4); @@ -297,7 +297,7 @@ pub const DeclState = struct { }, .Array => { // DW.AT.array_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.array_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.array_type)); // DW.AT.name, DW.FORM.string try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)}); // DW.AT.type, DW.FORM.ref4 @@ -305,7 +305,7 @@ pub const DeclState = struct { try dbg_info_buffer.resize(index + 4); try self.addTypeRelocGlobal(atom_index, ty.childType(mod), @intCast(u32, index)); // DW.AT.subrange_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.array_dim)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.array_dim)); // DW.AT.type, DW.FORM.ref4 index = dbg_info_buffer.items.len; try dbg_info_buffer.resize(index + 4); @@ -318,7 +318,7 @@ pub const DeclState = struct { }, .Struct => blk: { // DW.AT.structure_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type)); // DW.AT.byte_size, DW.FORM.udata try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); @@ -329,7 +329,7 @@ pub const DeclState = struct { for (fields.types, 0..) |field_ty, field_index| { // DW.AT.member - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_member)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string try dbg_info_buffer.writer().print("{d}\x00", .{field_index}); // DW.AT.type, DW.FORM.ref4 @@ -363,7 +363,7 @@ pub const DeclState = struct { const field_name = mod.intern_pool.stringToSlice(field_name_ip); // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(field_name.len + 2); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity(field_name); dbg_info_buffer.appendAssumeCapacity(0); @@ -384,7 +384,7 @@ pub const DeclState = struct { }, .Enum => { // DW.AT.enumeration_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.enum_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.enum_type)); // DW.AT.byte_size, DW.FORM.udata try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod)); // DW.AT.name, DW.FORM.string @@ -398,7 +398,7 @@ pub const DeclState = struct { const field_name = mod.intern_pool.stringToSlice(field_name_index); // DW.AT.enumerator try dbg_info_buffer.ensureUnusedCapacity(field_name.len + 2 + @sizeOf(u64)); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.enum_variant)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.enum_variant)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity(field_name); dbg_info_buffer.appendAssumeCapacity(0); @@ -408,7 +408,7 @@ pub const DeclState = struct { const value = enum_type.values[field_i]; // TODO do not assume a 64bit enum value - could be bigger. // See https://github.com/ziglang/zig/issues/645 - const field_int_val = try value.toValue().enumToInt(ty, mod); + const field_int_val = try value.toValue().intFromEnum(ty, mod); break :value @bitCast(u64, field_int_val.toSignedInt(mod)); }; mem.writeInt(u64, dbg_info_buffer.addManyAsArrayAssumeCapacity(8), value, target_endian); @@ -430,7 +430,7 @@ pub const DeclState = struct { // for untagged unions. if (is_tagged) { // DW.AT.structure_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type)); // DW.AT.byte_size, DW.FORM.udata try leb128.writeULEB128(dbg_info_buffer.writer(), layout.abi_size); // DW.AT.name, DW.FORM.string @@ -440,7 +440,7 @@ pub const DeclState = struct { // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(9); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("payload"); dbg_info_buffer.appendAssumeCapacity(0); @@ -453,7 +453,7 @@ pub const DeclState = struct { } // DW.AT.union_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.union_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.union_type)); // DW.AT.byte_size, DW.FORM.udata, try leb128.writeULEB128(dbg_info_buffer.writer(), layout.payload_size); // DW.AT.name, DW.FORM.string @@ -468,7 +468,7 @@ pub const DeclState = struct { const field = fields.get(field_name).?; if (!field.ty.hasRuntimeBits(mod)) continue; // DW.AT.member - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_member)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string try dbg_info_buffer.appendSlice(mod.intern_pool.stringToSlice(field_name)); try dbg_info_buffer.append(0); @@ -485,7 +485,7 @@ pub const DeclState = struct { if (is_tagged) { // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(5); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("tag"); dbg_info_buffer.appendAssumeCapacity(0); @@ -519,7 +519,7 @@ pub const DeclState = struct { const error_off = if (error_align >= payload_align) 0 else payload_ty.abiSize(mod); // DW.AT.structure_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.struct_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.struct_type)); // DW.AT.byte_size, DW.FORM.udata try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); // DW.AT.name, DW.FORM.string @@ -529,7 +529,7 @@ pub const DeclState = struct { if (!payload_ty.isNoReturn(mod)) { // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(7); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("value"); dbg_info_buffer.appendAssumeCapacity(0); @@ -544,7 +544,7 @@ pub const DeclState = struct { { // DW.AT.member try dbg_info_buffer.ensureUnusedCapacity(5); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.struct_member)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.struct_member)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity("err"); dbg_info_buffer.appendAssumeCapacity(0); @@ -561,7 +561,7 @@ pub const DeclState = struct { }, else => { log.debug("TODO implement .debug_info for type '{}'", .{ty.fmt(self.mod)}); - try dbg_info_buffer.append(@enumToInt(AbbrevKind.pad1)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.pad1)); }, } } @@ -595,7 +595,7 @@ pub const DeclState = struct { switch (loc) { .register => |reg| { try dbg_info.ensureUnusedCapacity(4); - dbg_info.appendAssumeCapacity(@enumToInt(AbbrevKind.parameter)); + dbg_info.appendAssumeCapacity(@intFromEnum(AbbrevKind.parameter)); // DW.AT.location, DW.FORM.exprloc var expr_len = std.io.countingWriter(std.io.null_writer); if (reg < 32) { @@ -614,7 +614,7 @@ pub const DeclState = struct { }, .stack => |info| { try dbg_info.ensureUnusedCapacity(9); - dbg_info.appendAssumeCapacity(@enumToInt(AbbrevKind.parameter)); + dbg_info.appendAssumeCapacity(@intFromEnum(AbbrevKind.parameter)); // DW.AT.location, DW.FORM.exprloc var expr_len = std.io.countingWriter(std.io.null_writer); if (info.fp_register < 32) { @@ -643,7 +643,7 @@ pub const DeclState = struct { // where each argument is encoded as // <opcode> i:uleb128 dbg_info.appendSliceAssumeCapacity(&.{ - @enumToInt(AbbrevKind.parameter), + @intFromEnum(AbbrevKind.parameter), DW.OP.WASM_location, DW.OP.WASM_local, }); @@ -670,7 +670,7 @@ pub const DeclState = struct { const dbg_info = &self.dbg_info; const atom_index = self.di_atom_decls.get(owner_decl).?; const name_with_null = name.ptr[0 .. name.len + 1]; - try dbg_info.append(@enumToInt(AbbrevKind.variable)); + try dbg_info.append(@intFromEnum(AbbrevKind.variable)); const mod = self.mod; const target = mod.getTarget(); const endian = target.cpu.arch.endian(); @@ -679,7 +679,7 @@ pub const DeclState = struct { switch (loc) { .register => |reg| { try dbg_info.ensureUnusedCapacity(4); - dbg_info.appendAssumeCapacity(@enumToInt(AbbrevKind.parameter)); + dbg_info.appendAssumeCapacity(@intFromEnum(AbbrevKind.parameter)); // DW.AT.location, DW.FORM.exprloc var expr_len = std.io.countingWriter(std.io.null_writer); if (reg < 32) { @@ -699,7 +699,7 @@ pub const DeclState = struct { .stack => |info| { try dbg_info.ensureUnusedCapacity(9); - dbg_info.appendAssumeCapacity(@enumToInt(AbbrevKind.parameter)); + dbg_info.appendAssumeCapacity(@intFromEnum(AbbrevKind.parameter)); // DW.AT.location, DW.FORM.exprloc var expr_len = std.io.countingWriter(std.io.null_writer); if (info.fp_register < 32) { @@ -741,7 +741,7 @@ pub const DeclState = struct { const ptr_width = @intCast(u8, @divExact(target.ptrBitWidth(), 8)); try dbg_info.ensureUnusedCapacity(2 + ptr_width); dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc - 1 + ptr_width + @boolToInt(is_ptr), + 1 + ptr_width + @intFromBool(is_ptr), DW.OP.addr, // literal address }); const offset = @intCast(u32, dbg_info.items.len); @@ -1015,9 +1015,9 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) const fn_ret_type = decl.ty.fnReturnType(mod); const fn_ret_has_bits = fn_ret_type.hasRuntimeBits(mod); if (fn_ret_has_bits) { - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.subprogram)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.subprogram)); } else { - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.subprogram_retvoid)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.subprogram_retvoid)); } // These get overwritten after generating the machine code. These values are // "relocations" and have to be in this fixed place so that functions can be @@ -1617,14 +1617,14 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { // These are LEB encoded but since the values are all less than 127 // we can simply append these bytes. const abbrev_buf = [_]u8{ - @enumToInt(AbbrevKind.compile_unit), DW.TAG.compile_unit, DW.CHILDREN.yes, // header - DW.AT.stmt_list, DW.FORM.sec_offset, DW.AT.low_pc, - DW.FORM.addr, DW.AT.high_pc, DW.FORM.addr, - DW.AT.name, DW.FORM.strp, DW.AT.comp_dir, - DW.FORM.strp, DW.AT.producer, DW.FORM.strp, - DW.AT.language, DW.FORM.data2, 0, + @intFromEnum(AbbrevKind.compile_unit), DW.TAG.compile_unit, DW.CHILDREN.yes, // header + DW.AT.stmt_list, DW.FORM.sec_offset, DW.AT.low_pc, + DW.FORM.addr, DW.AT.high_pc, DW.FORM.addr, + DW.AT.name, DW.FORM.strp, DW.AT.comp_dir, + DW.FORM.strp, DW.AT.producer, DW.FORM.strp, + DW.AT.language, DW.FORM.data2, 0, 0, // table sentinel - @enumToInt(AbbrevKind.subprogram), + @intFromEnum(AbbrevKind.subprogram), DW.TAG.subprogram, DW.CHILDREN.yes, // header DW.AT.low_pc, @@ -1635,15 +1635,15 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.ref4, DW.AT.name, DW.FORM.string, - 0, 0, // table sentinel - @enumToInt(AbbrevKind.subprogram_retvoid), + 0, 0, // table sentinel + @intFromEnum(AbbrevKind.subprogram_retvoid), DW.TAG.subprogram, DW.CHILDREN.yes, // header DW.AT.low_pc, DW.FORM.addr, DW.AT.high_pc, DW.FORM.data4, DW.AT.name, DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.base_type), + @intFromEnum(AbbrevKind.base_type), DW.TAG.base_type, DW.CHILDREN.no, // header DW.AT.encoding, @@ -1654,14 +1654,14 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.ptr_type), + @intFromEnum(AbbrevKind.ptr_type), DW.TAG.pointer_type, DW.CHILDREN.no, // header DW.AT.type, DW.FORM.ref4, 0, 0, // table sentinel - @enumToInt(AbbrevKind.struct_type), + @intFromEnum(AbbrevKind.struct_type), DW.TAG.structure_type, DW.CHILDREN.yes, // header DW.AT.byte_size, @@ -1670,7 +1670,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.struct_member), + @intFromEnum(AbbrevKind.struct_member), DW.TAG.member, DW.CHILDREN.no, // header DW.AT.name, @@ -1681,7 +1681,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.udata, 0, 0, // table sentinel - @enumToInt(AbbrevKind.enum_type), + @intFromEnum(AbbrevKind.enum_type), DW.TAG.enumeration_type, DW.CHILDREN.yes, // header DW.AT.byte_size, @@ -1690,7 +1690,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.enum_variant), + @intFromEnum(AbbrevKind.enum_variant), DW.TAG.enumerator, DW.CHILDREN.no, // header DW.AT.name, @@ -1699,7 +1699,7 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.data8, 0, 0, // table sentinel - @enumToInt(AbbrevKind.union_type), + @intFromEnum(AbbrevKind.union_type), DW.TAG.union_type, DW.CHILDREN.yes, // header DW.AT.byte_size, @@ -1708,32 +1708,32 @@ pub fn writeDbgAbbrev(self: *Dwarf) !void { DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.pad1), + @intFromEnum(AbbrevKind.pad1), DW.TAG.unspecified_type, DW.CHILDREN.no, // header 0, 0, // table sentinel - @enumToInt(AbbrevKind.parameter), + @intFromEnum(AbbrevKind.parameter), DW.TAG.formal_parameter, DW.CHILDREN.no, // header DW.AT.location, DW.FORM.exprloc, DW.AT.type, DW.FORM.ref4, DW.AT.name, DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.variable), + @intFromEnum(AbbrevKind.variable), DW.TAG.variable, DW.CHILDREN.no, // header DW.AT.location, DW.FORM.exprloc, DW.AT.type, DW.FORM.ref4, DW.AT.name, DW.FORM.string, 0, 0, // table sentinel - @enumToInt(AbbrevKind.array_type), + @intFromEnum(AbbrevKind.array_type), DW.TAG.array_type, DW.CHILDREN.yes, // header DW.AT.name, DW.FORM.string, DW.AT.type, DW.FORM.ref4, 0, 0, // table sentinel - @enumToInt(AbbrevKind.array_dim), + @intFromEnum(AbbrevKind.array_dim), DW.TAG.subrange_type, DW.CHILDREN.no, // header DW.AT.type, DW.FORM.ref4, DW.AT.count, DW.FORM.udata, @@ -1838,7 +1838,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, module: *Module, low_pc: u64, high_pc: u const comp_dir_strp = try self.strtab.insert(self.allocator, compile_unit_dir); const producer_strp = try self.strtab.insert(self.allocator, link.producer_string); - di_buf.appendAssumeCapacity(@enumToInt(AbbrevKind.compile_unit)); + di_buf.appendAssumeCapacity(@intFromEnum(AbbrevKind.compile_unit)); if (self.bin_file.tag == .macho) { mem.writeIntLittle(u32, di_buf.addManyAsArrayAssumeCapacity(4), 0); // DW.AT.stmt_list, DW.FORM.sec_offset mem.writeIntLittle(u64, di_buf.addManyAsArrayAssumeCapacity(8), low_pc); @@ -2038,7 +2038,7 @@ fn pwriteDbgInfoNops( const tracy = trace(@src()); defer tracy.end(); - const page_of_nops = [1]u8{@enumToInt(AbbrevKind.pad1)} ** 4096; + const page_of_nops = [1]u8{@intFromEnum(AbbrevKind.pad1)} ** 4096; var vecs: [32]std.os.iovec_const = undefined; var vec_index: usize = 0; { @@ -2110,9 +2110,9 @@ fn writeDbgInfoNopsToArrayList( buffer.items.len, offset + content.len + next_padding_size + 1, )); - @memset(buffer.items[offset - prev_padding_size .. offset], @enumToInt(AbbrevKind.pad1)); + @memset(buffer.items[offset - prev_padding_size .. offset], @intFromEnum(AbbrevKind.pad1)); @memcpy(buffer.items[offset..][0..content.len], content); - @memset(buffer.items[offset + content.len ..][0..next_padding_size], @enumToInt(AbbrevKind.pad1)); + @memset(buffer.items[offset + content.len ..][0..next_padding_size], @intFromEnum(AbbrevKind.pad1)); if (trailing_zero) { buffer.items[offset + content.len + next_padding_size] = 0; @@ -2653,7 +2653,7 @@ fn addDbgInfoErrorSet( const target_endian = target.cpu.arch.endian(); // DW.AT.enumeration_type - try dbg_info_buffer.append(@enumToInt(AbbrevKind.enum_type)); + try dbg_info_buffer.append(@intFromEnum(AbbrevKind.enum_type)); // DW.AT.byte_size, DW.FORM.udata const abi_size = Type.anyerror.abiSize(mod); try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size); @@ -2664,7 +2664,7 @@ fn addDbgInfoErrorSet( // DW.AT.enumerator const no_error = "(no error)"; try dbg_info_buffer.ensureUnusedCapacity(no_error.len + 2 + @sizeOf(u64)); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.enum_variant)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.enum_variant)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity(no_error); dbg_info_buffer.appendAssumeCapacity(0); @@ -2677,7 +2677,7 @@ fn addDbgInfoErrorSet( const error_name = mod.intern_pool.stringToSlice(error_name_ip); // DW.AT.enumerator try dbg_info_buffer.ensureUnusedCapacity(error_name.len + 2 + @sizeOf(u64)); - dbg_info_buffer.appendAssumeCapacity(@enumToInt(AbbrevKind.enum_variant)); + dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevKind.enum_variant)); // DW.AT.name, DW.FORM.string dbg_info_buffer.appendSliceAssumeCapacity(error_name); dbg_info_buffer.appendAssumeCapacity(0); diff --git a/src/link/Elf.zig b/src/link/Elf.zig index a0d6333535..283bd9ccca 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1826,7 +1826,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v for (system_libs, 0..) |link_lib, i| { const lib_as_needed = !system_libs_values[i].needed; - switch ((@as(u2, @boolToInt(lib_as_needed)) << 1) | @boolToInt(as_needed)) { + switch ((@as(u2, @intFromBool(lib_as_needed)) << 1) | @intFromBool(as_needed)) { 0b00, 0b11 => {}, 0b01 => { argv.appendAssumeCapacity("--no-as-needed"); @@ -2048,11 +2048,11 @@ fn writeElfHeader(self: *Elf) !void { .Dynamic => elf.ET.DYN, }, }; - mem.writeInt(u16, hdr_buf[index..][0..2], @enumToInt(elf_type), endian); + mem.writeInt(u16, hdr_buf[index..][0..2], @intFromEnum(elf_type), endian); index += 2; const machine = self.base.options.target.cpu.arch.toElfMachine(); - mem.writeInt(u16, hdr_buf[index..][0..2], @enumToInt(machine), endian); + mem.writeInt(u16, hdr_buf[index..][0..2], @intFromEnum(machine), endian); index += 2; // ELF Version, again @@ -2557,7 +2557,7 @@ fn updateDeclCode(self: *Elf, decl_index: Module.Decl.Index, code: []const u8, s .iov_len = code.len, }}; var remote_vec: [1]std.os.iovec_const = .{.{ - .iov_base = @intToPtr([*]u8, @intCast(usize, local_sym.st_value)), + .iov_base = @ptrFromInt([*]u8, @intCast(usize, local_sym.st_value)), .iov_len = code.len, }}; const rc = std.os.linux.process_vm_writev(pid, &code_vec, &remote_vec, 0); @@ -3051,7 +3051,7 @@ fn writeOffsetTableEntry(self: *Elf, index: @TypeOf(self.got_table).Index) !void .iov_len = buf.len, }}; var remote_vec: [1]std.os.iovec_const = .{.{ - .iov_base = @intToPtr([*]u8, @intCast(usize, vaddr)), + .iov_base = @ptrFromInt([*]u8, @intCast(usize, vaddr)), .iov_len = buf.len, }}; const rc = std.os.linux.process_vm_writev(pid, &local_vec, &remote_vec, 0); diff --git a/src/link/MachO/UnwindInfo.zig b/src/link/MachO/UnwindInfo.zig index 8d2a36be9d..3c9a438f92 100644 --- a/src/link/MachO/UnwindInfo.zig +++ b/src/link/MachO/UnwindInfo.zig @@ -760,14 +760,14 @@ pub const UnwindEncoding = struct { pub fn isDwarf(enc: macho.compact_unwind_encoding_t, cpu_arch: std.Target.Cpu.Arch) bool { const mode = getMode(enc); return switch (cpu_arch) { - .aarch64 => @intToEnum(macho.UNWIND_ARM64_MODE, mode) == .DWARF, - .x86_64 => @intToEnum(macho.UNWIND_X86_64_MODE, mode) == .DWARF, + .aarch64 => @enumFromInt(macho.UNWIND_ARM64_MODE, mode) == .DWARF, + .x86_64 => @enumFromInt(macho.UNWIND_X86_64_MODE, mode) == .DWARF, else => unreachable, }; } pub fn setMode(enc: *macho.compact_unwind_encoding_t, mode: anytype) void { - enc.* |= @intCast(u32, @enumToInt(mode)) << 24; + enc.* |= @intCast(u32, @intFromEnum(mode)) << 24; } pub fn hasLsda(enc: macho.compact_unwind_encoding_t) bool { @@ -776,7 +776,7 @@ pub const UnwindEncoding = struct { } pub fn setHasLsda(enc: *macho.compact_unwind_encoding_t, has_lsda: bool) void { - const mask = @intCast(u32, @boolToInt(has_lsda)) << 31; + const mask = @intCast(u32, @intFromBool(has_lsda)) << 31; enc.* |= mask; } diff --git a/src/link/MachO/ZldAtom.zig b/src/link/MachO/ZldAtom.zig index baa6340a13..1252379aa7 100644 --- a/src/link/MachO/ZldAtom.zig +++ b/src/link/MachO/ZldAtom.zig @@ -214,7 +214,7 @@ pub fn parseRelocTarget(zld: *Zld, ctx: struct { mem.readIntLittle(u32, ctx.code[rel_offset..][0..4]); } else blk: { assert(zld.options.target.cpu.arch == .x86_64); - const correction: u3 = switch (@intToEnum(macho.reloc_type_x86_64, ctx.rel.r_type)) { + const correction: u3 = switch (@enumFromInt(macho.reloc_type_x86_64, ctx.rel.r_type)) { .X86_64_RELOC_SIGNED => 0, .X86_64_RELOC_SIGNED_1 => 1, .X86_64_RELOC_SIGNED_2 => 2, @@ -272,7 +272,7 @@ pub fn getRelocTargetAtomIndex(zld: *Zld, target: SymbolWithLoc, is_via_got: boo fn scanAtomRelocsArm64(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) const macho.relocation_info) !void { for (relocs) |rel| { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); switch (rel_type) { .ARM64_RELOC_ADDEND, .ARM64_RELOC_SUBTRACTOR => continue, @@ -321,7 +321,7 @@ fn scanAtomRelocsArm64(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) cons fn scanAtomRelocsX86(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) const macho.relocation_info) !void { for (relocs) |rel| { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); switch (rel_type) { .X86_64_RELOC_SUBTRACTOR => continue, @@ -495,7 +495,7 @@ fn resolveRelocsArm64( var subtractor: ?SymbolWithLoc = null; for (atom_relocs) |rel| { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); switch (rel_type) { .ARM64_RELOC_ADDEND => { @@ -797,7 +797,7 @@ fn resolveRelocsX86( var subtractor: ?SymbolWithLoc = null; for (atom_relocs) |rel| { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); switch (rel_type) { .X86_64_RELOC_SUBTRACTOR => { @@ -1004,14 +1004,14 @@ pub fn getAtomRelocs(zld: *Zld, atom_index: AtomIndex) []const macho.relocation_ pub fn relocRequiresGot(zld: *Zld, rel: macho.relocation_info) bool { switch (zld.options.target.cpu.arch) { - .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) { + .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) { .ARM64_RELOC_GOT_LOAD_PAGE21, .ARM64_RELOC_GOT_LOAD_PAGEOFF12, .ARM64_RELOC_POINTER_TO_GOT, => return true, else => return false, }, - .x86_64 => switch (@intToEnum(macho.reloc_type_x86_64, rel.r_type)) { + .x86_64 => switch (@enumFromInt(macho.reloc_type_x86_64, rel.r_type)) { .X86_64_RELOC_GOT, .X86_64_RELOC_GOT_LOAD, => return true, diff --git a/src/link/MachO/dead_strip.zig b/src/link/MachO/dead_strip.zig index ca0d961e2d..b2c569447d 100644 --- a/src/link/MachO/dead_strip.zig +++ b/src/link/MachO/dead_strip.zig @@ -148,7 +148,7 @@ fn markLive(zld: *Zld, atom_index: AtomIndex, alive: *AtomTable) void { for (relocs) |rel| { const target = switch (cpu_arch) { - .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) { + .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) { .ARM64_RELOC_ADDEND => continue, else => Atom.parseRelocTarget(zld, .{ .object_id = atom.getFile().?, @@ -208,7 +208,7 @@ fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable) bool { for (relocs) |rel| { const target = switch (cpu_arch) { - .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) { + .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) { .ARM64_RELOC_ADDEND => continue, else => Atom.parseRelocTarget(zld, .{ .object_id = atom.getFile().?, diff --git a/src/link/MachO/eh_frame.zig b/src/link/MachO/eh_frame.zig index ea8d4128c2..1672e37229 100644 --- a/src/link/MachO/eh_frame.zig +++ b/src/link/MachO/eh_frame.zig @@ -291,7 +291,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { for (relocs) |rel| { switch (cpu_arch) { .aarch64 => { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); switch (rel_type) { .ARM64_RELOC_SUBTRACTOR, .ARM64_RELOC_UNSIGNED, @@ -301,7 +301,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { } }, .x86_64 => { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); switch (rel_type) { .X86_64_RELOC_GOT => {}, else => unreachable, @@ -342,7 +342,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { switch (cpu_arch) { .aarch64 => { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); switch (rel_type) { .ARM64_RELOC_SUBTRACTOR => { // Address of the __eh_frame in the source object file @@ -363,7 +363,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { } }, .x86_64 => { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); switch (rel_type) { .X86_64_RELOC_GOT => { const target_addr = try Atom.getRelocTargetAddress(zld, target, true, false); diff --git a/src/link/MachO/thunks.zig b/src/link/MachO/thunks.zig index 7895190005..f3289e544b 100644 --- a/src/link/MachO/thunks.zig +++ b/src/link/MachO/thunks.zig @@ -289,7 +289,7 @@ fn scanRelocs( } inline fn relocNeedsThunk(rel: macho.relocation_info) bool { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); return rel_type == .ARM64_RELOC_BRANCH26; } diff --git a/src/link/MachO/zld.zig b/src/link/MachO/zld.zig index 7902d67d87..be283900f5 100644 --- a/src/link/MachO/zld.zig +++ b/src/link/MachO/zld.zig @@ -1819,12 +1819,12 @@ pub const Zld = struct { for (relocs) |rel| { switch (cpu_arch) { .aarch64 => { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); if (rel_type != .ARM64_RELOC_UNSIGNED) continue; if (rel.r_length != 3) continue; }, .x86_64 => { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); if (rel_type != .X86_64_RELOC_UNSIGNED) continue; if (rel.r_length != 3) continue; }, @@ -1958,12 +1958,12 @@ pub const Zld = struct { for (relocs) |rel| { switch (cpu_arch) { .aarch64 => { - const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type); if (rel_type != .ARM64_RELOC_UNSIGNED) continue; if (rel.r_length != 3) continue; }, .x86_64 => { - const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); + const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type); if (rel_type != .X86_64_RELOC_UNSIGNED) continue; if (rel.r_length != 3) continue; }, diff --git a/src/link/Plan9.zig b/src/link/Plan9.zig index 6433fb2762..b36e16452e 100644 --- a/src/link/Plan9.zig +++ b/src/link/Plan9.zig @@ -1192,7 +1192,7 @@ pub fn writeSym(self: *Plan9, w: anytype, sym: aout.Sym) !void { } else { try w.writeIntBig(u64, sym.value); } - try w.writeByte(@enumToInt(sym.type)); + try w.writeByte(@intFromEnum(sym.type)); try w.writeAll(sym.name); try w.writeByte(0); } diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 2d2930be8c..1e94e886b9 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -196,7 +196,7 @@ pub const Segment = struct { }; pub fn isPassive(segment: Segment) bool { - return segment.flags & @enumToInt(Flag.WASM_DATA_SEGMENT_IS_PASSIVE) != 0; + return segment.flags & @intFromEnum(Flag.WASM_DATA_SEGMENT_IS_PASSIVE) != 0; } /// For a given segment, determines if it needs passive initialization @@ -1094,14 +1094,14 @@ fn validateFeatures( const value = @intCast(u16, object_index) << 1 | @as(u1, 1); switch (feature.prefix) { .used => { - used[@enumToInt(feature.tag)] = value; + used[@intFromEnum(feature.tag)] = value; }, .disallowed => { - disallowed[@enumToInt(feature.tag)] = value; + disallowed[@intFromEnum(feature.tag)] = value; }, .required => { - required[@enumToInt(feature.tag)] = value; - used[@enumToInt(feature.tag)] = value; + required[@intFromEnum(feature.tag)] = value; + used[@intFromEnum(feature.tag)] = value; }, } } @@ -1120,9 +1120,9 @@ fn validateFeatures( const is_enabled = @truncate(u1, used_set) != 0; if (infer) { allowed[used_index] = is_enabled; - emit_features_count.* += @boolToInt(is_enabled); + emit_features_count.* += @intFromBool(is_enabled); } else if (is_enabled and !allowed[used_index]) { - log.err("feature '{}' not allowed, but used by linked object", .{@intToEnum(types.Feature.Tag, used_index)}); + log.err("feature '{}' not allowed, but used by linked object", .{@enumFromInt(types.Feature.Tag, used_index)}); log.err(" defined in '{s}'", .{wasm.objects.items[used_set >> 1].name}); valid_feature_set = false; } @@ -1133,7 +1133,7 @@ fn validateFeatures( } if (wasm.base.options.shared_memory) { - const disallowed_feature = disallowed[@enumToInt(types.Feature.Tag.shared_mem)]; + const disallowed_feature = disallowed[@intFromEnum(types.Feature.Tag.shared_mem)]; if (@truncate(u1, disallowed_feature) != 0) { log.err( "shared-memory is disallowed by '{s}' because it wasn't compiled with 'atomics' and 'bulk-memory' features enabled", @@ -1143,7 +1143,7 @@ fn validateFeatures( } for ([_]types.Feature.Tag{ .atomics, .bulk_memory }) |feature| { - if (!allowed[@enumToInt(feature)]) { + if (!allowed[@intFromEnum(feature)]) { log.err("feature '{}' is not used but is required for shared-memory", .{feature}); } } @@ -1151,7 +1151,7 @@ fn validateFeatures( if (has_tls) { for ([_]types.Feature.Tag{ .atomics, .bulk_memory }) |feature| { - if (!allowed[@enumToInt(feature)]) { + if (!allowed[@intFromEnum(feature)]) { log.err("feature '{}' is not used but is required for thread-local storage", .{feature}); } } @@ -1162,7 +1162,7 @@ fn validateFeatures( for (object.features) |feature| { if (feature.prefix == .disallowed) continue; // already defined in 'disallowed' set. // from here a feature is always used - const disallowed_feature = disallowed[@enumToInt(feature.tag)]; + const disallowed_feature = disallowed[@intFromEnum(feature.tag)]; if (@truncate(u1, disallowed_feature) != 0) { log.err("feature '{}' is disallowed, but used by linked object", .{feature.tag}); log.err(" disallowed by '{s}'", .{wasm.objects.items[disallowed_feature >> 1].name}); @@ -1170,14 +1170,14 @@ fn validateFeatures( valid_feature_set = false; } - object_used_features[@enumToInt(feature.tag)] = true; + object_used_features[@intFromEnum(feature.tag)] = true; } // validate the linked object file has each required feature for (required, 0..) |required_feature, feature_index| { const is_required = @truncate(u1, required_feature) != 0; if (is_required and !object_used_features[feature_index]) { - log.err("feature '{}' is required but not used in linked object", .{@intToEnum(types.Feature.Tag, feature_index)}); + log.err("feature '{}' is required but not used in linked object", .{@enumFromInt(types.Feature.Tag, feature_index)}); log.err(" required by '{s}'", .{wasm.objects.items[required_feature >> 1].name}); log.err(" missing in '{s}'", .{object.name}); valid_feature_set = false; @@ -1324,7 +1324,7 @@ pub fn allocateSymbol(wasm: *Wasm) !u32 { try wasm.symbols.ensureUnusedCapacity(wasm.base.allocator, 1); var symbol: Symbol = .{ .name = undefined, // will be set after updateDecl - .flags = @enumToInt(Symbol.Flag.WASM_SYM_BINDING_LOCAL), + .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL), .tag = undefined, // will be set after updateDecl .index = undefined, // will be set after updateDecl .virtual_address = undefined, // will be set during atom allocation @@ -1560,7 +1560,7 @@ pub fn lowerUnnamedConst(wasm: *Wasm, tv: TypedValue, decl_index: Module.Decl.In atom.alignment = tv.ty.abiAlignment(mod); wasm.symbols.items[atom.sym_index] = .{ .name = try wasm.string_table.put(wasm.base.allocator, name), - .flags = @enumToInt(Symbol.Flag.WASM_SYM_BINDING_LOCAL), + .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL), .tag = .data, .index = undefined, .virtual_address = undefined, @@ -2028,7 +2028,7 @@ fn parseAtom(wasm: *Wasm, atom_index: Atom.Index, kind: Kind) !void { const index = @intCast(u32, wasm.segments.items.len); var flags: u32 = 0; if (wasm.base.options.shared_memory) { - flags |= @enumToInt(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE); + flags |= @intFromEnum(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE); } try wasm.segments.append(wasm.base.allocator, .{ .alignment = atom.alignment, @@ -2868,7 +2868,7 @@ pub fn getMatchingSegment(wasm: *Wasm, object_index: u16, relocatable_index: u32 result.value_ptr.* = index; var flags: u32 = 0; if (wasm.base.options.shared_memory) { - flags |= @enumToInt(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE); + flags |= @intFromEnum(Segment.Flag.WASM_DATA_SEGMENT_IS_PASSIVE); } try wasm.segments.append(wasm.base.allocator, .{ .alignment = 1, @@ -3073,7 +3073,7 @@ pub fn createDebugSectionForIndex(wasm: *Wasm, index: *?u32, name: []const u8) ! .tag = .section, .name = try wasm.string_table.put(wasm.base.allocator, name), .index = 0, - .flags = @enumToInt(Symbol.Flag.WASM_SYM_BINDING_LOCAL), + .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL), }; atom.alignment = 1; // debug sections are always 1-byte-aligned @@ -3544,7 +3544,7 @@ fn writeToFile( header_offset, .import, @intCast(u32, binary_bytes.items.len - header_offset - header_size), - @intCast(u32, wasm.imports.count() + @boolToInt(import_memory)), + @intCast(u32, wasm.imports.count() + @intFromBool(import_memory)), ); section_count += 1; } @@ -3606,7 +3606,7 @@ fn writeToFile( for (wasm.wasm_globals.items) |global| { try binary_writer.writeByte(std.wasm.valtype(global.global_type.valtype)); - try binary_writer.writeByte(@boolToInt(global.global_type.mutable)); + try binary_writer.writeByte(@intFromBool(global.global_type.mutable)); try emitInit(binary_writer, global.init); } @@ -3628,7 +3628,7 @@ fn writeToFile( const name = wasm.string_table.get(exp.name); try leb.writeULEB128(binary_writer, @intCast(u32, name.len)); try binary_writer.writeAll(name); - try leb.writeULEB128(binary_writer, @enumToInt(exp.kind)); + try leb.writeULEB128(binary_writer, @intFromEnum(exp.kind)); try leb.writeULEB128(binary_writer, exp.index); } @@ -3644,7 +3644,7 @@ fn writeToFile( header_offset, .@"export", @intCast(u32, binary_bytes.items.len - header_offset - header_size), - @intCast(u32, wasm.exports.items.len) + @boolToInt(!import_memory), + @intCast(u32, wasm.exports.items.len) + @intFromBool(!import_memory), ); section_count += 1; } @@ -3682,7 +3682,7 @@ fn writeToFile( } // When the shared-memory option is enabled, we *must* emit the 'data count' section. - const data_segments_count = wasm.data_segments.count() - @boolToInt(wasm.data_segments.contains(".bss") and import_memory); + const data_segments_count = wasm.data_segments.count() - @intFromBool(wasm.data_segments.contains(".bss") and import_memory); if (data_segments_count != 0 and wasm.base.options.shared_memory) { const header_offset = try reserveVecSectionHeader(&binary_bytes); try writeVecSectionHeader( @@ -3760,7 +3760,7 @@ fn writeToFile( var atom_index = wasm.atoms.get(segment_index).?; try leb.writeULEB128(binary_writer, segment.flags); - if (segment.flags & @enumToInt(Wasm.Segment.Flag.WASM_DATA_SEGMENT_HAS_MEMINDEX) != 0) { + if (segment.flags & @intFromEnum(Wasm.Segment.Flag.WASM_DATA_SEGMENT_HAS_MEMINDEX) != 0) { try leb.writeULEB128(binary_writer, @as(u32, 0)); // memory is always index 0 as we only have 1 memory entry } // when a segment is passive, it's initialized during runtime. @@ -4030,8 +4030,8 @@ fn emitFeaturesSection(binary_bytes: *std.ArrayList(u8), enabled_features: []con try leb.writeULEB128(writer, features_count); for (enabled_features, 0..) |enabled, feature_index| { if (enabled) { - const feature: types.Feature = .{ .prefix = .used, .tag = @intToEnum(types.Feature.Tag, feature_index) }; - try leb.writeULEB128(writer, @enumToInt(feature.prefix)); + const feature: types.Feature = .{ .prefix = .used, .tag = @enumFromInt(types.Feature.Tag, feature_index) }; + try leb.writeULEB128(writer, @intFromEnum(feature.prefix)); var buf: [100]u8 = undefined; const string = try std.fmt.bufPrint(&buf, "{}", .{feature.tag}); try leb.writeULEB128(writer, @intCast(u32, string.len)); @@ -4121,7 +4121,7 @@ fn emitNameSubsection(wasm: *Wasm, section_id: std.wasm.NameSubsection, names: a } // From now, write to the actual writer - try leb.writeULEB128(writer, @enumToInt(section_id)); + try leb.writeULEB128(writer, @intFromEnum(section_id)); try leb.writeULEB128(writer, @intCast(u32, section_list.items.len)); try writer.writeAll(section_list.items); } @@ -4169,12 +4169,12 @@ fn emitImport(wasm: *Wasm, writer: anytype, import: types.Import) !void { try leb.writeULEB128(writer, @intCast(u32, name.len)); try writer.writeAll(name); - try writer.writeByte(@enumToInt(import.kind)); + try writer.writeByte(@intFromEnum(import.kind)); switch (import.kind) { .function => |type_index| try leb.writeULEB128(writer, type_index), .global => |global_type| { try leb.writeULEB128(writer, std.wasm.valtype(global_type.valtype)); - try writer.writeByte(@boolToInt(global_type.mutable)); + try writer.writeByte(@intFromBool(global_type.mutable)); }, .table => |table| { try leb.writeULEB128(writer, std.wasm.reftype(table.reftype)); @@ -4609,7 +4609,7 @@ fn reserveCustomSectionHeader(bytes: *std.ArrayList(u8)) !u32 { fn writeVecSectionHeader(buffer: []u8, offset: u32, section: std.wasm.Section, size: u32, items: u32) !void { var buf: [1 + 5 + 5]u8 = undefined; - buf[0] = @enumToInt(section); + buf[0] = @intFromEnum(section); leb.writeUnsignedFixed(5, buf[1..6], size); leb.writeUnsignedFixed(5, buf[6..], items); buffer[offset..][0..buf.len].* = buf; @@ -4645,7 +4645,7 @@ fn emitLinkSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: *std.AutoArrayHashMap(SymbolLoc, u32)) !void { const writer = binary_bytes.writer(); - try leb.writeULEB128(writer, @enumToInt(types.SubsectionType.WASM_SYMBOL_TABLE)); + try leb.writeULEB128(writer, @intFromEnum(types.SubsectionType.WASM_SYMBOL_TABLE)); const table_offset = binary_bytes.items.len; var symbol_count: u32 = 0; @@ -4655,7 +4655,7 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: try symbol_table.putNoClobber(sym_loc, symbol_count); symbol_count += 1; log.debug("Emit symbol: {}", .{symbol}); - try leb.writeULEB128(writer, @enumToInt(symbol.tag)); + try leb.writeULEB128(writer, @intFromEnum(symbol.tag)); try leb.writeULEB128(writer, symbol.flags); const sym_name = if (wasm.export_names.get(sym_loc)) |exp_name| wasm.string_table.get(exp_name) else sym_loc.getName(wasm); @@ -4693,7 +4693,7 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void { const writer = binary_bytes.writer(); - try leb.writeULEB128(writer, @enumToInt(types.SubsectionType.WASM_SEGMENT_INFO)); + try leb.writeULEB128(writer, @intFromEnum(types.SubsectionType.WASM_SEGMENT_INFO)); const segment_offset = binary_bytes.items.len; try leb.writeULEB128(writer, @intCast(u32, wasm.segment_info.count())); @@ -4754,7 +4754,7 @@ fn emitCodeRelocations( count += 1; const sym_loc: SymbolLoc = .{ .file = atom.file, .index = relocation.index }; const symbol_index = symbol_table.get(sym_loc).?; - try leb.writeULEB128(writer, @enumToInt(relocation.relocation_type)); + try leb.writeULEB128(writer, @intFromEnum(relocation.relocation_type)); const offset = atom.offset + relocation.offset + size_offset; try leb.writeULEB128(writer, offset); try leb.writeULEB128(writer, symbol_index); @@ -4804,7 +4804,7 @@ fn emitDataRelocations( .index = relocation.index, }; const symbol_index = symbol_table.get(sym_loc).?; - try leb.writeULEB128(writer, @enumToInt(relocation.relocation_type)); + try leb.writeULEB128(writer, @intFromEnum(relocation.relocation_type)); const offset = atom.offset + relocation.offset + size_offset; try leb.writeULEB128(writer, offset); try leb.writeULEB128(writer, symbol_index); diff --git a/src/link/Wasm/Object.zig b/src/link/Wasm/Object.zig index 33f54dece5..db96381938 100644 --- a/src/link/Wasm/Object.zig +++ b/src/link/Wasm/Object.zig @@ -365,7 +365,7 @@ fn Parser(comptime ReaderType: type) type { const len = try readLeb(u32, parser.reader.reader()); var limited_reader = std.io.limitedReader(parser.reader.reader(), len); const reader = limited_reader.reader(); - switch (@intToEnum(std.wasm.Section, byte)) { + switch (@enumFromInt(std.wasm.Section, byte)) { .custom => { const name_len = try readLeb(u32, reader); const name = try gpa.alloc(u8, name_len); @@ -645,7 +645,7 @@ fn Parser(comptime ReaderType: type) type { /// such as access to the `import` section to find the name of a symbol. fn parseSubsection(parser: *ObjectParser, gpa: Allocator, reader: anytype) !void { const sub_type = try leb.readULEB128(u8, reader); - log.debug("Found subsection: {s}", .{@tagName(@intToEnum(types.SubsectionType, sub_type))}); + log.debug("Found subsection: {s}", .{@tagName(@enumFromInt(types.SubsectionType, sub_type))}); const payload_len = try leb.readULEB128(u32, reader); if (payload_len == 0) return; @@ -655,7 +655,7 @@ fn Parser(comptime ReaderType: type) type { // every subsection contains a 'count' field const count = try leb.readULEB128(u32, limited_reader); - switch (@intToEnum(types.SubsectionType, sub_type)) { + switch (@enumFromInt(types.SubsectionType, sub_type)) { .WASM_SEGMENT_INFO => { const segments = try gpa.alloc(types.Segment, count); errdefer gpa.free(segments); @@ -678,7 +678,7 @@ fn Parser(comptime ReaderType: type) type { // support legacy object files that specified being TLS by the name instead of the TLS flag. if (!segment.isTLS() and (std.mem.startsWith(u8, segment.name, ".tdata") or std.mem.startsWith(u8, segment.name, ".tbss"))) { // set the flag so we can simply check for the flag in the rest of the linker. - segment.flags |= @enumToInt(types.Segment.Flags.WASM_SEG_FLAG_TLS); + segment.flags |= @intFromEnum(types.Segment.Flags.WASM_SEG_FLAG_TLS); } } parser.object.segment_info = segments; @@ -714,7 +714,7 @@ fn Parser(comptime ReaderType: type) type { errdefer gpa.free(symbols); for (symbols) |*symbol| { symbol.* = .{ - .kind = @intToEnum(types.ComdatSym.Type, try leb.readULEB128(u8, reader)), + .kind = @enumFromInt(types.ComdatSym.Type, try leb.readULEB128(u8, reader)), .index = try leb.readULEB128(u32, reader), }; } @@ -758,7 +758,7 @@ fn Parser(comptime ReaderType: type) type { /// requires access to `Object` to find the name of a symbol when it's /// an import and flag `WASM_SYM_EXPLICIT_NAME` is not set. fn parseSymbol(parser: *ObjectParser, gpa: Allocator, reader: anytype) !Symbol { - const tag = @intToEnum(Symbol.Tag, try leb.readULEB128(u8, reader)); + const tag = @enumFromInt(Symbol.Tag, try leb.readULEB128(u8, reader)); const flags = try leb.readULEB128(u32, reader); var symbol: Symbol = .{ .flags = flags, @@ -846,7 +846,7 @@ fn readLeb(comptime T: type, reader: anytype) !T { /// Asserts `T` is an enum fn readEnum(comptime T: type, reader: anytype) !T { switch (@typeInfo(T)) { - .Enum => |enum_type| return @intToEnum(T, try readLeb(enum_type.tag_type, reader)), + .Enum => |enum_type| return @enumFromInt(T, try readLeb(enum_type.tag_type, reader)), else => @compileError("T must be an enum. Instead was given type " ++ @typeName(T)), } } @@ -867,7 +867,7 @@ fn readLimits(reader: anytype) !std.wasm.Limits { fn readInit(reader: anytype) !std.wasm.InitExpression { const opcode = try reader.readByte(); - const init_expr: std.wasm.InitExpression = switch (@intToEnum(std.wasm.Opcode, opcode)) { + const init_expr: std.wasm.InitExpression = switch (@enumFromInt(std.wasm.Opcode, opcode)) { .i32_const => .{ .i32_const = try readLeb(i32, reader) }, .global_get => .{ .global_get = try readLeb(u32, reader) }, else => @panic("TODO: initexpression for other opcodes"), diff --git a/src/link/Wasm/Symbol.zig b/src/link/Wasm/Symbol.zig index 8a1c4c5fdb..8dc10771ae 100644 --- a/src/link/Wasm/Symbol.zig +++ b/src/link/Wasm/Symbol.zig @@ -91,32 +91,32 @@ pub fn requiresImport(symbol: Symbol) bool { } pub fn isTLS(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_TLS) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_TLS) != 0; } pub fn hasFlag(symbol: Symbol, flag: Flag) bool { - return symbol.flags & @enumToInt(flag) != 0; + return symbol.flags & @intFromEnum(flag) != 0; } pub fn setFlag(symbol: *Symbol, flag: Flag) void { - symbol.flags |= @enumToInt(flag); + symbol.flags |= @intFromEnum(flag); } pub fn isUndefined(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_UNDEFINED) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_UNDEFINED) != 0; } pub fn setUndefined(symbol: *Symbol, is_undefined: bool) void { if (is_undefined) { symbol.setFlag(.WASM_SYM_UNDEFINED); } else { - symbol.flags &= ~@enumToInt(Flag.WASM_SYM_UNDEFINED); + symbol.flags &= ~@intFromEnum(Flag.WASM_SYM_UNDEFINED); } } pub fn setGlobal(symbol: *Symbol, is_global: bool) void { if (is_global) { - symbol.flags &= ~@enumToInt(Flag.WASM_SYM_BINDING_LOCAL); + symbol.flags &= ~@intFromEnum(Flag.WASM_SYM_BINDING_LOCAL); } else { symbol.setFlag(.WASM_SYM_BINDING_LOCAL); } @@ -127,23 +127,23 @@ pub fn isDefined(symbol: Symbol) bool { } pub fn isVisible(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_VISIBILITY_HIDDEN) == 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_VISIBILITY_HIDDEN) == 0; } pub fn isLocal(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_BINDING_LOCAL) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_BINDING_LOCAL) != 0; } pub fn isGlobal(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_BINDING_LOCAL) == 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_BINDING_LOCAL) == 0; } pub fn isHidden(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_VISIBILITY_HIDDEN) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_VISIBILITY_HIDDEN) != 0; } pub fn isNoStrip(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_NO_STRIP) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_NO_STRIP) != 0; } pub fn isExported(symbol: Symbol, is_dynamic: bool) bool { @@ -153,7 +153,7 @@ pub fn isExported(symbol: Symbol, is_dynamic: bool) bool { } pub fn isWeak(symbol: Symbol) bool { - return symbol.flags & @enumToInt(Flag.WASM_SYM_BINDING_WEAK) != 0; + return symbol.flags & @intFromEnum(Flag.WASM_SYM_BINDING_WEAK) != 0; } /// Formats the symbol into human-readable text diff --git a/src/link/Wasm/types.zig b/src/link/Wasm/types.zig index 801c25e9d9..9bf54f25c3 100644 --- a/src/link/Wasm/types.zig +++ b/src/link/Wasm/types.zig @@ -118,7 +118,7 @@ pub const Segment = struct { flags: u32, pub fn isTLS(segment: Segment) bool { - return segment.flags & @enumToInt(Flags.WASM_SEG_FLAG_TLS) != 0; + return segment.flags & @intFromEnum(Flags.WASM_SEG_FLAG_TLS) != 0; } /// Returns the name as how it will be output into the final object @@ -205,7 +205,7 @@ pub const Feature = struct { /// From a given cpu feature, returns its linker feature pub fn fromCpuFeature(feature: std.Target.wasm.Feature) Tag { - return @intToEnum(Tag, @enumToInt(feature)); + return @enumFromInt(Tag, @intFromEnum(feature)); } pub fn format(tag: Tag, comptime fmt: []const u8, opt: std.fmt.FormatOptions, writer: anytype) !void { |
