mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
update cli test zig platform to zig 13
This commit is contained in:
parent
2be2c02b60
commit
164243821f
7 changed files with 37 additions and 37 deletions
|
@ -1,6 +1,6 @@
|
|||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const str = @import("glue").str;
|
||||
const str = @import("glue/str.zig");
|
||||
const RocStr = str.RocStr;
|
||||
const testing = std.testing;
|
||||
const expectEqual = testing.expectEqual;
|
||||
|
@ -25,7 +25,7 @@ const DEBUG: bool = false;
|
|||
|
||||
export fn roc_alloc(size: usize, alignment: u32) callconv(.C) ?*anyopaque {
|
||||
if (DEBUG) {
|
||||
var ptr = malloc(size);
|
||||
const ptr = malloc(size);
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
stdout.print("alloc: {d} (alignment {d}, size {d})\n", .{ ptr, alignment, size }) catch unreachable;
|
||||
return ptr;
|
||||
|
@ -97,13 +97,13 @@ fn roc_mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int, fd: c_
|
|||
|
||||
comptime {
|
||||
if (builtin.os.tag == .macos or builtin.os.tag == .linux) {
|
||||
@export(roc_getppid, .{ .name = "roc_getppid", .linkage = .Strong });
|
||||
@export(roc_mmap, .{ .name = "roc_mmap", .linkage = .Strong });
|
||||
@export(roc_shm_open, .{ .name = "roc_shm_open", .linkage = .Strong });
|
||||
@export(roc_getppid, .{ .name = "roc_getppid", .linkage = .strong });
|
||||
@export(roc_mmap, .{ .name = "roc_mmap", .linkage = .strong });
|
||||
@export(roc_shm_open, .{ .name = "roc_shm_open", .linkage = .strong });
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .windows) {
|
||||
@export(roc_getppid_windows_stub, .{ .name = "roc_getppid", .linkage = .Strong });
|
||||
@export(roc_getppid_windows_stub, .{ .name = "roc_getppid", .linkage = .strong });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const str = @import("glue").str;
|
||||
const str = @import("glue/str.zig");
|
||||
const RocStr = str.RocStr;
|
||||
const testing = std.testing;
|
||||
const expectEqual = testing.expectEqual;
|
||||
|
@ -22,7 +22,7 @@ const DEBUG: bool = false;
|
|||
|
||||
export fn roc_alloc(size: usize, alignment: u32) callconv(.C) ?*anyopaque {
|
||||
if (DEBUG) {
|
||||
var ptr = malloc(size);
|
||||
const ptr = malloc(size);
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
stdout.print("alloc: {d} (alignment {d}, size {d})\n", .{ ptr, alignment, size }) catch unreachable;
|
||||
return ptr;
|
||||
|
@ -94,13 +94,13 @@ fn roc_mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int, fd: c_
|
|||
|
||||
comptime {
|
||||
if (builtin.os.tag == .macos or builtin.os.tag == .linux) {
|
||||
@export(roc_getppid, .{ .name = "roc_getppid", .linkage = .Strong });
|
||||
@export(roc_mmap, .{ .name = "roc_mmap", .linkage = .Strong });
|
||||
@export(roc_shm_open, .{ .name = "roc_shm_open", .linkage = .Strong });
|
||||
@export(roc_getppid, .{ .name = "roc_getppid", .linkage = .strong });
|
||||
@export(roc_mmap, .{ .name = "roc_mmap", .linkage = .strong });
|
||||
@export(roc_shm_open, .{ .name = "roc_shm_open", .linkage = .strong });
|
||||
}
|
||||
|
||||
if (builtin.os.tag == .windows) {
|
||||
@export(roc_getppid_windows_stub, .{ .name = "roc_getppid", .linkage = .Strong });
|
||||
@export(roc_getppid_windows_stub, .{ .name = "roc_getppid", .linkage = .strong });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ pub export fn main() u8 {
|
|||
numbers[i] = @mod(@as(i64, @intCast(i)), 12);
|
||||
}
|
||||
|
||||
var roc_list = RocList{ .elements = numbers, .length = NUM_NUMS, .capacity = NUM_NUMS };
|
||||
const roc_list = RocList{ .elements = numbers, .length = NUM_NUMS, .capacity = NUM_NUMS };
|
||||
|
||||
var timer = std.time.Timer.start() catch unreachable;
|
||||
|
||||
|
@ -134,7 +134,7 @@ pub export fn main() u8 {
|
|||
|
||||
// stdout the result
|
||||
const length = @min(20, callresult.length);
|
||||
var result = callresult.elements[0..length];
|
||||
const result = callresult.elements[0..length];
|
||||
|
||||
const nanos = timer.read();
|
||||
const seconds = (@as(f64, @floatFromInt(nanos)) / 1_000_000_000.0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue