aboutsummaryrefslogtreecommitdiff
path: root/lib/compiler_rt/log2.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-06-17 18:10:00 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-06-17 18:10:00 -0700
commit0556a2ba53b8bbb1a60ff31d8dcdde78a8b16727 (patch)
treec691076f8f43db00ba0c6e58afebb1300ea4093e /lib/compiler_rt/log2.zig
parent3efc229bbf8aaec9de54a702054b091bf890d56e (diff)
downloadzig-0556a2ba53b8bbb1a60ff31d8dcdde78a8b16727.tar.gz
zig-0556a2ba53b8bbb1a60ff31d8dcdde78a8b16727.zip
compiler-rt: finish cleanups
Finishes cleanups that I started in other commits in this branch. * Use common.linkage for all exports instead of redoing the logic in each file. * Remove pointless `@setRuntimeSafety` calls. * Avoid redundantly exporting multiple versions of functions. For example, if PPC wants `ceilf128` then don't also export `ceilq`; similarly if ARM wants `__aeabi_ddiv` then don't also export `__divdf3`. * Use `inline` for helper functions instead of making inline calls at callsites.
Diffstat (limited to 'lib/compiler_rt/log2.zig')
-rw-r--r--lib/compiler_rt/log2.zig38
1 files changed, 15 insertions, 23 deletions
diff --git a/lib/compiler_rt/log2.zig b/lib/compiler_rt/log2.zig
index d2a1dd1189..6f6c07212a 100644
--- a/lib/compiler_rt/log2.zig
+++ b/lib/compiler_rt/log2.zig
@@ -1,8 +1,8 @@
-// Ported from musl, which is licensed under the MIT license:
-// https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
-//
-// https://git.musl-libc.org/cgit/musl/tree/src/math/log2f.c
-// https://git.musl-libc.org/cgit/musl/tree/src/math/log2.c
+//! Ported from musl, which is licensed under the MIT license:
+//! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
+//!
+//! https://git.musl-libc.org/cgit/musl/tree/src/math/log2f.c
+//! https://git.musl-libc.org/cgit/musl/tree/src/math/log2.c
const std = @import("std");
const builtin = @import("builtin");
@@ -10,22 +10,18 @@ const math = std.math;
const expect = std.testing.expect;
const maxInt = std.math.maxInt;
const arch = builtin.cpu.arch;
-const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
-pub const panic = @import("common.zig").panic;
+const common = @import("common.zig");
+
+pub const panic = common.panic;
comptime {
- @export(__log2h, .{ .name = "__log2h", .linkage = linkage });
- @export(log2f, .{ .name = "log2f", .linkage = linkage });
- @export(log2, .{ .name = "log2", .linkage = linkage });
- @export(__log2x, .{ .name = "__log2x", .linkage = linkage });
- @export(log2q, .{ .name = "log2q", .linkage = linkage });
- @export(log2l, .{ .name = "log2l", .linkage = linkage });
-
- if (!builtin.is_test) {
- if (arch.isPPC() or arch.isPPC64()) {
- @export(log2f128, .{ .name = "log2f128", .linkage = linkage });
- }
- }
+ @export(__log2h, .{ .name = "__log2h", .linkage = common.linkage });
+ @export(log2f, .{ .name = "log2f", .linkage = common.linkage });
+ @export(log2, .{ .name = "log2", .linkage = common.linkage });
+ @export(__log2x, .{ .name = "__log2x", .linkage = common.linkage });
+ const log2q_sym_name = if (common.want_ppc_abi) "log2f128" else "log2q";
+ @export(log2q, .{ .name = log2q_sym_name, .linkage = common.linkage });
+ @export(log2l, .{ .name = "log2l", .linkage = common.linkage });
}
pub fn __log2h(a: f16) callconv(.C) f16 {
@@ -170,10 +166,6 @@ pub fn log2q(a: f128) callconv(.C) f128 {
return log2(@floatCast(f64, a));
}
-pub fn log2f128(a: f128) callconv(.C) f128 {
- return @call(.{ .modifier = .always_inline }, log2q, .{a});
-}
-
pub fn log2l(x: c_longdouble) callconv(.C) c_longdouble {
switch (@typeInfo(c_longdouble).Float.bits) {
16 => return __log2h(x),