@zigc/lib 0.17.0-dev.9 → 0.17.0-dev.93

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.
Files changed (107) hide show
  1. package/c/fcntl.zig +6 -1
  2. package/c/inttypes.zig +0 -10
  3. package/c/math.zig +46 -122
  4. package/c/search.zig +1 -27
  5. package/c/stdlib/drand48.zig +0 -57
  6. package/c/stdlib.zig +0 -100
  7. package/c/string.zig +0 -7
  8. package/c/strings.zig +0 -38
  9. package/c/unistd.zig +27 -26
  10. package/c.zig +1 -2
  11. package/compiler/aro/aro/CodeGen.zig +3 -2
  12. package/compiler/aro/aro/Compilation.zig +15 -12
  13. package/compiler/aro/aro/Driver.zig +9 -6
  14. package/compiler/aro/aro/Parser.zig +18 -12
  15. package/compiler/aro/aro/Pragma.zig +3 -2
  16. package/compiler/aro/aro/Preprocessor.zig +9 -6
  17. package/compiler/aro/aro/pragmas/message.zig +3 -2
  18. package/compiler/aro/aro/text_literal.zig +3 -2
  19. package/compiler/aro/assembly_backend/x86_64.zig +3 -2
  20. package/compiler/build_runner.zig +0 -2
  21. package/compiler/test_runner.zig +1 -1
  22. package/compiler/translate-c/Translator.zig +4 -0
  23. package/compiler_rt/cos.zig +0 -2
  24. package/compiler_rt/divmodei4.zig +40 -17
  25. package/compiler_rt/exp.zig +1 -6
  26. package/compiler_rt/exp2.zig +1 -6
  27. package/compiler_rt/exp_f128.zig +377 -0
  28. package/compiler_rt/fabs.zig +0 -2
  29. package/compiler_rt/fma.zig +0 -2
  30. package/compiler_rt/fmax.zig +0 -2
  31. package/compiler_rt/fmin.zig +0 -2
  32. package/compiler_rt/fmod.zig +0 -2
  33. package/compiler_rt/limb64.zig +876 -15
  34. package/compiler_rt/log.zig +0 -2
  35. package/compiler_rt/log10.zig +0 -2
  36. package/compiler_rt/log2.zig +0 -2
  37. package/compiler_rt/mulXi3.zig +1 -1
  38. package/compiler_rt/round.zig +0 -2
  39. package/compiler_rt/sin.zig +0 -2
  40. package/compiler_rt/sincos.zig +0 -2
  41. package/compiler_rt/sqrt.zig +0 -2
  42. package/compiler_rt/ssp.zig +1 -1
  43. package/compiler_rt/tan.zig +0 -2
  44. package/compiler_rt/trunc.zig +0 -2
  45. package/compiler_rt/udivmodei4.zig +28 -0
  46. package/fuzzer.zig +2 -0
  47. package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
  48. package/package.json +1 -1
  49. package/std/Build/Step/Compile.zig +0 -1
  50. package/std/Build.zig +0 -3
  51. package/std/Io/Dispatch.zig +3 -13
  52. package/std/Io/Semaphore.zig +112 -17
  53. package/std/Io/Threaded.zig +167 -33
  54. package/std/Io/Uring.zig +12 -14
  55. package/std/Io/Writer.zig +46 -42
  56. package/std/Io/net.zig +11 -11
  57. package/std/Io.zig +89 -25
  58. package/std/Target.zig +50 -5
  59. package/std/builtin.zig +4 -0
  60. package/std/c/haiku.zig +3 -0
  61. package/std/c/serenity.zig +1 -6
  62. package/std/c.zig +59 -6
  63. package/std/debug.zig +4 -3
  64. package/std/fmt.zig +7 -2
  65. package/std/fs/path.zig +6 -4
  66. package/std/heap/BufferFirstAllocator.zig +165 -0
  67. package/std/heap.zig +2 -126
  68. package/std/http/Client.zig +21 -24
  69. package/std/os/linux/aarch64.zig +41 -12
  70. package/std/os/linux/arc.zig +41 -12
  71. package/std/os/linux/arm.zig +41 -12
  72. package/std/os/linux/hexagon.zig +33 -11
  73. package/std/os/linux/loongarch32.zig +41 -13
  74. package/std/os/linux/loongarch64.zig +41 -12
  75. package/std/os/linux/m68k.zig +41 -13
  76. package/std/os/linux/mips.zig +67 -36
  77. package/std/os/linux/mips64.zig +60 -29
  78. package/std/os/linux/mipsn32.zig +60 -29
  79. package/std/os/linux/or1k.zig +41 -12
  80. package/std/os/linux/powerpc.zig +41 -12
  81. package/std/os/linux/powerpc64.zig +41 -12
  82. package/std/os/linux/riscv32.zig +41 -12
  83. package/std/os/linux/riscv64.zig +41 -12
  84. package/std/os/linux/s390x.zig +44 -7
  85. package/std/os/linux/sparc64.zig +83 -52
  86. package/std/os/linux/thumb.zig +52 -36
  87. package/std/os/linux/x32.zig +41 -12
  88. package/std/os/linux/x86.zig +42 -13
  89. package/std/os/linux/x86_64.zig +41 -12
  90. package/std/os/linux.zig +398 -434
  91. package/std/os.zig +41 -0
  92. package/std/sort.zig +3 -3
  93. package/std/zig/AstGen.zig +22 -92
  94. package/std/zig/AstRlAnnotate.zig +0 -11
  95. package/std/zig/BuiltinFn.zig +0 -32
  96. package/std/zig/LibCInstallation.zig +1 -0
  97. package/std/zig/Zir.zig +50 -63
  98. package/std/zig/ZonGen.zig +5 -4
  99. package/std/zig/llvm/Builder.zig +12 -12
  100. package/std/zig.zig +0 -10
  101. package/zig.h +340 -1
  102. package/libc/mingw/math/fdiml.c +0 -24
  103. package/libc/musl/src/linux/tee.c +0 -8
  104. package/libc/musl/src/math/fdimf.c +0 -10
  105. package/libc/musl/src/math/fdiml.c +0 -18
  106. package/libc/musl/src/unistd/dup2.c +0 -20
  107. package/libc/musl/src/unistd/dup3.c +0 -26
@@ -1761,8 +1761,9 @@ fn addToSearchPath(comp: *Compilation, include: Include, verbose: bool) !void {
1761
1761
  try comp.search_path.append(comp.gpa, include);
1762
1762
  }
1763
1763
  fn removeDuplicateSearchPaths(comp: *Compilation, start: usize, verbose: bool) !void {
1764
- var sf = std.heap.stackFallback(1024, comp.gpa);
1765
- const allocator = sf.get();
1764
+ var bfa_buf: [1024]u8 = undefined;
1765
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, comp.gpa);
1766
+ const allocator = bfa.allocator();
1766
1767
  var seen_includes: std.StringHashMapUnmanaged(void) = .empty;
1767
1768
  defer seen_includes.deinit(allocator);
1768
1769
  var seen_frameworks: std.StringHashMapUnmanaged(void) = .empty;
@@ -1976,10 +1977,11 @@ const FindInclude = struct {
1976
1977
  ) Allocator.Error!?Result {
1977
1978
  const comp = find.comp;
1978
1979
 
1979
- var stack_fallback = std.heap.stackFallback(path_buf_stack_limit, comp.gpa);
1980
- const sfa = stack_fallback.get();
1981
- const header_path = try std.fmt.allocPrint(sfa, format, args);
1982
- defer sfa.free(header_path);
1980
+ var bfa_buf: [path_buf_stack_limit]u8 = undefined;
1981
+ var bfa_state: std.heap.BufferFirstAllocator = .init(&bfa_buf, comp.gpa);
1982
+ const bfa = bfa_state.allocator();
1983
+ const header_path = try std.fmt.allocPrint(bfa, format, args);
1984
+ defer bfa.free(header_path);
1983
1985
  find.comp.normalizePath(header_path);
1984
1986
 
1985
1987
  const source = comp.addSourceFromPathExtra(header_path, kind) catch |err| switch (err) {
@@ -2068,14 +2070,15 @@ pub fn findEmbed(
2068
2070
  }
2069
2071
  }
2070
2072
 
2071
- var stack_fallback = std.heap.stackFallback(path_buf_stack_limit, comp.gpa);
2072
- const sf_allocator = stack_fallback.get();
2073
+ var bfa_buf: [path_buf_stack_limit]u8 = undefined;
2074
+ var bfa_state: std.heap.BufferFirstAllocator = .init(&bfa_buf, comp.gpa);
2075
+ const bfa = bfa_state.allocator();
2073
2076
 
2074
2077
  switch (include_type) {
2075
2078
  .quotes, .cli => {
2076
2079
  const dir = std.fs.path.dirname(comp.getSource(includer_token_source).path) orelse ".";
2077
- const path = try std.fs.path.join(sf_allocator, &.{ dir, filename });
2078
- defer sf_allocator.free(path);
2080
+ const path = try std.fs.path.join(bfa, &.{ dir, filename });
2081
+ defer bfa.free(path);
2079
2082
  comp.normalizePath(path);
2080
2083
  if (comp.getPathContents(path, limit)) |some| {
2081
2084
  errdefer comp.gpa.free(some);
@@ -2089,8 +2092,8 @@ pub fn findEmbed(
2089
2092
  .angle_brackets => {},
2090
2093
  }
2091
2094
  for (comp.embed_dirs.items) |embed_dir| {
2092
- const path = try std.fs.path.join(sf_allocator, &.{ embed_dir, filename });
2093
- defer sf_allocator.free(path);
2095
+ const path = try std.fs.path.join(bfa, &.{ embed_dir, filename });
2096
+ defer bfa.free(path);
2094
2097
  comp.normalizePath(path);
2095
2098
  if (comp.getPathContents(path, limit)) |some| {
2096
2099
  errdefer comp.gpa.free(some);
@@ -947,8 +947,9 @@ fn addImacros(d: *Driver, path: []const u8) !void {
947
947
  }
948
948
 
949
949
  pub fn err(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void {
950
- var sf = std.heap.stackFallback(1024, d.comp.gpa);
951
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
950
+ var bfa_buf: [1024]u8 = undefined;
951
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, d.comp.gpa);
952
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
952
953
  defer allocating.deinit();
953
954
 
954
955
  Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory;
@@ -956,8 +957,9 @@ pub fn err(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void {
956
957
  }
957
958
 
958
959
  pub fn warn(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void {
959
- var sf = std.heap.stackFallback(1024, d.comp.gpa);
960
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
960
+ var bfa_buf: [1024]u8 = undefined;
961
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, d.comp.gpa);
962
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
961
963
  defer allocating.deinit();
962
964
 
963
965
  Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory;
@@ -1101,8 +1103,9 @@ fn parseTarget(d: *Driver, arch_os_abi: []const u8, opt_cpu_features: ?[]const u
1101
1103
  }
1102
1104
 
1103
1105
  pub fn fatal(d: *Driver, comptime fmt: []const u8, args: anytype) error{ FatalError, OutOfMemory } {
1104
- var sf = std.heap.stackFallback(1024, d.comp.gpa);
1105
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
1106
+ var bfa_buf: [1024]u8 = undefined;
1107
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, d.comp.gpa);
1108
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
1106
1109
  defer allocating.deinit();
1107
1110
 
1108
1111
  Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory;
@@ -215,8 +215,9 @@ fn checkIdentifierCodepointWarnings(p: *Parser, codepoint: u21, loc: Source.Loca
215
215
  assert(codepoint >= 0x80);
216
216
 
217
217
  const prev_total = p.diagnostics.total;
218
- var sf = std.heap.stackFallback(1024, p.comp.gpa);
219
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
218
+ var bfa_buf: [1024]u8 = undefined;
219
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, p.comp.gpa);
220
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
220
221
  defer allocating.deinit();
221
222
 
222
223
  if (!char_info.isC99IdChar(codepoint)) {
@@ -429,8 +430,9 @@ pub fn err(p: *Parser, tok_i: TokenIndex, diagnostic: Diagnostic, args: anytype)
429
430
  if (diagnostic.suppress_unless_version) |some| if (!p.comp.langopts.standard.atLeast(some)) return;
430
431
  if (p.diagnostics.effectiveKind(diagnostic) == .off) return;
431
432
 
432
- var sf = std.heap.stackFallback(1024, p.comp.gpa);
433
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
433
+ var bfa_buf: [1024]u8 = undefined;
434
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, p.comp.gpa);
435
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
434
436
  defer allocating.deinit();
435
437
 
436
438
  p.formatArgs(&allocating.writer, diagnostic.fmt, args) catch return error.OutOfMemory;
@@ -1537,8 +1539,9 @@ fn staticAssert(p: *Parser) Error!bool {
1537
1539
  }
1538
1540
  } else {
1539
1541
  if (!res.val.toBool(p.comp)) {
1540
- var sf = std.heap.stackFallback(1024, gpa);
1541
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
1542
+ var bfa_buf: [1024]u8 = undefined;
1543
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, gpa);
1544
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
1542
1545
  defer allocating.deinit();
1543
1546
 
1544
1547
  if (p.staticAssertMessage(res_node, str, &allocating) catch return error.OutOfMemory) |message| {
@@ -4837,8 +4840,9 @@ fn gnuAsmStmt(p: *Parser, quals: Tree.GNUAssemblyQualifiers, asm_tok: TokenIndex
4837
4840
  const expected_items = 8; // arbitrarily chosen, most assembly will have fewer than 8 inputs/outputs/constraints/names
4838
4841
  const bytes_needed = expected_items * @sizeOf(Tree.Node.AsmStmt.Operand) + expected_items * 2 * @sizeOf(Node.Index);
4839
4842
 
4840
- var stack_fallback = std.heap.stackFallback(bytes_needed, gpa);
4841
- const allocator = stack_fallback.get();
4843
+ var bfa_buf: [bytes_needed]u8 = undefined;
4844
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, gpa);
4845
+ const allocator = bfa.allocator();
4842
4846
 
4843
4847
  var operands: std.ArrayList(Tree.Node.AsmStmt.Operand) = .empty;
4844
4848
  defer operands.deinit(allocator);
@@ -9922,8 +9926,9 @@ fn primaryExpr(p: *Parser) Error!?Result {
9922
9926
  if (p.func.pretty_ident) |some| {
9923
9927
  qt = some.qt;
9924
9928
  } else if (p.func.qt) |func_qt| {
9925
- var sf = std.heap.stackFallback(1024, gpa);
9926
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
9929
+ var bfa_buf: [1024]u8 = undefined;
9930
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, gpa);
9931
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
9927
9932
  defer allocating.deinit();
9928
9933
 
9929
9934
  func_qt.printNamed(p.tokSlice(p.func.name), p.comp, &allocating.writer) catch return error.OutOfMemory;
@@ -10212,8 +10217,9 @@ fn charLiteral(p: *Parser) Error!?Result {
10212
10217
  };
10213
10218
 
10214
10219
  const max_chars_expected = 4;
10215
- var sf = std.heap.stackFallback(max_chars_expected * @sizeOf(u32), gpa);
10216
- const allocator = sf.get();
10220
+ var bfa_buf: [max_chars_expected]u32 = undefined;
10221
+ var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&bfa_buf), gpa);
10222
+ const allocator = bfa.allocator();
10217
10223
  var chars: std.ArrayList(u32) = .empty;
10218
10224
  defer chars.deinit(allocator);
10219
10225
 
@@ -212,8 +212,9 @@ pub const Diagnostic = struct {
212
212
  };
213
213
 
214
214
  pub fn err(pp: *Preprocessor, tok_i: TokenIndex, diagnostic: Diagnostic, args: anytype) Compilation.Error!void {
215
- var sf = std.heap.stackFallback(1024, pp.comp.gpa);
216
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
215
+ var buf: [1024]u8 = undefined;
216
+ var bfa: std.heap.BufferFirstAllocator = .init(&buf, pp.comp.gpa);
217
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
217
218
  defer allocating.deinit();
218
219
 
219
220
  Diagnostics.formatArgs(&allocating.writer, diagnostic.fmt, args) catch return error.OutOfMemory;
@@ -1023,8 +1023,9 @@ fn err(pp: *Preprocessor, loc: anytype, diagnostic: Diagnostic, args: anytype) C
1023
1023
  defer pp.diagnostics.state.suppress_system_headers = old_suppress_system;
1024
1024
  if (diagnostic.show_in_system_headers) pp.diagnostics.state.suppress_system_headers = false;
1025
1025
 
1026
- var sf = std.heap.stackFallback(1024, pp.comp.gpa);
1027
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
1026
+ var bfa_buf: [1024]u8 = undefined;
1027
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, pp.comp.gpa);
1028
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
1028
1029
  defer allocating.deinit();
1029
1030
 
1030
1031
  Diagnostics.formatArgs(&allocating.writer, diagnostic.fmt, args) catch return error.OutOfMemory;
@@ -1052,8 +1053,9 @@ fn err(pp: *Preprocessor, loc: anytype, diagnostic: Diagnostic, args: anytype) C
1052
1053
  }
1053
1054
 
1054
1055
  fn fatal(pp: *Preprocessor, raw: RawToken, comptime fmt: []const u8, args: anytype) Compilation.Error {
1055
- var sf = std.heap.stackFallback(1024, pp.comp.gpa);
1056
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
1056
+ var bfa_buf: [1024]u8 = undefined;
1057
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, pp.comp.gpa);
1058
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
1057
1059
  defer allocating.deinit();
1058
1060
 
1059
1061
  Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory;
@@ -1074,8 +1076,9 @@ fn fatalNotFound(pp: *Preprocessor, tok: TokenWithExpansionLocs, filename: []con
1074
1076
  pp.diagnostics.state.fatal_errors = true;
1075
1077
  defer pp.diagnostics.state.fatal_errors = old;
1076
1078
 
1077
- var sf = std.heap.stackFallback(1024, pp.comp.gpa);
1078
- const allocator = sf.get();
1079
+ var bfa_buf: [1024]u8 = undefined;
1080
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, pp.comp.gpa);
1081
+ const allocator = bfa.allocator();
1079
1082
  var buf: std.ArrayList(u8) = .empty;
1080
1083
  defer buf.deinit(allocator);
1081
1084
 
@@ -44,8 +44,9 @@ fn preprocessorHandler(_: *Pragma, pp: *Preprocessor, start_idx: TokenIndex) Pra
44
44
 
45
45
  const diagnostic: Pragma.Diagnostic = .pragma_message;
46
46
 
47
- var sf = std.heap.stackFallback(1024, pp.comp.gpa);
48
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
47
+ var bfa_buf: [1024]u8 = undefined;
48
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, pp.comp.gpa);
49
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
49
50
  defer allocating.deinit();
50
51
 
51
52
  Diagnostics.formatArgs(&allocating.writer, diagnostic.fmt, .{str}) catch return error.OutOfMemory;
@@ -315,8 +315,9 @@ pub const Parser = struct {
315
315
  if (p.errored) return;
316
316
  if (p.comp.diagnostics.effectiveKind(diagnostic) == .off) return;
317
317
 
318
- var sf = std.heap.stackFallback(1024, p.comp.gpa);
319
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
318
+ var bfa_buf: [1024]u8 = undefined;
319
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, p.comp.gpa);
320
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
320
321
  defer allocating.deinit();
321
322
 
322
323
  formatArgs(&allocating.writer, diagnostic.fmt, args) catch return error.OutOfMemory;
@@ -68,8 +68,9 @@ fn serializeFloat(comptime T: type, value: T, w: *std.Io.Writer) !void {
68
68
  pub fn todo(c: *AsmCodeGen, msg: []const u8, tok: Tree.TokenIndex) Error {
69
69
  const loc: Source.Location = c.tree.tokens.items(.loc)[tok];
70
70
 
71
- var sf = std.heap.stackFallback(1024, c.comp.gpa);
72
- const allocator = sf.get();
71
+ var bfa_buf: [u8]1024 = undefined;
72
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, c.comp.gpa);
73
+ const allocator = bfa.allocator();
73
74
  var buf: std.ArrayList(u8) = .empty;
74
75
  defer buf.deinit(allocator);
75
76
 
@@ -333,8 +333,6 @@ pub fn main(init: process.Init.Minimal) !void {
333
333
  builder.verbose_llvm_ir = arg["--verbose-llvm-ir=".len..];
334
334
  } else if (mem.startsWith(u8, arg, "--verbose-llvm-bc=")) {
335
335
  builder.verbose_llvm_bc = arg["--verbose-llvm-bc=".len..];
336
- } else if (mem.eql(u8, arg, "--verbose-cimport")) {
337
- builder.verbose_cimport = true;
338
336
  } else if (mem.eql(u8, arg, "--verbose-cc")) {
339
337
  builder.verbose_cc = true;
340
338
  } else if (mem.eql(u8, arg, "--verbose-llvm-cpu-features")) {
@@ -563,7 +563,7 @@ pub fn fuzz(
563
563
  const stderr = std.debug.lockStderr(&.{}).terminal();
564
564
  p: {
565
565
  if (@errorReturnTrace()) |trace| {
566
- std.debug.writeStackTrace(trace, stderr) catch break :p;
566
+ std.debug.writeErrorReturnTrace(trace, stderr) catch break :p;
567
567
  }
568
568
  stderr.writer.print("failed with error.{t}\n", .{err}) catch break :p;
569
569
  }
@@ -475,8 +475,12 @@ pub const builtin_typedef_map = std.StaticStringMap([]const u8).initComptime(.{
475
475
  .{ "int8_t", "i8" },
476
476
  .{ "uint16_t", "u16" },
477
477
  .{ "int16_t", "i16" },
478
+ .{ "uint24_t", "u24" },
479
+ .{ "int24_t", "i24" },
478
480
  .{ "uint32_t", "u32" },
479
481
  .{ "int32_t", "i32" },
482
+ .{ "uint48_t", "u48" },
483
+ .{ "int48_t", "i48" },
480
484
  .{ "uint64_t", "u64" },
481
485
  .{ "int64_t", "i64" },
482
486
  .{ "intptr_t", "isize" },
@@ -173,8 +173,6 @@ pub fn cosq(x: f128) callconv(.c) f128 {
173
173
 
174
174
  pub fn cosl(x: c_longdouble) callconv(.c) c_longdouble {
175
175
  switch (@typeInfo(c_longdouble).float.bits) {
176
- 16 => return cosh(x),
177
- 32 => return cosf(x),
178
176
  64 => return cos(x),
179
177
  80 => return cosx(x),
180
178
  128 => return cosq(x),
@@ -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(x: []u32, i: usize) *u32 {
16
- return if (endian == .little) &x[i] else &x[x.len - 1 - i];
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(x: []u32) void {
21
+ inline fn neg(out: []u32, in: []const u32) void {
20
22
  var ov: u1 = 1;
21
- for (0..x.len) |limb_index| {
22
- const l = limb(x, limb_index);
23
- l.*, ov = @addWithOverflow(~l.*, ov);
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
- /// Mutates the arguments!
28
- fn divmod(q: ?[]u32, r: ?[]u32, u: []u32, v: []u32) !void {
29
- const u_sign: i32 = @bitCast(u[u.len - 1]);
30
- const v_sign: i32 = @bitCast(v[v.len - 1]);
31
- if (u_sign < 0) neg(u);
32
- if (v_sign < 0) neg(v);
33
- try @call(.always_inline, udivmod, .{ q, r, u, v });
34
- if (q) |x| if (u_sign ^ v_sign < 0) neg(x);
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
  }
@@ -194,15 +194,10 @@ pub fn __expx(a: f80) callconv(.c) f80 {
194
194
  return @floatCast(expq(a));
195
195
  }
196
196
 
197
- pub fn expq(a: f128) callconv(.c) f128 {
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) {
204
- 16 => return __exph(x),
205
- 32 => return expf(x),
206
201
  64 => return exp(x),
207
202
  80 => return __expx(x),
208
203
  128 => return expq(x),
@@ -161,15 +161,10 @@ pub fn __exp2x(x: f80) callconv(.c) f80 {
161
161
  return @floatCast(exp2q(x));
162
162
  }
163
163
 
164
- pub fn exp2q(x: f128) callconv(.c) f128 {
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) {
171
- 16 => return __exp2h(x),
172
- 32 => return exp2f(x),
173
168
  64 => return exp2(x),
174
169
  80 => return __exp2x(x),
175
170
  128 => return exp2q(x),