cosmopolitan build

This commit is contained in:
veclav talica
2023-09-21 11:43:12 +05:00
parent bb91e60199
commit d5f3944b1a
8 changed files with 41 additions and 4 deletions

View File

View File

@ -1,20 +1,29 @@
const std = @import("std");
const tolmac = @import("tolmac.zig");
const cosmo = @import("cosmopolitan/cosmopolitan.zig");
fn printInt3(int: u64, other: u32, another: u16) callconv(.SysV) void {
@setAlignStack(16);
std.debug.print("test: {}, {}, {}\n", .{ int, other, another });
_ = cosmo.printf("%u\n", @as(c_uint, @intCast(int + other + another)));
}
fn printInt2(int: u64, other: u8) callconv(.SysV) void {
@setAlignStack(16);
std.debug.print("test: {}, {}\n", .{ int, other });
_ = cosmo.printf("%u\n", @as(c_uint, @intCast(int + other)));
}
const opPrintInt3Zov = tolmac.generateOpZovSysvFromPrototype(printInt3) catch unreachable;
const opPrintInt2Zov = tolmac.generateOpZovSysvFromPrototype(printInt2) catch unreachable;
pub fn main() !void {
comptime {
@export(cosmopolitanMain, .{ .name = "main" });
}
// todo: No cosmopolitan main.
export fn cosmopolitanMain(argc: c_int, argv: [*][*:0]u8) c_int {
_ = argc;
_ = argv;
const add = [_]tolmac.Word{
@as(tolmac.Word, @intFromPtr(&tolmac.opSumWordsWithOverflow)),
@as(tolmac.Word, @intFromPtr(&tolmac.opReturn)),
@ -43,6 +52,8 @@ pub fn main() !void {
};
tolmac.execute(&entry, 0);
return 0;
}
test {