@zigc/lib 0.16.0 → 0.17.0-dev.39

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 (49) hide show
  1. package/c/fcntl.zig +1 -1
  2. package/c/math.zig +20 -7
  3. package/compiler/build_runner.zig +0 -2
  4. package/compiler/test_runner.zig +1 -1
  5. package/compiler_rt/divmodei4.zig +40 -17
  6. package/compiler_rt/exp.zig +1 -4
  7. package/compiler_rt/exp2.zig +1 -4
  8. package/compiler_rt/exp_f128.zig +377 -0
  9. package/compiler_rt/limb64.zig +875 -15
  10. package/compiler_rt/mulXi3.zig +1 -1
  11. package/compiler_rt/ssp.zig +1 -1
  12. package/compiler_rt/udivmodei4.zig +28 -0
  13. package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
  14. package/package.json +1 -1
  15. package/std/Build/Step/Compile.zig +0 -1
  16. package/std/Build.zig +0 -3
  17. package/std/Io/Threaded.zig +8 -8
  18. package/std/Io/Writer.zig +46 -42
  19. package/std/os/emscripten.zig +1 -1
  20. package/std/os/linux/aarch64.zig +41 -12
  21. package/std/os/linux/arc.zig +173 -0
  22. package/std/os/linux/arm.zig +41 -12
  23. package/std/os/linux/hexagon.zig +33 -11
  24. package/std/os/linux/loongarch32.zig +41 -13
  25. package/std/os/linux/loongarch64.zig +41 -12
  26. package/std/os/linux/m68k.zig +41 -13
  27. package/std/os/linux/mips.zig +67 -36
  28. package/std/os/linux/mips64.zig +60 -29
  29. package/std/os/linux/mipsn32.zig +60 -29
  30. package/std/os/linux/or1k.zig +41 -12
  31. package/std/os/linux/powerpc.zig +41 -12
  32. package/std/os/linux/powerpc64.zig +41 -12
  33. package/std/os/linux/riscv32.zig +41 -12
  34. package/std/os/linux/riscv64.zig +41 -12
  35. package/std/os/linux/s390x.zig +44 -7
  36. package/std/os/linux/sparc64.zig +83 -52
  37. package/std/os/linux/thumb.zig +52 -36
  38. package/std/os/linux/x32.zig +41 -12
  39. package/std/os/linux/x86.zig +42 -13
  40. package/std/os/linux/x86_64.zig +41 -12
  41. package/std/os/linux.zig +400 -434
  42. package/std/zig/AstGen.zig +1 -74
  43. package/std/zig/AstRlAnnotate.zig +0 -11
  44. package/std/zig/BuiltinFn.zig +0 -32
  45. package/std/zig/Zir.zig +50 -63
  46. package/std/zig.zig +0 -10
  47. package/libc/mingw/math/fdiml.c +0 -24
  48. package/libc/musl/src/math/fdimf.c +0 -10
  49. package/libc/musl/src/math/fdiml.c +0 -18
@@ -63,7 +63,7 @@ fn DoubleInt(comptime T: type) type {
63
63
  };
64
64
  }
65
65
 
