mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 11:22:19 +00:00
Merge branch 'main' into div-0-should-crash
This commit is contained in:
commit
20bcd70ad2
195 changed files with 7098 additions and 1165 deletions
|
@ -460,6 +460,10 @@ pub const RocDec = extern struct {
|
|||
return RocDec{ .num = out };
|
||||
}
|
||||
|
||||
pub fn log(self: RocDec) RocDec {
|
||||
return fromF64(@log(self.toF64())).?;
|
||||
}
|
||||
|
||||
// I belive the output of the trig functions is always in range of Dec.
|
||||
// If not, we probably should just make it saturate the Dec.
|
||||
// I don't think this should crash or return errors.
|
||||
|
@ -1187,6 +1191,10 @@ test "div: 500 / 1000" {
|
|||
try expectEqual(RocDec.fromStr(roc_str), number1.div(number2));
|
||||
}
|
||||
|
||||
test "log: 1" {
|
||||
try expectEqual(RocDec.fromU64(0), RocDec.log(RocDec.fromU64(1)));
|
||||
}
|
||||
|
||||
// exports
|
||||
|
||||
pub fn fromStr(arg: RocStr) callconv(.C) num_.NumParseResult(i128) {
|
||||
|
@ -1283,6 +1291,10 @@ pub fn divC(arg1: RocDec, arg2: RocDec) callconv(.C) i128 {
|
|||
return @call(.always_inline, RocDec.div, .{ arg1, arg2 }).num;
|
||||
}
|
||||
|
||||
pub fn logC(arg: RocDec) callconv(.C) i128 {
|
||||
return @call(.always_inline, RocDec.log, .{arg}).num;
|
||||
}
|
||||
|
||||
pub fn sinC(arg: RocDec) callconv(.C) i128 {
|
||||
return @call(.always_inline, RocDec.sin, .{arg}).num;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,3 @@ pub fn notifyParent(shared_buffer: [*]u8, tag: u32) callconv(.C) void {
|
|||
pub fn notifyParentExpect(shared_buffer: [*]u8) callconv(.C) void {
|
||||
notifyParent(shared_buffer, 1);
|
||||
}
|
||||
|
||||
pub fn notifyParentDbg(shared_buffer: [*]u8) callconv(.C) void {
|
||||
notifyParent(shared_buffer, 2);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ comptime {
|
|||
exportDecFn(dec.fromF64C, "from_float.f64");
|
||||
exportDecFn(dec.fromStr, "from_str");
|
||||
exportDecFn(dec.fromU64C, "from_u64");
|
||||
exportDecFn(dec.logC, "log");
|
||||
exportDecFn(dec.mulC, "mul_with_overflow");
|
||||
exportDecFn(dec.mulOrPanicC, "mul_or_panic");
|
||||
exportDecFn(dec.mulSaturatedC, "mul_saturated");
|
||||
|
@ -230,6 +231,7 @@ comptime {
|
|||
|
||||
// Utils
|
||||
comptime {
|
||||
exportUtilsFn(utils.test_dbg, "test_dbg");
|
||||
exportUtilsFn(utils.test_panic, "test_panic");
|
||||
exportUtilsFn(utils.increfRcPtrC, "incref_rc_ptr");
|
||||
exportUtilsFn(utils.decrefRcPtrC, "decref_rc_ptr");
|
||||
|
@ -248,7 +250,6 @@ comptime {
|
|||
exportUtilsFn(expect.expectFailedStartSharedBuffer, "expect_failed_start_shared_buffer");
|
||||
exportUtilsFn(expect.expectFailedStartSharedFile, "expect_failed_start_shared_file");
|
||||
exportUtilsFn(expect.notifyParentExpect, "notify_parent_expect");
|
||||
exportUtilsFn(expect.notifyParentDbg, "notify_parent_dbg");
|
||||
|
||||
// sets the buffer used for expect failures
|
||||
@export(expect.setSharedBuffer, .{ .name = "set_shared_buffer", .linkage = .Weak });
|
||||
|
|
|
@ -20,6 +20,13 @@ extern fn roc_realloc(c_ptr: *anyopaque, new_size: usize, old_size: usize, align
|
|||
// This should never be passed a null pointer.
|
||||
extern fn roc_dealloc(c_ptr: *anyopaque, alignment: u32) callconv(.C) void;
|
||||
|
||||
extern fn roc_dbg(file_path: *anyopaque, message: *anyopaque) callconv(.C) void;
|
||||
|
||||
// Since roc_dbg is never used by the builtins, we need at export a function that uses it to stop DCE.
|
||||
pub fn test_dbg(file_path: *anyopaque, message: *anyopaque) callconv(.C) void {
|
||||
roc_dbg(file_path, message);
|
||||
}
|
||||
|
||||
extern fn kill(pid: c_int, sig: c_int) c_int;
|
||||
extern fn shm_open(name: *const i8, oflag: c_int, mode: c_uint) c_int;
|
||||
extern fn mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int, fd: c_int, offset: c_uint) *anyopaque;
|
||||
|
@ -40,6 +47,11 @@ fn testing_roc_mmap(addr: ?*anyopaque, length: c_uint, prot: c_int, flags: c_int
|
|||
return mmap(addr, length, prot, flags, fd, offset);
|
||||
}
|
||||
|
||||
fn testing_roc_dbg(file_path: *anyopaque, message: *anyopaque) callconv(.C) void {
|
||||
_ = message;
|
||||
_ = file_path;
|
||||
}
|
||||
|
||||
comptime {
|
||||
// During tests, use the testing allocators to satisfy these functions.
|
||||
if (builtin.is_test) {
|
||||
|
@ -47,6 +59,7 @@ comptime {
|
|||
@export(testing_roc_realloc, .{ .name = "roc_realloc", .linkage = .Strong });
|
||||
@export(testing_roc_dealloc, .{ .name = "roc_dealloc", .linkage = .Strong });
|
||||
@export(testing_roc_panic, .{ .name = "roc_panic", .linkage = .Strong });
|
||||
@export(testing_roc_dbg, .{ .name = "roc_dbg", .linkage = .Strong });
|
||||
|
||||
if (builtin.os.tag == .macos or builtin.os.tag == .linux) {
|
||||
@export(testing_roc_getppid, .{ .name = "roc_getppid", .linkage = .Strong });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue