mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-09 15:19:07 +00:00
generate_linux_syscalls: Add generation code for csky.
This commit is contained in:
parent
2e910f23f9
commit
dd78ee43e4
1 changed files with 54 additions and 0 deletions
|
|
@ -532,6 +532,60 @@ pub fn main() !void {
|
||||||
|
|
||||||
try writer.writeAll("};\n\n");
|
try writer.writeAll("};\n\n");
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
try writer.writeAll("pub const CSky = enum(usize) {\n");
|
||||||
|
|
||||||
|
const child_args = [_][]const u8{
|
||||||
|
zig_exe,
|
||||||
|
"cc",
|
||||||
|
"-target",
|
||||||
|
"csky-freestanding-none",
|
||||||
|
"-E",
|
||||||
|
"-dD",
|
||||||
|
"-P",
|
||||||
|
"-nostdinc",
|
||||||
|
"-Itools/include",
|
||||||
|
"-Itools/include/uapi",
|
||||||
|
"-D __SYSCALL(nr, nm)=zigsyscall nm nr",
|
||||||
|
"arch/csky/include/uapi/asm/unistd.h",
|
||||||
|
};
|
||||||
|
|
||||||
|
const child_result = try std.process.Child.run(.{
|
||||||
|
.allocator = allocator,
|
||||||
|
.argv = &child_args,
|
||||||
|
.cwd = linux_path,
|
||||||
|
.cwd_dir = linux_dir,
|
||||||
|
});
|
||||||
|
if (child_result.stderr.len > 0) std.debug.print("{s}\n", .{child_result.stderr});
|
||||||
|
|
||||||
|
const defines = switch (child_result.term) {
|
||||||
|
.Exited => |code| if (code == 0) child_result.stdout else {
|
||||||
|
std.debug.print("zig cc exited with code {d}\n", .{code});
|
||||||
|
std.process.exit(1);
|
||||||
|
},
|
||||||
|
else => {
|
||||||
|
std.debug.print("zig cc crashed\n", .{});
|
||||||
|
std.process.exit(1);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
var lines = mem.tokenizeScalar(u8, defines, '\n');
|
||||||
|
while (lines.next()) |line| {
|
||||||
|
var fields = mem.tokenizeAny(u8, line, " ");
|
||||||
|
const prefix = fields.next() orelse return error.Incomplete;
|
||||||
|
|
||||||
|
if (!mem.eql(u8, prefix, "zigsyscall")) continue;
|
||||||
|
|
||||||
|
const sys_name = fields.next() orelse return error.Incomplete;
|
||||||
|
const value = fields.rest();
|
||||||
|
const name = (getOverridenNameNew(value) orelse sys_name)["sys_".len..];
|
||||||
|
const fixed_name = if (stdlib_renames_new.get(name)) |f| f else if (stdlib_renames.get(name)) |f| f else name;
|
||||||
|
|
||||||
|
try writer.print(" {p} = {s},\n", .{ zig.fmtId(fixed_name), value });
|
||||||
|
}
|
||||||
|
|
||||||
|
try writer.writeAll("};\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
try buf_out.flush();
|
try buf_out.flush();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue