@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
|
@@ -50,6 +50,7 @@ pub const Node = extern union {
|
|
|
50
50
|
break_val,
|
|
51
51
|
@"return",
|
|
52
52
|
field_access,
|
|
53
|
+
field_builtin,
|
|
53
54
|
array_access,
|
|
54
55
|
call,
|
|
55
56
|
var_decl,
|
|
@@ -371,6 +372,7 @@ pub const Node = extern union {
|
|
|
371
372
|
.div_exact,
|
|
372
373
|
.offset_of,
|
|
373
374
|
.static_assert,
|
|
375
|
+
.field_builtin,
|
|
374
376
|
=> Payload.BinOp,
|
|
375
377
|
|
|
376
378
|
.integer_literal,
|
|
@@ -455,14 +457,14 @@ pub const Node = extern union {
|
|
|
455
457
|
return .{ .ptr_otherwise = payload };
|
|
456
458
|
}
|
|
457
459
|
|
|
458
|
-
pub fn isNoreturn(node: Node
|
|
459
|
-
switch (node.tag()) {
|
|
460
|
+
pub fn isNoreturn(node: Node) bool {
|
|
461
|
+
return switch (node.tag()) {
|
|
460
462
|
.block => {
|
|
461
463
|
const block_node = node.castTag(.block).?;
|
|
462
464
|
if (block_node.data.stmts.len == 0) return false;
|
|
463
465
|
|
|
464
466
|
const last = block_node.data.stmts[block_node.data.stmts.len - 1];
|
|
465
|
-
return last.isNoreturn(
|
|
467
|
+
return last.isNoreturn();
|
|
466
468
|
},
|
|
467
469
|
.@"switch" => {
|
|
468
470
|
const switch_node = node.castTag(.@"switch").?;
|
|
@@ -475,15 +477,16 @@ pub const Node = extern union {
|
|
|
475
477
|
else
|
|
476
478
|
unreachable;
|
|
477
479
|
|
|
478
|
-
if (!body.isNoreturn(
|
|
480
|
+
if (!body.isNoreturn()) return false;
|
|
479
481
|
}
|
|
480
482
|
return true;
|
|
481
483
|
},
|
|
482
|
-
.@"return", .return_void =>
|
|
483
|
-
.@"break" =>
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
484
|
+
.@"return", .return_void => true,
|
|
485
|
+
.@"break" => true,
|
|
486
|
+
.@"continue" => true,
|
|
487
|
+
.@"unreachable" => true,
|
|
488
|
+
else => false,
|
|
489
|
+
};
|
|
487
490
|
}
|
|
488
491
|
|
|
489
492
|
pub fn isBoolRes(res: Node) bool {
|
|
@@ -2015,6 +2018,10 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
|
|
|
2015
2018
|
const lhs = try renderNodeGrouped(c, payload.lhs);
|
|
2016
2019
|
return renderFieldAccess(c, lhs, payload.field_name);
|
|
2017
2020
|
},
|
|
2021
|
+
.field_builtin => {
|
|
2022
|
+
const payload = node.castTag(.field_builtin).?.data;
|
|
2023
|
+
return renderBuiltinCall(c, "@field", &.{ payload.lhs, payload.rhs });
|
|
2024
|
+
},
|
|
2018
2025
|
.@"struct", .@"union", .@"opaque" => return renderContainer(c, node),
|
|
2019
2026
|
.enum_constant => {
|
|
2020
2027
|
const payload = node.castTag(.enum_constant).?.data;
|
|
@@ -2424,7 +2431,7 @@ fn renderNullSentinelArrayType(c: *Context, len: u64, elem_type: Node) !NodeInde
|
|
|
2424
2431
|
fn addSemicolonIfNeeded(c: *Context, node: Node) !void {
|
|
2425
2432
|
switch (node.tag()) {
|
|
2426
2433
|
.warning => unreachable,
|
|
2427
|
-
.var_decl, .var_simple, .arg_redecl, .alias, .block, .empty_block, .block_single, .@"switch", .wrapped_local, .mut_str => {},
|
|
2434
|
+
.static_assert, .var_decl, .var_simple, .arg_redecl, .alias, .block, .empty_block, .block_single, .@"switch", .wrapped_local, .mut_str => {},
|
|
2428
2435
|
.while_true => {
|
|
2429
2436
|
const payload = node.castTag(.while_true).?.data;
|
|
2430
2437
|
return addSemicolonIfNotBlock(c, payload);
|
|
@@ -2532,6 +2539,8 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
|
|
|
2532
2539
|
.trunc,
|
|
2533
2540
|
.floor,
|
|
2534
2541
|
.root_ref,
|
|
2542
|
+
.field_builtin,
|
|
2543
|
+
.@"switch",
|
|
2535
2544
|
=> {
|
|
2536
2545
|
// no grouping needed
|
|
2537
2546
|
return renderNode(c, node);
|
|
@@ -2594,7 +2603,6 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
|
|
|
2594
2603
|
.pub_var_simple,
|
|
2595
2604
|
.enum_constant,
|
|
2596
2605
|
.@"while",
|
|
2597
|
-
.@"switch",
|
|
2598
2606
|
.@"break",
|
|
2599
2607
|
.break_val,
|
|
2600
2608
|
.pub_inline_fn,
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
|
-
const Io = std.Io;
|
|
3
2
|
const assert = std.debug.assert;
|
|
4
3
|
const mem = std.mem;
|
|
5
4
|
const process = std.process;
|
|
5
|
+
const Io = std.Io;
|
|
6
|
+
|
|
6
7
|
const aro = @import("aro");
|
|
7
8
|
const compiler_util = @import("../util.zig");
|
|
9
|
+
|
|
8
10
|
const Translator = @import("Translator.zig");
|
|
9
11
|
|
|
10
12
|
const fast_exit = @import("builtin").mode != .Debug;
|
|
11
13
|
|
|
12
|
-
pub fn main(init:
|
|
14
|
+
pub fn main(init: process.Init) u8 {
|
|
13
15
|
const gpa = init.gpa;
|
|
14
16
|
const arena = init.arena.allocator();
|
|
15
17
|
const io = init.io;
|
|
@@ -33,16 +35,20 @@ pub fn main(init: std.process.Init) u8 {
|
|
|
33
35
|
var stderr = Io.File.stderr().writer(io, &stderr_buf);
|
|
34
36
|
var diagnostics: aro.Diagnostics = switch (zig_integration) {
|
|
35
37
|
false => .{ .output = .{ .to_writer = .{
|
|
36
|
-
.mode = Io.Terminal.Mode.detect(io, stderr.file, NO_COLOR, CLICOLOR_FORCE) catch
|
|
38
|
+
.mode = Io.Terminal.Mode.detect(io, stderr.file, NO_COLOR, CLICOLOR_FORCE) catch .no_color,
|
|
37
39
|
.writer = &stderr.interface,
|
|
38
40
|
} } },
|
|
39
|
-
true => .{ .output = .{ .to_list = .{
|
|
40
|
-
.arena = .init(gpa),
|
|
41
|
-
} } },
|
|
41
|
+
true => .{ .output = .{ .to_list = .{ .arena = .init(gpa) } } },
|
|
42
42
|
};
|
|
43
43
|
defer diagnostics.deinit();
|
|
44
44
|
|
|
45
|
-
var comp = aro.Compilation.
|
|
45
|
+
var comp = aro.Compilation.init(.{
|
|
46
|
+
.gpa = gpa,
|
|
47
|
+
.arena = arena,
|
|
48
|
+
.io = io,
|
|
49
|
+
.diagnostics = &diagnostics,
|
|
50
|
+
.environ_map = environ_map,
|
|
51
|
+
}) catch |err| switch (err) {
|
|
46
52
|
error.OutOfMemory => {
|
|
47
53
|
std.debug.print("ran out of memory initializing C compilation\n", .{});
|
|
48
54
|
if (fast_exit) process.exit(1);
|
|
@@ -82,7 +88,6 @@ pub fn main(init: std.process.Init) u8 {
|
|
|
82
88
|
return 1;
|
|
83
89
|
},
|
|
84
90
|
};
|
|
85
|
-
|
|
86
91
|
assert(comp.diagnostics.errors == 0 or !zig_integration);
|
|
87
92
|
if (fast_exit) process.exit(@intFromBool(comp.diagnostics.errors != 0));
|
|
88
93
|
return @intFromBool(comp.diagnostics.errors != 0);
|
|
@@ -107,10 +112,23 @@ pub const usage =
|
|
|
107
112
|
\\Usage {s}: [options] file [CC options]
|
|
108
113
|
\\
|
|
109
114
|
\\Options:
|
|
110
|
-
\\ --help
|
|
111
|
-
\\ --version
|
|
112
|
-
\\ -fmodule-libs
|
|
113
|
-
\\ -fno-module-libs
|
|
115
|
+
\\ --help Print this message
|
|
116
|
+
\\ --version Print translate-c version
|
|
117
|
+
\\ -fmodule-libs Import libraries as modules
|
|
118
|
+
\\ -fno-module-libs (default) Install libraries next to output file
|
|
119
|
+
\\ -fpub-static (default) Translate static functions as pub
|
|
120
|
+
\\ -fno-pub-static Do not translate static functions as pub
|
|
121
|
+
\\ -ffunc-bodies (default) Translate function bodies
|
|
122
|
+
\\ -fno-func-bodies Do not translate function bodies
|
|
123
|
+
\\ -fkeep-macro-literals (default) Preserve macro names for literals
|
|
124
|
+
\\ -fno-keep-macro-literals Do not preserve macro names for literals
|
|
125
|
+
\\ -fdefault-init Default initialize struct fields
|
|
126
|
+
\\ -fno-default-init (default) Do not default initialize struct fields
|
|
127
|
+
\\ -fstrict-flex-arrays=<n> Control when to treat a trailing array as a flexible array member (default: 2)
|
|
128
|
+
\\ 0: any trailing array
|
|
129
|
+
\\ 1: size [0]/[1]/[]
|
|
130
|
+
\\ 2: size [0]/[]
|
|
131
|
+
\\ 3: [] only
|
|
114
132
|
\\
|
|
115
133
|
\\
|
|
116
134
|
;
|
|
@@ -119,7 +137,14 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: []const [:0]const u8, zig
|
|
|
119
137
|
const gpa = d.comp.gpa;
|
|
120
138
|
const io = d.comp.io;
|
|
121
139
|
|
|
122
|
-
var
|
|
140
|
+
var module_libs = true;
|
|
141
|
+
var pub_static = true;
|
|
142
|
+
var func_bodies = true;
|
|
143
|
+
var keep_macro_literals = true;
|
|
144
|
+
var default_init = true;
|
|
145
|
+
var strict_flex_arrays: Translator.StrictFlexArraysLevel = .@"2";
|
|
146
|
+
|
|
147
|
+
var aro_args: std.ArrayList([:0]const u8) = try .initCapacity(gpa, args.len);
|
|
123
148
|
defer aro_args.deinit(gpa);
|
|
124
149
|
|
|
125
150
|
for (args, 0..) |arg, i| {
|
|
@@ -139,8 +164,34 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: []const [:0]const u8, zig
|
|
|
139
164
|
} else if (mem.eql(u8, arg, "--zig-integration")) {
|
|
140
165
|
if (i != 1 or !zig_integration)
|
|
141
166
|
return d.fatal("--zig-integration must be the first argument", .{});
|
|
167
|
+
} else if (mem.eql(u8, arg, "-fmodule-libs")) {
|
|
168
|
+
module_libs = true;
|
|
169
|
+
} else if (mem.eql(u8, arg, "-fno-module-libs")) {
|
|
170
|
+
module_libs = false;
|
|
171
|
+
} else if (mem.eql(u8, arg, "-fpub-static")) {
|
|
172
|
+
pub_static = true;
|
|
173
|
+
} else if (mem.eql(u8, arg, "-fno-pub-static")) {
|
|
174
|
+
pub_static = false;
|
|
175
|
+
} else if (mem.eql(u8, arg, "-ffunc-bodies")) {
|
|
176
|
+
func_bodies = true;
|
|
177
|
+
} else if (mem.eql(u8, arg, "-fno-func-bodies")) {
|
|
178
|
+
func_bodies = false;
|
|
179
|
+
} else if (mem.eql(u8, arg, "-fkeep-macro-literals")) {
|
|
180
|
+
keep_macro_literals = true;
|
|
181
|
+
} else if (mem.eql(u8, arg, "-fno-keep-macro-literals")) {
|
|
182
|
+
keep_macro_literals = false;
|
|
183
|
+
} else if (mem.eql(u8, arg, "-fdefault-init")) {
|
|
184
|
+
default_init = true;
|
|
185
|
+
} else if (mem.eql(u8, arg, "-fno-default-init")) {
|
|
186
|
+
default_init = false;
|
|
187
|
+
} else if (mem.startsWith(u8, arg, "-fstrict-flex-arrays=")) {
|
|
188
|
+
const val_str = arg["-fstrict-flex-arrays=".len..];
|
|
189
|
+
if (val_str.len != 1 or val_str[0] < '0' or val_str[0] > '3') {
|
|
190
|
+
return d.fatal("-fstrict-flex-arrays= requires a value of '0', '1', '2', or '3'", .{});
|
|
191
|
+
}
|
|
192
|
+
strict_flex_arrays = @enumFromInt(val_str[0] - '0');
|
|
142
193
|
} else {
|
|
143
|
-
|
|
194
|
+
aro_args.appendAssumeCapacity(arg);
|
|
144
195
|
}
|
|
145
196
|
}
|
|
146
197
|
const user_macros = macros: {
|
|
@@ -148,7 +199,7 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: []const [:0]const u8, zig
|
|
|
148
199
|
defer macro_buf.deinit(gpa);
|
|
149
200
|
|
|
150
201
|
var discard_buf: [256]u8 = undefined;
|
|
151
|
-
var discarding:
|
|
202
|
+
var discarding: Io.Writer.Discarding = .init(&discard_buf);
|
|
152
203
|
assert(!try d.parseArgs(&discarding.writer, ¯o_buf, aro_args.items));
|
|
153
204
|
if (macro_buf.items.len > std.math.maxInt(u32)) {
|
|
154
205
|
return d.fatal("user provided macro source exceeded max size", .{});
|
|
@@ -185,7 +236,9 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: []const [:0]const u8, zig
|
|
|
185
236
|
else => |e| return e,
|
|
186
237
|
};
|
|
187
238
|
|
|
188
|
-
var pp = try aro.Preprocessor.
|
|
239
|
+
var pp = try aro.Preprocessor.init(d.comp, .{
|
|
240
|
+
.base_file = source.id,
|
|
241
|
+
});
|
|
189
242
|
defer pp.deinit();
|
|
190
243
|
|
|
191
244
|
var name_buf: [std.fs.max_name_bytes]u8 = undefined;
|
|
@@ -235,6 +288,12 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: []const [:0]const u8, zig
|
|
|
235
288
|
.comp = d.comp,
|
|
236
289
|
.pp = &pp,
|
|
237
290
|
.tree = &c_tree,
|
|
291
|
+
.module_libs = module_libs,
|
|
292
|
+
.pub_static = pub_static,
|
|
293
|
+
.func_bodies = func_bodies,
|
|
294
|
+
.keep_macro_literals = keep_macro_literals,
|
|
295
|
+
.default_init = default_init,
|
|
296
|
+
.strict_flex_arrays = strict_flex_arrays,
|
|
238
297
|
});
|
|
239
298
|
defer gpa.free(rendered_zig);
|
|
240
299
|
|
package/compiler_rt/cos.zig
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
|
+
//! Ported from musl, which is licensed under the MIT license:
|
|
2
|
+
//! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
|
|
3
|
+
//!
|
|
4
|
+
//! https://git.musl-libc.org/cgit/musl/tree/src/math/cosf.c
|
|
5
|
+
//! https://git.musl-libc.org/cgit/musl/tree/src/math/cos.c
|
|
6
|
+
//! https://git.musl-libc.org/cgit/musl/tree/src/math/cosl.c
|
|
7
|
+
|
|
1
8
|
const std = @import("std");
|
|
2
9
|
const math = std.math;
|
|
3
10
|
const mem = std.mem;
|
|
4
11
|
const expect = std.testing.expect;
|
|
12
|
+
const expectApproxEqAbs = std.testing.expectApproxEqAbs;
|
|
5
13
|
|
|
6
14
|
const compiler_rt = @import("../compiler_rt.zig");
|
|
7
15
|
const symbol = @import("../compiler_rt.zig").symbol;
|
|
8
16
|
const trig = @import("trig.zig");
|
|
9
17
|
const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
|
|
10
18
|
const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
|
|
19
|
+
const rem_pio2l = @import("rem_pio2l.zig").rem_pio2l;
|
|
20
|
+
const ld = @import("long_double.zig");
|
|
11
21
|
|
|
12
22
|
comptime {
|
|
13
|
-
symbol(&
|
|
23
|
+
symbol(&cosh, "__cosh");
|
|
24
|
+
symbol(&cosl, "__cosl");
|
|
14
25
|
symbol(&cosf, "cosf");
|
|
15
26
|
symbol(&cos, "cos");
|
|
16
|
-
symbol(&
|
|
27
|
+
symbol(&cosx, "__cosx");
|
|
17
28
|
if (compiler_rt.want_ppc_abi) {
|
|
18
29
|
symbol(&cosq, "cosf128");
|
|
19
30
|
}
|
|
@@ -21,7 +32,7 @@ comptime {
|
|
|
21
32
|
symbol(&cosl, "cosl");
|
|
22
33
|
}
|
|
23
34
|
|
|
24
|
-
pub fn
|
|
35
|
+
pub fn cosh(a: f16) callconv(.c) f16 {
|
|
25
36
|
// TODO: more efficient implementation
|
|
26
37
|
return @floatCast(cosf(a));
|
|
27
38
|
}
|
|
@@ -43,27 +54,27 @@ pub fn cosf(x: f32) callconv(.c) f32 {
|
|
|
43
54
|
if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
|
|
44
55
|
return 1.0;
|
|
45
56
|
}
|
|
46
|
-
return trig.
|
|
57
|
+
return trig.cosdf(x);
|
|
47
58
|
}
|
|
48
59
|
if (ix <= 0x407b53d1) { // |x| ~<= 5*pi/4
|
|
49
60
|
if (ix > 0x4016cbe3) { // |x| ~> 3*pi/4
|
|
50
|
-
return -trig.
|
|
61
|
+
return -trig.cosdf(if (sign) x + c2pio2 else x - c2pio2);
|
|
51
62
|
} else {
|
|
52
63
|
if (sign) {
|
|
53
|
-
return trig.
|
|
64
|
+
return trig.sindf(x + c1pio2);
|
|
54
65
|
} else {
|
|
55
|
-
return trig.
|
|
66
|
+
return trig.sindf(c1pio2 - x);
|
|
56
67
|
}
|
|
57
68
|
}
|
|
58
69
|
}
|
|
59
70
|
if (ix <= 0x40e231d5) { // |x| ~<= 9*pi/4
|
|
60
71
|
if (ix > 0x40afeddf) { // |x| ~> 7*pi/4
|
|
61
|
-
return trig.
|
|
72
|
+
return trig.cosdf(if (sign) x + c4pio2 else x - c4pio2);
|
|
62
73
|
} else {
|
|
63
74
|
if (sign) {
|
|
64
|
-
return trig.
|
|
75
|
+
return trig.sindf(-x - c3pio2);
|
|
65
76
|
} else {
|
|
66
|
-
return trig.
|
|
77
|
+
return trig.sindf(x - c3pio2);
|
|
67
78
|
}
|
|
68
79
|
}
|
|
69
80
|
}
|
|
@@ -76,10 +87,10 @@ pub fn cosf(x: f32) callconv(.c) f32 {
|
|
|
76
87
|
var y: f64 = undefined;
|
|
77
88
|
const n = rem_pio2f(x, &y);
|
|
78
89
|
return switch (n & 3) {
|
|
79
|
-
0 => trig.
|
|
80
|
-
1 => trig.
|
|
81
|
-
2 => -trig.
|
|
82
|
-
else => trig.
|
|
90
|
+
0 => trig.cosdf(y),
|
|
91
|
+
1 => trig.sindf(-y),
|
|
92
|
+
2 => -trig.cosdf(y),
|
|
93
|
+
else => trig.sindf(y),
|
|
83
94
|
};
|
|
84
95
|
}
|
|
85
96
|
|
|
@@ -94,7 +105,7 @@ pub fn cos(x: f64) callconv(.c) f64 {
|
|
|
94
105
|
if (compiler_rt.want_float_exceptions) mem.doNotOptimizeAway(x + 0x1p120);
|
|
95
106
|
return 1.0;
|
|
96
107
|
}
|
|
97
|
-
return trig.
|
|
108
|
+
return trig.cos(x, 0);
|
|
98
109
|
}
|
|
99
110
|
|
|
100
111
|
// cos(Inf or NaN) is NaN
|
|
@@ -105,66 +116,144 @@ pub fn cos(x: f64) callconv(.c) f64 {
|
|
|
105
116
|
var y: [2]f64 = undefined;
|
|
106
117
|
const n = rem_pio2(x, &y);
|
|
107
118
|
return switch (n & 3) {
|
|
108
|
-
0 => trig.
|
|
109
|
-
1 => -trig.
|
|
110
|
-
2 => -trig.
|
|
111
|
-
else => trig.
|
|
119
|
+
0 => trig.cos(y[0], y[1]),
|
|
120
|
+
1 => -trig.sin(y[0], y[1], 1),
|
|
121
|
+
2 => -trig.cos(y[0], y[1]),
|
|
122
|
+
else => trig.sin(y[0], y[1], 1),
|
|
112
123
|
};
|
|
113
124
|
}
|
|
114
125
|
|
|
115
|
-
pub fn
|
|
116
|
-
|
|
117
|
-
|
|
126
|
+
pub fn cosx(x: f80) callconv(.c) f80 {
|
|
127
|
+
const se = ld.signExponent(x) & 0x7fff;
|
|
128
|
+
if (se == 0x7fff) {
|
|
129
|
+
return x - x;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (@abs(x) < trig.pi_4) {
|
|
133
|
+
if (se < 0x3fff - math.floatMantissaBits(f80)) {
|
|
134
|
+
// raise inexact if x!=0
|
|
135
|
+
return 1.0 + x;
|
|
136
|
+
}
|
|
137
|
+
return trig.cosx(x, 0.0);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var y: [2]f80 = undefined;
|
|
141
|
+
const n = rem_pio2l(f80, x, &y);
|
|
142
|
+
return switch (n & 3) {
|
|
143
|
+
0 => trig.cosx(y[0], y[1]),
|
|
144
|
+
1 => -trig.sinx(y[0], y[1], 1),
|
|
145
|
+
2 => -trig.cosx(y[0], y[1]),
|
|
146
|
+
else => trig.sinx(y[0], y[1], 1),
|
|
147
|
+
};
|
|
118
148
|
}
|
|
119
149
|
|
|
120
|
-
pub fn cosq(
|
|
121
|
-
|
|
122
|
-
|
|
150
|
+
pub fn cosq(x: f128) callconv(.c) f128 {
|
|
151
|
+
const se = ld.signExponent(x) & 0x7fff;
|
|
152
|
+
if (se == 0x7fff) {
|
|
153
|
+
return x - x;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (@abs(x) < trig.pi_4) {
|
|
157
|
+
if (se < 0x3fff - math.floatMantissaBits(f128)) {
|
|
158
|
+
// raise inexact if x!=0
|
|
159
|
+
return 1.0 + x;
|
|
160
|
+
}
|
|
161
|
+
return trig.cosq(x, 0.0);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var y: [2]f128 = undefined;
|
|
165
|
+
const n = rem_pio2l(f128, x, &y);
|
|
166
|
+
return switch (n & 3) {
|
|
167
|
+
0 => trig.cosq(y[0], y[1]),
|
|
168
|
+
1 => -trig.sinq(y[0], y[1], 1),
|
|
169
|
+
2 => -trig.cosq(y[0], y[1]),
|
|
170
|
+
else => trig.sinq(y[0], y[1], 1),
|
|
171
|
+
};
|
|
123
172
|
}
|
|
124
173
|
|
|
125
174
|
pub fn cosl(x: c_longdouble) callconv(.c) c_longdouble {
|
|
126
175
|
switch (@typeInfo(c_longdouble).float.bits) {
|
|
127
|
-
16 => return
|
|
176
|
+
16 => return cosh(x),
|
|
128
177
|
32 => return cosf(x),
|
|
129
178
|
64 => return cos(x),
|
|
130
|
-
80 => return
|
|
179
|
+
80 => return cosx(x),
|
|
131
180
|
128 => return cosq(x),
|
|
132
181
|
else => @compileError("unreachable"),
|
|
133
182
|
}
|
|
134
183
|
}
|
|
135
184
|
|
|
136
|
-
|
|
137
|
-
const
|
|
185
|
+
fn testCosSpecial(comptime T: type) !void {
|
|
186
|
+
const f = switch (T) {
|
|
187
|
+
f32 => cosf,
|
|
188
|
+
f64 => cos,
|
|
189
|
+
f80 => cosx,
|
|
190
|
+
f128 => cosq,
|
|
191
|
+
else => @compileError("unimplemented"),
|
|
192
|
+
};
|
|
138
193
|
|
|
139
|
-
try expect(
|
|
140
|
-
try expect(
|
|
141
|
-
try expect(math.
|
|
142
|
-
try expect(math.
|
|
143
|
-
try expect(math.
|
|
144
|
-
try expect(math.approxEqAbs(f32, cosf(37.45), 0.969132, epsilon));
|
|
145
|
-
try expect(math.approxEqAbs(f32, cosf(89.123), 0.400798, epsilon));
|
|
194
|
+
try expect(f(0.0) == 1.0);
|
|
195
|
+
try expect(f(-0.0) == 1.0);
|
|
196
|
+
try expect(math.isNan(f(math.inf(T))));
|
|
197
|
+
try expect(math.isNan(f(-math.inf(T))));
|
|
198
|
+
try expect(math.isNan(f(math.nan(T))));
|
|
146
199
|
}
|
|
147
200
|
|
|
148
|
-
test "
|
|
149
|
-
const epsilon =
|
|
150
|
-
|
|
151
|
-
try
|
|
152
|
-
try
|
|
153
|
-
try
|
|
154
|
-
try
|
|
155
|
-
try
|
|
156
|
-
try
|
|
157
|
-
try expect(math.approxEqAbs(f64, cos(89.123), 0.40080, epsilon));
|
|
201
|
+
test "cos32.normal" {
|
|
202
|
+
const epsilon = math.floatEps(f32);
|
|
203
|
+
try expectApproxEqAbs(@as(f32, 1.0), cosf(0.0), epsilon);
|
|
204
|
+
try expectApproxEqAbs(@as(f32, 0.9800666), cosf(0.2), epsilon);
|
|
205
|
+
try expectApproxEqAbs(@as(f32, 0.6276231), cosf(0.8923), epsilon);
|
|
206
|
+
try expectApproxEqAbs(@as(f32, 0.0707372), cosf(1.5), epsilon);
|
|
207
|
+
try expectApproxEqAbs(@as(f32, 0.0707372), cosf(-1.5), epsilon);
|
|
208
|
+
try expectApproxEqAbs(@as(f32, 0.96913195), cosf(37.45), epsilon);
|
|
209
|
+
try expectApproxEqAbs(@as(f32, 0.40079966), cosf(89.123), epsilon);
|
|
158
210
|
}
|
|
159
211
|
|
|
160
212
|
test "cos32.special" {
|
|
161
|
-
try
|
|
162
|
-
|
|
163
|
-
|
|
213
|
+
try testCosSpecial(f32);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
test "cos64.normal" {
|
|
217
|
+
const epsilon = math.floatEps(f64);
|
|
218
|
+
try expectApproxEqAbs(@as(f64, 1.0), cos(0.0), epsilon);
|
|
219
|
+
try expectApproxEqAbs(@as(f64, 0.9800665778412416), cos(0.2), epsilon);
|
|
220
|
+
try expectApproxEqAbs(@as(f64, 0.6276230983360804), cos(0.8923), epsilon);
|
|
221
|
+
try expectApproxEqAbs(@as(f64, 0.0707372016677029), cos(1.5), epsilon);
|
|
222
|
+
try expectApproxEqAbs(@as(f64, 0.0707372016677029), cos(-1.5), epsilon);
|
|
223
|
+
try expectApproxEqAbs(@as(f64, 0.9691317730707778), cos(37.45), epsilon);
|
|
224
|
+
try expectApproxEqAbs(@as(f64, 0.4008006809354791), cos(89.123), epsilon);
|
|
164
225
|
}
|
|
165
226
|
|
|
166
227
|
test "cos64.special" {
|
|
167
|
-
try
|
|
168
|
-
|
|
169
|
-
|
|
228
|
+
try testCosSpecial(f64);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
test "cos80.normal" {
|
|
232
|
+
const epsilon = math.floatEps(f80);
|
|
233
|
+
try expectApproxEqAbs(@as(f80, 1.0), cosx(0.0), epsilon);
|
|
234
|
+
try expectApproxEqAbs(@as(f80, 0.98006657784124163112419651674816888), cosx(0.2), epsilon);
|
|
235
|
+
try expectApproxEqAbs(@as(f80, 0.62762309833608037003563995939286067), cosx(0.8923), epsilon);
|
|
236
|
+
try expectApproxEqAbs(@as(f80, 0.070737201667702910088189851434268747), cosx(1.5), epsilon);
|
|
237
|
+
try expectApproxEqAbs(@as(f80, 0.070737201667702910088189851434268747), cosx(-1.5), epsilon);
|
|
238
|
+
try expectApproxEqAbs(@as(f80, 0.9691317730707771246), cosx(37.45), epsilon);
|
|
239
|
+
try expectApproxEqAbs(@as(f80, 0.4008006809354834001), cosx(89.123), epsilon);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
test "cos80.special" {
|
|
243
|
+
try testCosSpecial(f80);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
test "cos128.normal" {
|
|
247
|
+
const epsilon = math.floatEps(f128);
|
|
248
|
+
try expectApproxEqAbs(@as(f128, 1.0), cosq(0.0), epsilon);
|
|
249
|
+
try expectApproxEqAbs(@as(f128, 0.98006657784124163112419651674816888), cosq(0.2), epsilon);
|
|
250
|
+
try expectApproxEqAbs(@as(f128, 0.62762309833608037003563995939286067), cosq(0.8923), epsilon);
|
|
251
|
+
try expectApproxEqAbs(@as(f128, 0.070737201667702910088189851434268747), cosq(1.5), epsilon);
|
|
252
|
+
try expectApproxEqAbs(@as(f128, 0.070737201667702910088189851434268747), cosq(-1.5), epsilon);
|
|
253
|
+
try expectApproxEqAbs(@as(f128, 0.96913177307077712443149563847233230), cosq(37.45), epsilon);
|
|
254
|
+
try expectApproxEqAbs(@as(f128, 0.40080068093548339848199454493704702), cosq(89.123), epsilon);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
test "cos128.special" {
|
|
258
|
+
try testCosSpecial(f128);
|
|
170
259
|
}
|
|
@@ -10,29 +10,30 @@ const symbol = @import("../compiler_rt.zig").symbol;
|
|
|
10
10
|
comptime {
|
|
11
11
|
symbol(&__divei4, "__divei4");
|
|
12
12
|
symbol(&__modei4, "__modei4");
|
|
13
|
+
symbol(&__divei5, "__divei5");
|
|
14
|
+
symbol(&__modei5, "__modei5");
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
inline fn limb(
|
|
16
|
-
return if (endian == .little)
|
|
17
|
+
inline fn limb(i: usize, len: usize) usize {
|
|
18
|
+
return if (endian == .little) i else len - 1 - i;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
inline fn neg(
|
|
21
|
+
inline fn neg(out: []u32, in: []const u32) void {
|
|
20
22
|
var ov: u1 = 1;
|
|
21
|
-
for (0..
|
|
22
|
-
const
|
|
23
|
-
|
|
23
|
+
for (0..in.len) |limb_index| {
|
|
24
|
+
const new, ov = @addWithOverflow(~in[limb(limb_index, in.len)], ov);
|
|
25
|
+
out[limb(limb_index, out.len)] = new;
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
if (v_sign < 0)
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
if (r) |x| if (u_sign < 0) neg(x);
|
|
29
|
+
fn divmod(q: ?[]u32, r: ?[]u32, u: []const u32, v: []const u32, tu: []u32, tv: []u32) !void {
|
|
30
|
+
const u_sign: i32 = @bitCast(u[limb(u.len - 1, u.len)]);
|
|
31
|
+
const v_sign: i32 = @bitCast(v[limb(v.len - 1, v.len)]);
|
|
32
|
+
if (u_sign < 0) neg(tu, u);
|
|
33
|
+
if (v_sign < 0) neg(tv, v);
|
|
34
|
+
try @call(.always_inline, udivmod, .{ q, r, if (u_sign < 0) tu else u, if (v_sign < 0) tv else v });
|
|
35
|
+
if (q) |x| if (u_sign ^ v_sign < 0) neg(x, x);
|
|
36
|
+
if (r) |x| if (u_sign < 0) neg(x, x);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
pub fn __divei4(q_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) void {
|
|
@@ -41,7 +42,7 @@ pub fn __divei4(q_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) vo
|
|
|
41
42
|
const q: []u32 = @ptrCast(@alignCast(q_p[0..byte_size]));
|
|
42
43
|
const u: []u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
|
|
43
44
|
const v: []u32 = @ptrCast(@alignCast(v_p[0..byte_size]));
|
|
44
|
-
@call(.always_inline, divmod, .{ q, null, u, v }) catch unreachable;
|
|
45
|
+
@call(.always_inline, divmod, .{ q, null, u, v, u, v }) catch unreachable;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
pub fn __modei4(r_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) void {
|
|
@@ -50,5 +51,27 @@ pub fn __modei4(r_p: [*]u8, u_p: [*]u8, v_p: [*]u8, bits: usize) callconv(.c) vo
|
|
|
50
51
|
const r: []u32 = @ptrCast(@alignCast(r_p[0..byte_size]));
|
|
51
52
|
const u: []u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
|
|
52
53
|
const v: []u32 = @ptrCast(@alignCast(v_p[0..byte_size]));
|
|
53
|
-
@call(.always_inline, divmod, .{ null, r, u, v }) catch unreachable;
|
|
54
|
+
@call(.always_inline, divmod, .{ null, r, u, v, u, v }) catch unreachable;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
pub fn __divei5(q_p: [*]u8, u_p: [*]const u8, v_p: [*]const u8, t_p: [*]u8, bits: usize) callconv(.c) void {
|
|
58
|
+
@setRuntimeSafety(compiler_rt.test_safety);
|
|
59
|
+
const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
|
|
60
|
+
const q: []u32 = @ptrCast(@alignCast(q_p[0..byte_size]));
|
|
61
|
+
const u: []const u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
|
|
62
|
+
const v: []const u32 = @ptrCast(@alignCast(v_p[0..byte_size]));
|
|
63
|
+
const tu: []u32 = @ptrCast(@alignCast(t_p[0..byte_size]));
|
|
64
|
+
const tv: []u32 = @ptrCast(@alignCast(t_p[byte_size..][0..byte_size]));
|
|
65
|
+
@call(.always_inline, divmod, .{ q, null, u, v, tu, tv }) catch unreachable;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
pub fn __modei5(r_p: [*]u8, u_p: [*]const u8, v_p: [*]const u8, t_p: [*]u8, bits: usize) callconv(.c) void {
|
|
69
|
+
@setRuntimeSafety(compiler_rt.test_safety);
|
|
70
|
+
const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
|
|
71
|
+
const r: []u32 = @ptrCast(@alignCast(r_p[0..byte_size]));
|
|
72
|
+
const u: []const u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
|
|
73
|
+
const v: []const u32 = @ptrCast(@alignCast(v_p[0..byte_size]));
|
|
74
|
+
const tu: []u32 = @ptrCast(@alignCast(t_p[0..byte_size]));
|
|
75
|
+
const tv: []u32 = @ptrCast(@alignCast(t_p[byte_size..][0..byte_size]));
|
|
76
|
+
@call(.always_inline, divmod, .{ null, r, u, v, tu, tv }) catch unreachable;
|
|
54
77
|
}
|
package/compiler_rt/exp.zig
CHANGED
|
@@ -194,10 +194,7 @@ pub fn __expx(a: f80) callconv(.c) f80 {
|
|
|
194
194
|
return @floatCast(expq(a));
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
// TODO: more correct implementation
|
|
199
|
-
return exp(@floatCast(a));
|
|
200
|
-
}
|
|
197
|
+
const expq = @import("exp_f128.zig").exp;
|
|
201
198
|
|
|
202
199
|
pub fn expl(x: c_longdouble) callconv(.c) c_longdouble {
|
|
203
200
|
switch (@typeInfo(c_longdouble).float.bits) {
|
package/compiler_rt/exp2.zig
CHANGED
|
@@ -161,10 +161,7 @@ pub fn __exp2x(x: f80) callconv(.c) f80 {
|
|
|
161
161
|
return @floatCast(exp2q(x));
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
pub
|
|
165
|
-
// TODO: more correct implementation
|
|
166
|
-
return exp2(@floatCast(x));
|
|
167
|
-
}
|
|
164
|
+
pub const exp2q = @import("exp_f128.zig").exp2;
|
|
168
165
|
|
|
169
166
|
pub fn exp2l(x: c_longdouble) callconv(.c) c_longdouble {
|
|
170
167
|
switch (@typeInfo(c_longdouble).float.bits) {
|