66
- fn muldXi(comptime T: type, a: T, b: T) DoubleInt(T) {
66
+ pub fn muldXi(comptime T: type, a: T, b: T) DoubleInt(T) {
67
67
  const DT = DoubleInt(T);
68
68
  const word_t = compiler_rt.HalveInt(DT, false);
69
69
  const bits_in_word_2 = @sizeOf(T) * 8 / 2;
@@ -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");
@@ -13,6 +13,8 @@ const max_limbs = std.math.divCeil(usize, 65535, 32) catch unreachable; // max s
13
13
  comptime {
14
14
  symbol(&__udivei4, "__udivei4");
15
15
  symbol(&__umodei4, "__umodei4");
16
+ symbol(&__udivei5, "__udivei5");
17
+ symbol(&__umodei5, "__umodei5");
16
18
  }
17
19
 
18
20
  /// Get the value of a limb.
@@ -132,6 +134,32 @@ pub fn __umodei4(r_p: [*]u8, u_p: [*]const u8, v_p: [*]const u8, bits: usize) ca
132
134
  @call(.always_inline, divmod, .{ null, r, u, v }) catch unreachable;
133
135
  }
134
136
 
137
+ pub fn __udivei5(q_p: [*]u8, u_p: [*]const u8, v_p: [*]const u8, t_p: [*]u8, bits: usize) callconv(.c) void {
138
+ @setRuntimeSafety(compiler_rt.test_safety);
139
+ const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
140
+ const q: []u32 = @ptrCast(@alignCast(q_p[0..byte_size]));
141
+ const u: []const u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
142
+ const v: []const u32 = @ptrCast(@alignCast(v_p[0..byte_size]));
143
+ const tu: []u32 = @ptrCast(@alignCast(t_p[0..byte_size]));
144
+ _ = tu;
145
+ const tv: []u32 = @ptrCast(@alignCast(t_p[byte_size..][0..byte_size]));
146
+ _ = tv;
147
+ @call(.always_inline, divmod, .{ q, null, u, v }) catch unreachable;
148
+ }
149
+
150
+ pub fn __umodei5(r_p: [*]u8, u_p: [*]const u8, v_p: [*]const u8, t_p: [*]u8, bits: usize) callconv(.c) void {
151
+ @setRuntimeSafety(compiler_rt.test_safety);
152
+ const byte_size = std.zig.target.intByteSize(&builtin.target, @intCast(bits));
153
+ const r: []u32 = @ptrCast(@alignCast(r_p[0..byte_size]));
154
+ const u: []const u32 = @ptrCast(@alignCast(u_p[0..byte_size]));
155
+ const v: []const u32 = @ptrCast(@alignCast(v_p[0..byte_size]));
156
+ const tu: []u32 = @ptrCast(@alignCast(t_p[0..byte_size]));
157
+ _ = tu;
158
+ const tv: []u32 = @ptrCast(@alignCast(t_p[byte_size..][0..byte_size]));
159
+ _ = tv;
160
+ @call(.always_inline, divmod, .{ null, r, u, v }) catch unreachable;
161
+ }
162
+
135
163
  test "__udivei4/__umodei4" {
136
164
  if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
137
165
  if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
@@ -1,6 +1,9 @@
1
1
  #define __SYSCALL_LL_E(x) (x)
2
2
  #define __SYSCALL_LL_O(x) (x)
3
3
 
4
+ #define __scc(X) sizeof(1?(X):0ULL) < 8 ? (unsigned long) (X) : (long long) (X)
5
+ typedef long long syscall_arg_t;
6
+
4
7
  #define SYSCALL_RLIM_INFINITY (-1UL/2)
5
8
 
6
9
  #if __mips_isa_rev >= 6
@@ -13,9 +16,9 @@
13
16
  "$14", "$15", "$24", "$25", "hi", "lo", "memory"
14
17
  #endif
15
18
 
16
- static inline long __syscall0(long n)
19
+ static inline long __syscall0(long long n)
17
20
  {
18
- register long r7 __asm__("$7");
21
+ register long long r7 __asm__("$7");
19
22
  register long r2 __asm__("$2");
20
23
  __asm__ __volatile__ (
21
24
  "daddu $2,$0,%2 ; syscall"
@@ -25,10 +28,10 @@ static inline long __syscall0(long n)
25
28
  return r7 && r2>0 ? -r2 : r2;
26
29
  }
27
30
 
28
- static inline long __syscall1(long n, long a)
31
+ static inline long __syscall1(long long n, long long a)
29
32
  {
30
- register long r4 __asm__("$4") = a;
31
- register long r7 __asm__("$7");
33
+ register long long r4 __asm__("$4") = a;
34
+ register long long r7 __asm__("$7");
32
35
  register long r2 __asm__("$2");
33
36
  __asm__ __volatile__ (
34
37
  "daddu $2,$0,%2 ; syscall"
@@ -38,11 +41,11 @@ static inline long __syscall1(long n, long a)
38
41
  return r7 && r2>0 ? -r2 : r2;
39
42
  }
40
43
 
41
- static inline long __syscall2(long n, long a, long b)
44
+ static inline long __syscall2(long long n, long long a, long long b)
42
45
  {
43
- register long r4 __asm__("$4") = a;
44
- register long r5 __asm__("$5") = b;
45
- register long r7 __asm__("$7");
46
+ register long long r4 __asm__("$4") = a;
47
+ register long long r5 __asm__("$5") = b;
48
+ register long long r7 __asm__("$7");
46
49
  register long r2 __asm__("$2");
47
50
 
48
51
  __asm__ __volatile__ (
@@ -53,12 +56,12 @@ static inline long __syscall2(long n, long a, long b)
53
56
  return r7 && r2>0 ? -r2 : r2;
54
57
  }
55
58
 
56
- static inline long __syscall3(long n, long a, long b, long c)
59
+ static inline long __syscall3(long long n, long long a, long long b, long long c)
57
60
  {
58
- register long r4 __asm__("$4") = a;
59
- register long r5 __asm__("$5") = b;
60
- register long r6 __asm__("$6") = c;
61
- register long r7 __asm__("$7");
61
+ register long long r4 __asm__("$4") = a;
62
+ register long long r5 __asm__("$5") = b;
63
+ register long long r6 __asm__("$6") = c;
64
+ register long long r7 __asm__("$7");
62
65
  register long r2 __asm__("$2");
63
66
 
64
67
  __asm__ __volatile__ (
@@ -69,12 +72,12 @@ static inline long __syscall3(long n, long a, long b, long c)
69
72
  return r7 && r2>0 ? -r2 : r2;
70
73
  }
71
74
 
72
- static inline long __syscall4(long n, long a, long b, long c, long d)
75
+ static inline long __syscall4(long long n, long long a, long long b, long long c, long long d)
73
76
  {
74
- register long r4 __asm__("$4") = a;
75
- register long r5 __asm__("$5") = b;
76
- register long r6 __asm__("$6") = c;
77
- register long r7 __asm__("$7") = d;
77
+ register long long r4 __asm__("$4") = a;
78
+ register long long r5 __asm__("$5") = b;
79
+ register long long r6 __asm__("$6") = c;
80
+ register long long r7 __asm__("$7") = d;
78
81
  register long r2 __asm__("$2");
79
82
 
80
83
  __asm__ __volatile__ (
@@ -85,13 +88,13 @@ static inline long __syscall4(long n, long a, long b, long c, long d)
85
88
  return r7 && r2>0 ? -r2 : r2;
86
89
  }
87
90
 
88
- static inline long __syscall5(long n, long a, long b, long c, long d, long e)
91
+ static inline long __syscall5(long long n, long long a, long long b, long long c, long long d, long long e)
89
92
  {
90
- register long r4 __asm__("$4") = a;
91
- register long r5 __asm__("$5") = b;
92
- register long r6 __asm__("$6") = c;
93
- register long r7 __asm__("$7") = d;
94
- register long r8 __asm__("$8") = e;
93
+ register long long r4 __asm__("$4") = a;
94
+ register long long r5 __asm__("$5") = b;
95
+ register long long r6 __asm__("$6") = c;
96
+ register long long r7 __asm__("$7") = d;
97
+ register long long r8 __asm__("$8") = e;
95
98
  register long r2 __asm__("$2");
96
99
 
97
100
  __asm__ __volatile__ (
@@ -102,14 +105,14 @@ static inline long __syscall5(long n, long a, long b, long c, long d, long e)
102
105
  return r7 && r2>0 ? -r2 : r2;
103
106
  }
104
107
 
105
- static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
108
+ static inline long __syscall6(long long n, long long a, long long b, long long c, long long d, long long e, long long f)
106
109
  {
107
- register long r4 __asm__("$4") = a;
108
- register long r5 __asm__("$5") = b;
109
- register long r6 __asm__("$6") = c;
110
- register long r7 __asm__("$7") = d;
111
- register long r8 __asm__("$8") = e;
112
- register long r9 __asm__("$9") = f;
110
+ register long long r4 __asm__("$4") = a;
111
+ register long long r5 __asm__("$5") = b;
112
+ register long long r6 __asm__("$6") = c;
113
+ register long long r7 __asm__("$7") = d;
114
+ register long long r8 __asm__("$8") = e;
115
+ register long long r9 __asm__("$9") = f;
113
116
  register long r2 __asm__("$2");
114
117
 
115
118
  __asm__ __volatile__ (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zigc/lib",
3
- "version": "0.16.0",
3
+ "version": "0.17.0-dev.39",
4
4
  "description": "Zig standard library and libc headers (shared across all platforms)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1393,7 +1393,6 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
1393
1393
  try zig_args.append("--debug-incremental");
1394
1394
  }
1395
1395
 
1396
- if (b.verbose_cimport) try zig_args.append("--verbose-cimport");
1397
1396
  if (b.verbose_air) try zig_args.append("--verbose-air");
1398
1397
  if (b.verbose_llvm_ir) |path| try zig_args.append(b.fmt("--verbose-llvm-ir={s}", .{path}));
1399
1398
  if (b.verbose_llvm_bc) |path| try zig_args.append(b.fmt("--verbose-llvm-bc={s}", .{path}));
package/std/Build.zig CHANGED
@@ -38,7 +38,6 @@ verbose_cc: bool,
38
38
  verbose_air: bool,
39
39
  verbose_llvm_ir: ?[]const u8,
40
40
  verbose_llvm_bc: ?[]const u8,
41
- verbose_cimport: bool,
42
41
  verbose_llvm_cpu_features: bool,
43
42
  reference_trace: ?u32 = null,
44
43
  invalid_user_input: bool,
@@ -278,7 +277,6 @@ pub fn create(
278
277
  .verbose_air = false,
279
278
  .verbose_llvm_ir = null,
280
279
  .verbose_llvm_bc = null,
281
- .verbose_cimport = false,
282
280
  .verbose_llvm_cpu_features = false,
283
281
  .invalid_user_input = false,
284
282
  .allocator = arena,
@@ -377,7 +375,6 @@ fn createChildOnly(
377
375
  .verbose_air = parent.verbose_air,
378
376
  .verbose_llvm_ir = parent.verbose_llvm_ir,
379
377
  .verbose_llvm_bc = parent.verbose_llvm_bc,
380
- .verbose_cimport = parent.verbose_cimport,
381
378
  .verbose_llvm_cpu_features = parent.verbose_llvm_cpu_features,
382
379
  .reference_trace = parent.reference_trace,
383
380
  .invalid_user_input = false,
@@ -10035,10 +10035,10 @@ fn fileSeekBy(userdata: ?*anyopaque, file: File, offset: i64) File.SeekError!voi
10035
10035
  if (posix.SEEK == void) return error.Unseekable;
10036
10036
 
10037
10037
  if (native_os == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
10038
- var result: u64 = undefined;
10038
+ var result: i64 = undefined;
10039
10039
  const syscall: Syscall = try .start();
10040
10040
  while (true) {
10041
- switch (posix.errno(posix.system.llseek(file.handle, @bitCast(offset), &result, posix.SEEK.CUR))) {
10041
+ switch (posix.errno(posix.system.llseek(file.handle, offset, &result, posix.SEEK.CUR))) {
10042
10042
  .SUCCESS => {
10043
10043
  syscall.finish();
10044
10044
  return;
@@ -10149,8 +10149,8 @@ fn posixSeekTo(fd: posix.fd_t, offset: u64) File.SeekError!void {
10149
10149
  if (native_os == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
10150
10150
  const syscall: Syscall = try .start();
10151
10151
  while (true) {
10152
- var result: u64 = undefined;
10153
- switch (posix.errno(posix.system.llseek(fd, offset, &result, posix.SEEK.SET))) {
10152
+ var result: i64 = undefined;
10153
+ switch (posix.errno(posix.system.llseek(fd, @bitCast(offset), &result, posix.SEEK.SET))) {
10154
10154
  .SUCCESS => {
10155
10155
  syscall.finish();
10156
10156
  return;
@@ -15247,7 +15247,7 @@ fn childWaitPosix(child: *process.Child) process.Child.WaitError!process.Child.T
15247
15247
  const ru_ptr = if (child.request_resource_usage_statistics) &ru else null;
15248
15248
 
15249
15249
  if (have_wait4) {
15250
- var status: if (builtin.link_libc) c_int else u32 = undefined;
15250
+ var status: if (builtin.link_libc) c_int else i32 = undefined;
15251
15251
  const syscall: Syscall = try .start();
15252
15252
  while (true) switch (posix.errno(posix.system.wait4(pid, &status, 0, ru_ptr))) {
15253
15253
  .SUCCESS => {
@@ -15290,7 +15290,7 @@ fn childWaitPosix(child: *process.Child) process.Child.WaitError!process.Child.T
15290
15290
  };
15291
15291
  }
15292
15292
 
15293
- var status: if (builtin.link_libc) c_int else u32 = undefined;
15293
+ var status: if (builtin.link_libc) c_int else i32 = undefined;
15294
15294
  const syscall: Syscall = try .start();
15295
15295
  while (true) switch (posix.errno(posix.system.waitpid(pid, &status, 0))) {
15296
15296
  .SUCCESS => {
@@ -15332,7 +15332,7 @@ fn childKillPosix(child: *process.Child) !void {
15332
15332
  };
15333
15333
 
15334
15334
  if (have_wait4) {
15335
- var status: if (builtin.link_libc) c_int else u32 = undefined;
15335
+ var status: if (builtin.link_libc) c_int else i32 = undefined;
15336
15336
  while (true) switch (posix.errno(posix.system.wait4(pid, &status, 0, null))) {
15337
15337
  .SUCCESS => return,
15338
15338
  .INTR => continue,
@@ -15352,7 +15352,7 @@ fn childKillPosix(child: *process.Child) !void {
15352
15352
  };
15353
15353
  }
15354
15354
 
15355
- var status: if (builtin.link_libc) c_int else u32 = undefined;
15355
+ var status: if (builtin.link_libc) c_int else i32 = undefined;
15356
15356
  while (true) switch (posix.errno(posix.system.waitpid(pid, &status, 0))) {
15357
15357
  .SUCCESS => return,
15358
15358
  .INTR => continue,
package/std/Io/Writer.zig CHANGED
@@ -551,64 +551,68 @@ pub fn writeAll(w: *Writer, bytes: []const u8) Error!void {
551
551
  while (index < bytes.len) index += try w.write(bytes[index..]);
552
552
  }
553
553
 
554
- /// Renders fmt string with args, calling `writer` with slices of bytes.
555
- /// If `writer` returns an error, the error is returned from `format` and
556
- /// `writer` is not called again.
554
+ /// Renders `fmt` string with `args`, calling `w` with slices of bytes.
557
555
  ///
558
- /// The format string must be comptime-known and may contain placeholders following
559
- /// this format:
560
- /// `{[argument][specifier]:[fill][alignment][width].[precision]}`
556
+ /// The format string must be comptime-known and may contain placeholders
557
+ /// following this format:
558
+ /// ```
559
+ /// {[argument][specifier]:[fill][alignment][width].[precision]}
560
+ /// ```
561
561
  ///
562
- /// Above, each word including its surrounding [ and ] is a parameter which you have to replace with something:
562
+ /// Above, each word including its surrounding [ and ] is a parameter to be replaced with:
563
563
  ///
564
- /// - *argument* is either the numeric index or the field name of the argument that should be inserted
565
- /// - when using a field name, you are required to enclose the field name (an identifier) in square
566
- /// brackets, e.g. {[score]...} as opposed to the numeric index form which can be written e.g. {2...}
567
- /// - *specifier* is a type-dependent formatting option that determines how a type should formatted (see below)
568
- /// - *fill* is a single byte which is used to pad formatted numbers.
569
- /// - *alignment* is one of the three bytes '<', '^', or '>' to make numbers
564
+ /// - **argument** is either the numeric index or the field name of the argument that should be inserted.
565
+ /// - When using a field name, the field name (an identifier) must be enclosed in square
566
+ /// brackets, e.g. `{[score]...}` as opposed to the numeric index form which can be written e.g. `{2...}`.
567
+ /// - **specifier** is a type-dependent formatting option that determines how a type should formatted (see below).
568
+ /// - **fill** is a single byte which is used to pad formatted numbers.
569
+ /// - **alignment** is one of the three bytes '<', '^', or '>' to make numbers
570
570
  /// left, center, or right-aligned, respectively.
571
571
  /// - Not all specifiers support alignment.
572
- /// - Alignment is not Unicode-aware; appropriate only when used with raw bytes or ASCII.
573
- /// - *width* is the total width of the field in bytes. This only applies to number formatting.
574
- /// - *precision* specifies how many decimals a formatted number should have.
572
+ /// - Alignment is not Unicode-aware; appropriate only when used with raw
573
+ /// bytes or ASCII.
574
+ /// - **width** is the total size of the field in bytes, only applicable to
575
+ /// number formatting.
576
+ /// - **precision** specifies how many decimals a formatted number should have.
575
577
  ///
576
- /// Note that most of the parameters are optional and may be omitted. Also you
577
- /// can leave out separators like `:` and `.` when all parameters after the
578
- /// separator are omitted.
578
+ /// Most of the parameters are optional and may be omitted. The separators (':'
579
+ /// and '.') may be omitted when all parameters afterwards are omitted.
579
580
  ///
580
- /// Only exception is the *fill* parameter. If a non-zero *fill* character is
581
- /// required at the same time as *width* is specified, one has to specify
582
- /// *alignment* as well, as otherwise the digit following `:` is interpreted as
583
- /// *width*, not *fill*.
581
+ /// The **fill** parameter is an exception. If a non-zero **fill** character is
582
+ /// required at the same time as **width** is specified, **alignment** is
583
+ /// required, otherwise the digit following ':' is interpreted as **width**.
584
584
  ///
585
- /// The *specifier* has several options for types:
586
- /// - `x` and `X`: output numeric value in hexadecimal notation, or string in hexadecimal bytes
585
+ /// **specifier** supports:
586
+ /// - `x` and `X`: numeric value in hexadecimal notation, or string in hexadecimal bytes
587
587
  /// - `s`:
588
588
  /// - for pointer-to-many and C pointers of u8, print as a C-string using zero-termination
589
589
  /// - for slices of u8, print the entire slice as a string without zero-termination
590
590
  /// - `t`:
591
591
  /// - for enums and tagged unions: prints the tag name
592
592
  /// - for error sets: prints the error name
593
- /// - `b64`: output string as standard base64
594
- /// - `e`: output floating point value in scientific notation
595
- /// - `d`: output numeric value in decimal notation
596
- /// - `b`: output integer value in binary notation
597
- /// - `o`: output integer value in octal notation
598
- /// - `c`: output integer as an ASCII character. Integer type must have 8 bits at max.
599
- /// - `u`: output integer as an UTF-8 sequence. Integer type must have 21 bits at max.
600
- /// - `D`: output nanoseconds as duration
601
- /// - `B`: output bytes in SI units (decimal)
602
- /// - `Bi`: output bytes in IEC units (binary)
603
- /// - `?`: output optional value as either the unwrapped value, or `null`; may be followed by a format specifier for the underlying value.
604
- /// - `!`: output error union value as either the unwrapped value, or the formatted error value; may be followed by a format specifier for the underlying value.
605
- /// - `*`: output the address of the value instead of the value itself.
606
- /// - `any`: output a value of any type using its default format.
607
- /// - `f`: delegates to a method on the type named "format" with the signature `fn (*Writer, args: anytype) Writer.Error!void`.
593
+ /// - `b64`: string as standard base64
594
+ /// - `e`: floating point value in scientific notation
595
+ /// - `d`: numeric value in decimal notation
596
+ /// - `b`: integer value in binary notation
597
+ /// - `o`: integer value in octal notation
598
+ /// - `c`: integer as an ASCII character. Integer type must have 8 bits at max.
599
+ /// - `u`: integer as an UTF-8 sequence. Integer type must have 21 bits at max.
600
+ /// - `B`: bytes in SI units (decimal)
601
+ /// - `Bi`: bytes in IEC units (binary)
602
+ /// - `?`: optional value as either the unwrapped value, or `null`; may be
603
+ /// followed by a format specifier for the underlying value.
604
+ /// - `!`: error union value as either the unwrapped value, or the formatted
605
+ /// error value; may be followed by a format specifier for the underlying
606
+ /// value.
607
+ /// - `*`: the address of the value instead of the value itself.
608
+ /// - `any`: a value of any type using its default format.
609
+ /// - `f`: delegates to the `format` method of the type, passing `*Writer` and
610
+ /// expecting `Error!void` returned.
608
611
  ///
609
- /// A user type may be a `struct`, `vector`, `union` or `enum` type.
612
+ /// A user type may be a struct, vector, union or enum type.
610
613
  ///
611
- /// To print literal curly braces, escape them by writing them twice, e.g. `{{` or `}}`.
614
+ /// Literal curly braces can be escaped in the format string via doubling, e.g.
615
+ /// `{{` or `}}`.
612
616
  pub fn print(w: *Writer, comptime fmt: []const u8, args: anytype) Error!void {
613
617
  const ArgsType = @TypeOf(args);
614
618
  const args_type_info = @typeInfo(ArgsType);
@@ -211,7 +211,7 @@ pub const W = struct {
211
211
  pub fn TERMSIG(s: u32) SIG {
212
212
  return @enumFromInt(s & 0x7f);
213
213
  }
214
- pub fn STOPSIG(s: u32) u32 {
214
+ pub fn STOPSIG(s: u32) SIG {
215
215
  return @enumFromInt(EXITSTATUS(s));
216
216
  }
217
217
  pub fn IFEXITED(s: u32) bool {
@@ -2,14 +2,21 @@ const builtin = @import("builtin");
2
2
  const std = @import("../../std.zig");
3
3
  const SYS = std.os.linux.SYS;
4
4
 
5
- pub fn syscall0(number: SYS) u64 {
5
+ pub const syscall_arg_t = u64;
6
+
7
+ pub fn syscall0(
8
+ number: SYS,
9
+ ) u64 {
6
10
  return asm volatile ("svc #0"
7
11
  : [ret] "={x0}" (-> u64),
8
12
  : [number] "{x8}" (@intFromEnum(number)),
9
13
  : .{ .memory = true });
10
14
  }
11
15
 
12
- pub fn syscall1(number: SYS, arg1: u64) u64 {
16
+ pub fn syscall1(
17
+ number: SYS,
18
+ arg1: syscall_arg_t,
19
+ ) u64 {
13
20
  return asm volatile ("svc #0"
14
21
  : [ret] "={x0}" (-> u64),
15
22
  : [number] "{x8}" (@intFromEnum(number)),
@@ -17,7 +24,11 @@ pub fn syscall1(number: SYS, arg1: u64) u64 {
17
24
  : .{ .memory = true });
18
25
  }
19
26
 
20
- pub fn syscall2(number: SYS, arg1: u64, arg2: u64) u64 {
27
+ pub fn syscall2(
28
+ number: SYS,
29
+ arg1: syscall_arg_t,
30
+ arg2: syscall_arg_t,
31
+ ) u64 {
21
32
  return asm volatile ("svc #0"
22
33
  : [ret] "={x0}" (-> u64),
23
34
  : [number] "{x8}" (@intFromEnum(number)),
@@ -26,7 +37,12 @@ pub fn syscall2(number: SYS, arg1: u64, arg2: u64) u64 {
26
37
  : .{ .memory = true });
27
38
  }
28
39
 
29
- pub fn syscall3(number: SYS, arg1: u64, arg2: u64, arg3: u64) u64 {
40
+ pub fn syscall3(
41
+ number: SYS,
42
+ arg1: syscall_arg_t,
43
+ arg2: syscall_arg_t,
44
+ arg3: syscall_arg_t,
45
+ ) u64 {
30
46
  return asm volatile ("svc #0"
31
47
  : [ret] "={x0}" (-> u64),
32
48
  : [number] "{x8}" (@intFromEnum(number)),
@@ -36,7 +52,13 @@ pub fn syscall3(number: SYS, arg1: u64, arg2: u64, arg3: u64) u64 {
36
52
  : .{ .memory = true });
37
53
  }
38
54
 
39
- pub fn syscall4(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64) u64 {
55
+ pub fn syscall4(
56
+ number: SYS,
57
+ arg1: syscall_arg_t,
58
+ arg2: syscall_arg_t,
59
+ arg3: syscall_arg_t,
60
+ arg4: syscall_arg_t,
61
+ ) u64 {
40
62
  return asm volatile ("svc #0"
41
63
  : [ret] "={x0}" (-> u64),
42
64
  : [number] "{x8}" (@intFromEnum(number)),
@@ -47,7 +69,14 @@ pub fn syscall4(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64) u64 {
47
69
  : .{ .memory = true });
48
70
  }
49
71
 
50
- pub fn syscall5(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) u64 {
72
+ pub fn syscall5(
73
+ number: SYS,
74
+ arg1: syscall_arg_t,
75
+ arg2: syscall_arg_t,
76
+ arg3: syscall_arg_t,
77
+ arg4: syscall_arg_t,
78
+ arg5: syscall_arg_t,
79
+ ) u64 {
51
80
  return asm volatile ("svc #0"
52
81
  : [ret] "={x0}" (-> u64),
53
82
  : [number] "{x8}" (@intFromEnum(number)),
@@ -61,12 +90,12 @@ pub fn syscall5(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u
61
90
 
62
91
  pub fn syscall6(
63
92
  number: SYS,
64
- arg1: u64,
65
- arg2: u64,
66
- arg3: u64,
67
- arg4: u64,
68
- arg5: u64,
69
- arg6: u64,
93
+ arg1: syscall_arg_t,
94
+ arg2: syscall_arg_t,
95
+ arg3: syscall_arg_t,
96
+ arg4: syscall_arg_t,
97
+ arg5: syscall_arg_t,
98
+ arg6: syscall_arg_t,
70
99
  ) u64 {
71
100
  return asm volatile ("svc #0"
72
101
  : [ret] "={x0}" (-> u64),