mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Zig allocator demo, using extram
This commit is contained in:
parent
a5018dab2f
commit
577aaadacd
9 changed files with 210 additions and 0 deletions
56
apps/zigalloc/build.zig
Normal file
56
apps/zigalloc/build.zig
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
const std = @import("std");
|
||||
const CrossTarget = @import("std").zig.CrossTarget;
|
||||
const Target = @import("std").Target;
|
||||
const Feature = @import("std").Target.Cpu.Feature;
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
var options = b.addOptions();
|
||||
const heapsize = b.option(u32, "heapsize", "heap size in bytes") orelse 0; // -Dheapsize=u32
|
||||
options.addOption(u32, "heapsize", heapsize);
|
||||
|
||||
const features = Target.riscv.Feature;
|
||||
var disabled_features = Feature.Set.empty;
|
||||
var enabled_features = Feature.Set.empty;
|
||||
|
||||
// disable all CPU extensions
|
||||
disabled_features.addFeature(@intFromEnum(features.a));
|
||||
disabled_features.addFeature(@intFromEnum(features.c));
|
||||
disabled_features.addFeature(@intFromEnum(features.d));
|
||||
disabled_features.addFeature(@intFromEnum(features.e));
|
||||
disabled_features.addFeature(@intFromEnum(features.f));
|
||||
// except multiply
|
||||
enabled_features.addFeature(@intFromEnum(features.m));
|
||||
|
||||
const target = b.resolveTargetQuery(.{
|
||||
.cpu_arch = Target.Cpu.Arch.riscv32,
|
||||
.os_tag = Target.Os.Tag.freestanding,
|
||||
.abi = Target.Abi.none,
|
||||
.cpu_model = .{ .explicit = &std.Target.riscv.cpu.generic_rv32},
|
||||
.cpu_features_sub = disabled_features,
|
||||
.cpu_features_add = enabled_features
|
||||
});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "zigalloc",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = .ReleaseSmall,
|
||||
}),
|
||||
});
|
||||
exe.root_module.addOptions("buildopts", options);
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
exe.addAssemblyFile(b.path("../crt0.S"));
|
||||
exe.setLinkerScript(b.path("../linker.ld"));
|
||||
exe.addIncludePath(b.path("../../common"));
|
||||
|
||||
const bin = b.addObjCopy(exe.getEmittedBin(), .{
|
||||
.format = .bin,
|
||||
});
|
||||
bin.step.dependOn(&exe.step);
|
||||
|
||||
const copy_bin = b.addInstallBinFile(bin.getOutput(), "zigalloc.bin");
|
||||
b.default_step.dependOn(©_bin.step);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue