update hosts with new string conventions

This commit is contained in:
Folkert 2022-03-13 00:16:21 +01:00
parent ec403958a3
commit ba40b6a957
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
4 changed files with 27 additions and 18 deletions

View file

@ -20,7 +20,8 @@ comptime {
const mem = std.mem;
const Allocator = mem.Allocator;
extern fn roc__mainForHost_1_exposed(RocList) RocList;
extern fn roc__mainForHost_1_exposed_generic(output: *RocList, input: *RocList) void;
// extern fn roc__mainForHost_1_exposed_generic(input: *RocList) RocList;
const Align = extern struct { a: usize, b: usize };
extern fn malloc(size: usize) callconv(.C) ?*align(@alignOf(Align)) c_void;
@ -69,11 +70,11 @@ export fn roc_panic(c_ptr: *c_void, tag_id: u32) callconv(.C) void {
std.process.exit(0);
}
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void{
export fn roc_memcpy(dst: [*]u8, src: [*]u8, size: usize) callconv(.C) void {
return memcpy(dst, src, size);
}
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void{
export fn roc_memset(dst: [*]u8, value: i32, size: usize) callconv(.C) void {
return memset(dst, value, size);
}
@ -99,14 +100,17 @@ pub export fn main() u8 {
numbers[i] = @mod(@intCast(i64, i), 12);
}
const roc_list = RocList{ .elements = numbers, .length = NUM_NUMS };
var roc_list = RocList{ .elements = numbers, .length = NUM_NUMS };
// start time
var ts1: std.os.timespec = undefined;
std.os.clock_gettime(std.os.CLOCK_REALTIME, &ts1) catch unreachable;
// actually call roc to populate the callresult
var callresult = roc__mainForHost_1_exposed(roc_list);
var callresult: RocList = undefined;
roc__mainForHost_1_exposed_generic(&callresult, &roc_list);
// const callresult: RocList = roc__mainForHost_1_exposed_generic(&roc_list);
// stdout the result
const length = std.math.min(20, callresult.length);
@ -126,9 +130,9 @@ pub export fn main() u8 {
}
}
const delta = to_seconds(ts2) - to_seconds(ts1);
stderr.print("runtime: {d:.3}ms\n", .{delta * 1000}) catch unreachable;
// TODO apparently the typestamps are still (partially) undefined?
// const delta = to_seconds(ts2) - to_seconds(ts1);
// stderr.print("runtime: {d:.3}ms\n", .{delta * 1000}) catch unreachable;
return 0;
}