mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
a way forward
This commit is contained in:
parent
8a4975ee8a
commit
6cc8f8624c
5 changed files with 18 additions and 6 deletions
|
@ -75,7 +75,7 @@ const num = @import("num.zig");
|
|||
comptime {
|
||||
exportNumFn(num.atan, "atan");
|
||||
exportNumFn(num.isFinite, "is_finite");
|
||||
exportNumFn(num.powInt, "pow_int");
|
||||
// exportNumFn(num.powInt, "pow_int");
|
||||
exportNumFn(num.acos, "acos");
|
||||
exportNumFn(num.asin, "asin");
|
||||
exportNumFn(num.bytesToU16C, "bytes_to_u16");
|
||||
|
|
|
@ -11,8 +11,20 @@ pub fn isFinite(num: f64) callconv(.C) bool {
|
|||
return @call(.{ .modifier = always_inline }, math.isFinite, .{num});
|
||||
}
|
||||
|
||||
pub fn powInt(base: i64, exp: i64) callconv(.C) i64 {
|
||||
return @call(.{ .modifier = always_inline }, math.pow, .{ i64, base, exp });
|
||||
comptime {
|
||||
var types = [_]type{ i32, i64, i16 };
|
||||
inline for (types) |T| {
|
||||
exportFunctions(T);
|
||||
}
|
||||
}
|
||||
fn exportFunctions(comptime T: type) void {
|
||||
comptime var f = struct {
|
||||
fn func(base: T, exp: T) callconv(.C) T {
|
||||
return std.math.pow(T, base, exp);
|
||||
}
|
||||
}.func;
|
||||
const args = .{ .name = "roc_builtins.num.pow_int_" ++ @typeName(T), .linkage = .Strong };
|
||||
@export(f, args);
|
||||
}
|
||||
|
||||
pub fn acos(num: f64) callconv(.C) f64 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue