| ... | ... | @@ -427,16 +427,11 @@ pub fn main() !void { |
| 427 | 427 | try writer.writeAll("};\n\n"); |
| 428 | 428 | } |
| 429 | 429 | { |
| 430 | | try writer.writeAll( |
| 431 | | \\ |
| 432 | | \\pub const LoongArch64 = enum(usize) { |
| 433 | | \\ |
| 434 | | ); |
| 430 | try writer.writeAll("pub const LoongArch64 = enum(usize) {\n"); |
| 435 | 431 | |
| 436 | 432 | const child_args = [_][]const u8{ |
| 437 | 433 | zig_exe, |
| 438 | 434 | "cc", |
| 439 | | "-march=loongarch64", |
| 440 | 435 | "-target", |
| 441 | 436 | "loongarch64-linux-gnu", |
| 442 | 437 | "-E", |
| ... | ... | @@ -445,6 +440,8 @@ pub fn main() !void { |
| 445 | 440 | "-nostdinc", |
| 446 | 441 | "-Iinclude", |
| 447 | 442 | "-Iinclude/uapi", |
| 443 | "-Iarch/loongarch/include/uapi", |
| 444 | "-D __SYSCALL(nr, nm)=zigsyscall nm nr", |
| 448 | 445 | "arch/loongarch/include/uapi/asm/unistd.h", |
| 449 | 446 | }; |
| 450 | 447 | |
| ... | ... | @@ -468,27 +465,21 @@ pub fn main() !void { |
| 468 | 465 | }; |
| 469 | 466 | |
| 470 | 467 | var lines = mem.tokenizeScalar(u8, defines, '\n'); |
| 471 | | loop: while (lines.next()) |line| { |
| 472 | | var fields = mem.tokenizeAny(u8, line, " \t"); |
| 473 | | const cmd = fields.next() orelse return error.Incomplete; |
| 474 | | if (!mem.eql(u8, cmd, "#define")) continue; |
| 475 | | const define = fields.next() orelse return error.Incomplete; |
| 476 | | const number = fields.next() orelse continue; |
| 468 | while (lines.next()) |line| { |
| 469 | var fields = mem.tokenizeAny(u8, line, " "); |
| 470 | const prefix = fields.next() orelse return error.Incomplete; |
| 477 | 471 | |
| 478 | | if (!std.ascii.isDigit(number[0])) continue; |
| 479 | | if (!mem.startsWith(u8, define, "__NR")) continue; |
| 480 | | const name = mem.trimLeft(u8, mem.trimLeft(u8, define, "__NR3264_"), "__NR_"); |
| 481 | | if (mem.eql(u8, name, "arch_specific_syscall")) continue; |
| 482 | | if (mem.eql(u8, name, "syscalls")) break :loop; |
| 472 | if (!mem.eql(u8, prefix, "zigsyscall")) continue; |
| 483 | 473 | |
| 484 | | const fixed_name = if (stdlib_renames.get(name)) |fixed| fixed else name; |
| 485 | | try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), number }); |
| 474 | const sys_name = fields.next() orelse return error.Incomplete; |
| 475 | const value = fields.rest(); |
| 476 | const name = (getOverridenNameNew(value) orelse sys_name)["sys_".len..]; |
| 477 | const fixed_name = if (stdlib_renames_new.get(name)) |f| f else if (stdlib_renames.get(name)) |f| f else name; |
| 478 | |
| 479 | try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), value }); |
| 486 | 480 | } |
| 487 | 481 | |
| 488 | | try writer.writeAll( |
| 489 | | \\}; |
| 490 | | \\ |
| 491 | | ); |
| 482 | try writer.writeAll("};\n\n"); |
| 492 | 483 | } |
| 493 | 484 | |
| 494 | 485 | try buf_out.flush(); |