@zigc/lib 0.16.0-test.1 → 0.17.0-dev.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/c/math.zig +148 -35
- package/c/stropts.zig +17 -0
- package/c.zig +1 -0
- package/compiler/aro/aro/Attribute/names.zig +604 -589
- package/compiler/aro/aro/Attribute.zig +202 -116
- package/compiler/aro/aro/Builtins/common.zig +874 -863
- package/compiler/aro/aro/Builtins/eval.zig +15 -7
- package/compiler/aro/aro/Builtins.zig +0 -1
- package/compiler/aro/aro/CodeGen.zig +3 -1
- package/compiler/aro/aro/Compilation.zig +120 -97
- package/compiler/aro/aro/Diagnostics.zig +21 -17
- package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
- package/compiler/aro/aro/Driver.zig +124 -50
- package/compiler/aro/aro/LangOpts.zig +12 -2
- package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
- package/compiler/aro/aro/Parser.zig +336 -142
- package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
- package/compiler/aro/aro/Preprocessor.zig +127 -56
- package/compiler/aro/aro/Target.zig +17 -12
- package/compiler/aro/aro/Tokenizer.zig +31 -14
- package/compiler/aro/aro/Toolchain.zig +4 -7
- package/compiler/aro/aro/Tree.zig +178 -148
- package/compiler/aro/aro/TypeStore.zig +82 -24
- package/compiler/aro/aro/Value.zig +13 -17
- package/compiler/aro/aro/features.zig +1 -0
- package/compiler/aro/aro/pragmas/once.zig +0 -1
- package/compiler/aro/aro/record_layout.zig +3 -3
- package/compiler/aro/assembly_backend/x86_64.zig +3 -4
- package/compiler/aro/backend/Assembly.zig +1 -2
- package/compiler/aro/backend/Interner.zig +2 -2
- package/compiler/aro/backend/Ir.zig +100 -92
- package/compiler/aro/include/ptrcheck.h +49 -0
- package/compiler/aro/main.zig +26 -10
- package/compiler/build_runner.zig +1 -0
- package/compiler/objdump.zig +93 -0
- package/compiler/reduce.zig +5 -1
- package/compiler/resinator/compile.zig +2 -2
- package/compiler/resinator/main.zig +7 -1
- package/compiler/resinator/preprocess.zig +1 -3
- package/compiler/std-docs.zig +8 -1
- package/compiler/test_runner.zig +194 -62
- package/compiler/translate-c/MacroTranslator.zig +80 -11
- package/compiler/translate-c/PatternList.zig +1 -9
- package/compiler/translate-c/Scope.zig +43 -6
- package/compiler/translate-c/Translator.zig +364 -126
- package/compiler/translate-c/ast.zig +19 -11
- package/compiler/translate-c/main.zig +75 -16
- package/compiler_rt/cos.zig +141 -52
- package/compiler_rt/divmodei4.zig +40 -17
- package/compiler_rt/exp.zig +1 -4
- package/compiler_rt/exp2.zig +1 -4
- package/compiler_rt/exp_f128.zig +377 -0
- package/compiler_rt/limb64.zig +1126 -0
- package/compiler_rt/long_double.zig +37 -0
- package/compiler_rt/mulXi3.zig +1 -1
- package/compiler_rt/mulo.zig +6 -1
- package/compiler_rt/rem_pio2l.zig +173 -0
- package/compiler_rt/sin.zig +140 -55
- package/compiler_rt/sincos.zig +279 -72
- package/compiler_rt/ssp.zig +1 -1
- package/compiler_rt/tan.zig +118 -47
- package/compiler_rt/trig.zig +256 -6
- package/compiler_rt/udivmodei4.zig +28 -0
- package/compiler_rt.zig +2 -0
- package/fuzzer.zig +855 -307
- package/libc/musl/src/math/pow.c +343 -0
- package/package.json +1 -1
- package/std/Build/Fuzz.zig +6 -19
- package/std/Build/Module.zig +1 -1
- package/std/Build/Step/CheckObject.zig +3 -3
- package/std/Build/Step/Compile.zig +18 -0
- package/std/Build/Step/ConfigHeader.zig +49 -33
- package/std/Build/Step/InstallArtifact.zig +18 -0
- package/std/Build/Step/Run.zig +536 -87
- package/std/Build/Step/TranslateC.zig +0 -6
- package/std/Build/Step.zig +8 -15
- package/std/Build/WebServer.zig +29 -17
- package/std/Build/abi.zig +47 -11
- package/std/Build.zig +17 -14
- package/std/Io/Dispatch.zig +2 -0
- package/std/Io/File/Reader.zig +3 -1
- package/std/Io/File.zig +1 -0
- package/std/Io/Kqueue.zig +2 -2
- package/std/Io/Threaded.zig +181 -143
- package/std/Io/Uring.zig +2 -1
- package/std/Io/Writer.zig +41 -41
- package/std/Io.zig +970 -2
- package/std/Target.zig +3 -2
- package/std/Thread.zig +8 -3
- package/std/array_hash_map.zig +96 -555
- package/std/array_list.zig +22 -31
- package/std/bit_set.zig +22 -6
- package/std/builtin/assembly.zig +68 -0
- package/std/c.zig +17 -17
- package/std/compress/flate/Compress.zig +3 -3
- package/std/crypto/Certificate/Bundle.zig +15 -1
- package/std/crypto/codecs/asn1.zig +33 -18
- package/std/crypto/codecs/base64_hex_ct.zig +14 -4
- package/std/debug/Dwarf.zig +29 -9
- package/std/debug/Info.zig +4 -0
- package/std/debug/MachOFile.zig +46 -8
- package/std/debug/Pdb.zig +539 -36
- package/std/debug/SelfInfo/Elf.zig +19 -18
- package/std/debug/SelfInfo/MachO.zig +18 -7
- package/std/debug/SelfInfo/Windows.zig +138 -36
- package/std/debug.zig +179 -65
- package/std/enums.zig +25 -19
- package/std/heap/ArenaAllocator.zig +145 -154
- package/std/heap/debug_allocator.zig +7 -7
- package/std/http/Client.zig +10 -6
- package/std/http.zig +11 -9
- package/std/json/Stringify.zig +3 -3
- package/std/json/dynamic.zig +4 -4
- package/std/math/big/int.zig +16 -17
- package/std/mem/Allocator.zig +4 -5
- package/std/mem.zig +48 -0
- package/std/os/emscripten.zig +2 -18
- package/std/os/linux/arc.zig +144 -0
- package/std/os/linux.zig +21 -4
- package/std/os/windows.zig +2 -2
- package/std/pdb.zig +143 -4
- package/std/posix.zig +6 -12
- package/std/priority_dequeue.zig +13 -12
- package/std/priority_queue.zig +5 -4
- package/std/process/Child.zig +1 -1
- package/std/process/Environ.zig +1 -1
- package/std/start.zig +17 -4
- package/std/std.zig +19 -6
- package/std/testing/FailingAllocator.zig +4 -4
- package/std/testing/Smith.zig +37 -2
- package/std/zig/Ast/Render.zig +186 -458
- package/std/zig/Ast.zig +0 -4
- package/std/zig/AstGen.zig +44 -7
- package/std/zig/AstSmith.zig +2602 -0
- package/std/zig/Client.zig +8 -3
- package/std/zig/Parse.zig +83 -74
- package/std/zig/Server.zig +26 -0
- package/std/zig/Zir.zig +17 -0
- package/std/zig/c_translation/helpers.zig +14 -9
- package/std/zig/llvm/Builder.zig +107 -48
- package/std/zig/system.zig +20 -4
- package/std/zig/tokenizer.zig +2 -1
- package/std/zig.zig +6 -0
- package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
- package/libc/mingw/complex/cabs.c +0 -48
- package/libc/mingw/complex/cabsf.c +0 -48
- package/libc/mingw/complex/cacos.c +0 -50
- package/libc/mingw/complex/cacosf.c +0 -50
- package/libc/mingw/complex/carg.c +0 -48
- package/libc/mingw/complex/cargf.c +0 -48
- package/libc/mingw/complex/casin.c +0 -50
- package/libc/mingw/complex/casinf.c +0 -50
- package/libc/mingw/complex/catan.c +0 -50
- package/libc/mingw/complex/catanf.c +0 -50
- package/libc/mingw/complex/ccos.c +0 -50
- package/libc/mingw/complex/ccosf.c +0 -50
- package/libc/mingw/complex/cexp.c +0 -48
- package/libc/mingw/complex/cexpf.c +0 -48
- package/libc/mingw/complex/cimag.c +0 -48
- package/libc/mingw/complex/cimagf.c +0 -48
- package/libc/mingw/complex/clog.c +0 -48
- package/libc/mingw/complex/clog10.c +0 -49
- package/libc/mingw/complex/clog10f.c +0 -49
- package/libc/mingw/complex/clogf.c +0 -48
- package/libc/mingw/complex/conj.c +0 -48
- package/libc/mingw/complex/conjf.c +0 -48
- package/libc/mingw/complex/cpow.c +0 -48
- package/libc/mingw/complex/cpowf.c +0 -48
- package/libc/mingw/complex/cproj.c +0 -48
- package/libc/mingw/complex/cprojf.c +0 -48
- package/libc/mingw/complex/creal.c +0 -48
- package/libc/mingw/complex/crealf.c +0 -48
- package/libc/mingw/complex/csin.c +0 -50
- package/libc/mingw/complex/csinf.c +0 -50
- package/libc/mingw/complex/csqrt.c +0 -48
- package/libc/mingw/complex/csqrtf.c +0 -48
- package/libc/mingw/complex/ctan.c +0 -50
- package/libc/mingw/complex/ctanf.c +0 -50
- package/libc/mingw/math/arm/s_rint.c +0 -86
- package/libc/mingw/math/arm/s_rintf.c +0 -51
- package/libc/mingw/math/arm/sincos.S +0 -30
- package/libc/mingw/math/arm-common/sincosl.c +0 -13
- package/libc/mingw/math/arm64/rint.c +0 -12
- package/libc/mingw/math/arm64/rintf.c +0 -12
- package/libc/mingw/math/arm64/sincos.S +0 -32
- package/libc/mingw/math/bsd_private_base.h +0 -148
- package/libc/mingw/math/fdiml.c +0 -24
- package/libc/mingw/math/frexpf.c +0 -13
- package/libc/mingw/math/frexpl.c +0 -71
- package/libc/mingw/math/x86/acosf.c +0 -29
- package/libc/mingw/math/x86/atanf.c +0 -23
- package/libc/mingw/math/x86/atanl.c +0 -18
- package/libc/mingw/math/x86/cos.def.h +0 -65
- package/libc/mingw/math/x86/cosl.c +0 -46
- package/libc/mingw/math/x86/cosl_internal.S +0 -55
- package/libc/mingw/math/x86/ldexp.c +0 -23
- package/libc/mingw/math/x86/scalbn.S +0 -41
- package/libc/mingw/math/x86/scalbnf.S +0 -40
- package/libc/mingw/math/x86/sin.def.h +0 -65
- package/libc/mingw/math/x86/sinl.c +0 -46
- package/libc/mingw/math/x86/sinl_internal.S +0 -58
- package/libc/mingw/math/x86/tanl.S +0 -62
- package/libc/mingw/misc/btowc.c +0 -28
- package/libc/mingw/misc/wcstof.c +0 -66
- package/libc/mingw/misc/wcstoimax.c +0 -132
- package/libc/mingw/misc/wcstoumax.c +0 -126
- package/libc/mingw/misc/wctob.c +0 -29
- package/libc/mingw/misc/winbs_uint64.c +0 -6
- package/libc/mingw/misc/winbs_ulong.c +0 -6
- package/libc/mingw/misc/winbs_ushort.c +0 -6
- package/libc/mingw/stdio/_Exit.c +0 -10
- package/libc/mingw/stdio/_findfirst64i32.c +0 -21
- package/libc/mingw/stdio/_findnext64i32.c +0 -21
- package/libc/mingw/stdio/_fstat64i32.c +0 -37
- package/libc/mingw/stdio/_stat64i32.c +0 -37
- package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
- package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
- package/libc/mingw/stdio/_wstat64i32.c +0 -37
- package/libc/musl/src/legacy/isastream.c +0 -7
- package/libc/musl/src/legacy/valloc.c +0 -8
- package/libc/musl/src/math/__cosl.c +0 -96
- package/libc/musl/src/math/__sinl.c +0 -78
- package/libc/musl/src/math/__tanl.c +0 -143
- package/libc/musl/src/math/aarch64/lrint.c +0 -10
- package/libc/musl/src/math/aarch64/lrintf.c +0 -10
- package/libc/musl/src/math/aarch64/rintf.c +0 -7
- package/libc/musl/src/math/cosl.c +0 -39
- package/libc/musl/src/math/fdim.c +0 -10
- package/libc/musl/src/math/fdimf.c +0 -10
- package/libc/musl/src/math/fdiml.c +0 -18
- package/libc/musl/src/math/finite.c +0 -7
- package/libc/musl/src/math/finitef.c +0 -7
- package/libc/musl/src/math/frexp.c +0 -23
- package/libc/musl/src/math/frexpf.c +0 -23
- package/libc/musl/src/math/frexpl.c +0 -29
- package/libc/musl/src/math/i386/lrint.c +0 -8
- package/libc/musl/src/math/i386/lrintf.c +0 -8
- package/libc/musl/src/math/i386/rintf.c +0 -7
- package/libc/musl/src/math/lrint.c +0 -72
- package/libc/musl/src/math/lrintf.c +0 -8
- package/libc/musl/src/math/powerpc64/lrint.c +0 -16
- package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
- package/libc/musl/src/math/rintf.c +0 -30
- package/libc/musl/src/math/s390x/rintf.c +0 -15
- package/libc/musl/src/math/sincosl.c +0 -60
- package/libc/musl/src/math/sinl.c +0 -41
- package/libc/musl/src/math/tanl.c +0 -29
- package/libc/musl/src/math/x32/lrint.s +0 -5
- package/libc/musl/src/math/x32/lrintf.s +0 -5
- package/libc/musl/src/math/x86_64/lrint.c +0 -8
- package/libc/musl/src/math/x86_64/lrintf.c +0 -8
- package/libc/wasi/libc-bottom-half/sources/reallocarray.c +0 -14
package/compiler_rt/sincos.zig
CHANGED
|
@@ -3,17 +3,21 @@ const builtin = @import("builtin");
|
|
|
3
3
|
const arch = builtin.cpu.arch;
|
|
4
4
|
const math = std.math;
|
|
5
5
|
const mem = std.mem;
|
|
6
|
+
const expect = std.testing.expect;
|
|
7
|
+
const expectApproxEqAbs = std.testing.expectApproxEqAbs;
|
|
6
8
|
const trig = @import("trig.zig");
|
|
7
9
|
const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
|
|
8
10
|
const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
|
|
11
|
+
const rem_pio2l = @import("rem_pio2l.zig").rem_pio2l;
|
|
12
|
+
const ld = @import("long_double.zig");
|
|
9
13
|
const compiler_rt = @import("../compiler_rt.zig");
|
|
10
14
|
const symbol = compiler_rt.symbol;
|
|
11
15
|
|
|
12
16
|
comptime {
|
|
13
|
-
symbol(&
|
|
17
|
+
symbol(&sincosh, "__sincosh");
|
|
14
18
|
symbol(&sincosf, "sincosf");
|
|
15
19
|
symbol(&sincos, "sincos");
|
|
16
|
-
symbol(&
|
|
20
|
+
symbol(&sincosx, "__sincosx");
|
|
17
21
|
if (compiler_rt.want_ppc_abi) {
|
|
18
22
|
symbol(&sincosq, "sincosf128");
|
|
19
23
|
}
|
|
@@ -21,7 +25,7 @@ comptime {
|
|
|
21
25
|
symbol(&sincosl, "sincosl");
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
pub fn
|
|
28
|
+
pub fn sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.c) void {
|
|
25
29
|
// TODO: more efficient implementation
|
|
26
30
|
var big_sin: f32 = undefined;
|
|
27
31
|
var big_cos: f32 = undefined;
|
|
@@ -56,8 +60,8 @@ pub fn sincosf(x: f32, r_sin: *f32, r_cos: *f32) callconv(.c) void {
|
|
|
56
60
|
r_cos.* = 1.0;
|
|
57
61
|
return;
|
|
58
62
|
}
|
|
59
|
-
r_sin.* = trig.
|
|
60
|
-
r_cos.* = trig.
|
|
63
|
+
r_sin.* = trig.sindf(x);
|
|
64
|
+
r_cos.* = trig.cosdf(x);
|
|
61
65
|
return;
|
|
62
66
|
}
|
|
63
67
|
|
|
@@ -66,17 +70,17 @@ pub fn sincosf(x: f32, r_sin: *f32, r_cos: *f32) callconv(.c) void {
|
|
|
66
70
|
// |x| ~<= 3pi/4
|
|
67
71
|
if (ix <= 0x4016cbe3) {
|
|
68
72
|
if (sign) {
|
|
69
|
-
r_sin.* = -trig.
|
|
70
|
-
r_cos.* = trig.
|
|
73
|
+
r_sin.* = -trig.cosdf(x + sc1pio2);
|
|
74
|
+
r_cos.* = trig.sindf(x + sc1pio2);
|
|
71
75
|
} else {
|
|
72
|
-
r_sin.* = trig.
|
|
73
|
-
r_cos.* = trig.
|
|
76
|
+
r_sin.* = trig.cosdf(sc1pio2 - x);
|
|
77
|
+
r_cos.* = trig.sindf(sc1pio2 - x);
|
|
74
78
|
}
|
|
75
79
|
return;
|
|
76
80
|
}
|
|
77
81
|
// -sin(x+c) is not correct if x+c could be 0: -0 vs +0
|
|
78
|
-
r_sin.* = -trig.
|
|
79
|
-
r_cos.* = -trig.
|
|
82
|
+
r_sin.* = -trig.sindf(if (sign) x + sc2pio2 else x - sc2pio2);
|
|
83
|
+
r_cos.* = -trig.cosdf(if (sign) x + sc2pio2 else x - sc2pio2);
|
|
80
84
|
return;
|
|
81
85
|
}
|
|
82
86
|
|
|
@@ -85,16 +89,16 @@ pub fn sincosf(x: f32, r_sin: *f32, r_cos: *f32) callconv(.c) void {
|
|
|
85
89
|
// |x| ~<= 7*pi/4
|
|
86
90
|
if (ix <= 0x40afeddf) {
|
|
87
91
|
if (sign) {
|
|
88
|
-
r_sin.* = trig.
|
|
89
|
-
r_cos.* = -trig.
|
|
92
|
+
r_sin.* = trig.cosdf(x + sc3pio2);
|
|
93
|
+
r_cos.* = -trig.sindf(x + sc3pio2);
|
|
90
94
|
} else {
|
|
91
|
-
r_sin.* = -trig.
|
|
92
|
-
r_cos.* = trig.
|
|
95
|
+
r_sin.* = -trig.cosdf(x - sc3pio2);
|
|
96
|
+
r_cos.* = trig.sindf(x - sc3pio2);
|
|
93
97
|
}
|
|
94
98
|
return;
|
|
95
99
|
}
|
|
96
|
-
r_sin.* = trig.
|
|
97
|
-
r_cos.* = trig.
|
|
100
|
+
r_sin.* = trig.sindf(if (sign) x + sc4pio2 else x - sc4pio2);
|
|
101
|
+
r_cos.* = trig.cosdf(if (sign) x + sc4pio2 else x - sc4pio2);
|
|
98
102
|
return;
|
|
99
103
|
}
|
|
100
104
|
|
|
@@ -109,8 +113,8 @@ pub fn sincosf(x: f32, r_sin: *f32, r_cos: *f32) callconv(.c) void {
|
|
|
109
113
|
// general argument reduction needed
|
|
110
114
|
var y: f64 = undefined;
|
|
111
115
|
const n = rem_pio2f(x, &y);
|
|
112
|
-
const s = trig.
|
|
113
|
-
const c = trig.
|
|
116
|
+
const s = trig.sindf(y);
|
|
117
|
+
const c = trig.cosdf(y);
|
|
114
118
|
switch (n & 3) {
|
|
115
119
|
0 => {
|
|
116
120
|
r_sin.* = s;
|
|
@@ -150,8 +154,8 @@ pub fn sincos(x: f64, r_sin: *f64, r_cos: *f64) callconv(.c) void {
|
|
|
150
154
|
r_cos.* = 1.0;
|
|
151
155
|
return;
|
|
152
156
|
}
|
|
153
|
-
r_sin.* = trig.
|
|
154
|
-
r_cos.* = trig.
|
|
157
|
+
r_sin.* = trig.sin(x, 0.0, 0);
|
|
158
|
+
r_cos.* = trig.cos(x, 0.0);
|
|
155
159
|
return;
|
|
156
160
|
}
|
|
157
161
|
|
|
@@ -166,8 +170,8 @@ pub fn sincos(x: f64, r_sin: *f64, r_cos: *f64) callconv(.c) void {
|
|
|
166
170
|
// argument reduction needed
|
|
167
171
|
var y: [2]f64 = undefined;
|
|
168
172
|
const n = rem_pio2(x, &y);
|
|
169
|
-
const s = trig.
|
|
170
|
-
const c = trig.
|
|
173
|
+
const s = trig.sin(y[0], y[1], 1);
|
|
174
|
+
const c = trig.cos(y[0], y[1]);
|
|
171
175
|
switch (n & 3) {
|
|
172
176
|
0 => {
|
|
173
177
|
r_sin.* = s;
|
|
@@ -188,50 +192,57 @@ pub fn sincos(x: f64, r_sin: *f64, r_cos: *f64) callconv(.c) void {
|
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
194
|
|
|
191
|
-
pub fn
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
195
|
+
pub fn sincosx(x: f80, r_sin: *f80, r_cos: *f80) callconv(.c) void {
|
|
196
|
+
const se = ld.signExponent(x) & 0x7fff;
|
|
197
|
+
if (se == 0x7fff) {
|
|
198
|
+
const result = x - x;
|
|
199
|
+
r_sin.* = result;
|
|
200
|
+
r_cos.* = result;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
200
203
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
204
|
+
if (@abs(x) < trig.pi_4) {
|
|
205
|
+
if (se < 0x3fff - math.floatMantissaBits(f80)) {
|
|
206
|
+
// raise underflow if subnormal
|
|
207
|
+
if (compiler_rt.want_float_exceptions and se == 0) {
|
|
208
|
+
mem.doNotOptimizeAway(x * 0x1p-120);
|
|
209
|
+
}
|
|
210
|
+
r_sin.* = x;
|
|
211
|
+
// raise inexact if x!=0
|
|
212
|
+
r_cos.* = 1.0 + x;
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
r_sin.* = trig.sinx(x, 0.0, 0);
|
|
216
|
+
r_cos.* = trig.cosx(x, 0.0);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
210
219
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
220
|
+
var y: [2]f80 = undefined;
|
|
221
|
+
const n = rem_pio2l(f80, x, &y);
|
|
222
|
+
const s = trig.sinx(y[0], y[1], 1);
|
|
223
|
+
const c = trig.cosx(y[0], y[1]);
|
|
224
|
+
switch (n & 3) {
|
|
225
|
+
0 => {
|
|
226
|
+
r_sin.* = s;
|
|
227
|
+
r_cos.* = c;
|
|
228
|
+
},
|
|
229
|
+
1 => {
|
|
230
|
+
r_sin.* = c;
|
|
231
|
+
r_cos.* = -s;
|
|
232
|
+
},
|
|
233
|
+
2 => {
|
|
234
|
+
r_sin.* = -s;
|
|
235
|
+
r_cos.* = -c;
|
|
236
|
+
},
|
|
237
|
+
else => {
|
|
238
|
+
r_sin.* = -c;
|
|
239
|
+
r_cos.* = s;
|
|
240
|
+
},
|
|
219
241
|
}
|
|
220
242
|
}
|
|
221
243
|
|
|
222
|
-
pub
|
|
223
|
-
|
|
224
|
-
/// Ported from musl sincosl.c. Needs the following dependencies to be complete:
|
|
225
|
-
/// * rem_pio2_generic ported from __rem_pio2l.c
|
|
226
|
-
/// * trig.sin_generic ported from __sinl.c
|
|
227
|
-
/// * trig.cos_generic ported from __cosl.c
|
|
228
|
-
inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void {
|
|
229
|
-
const sc1pio4: F = 1.0 * math.pi / 4.0;
|
|
230
|
-
const bits = @typeInfo(F).float.bits;
|
|
231
|
-
const I = std.meta.Int(.unsigned, bits);
|
|
232
|
-
const ix = @as(I, @bitCast(x)) & (math.maxInt(I) >> 1);
|
|
233
|
-
const se: u16 = @truncate(ix >> (bits - 16));
|
|
234
|
-
|
|
244
|
+
pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.c) void {
|
|
245
|
+
const se = ld.signExponent(x) & 0x7fff;
|
|
235
246
|
if (se == 0x7fff) {
|
|
236
247
|
const result = x - x;
|
|
237
248
|
r_sin.* = result;
|
|
@@ -239,26 +250,26 @@ inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void {
|
|
|
239
250
|
return;
|
|
240
251
|
}
|
|
241
252
|
|
|
242
|
-
if (@
|
|
243
|
-
if (se < 0x3fff - math.
|
|
253
|
+
if (@abs(x) < trig.pi_4) {
|
|
254
|
+
if (se < 0x3fff - math.floatMantissaBits(f128)) {
|
|
244
255
|
// raise underflow if subnormal
|
|
245
|
-
if (se == 0) {
|
|
246
|
-
|
|
256
|
+
if (compiler_rt.want_float_exceptions and se == 0) {
|
|
257
|
+
mem.doNotOptimizeAway(x * 0x1p-120);
|
|
247
258
|
}
|
|
248
259
|
r_sin.* = x;
|
|
249
260
|
// raise inexact if x!=0
|
|
250
261
|
r_cos.* = 1.0 + x;
|
|
251
262
|
return;
|
|
252
263
|
}
|
|
253
|
-
r_sin.* = trig.
|
|
254
|
-
r_cos.* = trig.
|
|
264
|
+
r_sin.* = trig.sinq(x, 0.0, 0);
|
|
265
|
+
r_cos.* = trig.cosq(x, 0.0);
|
|
255
266
|
return;
|
|
256
267
|
}
|
|
257
268
|
|
|
258
|
-
var y: [2]
|
|
259
|
-
const n =
|
|
260
|
-
const s = trig.
|
|
261
|
-
const c = trig.
|
|
269
|
+
var y: [2]f128 = undefined;
|
|
270
|
+
const n = rem_pio2l(f128, x, &y);
|
|
271
|
+
const s = trig.sinq(y[0], y[1], 1);
|
|
272
|
+
const c = trig.cosq(y[0], y[1]);
|
|
262
273
|
switch (n & 3) {
|
|
263
274
|
0 => {
|
|
264
275
|
r_sin.* = s;
|
|
@@ -278,3 +289,199 @@ inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void {
|
|
|
278
289
|
},
|
|
279
290
|
}
|
|
280
291
|
}
|
|
292
|
+
|
|
293
|
+
pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.c) void {
|
|
294
|
+
switch (@typeInfo(c_longdouble).float.bits) {
|
|
295
|
+
16 => return sincosh(x, r_sin, r_cos),
|
|
296
|
+
32 => return sincosf(x, r_sin, r_cos),
|
|
297
|
+
64 => return sincos(x, r_sin, r_cos),
|
|
298
|
+
80 => return sincosx(x, r_sin, r_cos),
|
|
299
|
+
128 => return sincosq(x, r_sin, r_cos),
|
|
300
|
+
else => @compileError("unreachable"),
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
fn testSincosSpecial(comptime T: type) !void {
|
|
305
|
+
const f = switch (T) {
|
|
306
|
+
f32 => sincosf,
|
|
307
|
+
f64 => sincos,
|
|
308
|
+
f80 => sincosx,
|
|
309
|
+
f128 => sincosq,
|
|
310
|
+
else => @compileError("unimplemented"),
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
var s: T = undefined;
|
|
314
|
+
var c: T = undefined;
|
|
315
|
+
|
|
316
|
+
f(0.0, &s, &c);
|
|
317
|
+
try expect(math.isPositiveZero(s));
|
|
318
|
+
try expect(c == 1.0);
|
|
319
|
+
|
|
320
|
+
f(-0.0, &s, &c);
|
|
321
|
+
try expect(math.isNegativeZero(s));
|
|
322
|
+
try expect(c == 1.0);
|
|
323
|
+
|
|
324
|
+
f(math.inf(T), &s, &c);
|
|
325
|
+
try expect(math.isNan(s));
|
|
326
|
+
try expect(math.isNan(c));
|
|
327
|
+
|
|
328
|
+
f(-math.inf(T), &s, &c);
|
|
329
|
+
try expect(math.isNan(s));
|
|
330
|
+
try expect(math.isNan(c));
|
|
331
|
+
|
|
332
|
+
f(math.nan(T), &s, &c);
|
|
333
|
+
try expect(math.isNan(s));
|
|
334
|
+
try expect(math.isNan(c));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
test "sincos32.normal" {
|
|
338
|
+
const epsilon = math.floatEps(f32);
|
|
339
|
+
var s: f32 = undefined;
|
|
340
|
+
var c: f32 = undefined;
|
|
341
|
+
|
|
342
|
+
sincosf(0.0, &s, &c);
|
|
343
|
+
try expectApproxEqAbs(@as(f32, 0.0), s, epsilon);
|
|
344
|
+
try expectApproxEqAbs(@as(f32, 1.0), c, epsilon);
|
|
345
|
+
|
|
346
|
+
sincosf(0.2, &s, &c);
|
|
347
|
+
try expectApproxEqAbs(@as(f32, 0.19866933), s, epsilon);
|
|
348
|
+
try expectApproxEqAbs(@as(f32, 0.9800666), c, epsilon);
|
|
349
|
+
|
|
350
|
+
sincosf(0.8923, &s, &c);
|
|
351
|
+
try expectApproxEqAbs(@as(f32, 0.77851737), s, epsilon);
|
|
352
|
+
try expectApproxEqAbs(@as(f32, 0.6276231), c, epsilon);
|
|
353
|
+
|
|
354
|
+
sincosf(1.5, &s, &c);
|
|
355
|
+
try expectApproxEqAbs(@as(f32, 0.997495), s, epsilon);
|
|
356
|
+
try expectApproxEqAbs(@as(f32, 0.0707372), c, epsilon);
|
|
357
|
+
|
|
358
|
+
sincosf(-1.5, &s, &c);
|
|
359
|
+
try expectApproxEqAbs(@as(f32, -0.997495), s, epsilon);
|
|
360
|
+
try expectApproxEqAbs(@as(f32, 0.0707372), c, epsilon);
|
|
361
|
+
|
|
362
|
+
sincosf(37.45, &s, &c);
|
|
363
|
+
try expectApproxEqAbs(@as(f32, -0.24654257), s, epsilon);
|
|
364
|
+
try expectApproxEqAbs(@as(f32, 0.96913195), c, epsilon);
|
|
365
|
+
|
|
366
|
+
sincosf(89.123, &s, &c);
|
|
367
|
+
try expectApproxEqAbs(@as(f32, 0.9161657), s, epsilon);
|
|
368
|
+
try expectApproxEqAbs(@as(f32, 0.40079966), c, epsilon);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
test "sincos32.special" {
|
|
372
|
+
try testSincosSpecial(f32);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
test "sincos64.normal" {
|
|
376
|
+
const epsilon = math.floatEps(f64);
|
|
377
|
+
var s: f64 = undefined;
|
|
378
|
+
var c: f64 = undefined;
|
|
379
|
+
|
|
380
|
+
sincos(0.0, &s, &c);
|
|
381
|
+
try expectApproxEqAbs(@as(f64, 0.0), s, epsilon);
|
|
382
|
+
try expectApproxEqAbs(@as(f64, 1.0), c, epsilon);
|
|
383
|
+
|
|
384
|
+
sincos(0.2, &s, &c);
|
|
385
|
+
try expectApproxEqAbs(@as(f64, 0.19866933079506122), s, epsilon);
|
|
386
|
+
try expectApproxEqAbs(@as(f64, 0.9800665778412416), c, epsilon);
|
|
387
|
+
|
|
388
|
+
sincos(0.8923, &s, &c);
|
|
389
|
+
try expectApproxEqAbs(@as(f64, 0.7785173385577349), s, epsilon);
|
|
390
|
+
try expectApproxEqAbs(@as(f64, 0.6276230983360804), c, epsilon);
|
|
391
|
+
|
|
392
|
+
sincos(1.5, &s, &c);
|
|
393
|
+
try expectApproxEqAbs(@as(f64, 0.9974949866040544), s, epsilon);
|
|
394
|
+
try expectApproxEqAbs(@as(f64, 0.0707372016677029), c, epsilon);
|
|
395
|
+
|
|
396
|
+
sincos(-1.5, &s, &c);
|
|
397
|
+
try expectApproxEqAbs(@as(f64, -0.9974949866040544), s, epsilon);
|
|
398
|
+
try expectApproxEqAbs(@as(f64, 0.0707372016677029), c, epsilon);
|
|
399
|
+
|
|
400
|
+
sincos(37.45, &s, &c);
|
|
401
|
+
try expectApproxEqAbs(@as(f64, -0.24654331551411082), s, epsilon);
|
|
402
|
+
try expectApproxEqAbs(@as(f64, 0.9691317730707778), c, epsilon);
|
|
403
|
+
|
|
404
|
+
sincos(89.123, &s, &c);
|
|
405
|
+
try expectApproxEqAbs(@as(f64, 0.9161652766622714), s, epsilon);
|
|
406
|
+
try expectApproxEqAbs(@as(f64, 0.4008006809354791), c, epsilon);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
test "sincos64.special" {
|
|
410
|
+
try testSincosSpecial(f64);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
test "sincos80.normal" {
|
|
414
|
+
const epsilon = math.floatEps(f80);
|
|
415
|
+
var s: f80 = undefined;
|
|
416
|
+
var c: f80 = undefined;
|
|
417
|
+
|
|
418
|
+
sincosx(0.0, &s, &c);
|
|
419
|
+
try expectApproxEqAbs(@as(f80, 0.0), s, epsilon);
|
|
420
|
+
try expectApproxEqAbs(@as(f80, 1.0), c, epsilon);
|
|
421
|
+
|
|
422
|
+
sincosx(0.2, &s, &c);
|
|
423
|
+
try expectApproxEqAbs(@as(f80, 0.19866933079506121545941262711838975), s, epsilon);
|
|
424
|
+
try expectApproxEqAbs(@as(f80, 0.98006657784124163112419651674816888), c, epsilon);
|
|
425
|
+
|
|
426
|
+
sincosx(0.8923, &s, &c);
|
|
427
|
+
try expectApproxEqAbs(@as(f80, 0.77851733855773487830689285621486050), s, epsilon);
|
|
428
|
+
try expectApproxEqAbs(@as(f80, 0.62762309833608037003563995939286067), c, epsilon);
|
|
429
|
+
|
|
430
|
+
sincosx(1.5, &s, &c);
|
|
431
|
+
try expectApproxEqAbs(@as(f80, 0.99749498660405443094172337114148732), s, epsilon);
|
|
432
|
+
try expectApproxEqAbs(@as(f80, 0.070737201667702910088189851434268747), c, epsilon);
|
|
433
|
+
|
|
434
|
+
sincosx(-1.5, &s, &c);
|
|
435
|
+
try expectApproxEqAbs(@as(f80, -0.99749498660405443094172337114148732), s, epsilon);
|
|
436
|
+
try expectApproxEqAbs(@as(f80, 0.070737201667702910088189851434268747), c, epsilon);
|
|
437
|
+
|
|
438
|
+
sincosx(37.45, &s, &c);
|
|
439
|
+
try expectApproxEqAbs(@as(f80, -0.24654331551411356504), s, epsilon);
|
|
440
|
+
try expectApproxEqAbs(@as(f80, 0.9691317730707771246), c, epsilon);
|
|
441
|
+
|
|
442
|
+
sincosx(89.123, &s, &c);
|
|
443
|
+
try expectApproxEqAbs(@as(f80, 0.91616527666226951006), s, epsilon);
|
|
444
|
+
try expectApproxEqAbs(@as(f80, 0.4008006809354834001), c, epsilon);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
test "sincos80.special" {
|
|
448
|
+
try testSincosSpecial(f80);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
test "sincos128.normal" {
|
|
452
|
+
const epsilon = math.floatEps(f128);
|
|
453
|
+
var s: f128 = undefined;
|
|
454
|
+
var c: f128 = undefined;
|
|
455
|
+
|
|
456
|
+
sincosq(0.0, &s, &c);
|
|
457
|
+
try expectApproxEqAbs(@as(f128, 0.0), s, epsilon);
|
|
458
|
+
try expectApproxEqAbs(@as(f128, 1.0), c, epsilon);
|
|
459
|
+
|
|
460
|
+
sincosq(0.2, &s, &c);
|
|
461
|
+
try expectApproxEqAbs(@as(f128, 0.19866933079506121545941262711838975), s, epsilon);
|
|
462
|
+
try expectApproxEqAbs(@as(f128, 0.98006657784124163112419651674816888), c, epsilon);
|
|
463
|
+
|
|
464
|
+
sincosq(0.8923, &s, &c);
|
|
465
|
+
try expectApproxEqAbs(@as(f128, 0.77851733855773487830689285621486050), s, epsilon);
|
|
466
|
+
try expectApproxEqAbs(@as(f128, 0.62762309833608037003563995939286067), c, epsilon);
|
|
467
|
+
|
|
468
|
+
sincosq(1.5, &s, &c);
|
|
469
|
+
try expectApproxEqAbs(@as(f128, 0.99749498660405443094172337114148732), s, epsilon);
|
|
470
|
+
try expectApproxEqAbs(@as(f128, 0.070737201667702910088189851434268747), c, epsilon);
|
|
471
|
+
|
|
472
|
+
sincosq(-1.5, &s, &c);
|
|
473
|
+
try expectApproxEqAbs(@as(f128, -0.99749498660405443094172337114148732), s, epsilon);
|
|
474
|
+
try expectApproxEqAbs(@as(f128, 0.070737201667702910088189851434268747), c, epsilon);
|
|
475
|
+
|
|
476
|
+
sincosq(37.45, &s, &c);
|
|
477
|
+
try expectApproxEqAbs(@as(f128, -0.24654331551411356571238581321661085), s, epsilon);
|
|
478
|
+
try expectApproxEqAbs(@as(f128, 0.96913177307077712443149563847233230), c, epsilon);
|
|
479
|
+
|
|
480
|
+
sincosq(89.123, &s, &c);
|
|
481
|
+
try expectApproxEqAbs(@as(f128, 0.91616527666226951075019849560482170), s, epsilon);
|
|
482
|
+
try expectApproxEqAbs(@as(f128, 0.40080068093548339848199454493704702), c, epsilon);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
test "sincos128.special" {
|
|
486
|
+
try testSincosSpecial(f128);
|
|
487
|
+
}
|
package/compiler_rt/ssp.zig
CHANGED
|
@@ -24,7 +24,7 @@ extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.c) ?[*]u8
|
|
|
24
24
|
comptime {
|
|
25
25
|
@export(&__stack_chk_fail, .{ .name = if (builtin.os.tag == .openbsd) "__stack_smash_handler" else "__stack_chk_fail", .linkage = compiler_rt.linkage, .visibility = compiler_rt.visibility });
|
|
26
26
|
symbol(&__chk_fail, "__chk_fail");
|
|
27
|
-
symbol(&__stack_chk_guard, "__stack_chk_guard");
|
|
27
|
+
symbol(&__stack_chk_guard, if (builtin.os.tag == .openbsd) "__guard_local" else "__stack_chk_guard");
|
|
28
28
|
symbol(&__strcpy_chk, "__strcpy_chk");
|
|
29
29
|
symbol(&__strncpy_chk, "__strncpy_chk");
|
|
30
30
|
symbol(&__strcat_chk, "__strcat_chk");
|