| ... | ... | @@ -586,6 +586,60 @@ pub fn main() !void { |
| 586 | 586 | |
| 587 | 587 | try writer.writeAll("};\n\n"); |
| 588 | 588 | } |
| 589 | { |
| 590 | try writer.writeAll("pub const Hexagon = enum(usize) {\n"); |
| 591 | |
| 592 | const child_args = [_][]const u8{ |
| 593 | zig_exe, |
| 594 | "cc", |
| 595 | "-target", |
| 596 | "hexagon-freestanding-none", |
| 597 | "-E", |
| 598 | "-dD", |
| 599 | "-P", |
| 600 | "-nostdinc", |
| 601 | "-Itools/include", |
| 602 | "-Itools/include/uapi", |
| 603 | "-D __SYSCALL(nr, nm)=zigsyscall nm nr", |
| 604 | "arch/hexagon/include/uapi/asm/unistd.h", |
| 605 | }; |
| 606 | |
| 607 | const child_result = try std.process.Child.run(.{ |
| 608 | .allocator = allocator, |
| 609 | .argv = &child_args, |
| 610 | .cwd = linux_path, |
| 611 | .cwd_dir = linux_dir, |
| 612 | }); |
| 613 | if (child_result.stderr.len > 0) std.debug.print("{s}\n", .{child_result.stderr}); |
| 614 | |
| 615 | const defines = switch (child_result.term) { |
| 616 | .Exited => |code| if (code == 0) child_result.stdout else { |
| 617 | std.debug.print("zig cc exited with code {d}\n", .{code}); |
| 618 | std.process.exit(1); |
| 619 | }, |
| 620 | else => { |
| 621 | std.debug.print("zig cc crashed\n", .{}); |
| 622 | std.process.exit(1); |
| 623 | }, |
| 624 | }; |
| 625 | |
| 626 | var lines = mem.tokenizeScalar(u8, defines, '\n'); |
| 627 | while (lines.next()) |line| { |
| 628 | var fields = mem.tokenizeAny(u8, line, " "); |
| 629 | const prefix = fields.next() orelse return error.Incomplete; |
| 630 | |
| 631 | if (!mem.eql(u8, prefix, "zigsyscall")) continue; |
| 632 | |
| 633 | const sys_name = fields.next() orelse return error.Incomplete; |
| 634 | const value = fields.rest(); |
| 635 | const name = (getOverridenNameNew(value) orelse sys_name)["sys_".len..]; |
| 636 | const fixed_name = if (stdlib_renames_new.get(name)) |f| f else if (stdlib_renames.get(name)) |f| f else name; |
| 637 | |
| 638 | try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), value }); |
| 639 | } |
| 640 | |
| 641 | try writer.writeAll("};\n\n"); |
| 642 | } |
| 589 | 643 | |
| 590 | 644 | try buf_out.flush(); |
| 591 | 645 | } |