diff --git a/build-cosmo.sh b/build-cosmo.sh index 50d2c11..dbebbe7 100755 --- a/build-cosmo.sh +++ b/build-cosmo.sh @@ -1,5 +1,5 @@ #!/bin/sh -zig build-obj ./src/main.zig -fno-PIE -fno-PIC -fno-stack-check +zig build-obj ./src/platform/cosmopolitan/main.zig -fno-PIE -fno-PIC -fno-stack-check --mod nmvm::src/nmvm.zig --deps nmvm ld.bfd main.o -o zig-out/bin/nmvm.com.dbg -T extern/cosmopolitan/ape.lds extern/cosmopolitan/crt.o extern/cosmopolitan/ape-copy-self.o \ extern/cosmopolitan/cosmopolitan.a -z common-page-size=0x1000 -z max-page-size=0x1000 --gc-sections diff --git a/prepare.sh b/prepare.sh index a750c45..3d5dbcb 100755 --- a/prepare.sh +++ b/prepare.sh @@ -4,4 +4,4 @@ cd ./extern ./get.sh cd ../ -zig translate-c ./extern/cosmopolitan/cosmopolitan.h > ./src/cosmopolitan/cosmopolitan.zig +zig translate-c ./extern/cosmopolitan/cosmopolitan.h > ./src/platform/cosmopolitan/cosmopolitan.zig diff --git a/src/arch/x86-64.zig b/src/arch/x86-64.zig index dbb8c71..66dfdad 100644 --- a/src/arch/x86-64.zig +++ b/src/arch/x86-64.zig @@ -1,2 +1,2 @@ pub usingnamespace @import("x86-64/jedino-jedro.zig"); -pub usingnamespace @import("x86-64/ve-sistema.zig"); +pub usingnamespace @import("x86-64/zov/ve-sistema.zig"); diff --git a/src/arch/x86-64/ve-sistema.zig b/src/arch/x86-64/zov/ve-sistema.zig similarity index 96% rename from src/arch/x86-64/ve-sistema.zig rename to src/arch/x86-64/zov/ve-sistema.zig index 98a7f63..18edcbf 100644 --- a/src/arch/x86-64/ve-sistema.zig +++ b/src/arch/x86-64/zov/ve-sistema.zig @@ -1,12 +1,16 @@ -//! ve sistema (.ve-sistema:x86-64) +//! .zov.ve-sistema:x86-64 //! //! Provides entry opcodes for System V calling convention, optimized for specific prototypes. //! // https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf +// todo: Provide opcode that would dynamically dispatch based on marshaled C prototypes, +// which will be sufficient for rare prototypes sporadically used, so to not bloat +// the binary with all possible permutations or ask for them on comptime, which is unreasonable. + const std = @import("std"); -const tolmac = @import("../../tolmac.zig"); +const tolmac = @import("../../../tolmac.zig"); /// Used for stack parameter passing. pub const WordLimit = 128; @@ -111,8 +115,8 @@ pub fn generateOpZovSysvFromPrototype(prototype: anytype) !*const fn () callconv ; var integer_allocation: usize = 0; - const IntegerAllocations = [_][]const u8{ "rdi", "rsi", "rdx", "rcx", "r8", "r9", "stack" }; - // var sse_allocation: enum { xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, stack } = .xmm0; + const IntegerAllocations = [_][]const u8{ "rdi", "rsi", "rdx", "rcx", "r8", "r9" }; + // var sse_allocation: enum { xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 } = .xmm0; var class_buffer = [_]Class{.void} ** ClassBufferLimit; diff --git a/src/cosmopolitan/.getkeep b/src/cosmopolitan/.getkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/nmvm.zig b/src/nmvm.zig new file mode 100644 index 0000000..d9a3351 --- /dev/null +++ b/src/nmvm.zig @@ -0,0 +1 @@ +pub const tolmac = @import("tolmac.zig"); diff --git a/src/main.zig b/src/platform/cosmopolitan/main.zig similarity index 93% rename from src/main.zig rename to src/platform/cosmopolitan/main.zig index 2032434..7188b7d 100644 --- a/src/main.zig +++ b/src/platform/cosmopolitan/main.zig @@ -1,5 +1,5 @@ -const tolmac = @import("tolmac.zig"); -const cosmo = @import("cosmopolitan/cosmopolitan.zig"); +const tolmac = @import("nmvm").tolmac; +const cosmo = @import("cosmopolitan.zig"); fn printInt3(int: u64, other: u32, another: u16) callconv(.SysV) void { @setAlignStack(16); @@ -57,5 +57,5 @@ fn cosmopolitanMain(argc: c_int, argv: [*][*:0]u8) callconv(.SysV) c_int { } test { - _ = @import("tolmac.zig"); + _ = @import("nmvm").tolmac; }