@zigc/lib 0.17.0-dev.27 → 0.17.0-dev.44

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 (42) hide show
  1. package/c/fcntl.zig +1 -1
  2. package/compiler/build_runner.zig +0 -2
  3. package/compiler/translate-c/Translator.zig +4 -0
  4. package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
  5. package/package.json +1 -1
  6. package/std/Build/Step/Compile.zig +0 -1
  7. package/std/Build.zig +0 -3
  8. package/std/Io/Threaded.zig +8 -8
  9. package/std/Io/Writer.zig +7 -3
  10. package/std/Target.zig +50 -3
  11. package/std/builtin.zig +4 -0
  12. package/std/fmt.zig +7 -2
  13. package/std/http/Client.zig +21 -24
  14. package/std/os/linux/aarch64.zig +41 -12
  15. package/std/os/linux/arc.zig +41 -12
  16. package/std/os/linux/arm.zig +41 -12
  17. package/std/os/linux/hexagon.zig +33 -11
  18. package/std/os/linux/loongarch32.zig +41 -13
  19. package/std/os/linux/loongarch64.zig +41 -12
  20. package/std/os/linux/m68k.zig +41 -13
  21. package/std/os/linux/mips.zig +67 -36
  22. package/std/os/linux/mips64.zig +60 -29
  23. package/std/os/linux/mipsn32.zig +60 -29
  24. package/std/os/linux/or1k.zig +41 -12
  25. package/std/os/linux/powerpc.zig +41 -12
  26. package/std/os/linux/powerpc64.zig +41 -12
  27. package/std/os/linux/riscv32.zig +41 -12
  28. package/std/os/linux/riscv64.zig +41 -12
  29. package/std/os/linux/s390x.zig +44 -7
  30. package/std/os/linux/sparc64.zig +83 -52
  31. package/std/os/linux/thumb.zig +52 -36
  32. package/std/os/linux/x32.zig +41 -12
  33. package/std/os/linux/x86.zig +42 -13
  34. package/std/os/linux/x86_64.zig +41 -12
  35. package/std/os/linux.zig +386 -432
  36. package/std/sort.zig +3 -3
  37. package/std/zig/AstGen.zig +1 -74
  38. package/std/zig/AstRlAnnotate.zig +0 -11
  39. package/std/zig/BuiltinFn.zig +0 -32
  40. package/std/zig/Zir.zig +50 -63
  41. package/std/zig.zig +0 -10
  42. package/zig.h +340 -1
package/c/fcntl.zig CHANGED
@@ -16,7 +16,7 @@ comptime {
16
16
  }
17
17
 
18
18
  fn fallocateLinux(fd: c_int, mode: c_int, offset: off_t, len: off_t) callconv(.c) c_int {
19
- return errno(linux.fallocate(fd, mode, offset, len));
19
+ return errno(linux.fallocate(fd, @bitCast(mode), offset, len));
20
20
  }
21
21
 
22
22
  fn posix_fadviseLinux(fd: c_int, offset: off_t, len: off_t, advice: c_int) callconv(.c) c_int {
@@ -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")) {
@@ -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" },
@@ -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.17.0-dev.27",
3
+ "version": "0.17.0-dev.44",
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
@@ -599,11 +599,15 @@ pub fn writeAll(w: *Writer, bytes: []const u8) Error!void {
599
599
  /// - `u`: integer as an UTF-8 sequence. Integer type must have 21 bits at max.
600
600
  /// - `B`: bytes in SI units (decimal)
601
601
  /// - `Bi`: bytes in IEC units (binary)
602
- /// - `?`: optional value as either the unwrapped value, or `null`; may be followed by a format specifier for the underlying value.
603
- /// - `!`: error union value as either the unwrapped value, or the formatted error value; may be followed by a format specifier for the underlying value.
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.
604
607
  /// - `*`: the address of the value instead of the value itself.
605
608
  /// - `any`: a value of any type using its default format.
606
- /// - `f`: delegates to a method on the type named "format" with the signature `fn (*Writer, args: anytype) Writer.Error!void`.
609
+ /// - `f`: delegates to the `format` method of the type, passing `*Writer` and
610
+ /// expecting `Error!void` returned.
607
611
  ///
608
612
  /// A user type may be a struct, vector, union or enum type.
609
613
  ///
package/std/Target.zig CHANGED
@@ -68,6 +68,8 @@ pub const Os = struct {
68
68
  opengl,
69
69
  vulkan,
70
70
 
71
+ tios,
72
+
71
73
  // LLVM tags deliberately omitted:
72
74
  // - bridgeos
73
75
  // - cheriotrtos
@@ -207,6 +209,8 @@ pub const Os = struct {
207
209
  .opencl,
208
210
  .opengl,
209
211
  .vulkan,
212
+
213
+ .tios,
210
214
  => .semver,
211
215
 
212
216
  .hurd => .hurd,
@@ -670,6 +674,12 @@ pub const Os = struct {
670
674
  .max = .{ .major = 4, .minor = 6, .patch = 0 },
671
675
  },
672
676
  },
677
+ .tios => .{
678
+ .semver = .{
679
+ .min = .{ .major = 5, .minor = 0, .patch = 0 },
680
+ .max = .{ .major = 5, .minor = 8, .patch = 4 },
681
+ },
682
+ },
673
683
  .vulkan => .{
674
684
  .semver = .{
675
685
  .min = .{ .major = 1, .minor = 2, .patch = 0 },
@@ -758,6 +768,7 @@ pub const wasm = @import("Target/wasm.zig");
758
768
  pub const x86 = @import("Target/x86.zig");
759
769
  pub const xcore = @import("Target/xcore.zig");
760
770
  pub const xtensa = @import("Target/xtensa.zig");
771
+ pub const z80 = @import("Target/generic.zig");
761
772
 
762
773
  pub const Abi = enum {
763
774
  none,
@@ -942,6 +953,7 @@ pub const Abi = enum {
942
953
  .opencl,
943
954
  .opengl,
944
955
  .vulkan,
956
+ .tios,
945
957
  => .none,
946
958
  };
947
959
  }
@@ -1068,6 +1080,7 @@ pub fn toElfMachine(target: *const Target) std.elf.EM {
1068
1080
  .avr => .AVR,
1069
1081
  .bpfeb, .bpfel => .BPF,
1070
1082
  .csky => .CSKY,
1083
+ .ez80 => .Z80,
1071
1084
  .hexagon => .QDSP6,
1072
1085
  .hppa, .hppa64 => .PARISC,
1073
1086
  .kalimba => .CSR_KALIMBA,
@@ -1130,6 +1143,7 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE {
1130
1143
  .bpfeb,
1131
1144
  .bpfel,
1132
1145
  .csky,
1146
+ .ez80,
1133
1147
  .hexagon,
1134
1148
  .hppa,
1135
1149
  .hppa64,
@@ -1336,6 +1350,7 @@ pub const Cpu = struct {
1336
1350
  bpfeb,
1337
1351
  bpfel,
1338
1352
  csky,
1353
+ ez80,
1339
1354
  hexagon,
1340
1355
  hppa,
1341
1356
  hppa64,
@@ -1437,6 +1452,7 @@ pub const Cpu = struct {
1437
1452
  x86,
1438
1453
  xcore,
1439
1454
  xtensa,
1455
+ z80,
1440
1456
  };
1441
1457
 
1442
1458
  pub inline fn family(arch: Arch) Family {
@@ -1449,6 +1465,7 @@ pub const Cpu = struct {
1449
1465
  .avr => .avr,
1450
1466
  .bpfeb, .bpfel => .bpf,
1451
1467
  .csky => .csky,
1468
+ .ez80 => .z80,
1452
1469
  .hexagon => .hexagon,
1453
1470
  .hppa, .hppa64 => .hppa,
1454
1471
  .kalimba => .kalimba,
@@ -1678,6 +1695,7 @@ pub const Cpu = struct {
1678
1695
  .x86_64,
1679
1696
  .xcore,
1680
1697
  .xtensa,
1698
+ .ez80,
1681
1699
  => .little,
1682
1700
 
1683
1701
  .aarch64_be,
@@ -1948,6 +1966,10 @@ pub const Cpu = struct {
1948
1966
  .spirv_fragment,
1949
1967
  .spirv_vertex,
1950
1968
  => &.{ .spirv32, .spirv64 },
1969
+
1970
+ .ez80_cet,
1971
+ .ez80_tiflags,
1972
+ => &.{.ez80},
1951
1973
  };
1952
1974
  }
1953
1975
  };
@@ -2236,6 +2258,7 @@ pub fn requiresLibC(target: *const Target) bool {
2236
2258
  .plan9,
2237
2259
  .other,
2238
2260
  .@"3ds",
2261
+ .tios,
2239
2262
  => false,
2240
2263
  };
2241
2264
  }
@@ -2398,6 +2421,8 @@ pub const DynamicLinker = struct {
2398
2421
  .ps5,
2399
2422
  .psp,
2400
2423
  .vita,
2424
+
2425
+ .tios,
2401
2426
  => .none,
2402
2427
  };
2403
2428
  }
@@ -2815,6 +2840,8 @@ pub const DynamicLinker = struct {
2815
2840
  .opencl,
2816
2841
  .opengl,
2817
2842
  .vulkan,
2843
+
2844
+ .tios,
2818
2845
  => none,
2819
2846
 
2820
2847
  // TODO go over each item in this list and either move it to the above list, or
@@ -2849,6 +2876,9 @@ pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
2849
2876
  .x86_16,
2850
2877
  => 16,
2851
2878
 
2879
+ .ez80,
2880
+ => 24,
2881
+
2852
2882
  .arc,
2853
2883
  .arceb,
2854
2884
  .arm,
@@ -2917,6 +2947,8 @@ pub fn ptrBitWidth(target: *const Target) u16 {
2917
2947
  pub fn stackAlignment(target: *const Target) u16 {
2918
2948
  // Overrides for when the stack alignment is not equal to the pointer width.
2919
2949
  switch (target.cpu.arch) {
2950
+ .ez80,
2951
+ => return 1,
2920
2952
  .m68k,
2921
2953
  => return 2,
2922
2954
  .amdgcn,
@@ -2997,6 +3029,7 @@ pub fn cCharSignedness(target: *const Target) std.builtin.Signedness {
2997
3029
  .arc,
2998
3030
  .arceb,
2999
3031
  .csky,
3032
+ .ez80,
3000
3033
  .hexagon,
3001
3034
  .msp430,
3002
3035
  .powerpc,
@@ -3364,6 +3397,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
3364
3397
  .long, .ulong => return 64,
3365
3398
  .longlong, .ulonglong, .double, .longdouble => return 64,
3366
3399
  },
3400
+ .tios => switch (c_type) {
3401
+ .char => return 8,
3402
+ .short, .ushort => return 16,
3403
+ .int, .uint => return 24,
3404
+ .long, .ulong, .float, .double => return 32,
3405
+ .longlong, .ulonglong, .longdouble => return 64,
3406
+ },
3367
3407
 
3368
3408
  .ps3,
3369
3409
  .contiki,
@@ -3376,7 +3416,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
3376
3416
  pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
3377
3417
  // Overrides for unusual alignments
3378
3418
  switch (target.cpu.arch) {
3379
- .avr => return 1,
3419
+ .avr, .ez80 => return 1,
3380
3420
  .x86 => switch (target.os.tag) {
3381
3421
  .windows, .uefi => switch (c_type) {
3382
3422
  .longlong, .ulonglong, .double => return 8,
@@ -3406,6 +3446,8 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
3406
3446
  return @min(
3407
3447
  std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
3408
3448
  @as(u16, switch (target.cpu.arch) {
3449
+ .ez80 => 1,
3450
+
3409
3451
  .msp430,
3410
3452
  .x86_16,
3411
3453
  => 2,
@@ -3484,7 +3526,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
3484
3526
  .longdouble => return 4,
3485
3527
  else => {},
3486
3528
  },
3487
- .avr => return 1,
3529
+ .avr, .ez80 => return 1,
3488
3530
  .x86 => switch (target.os.tag) {
3489
3531
  .windows, .uefi => switch (c_type) {
3490
3532
  .longdouble => switch (target.abi) {
@@ -3516,6 +3558,8 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
3516
3558
  return @min(
3517
3559
  std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
3518
3560
  @as(u16, switch (target.cpu.arch) {
3561
+ .ez80 => 1,
3562
+
3519
3563
  .x86_16, .msp430 => 2,
3520
3564
 
3521
3565
  .arc,
@@ -3587,7 +3631,9 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
3587
3631
 
3588
3632
  pub fn cMaxIntAlignment(target: *const Target) u16 {
3589
3633
  return switch (target.cpu.arch) {
3590
- .avr => 1,
3634
+ .avr,
3635
+ .ez80,
3636
+ => 1,
3591
3637
 
3592
3638
  .msp430, .x86_16 => 2,
3593
3639
 
@@ -3726,6 +3772,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
3726
3772
  .amdgcn => .{ .amdgcn_device = .{} },
3727
3773
  .nvptx, .nvptx64 => .nvptx_device,
3728
3774
  .spirv32, .spirv64 => .spirv_device,
3775
+ .ez80 => .ez80_cet,
3729
3776
  };
3730
3777
  }
3731
3778
 
package/std/builtin.zig CHANGED
@@ -341,6 +341,10 @@ pub const CallingConvention = union(enum(u8)) {
341
341
  spirv_fragment,
342
342
  spirv_vertex,
343
343
 
344
+ // Calling conventions for the `ez80` architecture.
345
+ ez80_cet,
346
+ ez80_tiflags,
347
+
344
348
  /// Options shared across most calling conventions.
345
349
  pub const CommonOptions = struct {
346
350
  /// The boundary the stack is aligned to when the function is called.
package/std/fmt.zig CHANGED
@@ -1342,9 +1342,9 @@ pub const hex_charset = "0123456789abcdef";
1342
1342
 
1343
1343
  /// Converts an unsigned integer of any multiple of u8 to an array of lowercase
1344
1344
  /// hex bytes, little endian.
1345
- pub fn hex(x: anytype) [@sizeOf(@TypeOf(x)) * 2]u8 {
1345
+ pub fn hex(x: anytype) [@typeInfo(@TypeOf(x)).int.bits / 4]u8 {
1346
1346
  comptime assert(@typeInfo(@TypeOf(x)).int.signedness == .unsigned);
1347
- var result: [@sizeOf(@TypeOf(x)) * 2]u8 = undefined;
1347
+ var result: [@typeInfo(@TypeOf(x)).int.bits / 4]u8 = undefined;
1348
1348
  var i: usize = 0;
1349
1349
  while (i < result.len / 2) : (i += 1) {
1350
1350
  const byte: u8 = @truncate(x >> @intCast(8 * i));
@@ -1360,6 +1360,11 @@ test hex {
1360
1360
  try std.testing.expect(x.len == 8);
1361
1361
  try std.testing.expectEqualStrings("efbeadde", &x);
1362
1362
  }
1363
+ {
1364
+ const s = "[" ++ hex(@as(u48, 0x12345678_abcd)) ++ "]";
1365
+ try std.testing.expect(s.len == 14);
1366
+ try std.testing.expectEqualStrings("[cdab78563412]", s);
1367
+ }
1363
1368
  {
1364
1369
  const s = "[" ++ hex(@as(u64, 0x12345678_abcdef00)) ++ "]";
1365
1370
  try std.testing.expect(s.len == 18);