@zigc/lib 0.16.0 → 0.17.0-dev.131

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 (155) 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/pthread.zig +57 -0
  5. package/c/search.zig +1 -27
  6. package/c/stdlib/drand48.zig +0 -57
  7. package/c/stdlib.zig +0 -100
  8. package/c/string.zig +20 -7
  9. package/c/strings.zig +0 -38
  10. package/c/unistd.zig +27 -26
  11. package/c/wchar.zig +10 -0
  12. package/c.zig +2 -2
  13. package/compiler/aro/aro/CodeGen.zig +5 -6
  14. package/compiler/aro/aro/Compilation.zig +17 -14
  15. package/compiler/aro/aro/Driver.zig +14 -13
  16. package/compiler/aro/aro/Parser.zig +20 -15
  17. package/compiler/aro/aro/Pragma.zig +3 -2
  18. package/compiler/aro/aro/Preprocessor.zig +9 -6
  19. package/compiler/aro/aro/pragmas/message.zig +3 -2
  20. package/compiler/aro/aro/text_literal.zig +3 -2
  21. package/compiler/aro/assembly_backend/x86_64.zig +4 -4
  22. package/compiler/build_runner.zig +0 -2
  23. package/compiler/reduce/Walk.zig +7 -7
  24. package/compiler/test_runner.zig +2 -2
  25. package/compiler/translate-c/Translator.zig +6 -2
  26. package/compiler/translate-c/main.zig +1 -1
  27. package/compiler_rt/cos.zig +0 -2
  28. package/compiler_rt/divmodei4.zig +40 -17
  29. package/compiler_rt/exp.zig +1 -6
  30. package/compiler_rt/exp2.zig +1 -6
  31. package/compiler_rt/exp_f128.zig +377 -0
  32. package/compiler_rt/fabs.zig +0 -2
  33. package/compiler_rt/fma.zig +0 -2
  34. package/compiler_rt/fmax.zig +0 -2
  35. package/compiler_rt/fmin.zig +0 -2
  36. package/compiler_rt/fmod.zig +0 -2
  37. package/compiler_rt/limb64.zig +876 -15
  38. package/compiler_rt/log.zig +0 -2
  39. package/compiler_rt/log10.zig +0 -2
  40. package/compiler_rt/log2.zig +0 -2
  41. package/compiler_rt/mulXi3.zig +1 -1
  42. package/compiler_rt/round.zig +0 -2
  43. package/compiler_rt/sin.zig +0 -2
  44. package/compiler_rt/sincos.zig +0 -2
  45. package/compiler_rt/sqrt.zig +0 -2
  46. package/compiler_rt/ssp.zig +1 -1
  47. package/compiler_rt/tan.zig +0 -2
  48. package/compiler_rt/trunc.zig +0 -2
  49. package/compiler_rt/udivmodei4.zig +28 -0
  50. package/fuzzer.zig +2 -0
  51. package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
  52. package/package.json +1 -1
  53. package/std/Build/Cache.zig +6 -6
  54. package/std/Build/Step/Compile.zig +0 -1
  55. package/std/Build/Step/Run.zig +2 -2
  56. package/std/Build/Step.zig +2 -4
  57. package/std/Build/WebServer.zig +2 -2
  58. package/std/Build.zig +0 -3
  59. package/std/Io/Dir.zig +7 -2
  60. package/std/Io/Dispatch.zig +3 -13
  61. package/std/Io/File/Writer.zig +8 -6
  62. package/std/Io/Reader.zig +8 -9
  63. package/std/Io/Semaphore.zig +112 -17
  64. package/std/Io/Terminal.zig +1 -1
  65. package/std/Io/Threaded.zig +171 -37
  66. package/std/Io/Uring.zig +13 -15
  67. package/std/Io/Writer.zig +46 -42
  68. package/std/Io/net.zig +11 -11
  69. package/std/Io.zig +90 -26
  70. package/std/SemanticVersion.zig +1 -1
  71. package/std/Target/Query.zig +2 -2
  72. package/std/Target.zig +50 -5
  73. package/std/array_hash_map.zig +9 -18
  74. package/std/builtin.zig +4 -0
  75. package/std/c/haiku.zig +3 -0
  76. package/std/c/serenity.zig +1 -6
  77. package/std/c.zig +89 -7
  78. package/std/compress/flate/Decompress.zig +2 -3
  79. package/std/compress/zstd/Decompress.zig +2 -4
  80. package/std/crypto/Certificate.zig +13 -1
  81. package/std/crypto/ascon.zig +75 -33
  82. package/std/crypto/codecs/asn1/Oid.zig +12 -1
  83. package/std/crypto/codecs/base64_hex_ct.zig +2 -4
  84. package/std/crypto/ml_kem.zig +2 -9
  85. package/std/crypto/tls/Client.zig +79 -4
  86. package/std/crypto/tls.zig +1 -1
  87. package/std/crypto.zig +1 -0
  88. package/std/debug/Pdb.zig +1 -1
  89. package/std/debug.zig +4 -3
  90. package/std/fmt.zig +8 -3
  91. package/std/fs/path.zig +6 -4
  92. package/std/heap/BufferFirstAllocator.zig +165 -0
  93. package/std/heap.zig +2 -126
  94. package/std/http/Client.zig +21 -24
  95. package/std/http.zig +3 -4
  96. package/std/json/Scanner.zig +2 -2
  97. package/std/os/emscripten.zig +1 -1
  98. package/std/os/linux/IoUring.zig +2 -0
  99. package/std/os/linux/aarch64.zig +41 -12
  100. package/std/os/linux/arc.zig +173 -0
  101. package/std/os/linux/arm.zig +41 -12
  102. package/std/os/linux/hexagon.zig +33 -11
  103. package/std/os/linux/loongarch32.zig +41 -13
  104. package/std/os/linux/loongarch64.zig +41 -12
  105. package/std/os/linux/m68k.zig +41 -13
  106. package/std/os/linux/mips.zig +67 -36
  107. package/std/os/linux/mips64.zig +60 -29
  108. package/std/os/linux/mipsn32.zig +60 -29
  109. package/std/os/linux/or1k.zig +41 -12
  110. package/std/os/linux/powerpc.zig +41 -12
  111. package/std/os/linux/powerpc64.zig +41 -12
  112. package/std/os/linux/riscv32.zig +41 -12
  113. package/std/os/linux/riscv64.zig +41 -12
  114. package/std/os/linux/s390x.zig +44 -7
  115. package/std/os/linux/sparc64.zig +83 -52
  116. package/std/os/linux/thumb.zig +52 -36
  117. package/std/os/linux/x32.zig +41 -12
  118. package/std/os/linux/x86.zig +42 -13
  119. package/std/os/linux/x86_64.zig +41 -12
  120. package/std/os/linux.zig +412 -436
  121. package/std/os/uefi/tables/boot_services.zig +9 -8
  122. package/std/os.zig +41 -0
  123. package/std/process.zig +1 -1
  124. package/std/sort.zig +3 -3
  125. package/std/zig/Ast/Render.zig +3 -3
  126. package/std/zig/AstGen.zig +44 -98
  127. package/std/zig/AstRlAnnotate.zig +0 -11
  128. package/std/zig/BuiltinFn.zig +0 -32
  129. package/std/zig/LibCInstallation.zig +4 -3
  130. package/std/zig/Parse.zig +7 -7
  131. package/std/zig/WindowsSdk.zig +13 -13
  132. package/std/zig/Zir.zig +50 -63
  133. package/std/zig/ZonGen.zig +6 -5
  134. package/std/zig/llvm/Builder.zig +12 -12
  135. package/std/zig.zig +1 -10
  136. package/std/zip.zig +5 -5
  137. package/zig.h +340 -1
  138. package/libc/mingw/math/fdiml.c +0 -24
  139. package/libc/mingw/winpthreads/spinlock.c +0 -82
  140. package/libc/musl/src/linux/tee.c +0 -8
  141. package/libc/musl/src/math/fdimf.c +0 -10
  142. package/libc/musl/src/math/fdiml.c +0 -18
  143. package/libc/musl/src/string/strdup.c +0 -10
  144. package/libc/musl/src/string/strndup.c +0 -12
  145. package/libc/musl/src/string/wcsdup.c +0 -10
  146. package/libc/musl/src/thread/pthread_spin_destroy.c +0 -6
  147. package/libc/musl/src/thread/pthread_spin_init.c +0 -6
  148. package/libc/musl/src/thread/pthread_spin_lock.c +0 -8
  149. package/libc/musl/src/thread/pthread_spin_trylock.c +0 -7
  150. package/libc/musl/src/thread/pthread_spin_unlock.c +0 -7
  151. package/libc/musl/src/unistd/dup2.c +0 -20
  152. package/libc/musl/src/unistd/dup3.c +0 -26
  153. package/libc/wasi/thread-stub/pthread_spin_lock.c +0 -8
  154. package/libc/wasi/thread-stub/pthread_spin_trylock.c +0 -8
  155. package/libc/wasi/thread-stub/pthread_spin_unlock.c +0 -7
@@ -280,8 +280,7 @@ pub fn Custom(
280
280
  if (it.index >= it.len) return null;
281
281
  const result = Entry{
282
282
  .key_ptr = &it.keys[it.index],
283
- // workaround for #6974
284
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &it.values[it.index],
283
+ .value_ptr = &it.values[it.index],
285
284
  };
286
285
  it.index += 1;
287
286
  return result;
@@ -323,8 +322,7 @@ pub fn Custom(
323
322
  const slice = self.entries.slice();
324
323
  return GetOrPutResult{
325
324
  .key_ptr = &slice.items(.key)[index],
326
- // workaround for #6974
327
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[index],
325
+ .value_ptr = &slice.items(.value)[index],
328
326
  .found_existing = true,
329
327
  .index = index,
330
328
  };
@@ -369,8 +367,7 @@ pub fn Custom(
369
367
  if (hashes_array[i] == h and checkedEql(ctx, key, item_key.*, i)) {
370
368
  return GetOrPutResult{
371
369
  .key_ptr = item_key,
372
- // workaround for #6974
373
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[i],
370
+ .value_ptr = &slice.items(.value)[i],
374
371
  .found_existing = true,
375
372
  .index = i,
376
373
  };
@@ -383,8 +380,7 @@ pub fn Custom(
383
380
 
384
381
  return GetOrPutResult{
385
382
  .key_ptr = &keys_array.ptr[index],
386
- // workaround for #6974
387
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value).ptr[index],
383
+ .value_ptr = &slice.items(.value).ptr[index],
388
384
  .found_existing = false,
389
385
  .index = index,
390
386
  };
@@ -569,8 +565,7 @@ pub fn Custom(
569
565
  const slice = self.entries.slice();
570
566
  return Entry{
571
567
  .key_ptr = &slice.items(.key)[index],
572
- // workaround for #6974
573
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &slice.items(.value)[index],
568
+ .value_ptr = &slice.items(.value)[index],
574
569
  };
575
570
  }
576
571
 
@@ -634,8 +629,7 @@ pub fn Custom(
634
629
  }
635
630
  pub fn getPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*V {
636
631
  const index = self.getIndexAdapted(key, ctx) orelse return null;
637
- // workaround for #6974
638
- return if (@sizeOf(*V) == 0) @as(*V, undefined) else &self.values()[index];
632
+ return &self.values()[index];
639
633
  }
640
634
 
641
635
  /// Find the actual key associated with an adapted key
@@ -1314,8 +1308,7 @@ pub fn Custom(
1314
1308
  return .{
1315
1309
  .found_existing = false,
1316
1310
  .key_ptr = &keys_array.ptr[new_index],
1317
- // workaround for #6974
1318
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array.ptr[new_index],
1311
+ .value_ptr = &values_array.ptr[new_index],
1319
1312
  .index = new_index,
1320
1313
  };
1321
1314
  }
@@ -1328,8 +1321,7 @@ pub fn Custom(
1328
1321
  return .{
1329
1322
  .found_existing = true,
1330
1323
  .key_ptr = &keys_array[slot_data.entry_index],
1331
- // workaround for #6974
1332
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array[slot_data.entry_index],
1324
+ .value_ptr = &values_array[slot_data.entry_index],
1333
1325
  .index = slot_data.entry_index,
1334
1326
  };
1335
1327
  }
@@ -1370,8 +1362,7 @@ pub fn Custom(
1370
1362
  return .{
1371
1363
  .found_existing = false,
1372
1364
  .key_ptr = &keys_array.ptr[new_index],
1373
- // workaround for #6974
1374
- .value_ptr = if (@sizeOf(*V) == 0) undefined else &values_array.ptr[new_index],
1365
+ .value_ptr = &values_array.ptr[new_index],
1375
1366
  .index = new_index,
1376
1367
  };
1377
1368
  }
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/c/haiku.zig CHANGED
@@ -6,6 +6,7 @@ const iovec = std.posix.iovec;
6
6
  const iovec_const = std.posix.iovec_const;
7
7
  const socklen_t = std.c.socklen_t;
8
8
  const fd_t = std.c.fd_t;
9
+ const off_t = std.c.off_t;
9
10
  const PATH_MAX = std.c.PATH_MAX;
10
11
  const uid_t = std.c.uid_t;
11
12
  const gid_t = std.c.gid_t;
@@ -28,6 +29,8 @@ pub extern "root" fn _kern_open_dir(fd: fd_t, path: [*:0]const u8) fd_t;
28
29
  pub extern "root" fn _kern_read_dir(fd: fd_t, buffer: [*]u8, bufferSize: usize, maxCount: u32) isize;
29
30
  pub extern "root" fn _kern_rewind_dir(fd: fd_t) status_t;
30
31
  pub extern "root" fn _kern_read_stat(fd: fd_t, path: [*:0]const u8, traverseLink: bool, stat: *std.c.Stat, statSize: usize) status_t;
32
+ pub extern "root" fn readv_pos(fd: fd_t, pos: off_t, vec: [*]const std.c.iovec, count: i32) isize;
33
+ pub extern "root" fn writev_pos(fd: fd_t, pos: off_t, vec: [*]const std.c.iovec_const, count: i32) isize;
31
34
 
32
35
  pub const area_info = extern struct {
33
36
  area: u32,
@@ -53,9 +53,7 @@ pub extern "c" fn profiling_enable(pid: pid_t, event_mask: PERF_EVENT) c_int;
53
53
  pub extern "c" fn profiling_disable(pid: pid_t) c_int;
54
54
  pub extern "c" fn profiling_free_buffer(pid: pid_t) c_int;
55
55
 
56
- pub extern "c" fn futex(userspace_address: *u32, futex_op: c_int, value: u32, timeout: *const timespec, userspace_address2: *u32, value3: u32) c_int;
57
- pub extern "c" fn futex_wait(userspace_address: *u32, value: u32, abstime: *const timespec, clockid: clockid_t, process_shared: c_int) c_int;
58
- pub extern "c" fn futex_wake(userspace_address: *u32, count: u32, process_shared: c_int) c_int;
56
+ pub extern "c" fn futex(userspace_address: *u32, futex_op: c_int, value: u32, timeout: ?*const timespec, userspace_address2: ?*u32, value3: u32) c_int;
59
57
 
60
58
  pub extern "c" fn purge(mode: c_int) c_int;
61
59
 
@@ -66,9 +64,6 @@ pub extern "c" fn get_stack_bounds(user_stack_base: *usize, user_stack_size: *us
66
64
 
67
65
  pub extern "c" fn anon_create(size: usize, options: O) c_int;
68
66
 
69
- pub extern "c" fn serenity_readlink(path: [*]const u8, path_length: usize, buffer: [*]u8, buffer_size: usize) c_int;
70
- pub extern "c" fn serenity_open(path: [*]const u8, path_length: usize, options: c_int, ...) c_int;
71
-
72
67
  pub extern "c" fn getkeymap(name_buffer: [*]u8, name_buffer_size: usize, map: [*]u32, shift_map: [*]u32, alt_map: [*]u32, altgr_map: [*]u32, shift_altgr_map: [*]u32) c_int;
73
68
  pub extern "c" fn setkeymap(name: [*]const u8, map: [*]const u32, shift_map: [*]const u32, alt_map: [*]const u32, altgr_map: [*]const u32, shift_altgr_map: [*]const u32) c_int;
74
69
 
package/std/c.zig CHANGED
@@ -3260,8 +3260,8 @@ pub const Sigaction = switch (native_os) {
3260
3260
 
3261
3261
  /// signal handler
3262
3262
  handler: extern union {
3263
- handler: handler_fn,
3264
- sigaction: sigaction_fn,
3263
+ handler: ?handler_fn,
3264
+ sigaction: ?sigaction_fn,
3265
3265
  },
3266
3266
 
3267
3267
  /// signal mask to apply
@@ -7898,6 +7898,20 @@ pub const Stat = switch (native_os) {
7898
7898
  else => void,
7899
7899
  };
7900
7900
 
7901
+ pub const pthread_spinlock_t = switch (native_os) {
7902
+ .openbsd => openbsd.pthread_spinlock_t,
7903
+ .freebsd => extern struct {
7904
+ inner: ?*anyopaque = null,
7905
+ },
7906
+ .netbsd => extern struct {
7907
+ pts_magic: c_uint,
7908
+ spin: pthread_spin_t,
7909
+ pts_flags: c_int,
7910
+ },
7911
+ .windows => isize,
7912
+ else => c_int,
7913
+ };
7914
+
7901
7915
  pub const pthread_mutex_t = switch (native_os) {
7902
7916
  .linux => extern struct {
7903
7917
  data: [data_len]u8 align(@alignOf(usize)) = [_]u8{0} ** data_len,
@@ -10956,6 +10970,19 @@ pub extern "c" fn dn_expand(
10956
10970
  length: c_int,
10957
10971
  ) c_int;
10958
10972
 
10973
+ pub const PTHREAD_PROCESS_PRIVATE: c_int = if (native_os.isDarwin())
10974
+ 2
10975
+ else
10976
+ 0;
10977
+
10978
+ pub const PTHREAD_PROCESS_SHARED: c_int = 1;
10979
+
10980
+ pub extern "c" fn pthread_spin_init(spin: *pthread_spinlock_t, pshared: c_int) c_int;
10981
+ pub extern "c" fn pthread_spin_lock(spin: *pthread_spinlock_t) c_int;
10982
+ pub extern "c" fn pthread_spin_unlock(spin: *pthread_spinlock_t) c_int;
10983
+ pub extern "c" fn pthread_spin_trylock(spin: *pthread_spinlock_t) c_int;
10984
+ pub extern "c" fn pthread_spin_destroy(spin: *pthread_spinlock_t) c_int;
10985
+
10959
10986
  pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = .{};
10960
10987
  pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) E;
10961
10988
  pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) E;
@@ -11102,6 +11129,64 @@ pub const ioctl = switch (native_os) {
11102
11129
  else => private.ioctl,
11103
11130
  };
11104
11131
 
11132
+ pub extern "c" fn bzero(s: *anyopaque, n: usize) void;
11133
+
11134
+ pub extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void;
11135
+
11136
+ pub extern "c" fn strncmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int;
11137
+ pub extern "c" fn strcasecmp(a: [*:0]const c_char, b: [*:0]const c_char) c_int;
11138
+ pub extern "c" fn strncasecmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int;
11139
+ pub extern "c" fn strdup(s: [*:0]const c_char) ?[*:0]c_char;
11140
+ pub extern "c" fn strndup(s: [*:0]const c_char, n: usize) ?[*:0]c_char;
11141
+ pub extern "c" fn wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t;
11142
+
11143
+ pub extern "c" fn ffs(i: c_int) c_int;
11144
+ pub extern "c" fn ffsl(i: c_long) c_long;
11145
+ pub extern "c" fn ffsll(i: c_longlong) c_longlong;
11146
+
11147
+ pub extern "c" fn erand48(xsubi: *[3]c_ushort) f64;
11148
+ pub extern "c" fn jrand48(xsubi: *[3]c_ushort) c_long;
11149
+ pub extern "c" fn nrand48(xsubi: *[3]c_ushort) c_long;
11150
+
11151
+ pub extern "c" fn insque(element: *anyopaque, pred: ?*anyopaque) void;
11152
+ pub extern "c" fn remque(element: *anyopaque) void;
11153
+
11154
+ pub extern "c" fn imaxabs(a: intmax_t) intmax_t;
11155
+ pub extern "c" fn imaxdiv(a: intmax_t, b: intmax_t) imaxdiv_t;
11156
+
11157
+ pub extern "c" fn abs(a: c_int) c_int;
11158
+ pub extern "c" fn labs(a: c_long) c_long;
11159
+ pub extern "c" fn llabs(a: c_longlong) c_longlong;
11160
+
11161
+ pub extern "c" fn div(a: c_int, b: c_int) div_t;
11162
+ pub extern "c" fn ldiv(a: c_long, b: c_long) ldiv_t;
11163
+ pub extern "c" fn lldiv(a: c_longlong, b: c_longlong) lldiv_t;
11164
+
11165
+ pub extern "c" fn atoi(str: [*:0]const c_char) c_int;
11166
+ pub extern "c" fn atol(str: [*:0]const c_char) c_long;
11167
+ pub extern "c" fn atoll(str: [*:0]const c_char) c_longlong;
11168
+
11169
+ pub extern "c" fn bsearch(
11170
+ key: *const anyopaque,
11171
+ base: *const anyopaque,
11172
+ n: usize,
11173
+ size: usize,
11174
+ compare: *const fn (a: *const anyopaque, b: *const anyopaque) callconv(.c) c_int,
11175
+ ) ?*anyopaque;
11176
+
11177
+ // Math
11178
+ pub extern "c" fn atan(x: f64) f64;
11179
+ pub extern "c" fn copysign(x: f64, y: f64) f64;
11180
+ pub extern "c" fn fdim(x: f64, y: f64) f64;
11181
+ pub extern "c" fn frexp(x: f64, e: *c_int) f64;
11182
+ pub extern "c" fn hypot(x: f64, y: f64) f64;
11183
+ pub extern "c" fn modff(x: f32, iptr: *f32) f32;
11184
+ pub extern "c" fn modf(x: f64, iptr: *f64) f64;
11185
+ pub extern "c" fn modfl(x: c_longdouble, iptr: *c_longdouble) c_longdouble;
11186
+ pub extern "c" fn rintf(x: f32) f32;
11187
+ pub extern "c" fn rint(x: f64) f64;
11188
+ pub extern "c" fn rintl(x: c_longdouble) c_longdouble;
11189
+
11105
11190
  // OS-specific bits. These are protected from being used on the wrong OS by
11106
11191
  // comptime assertions inside each OS-specific file.
11107
11192
 
@@ -11142,6 +11227,8 @@ pub const _kern_open_dir = haiku._kern_open_dir;
11142
11227
  pub const _kern_read_dir = haiku._kern_read_dir;
11143
11228
  pub const _kern_read_stat = haiku._kern_read_stat;
11144
11229
  pub const _kern_rewind_dir = haiku._kern_rewind_dir;
11230
+ pub const readv_pos = haiku.readv_pos;
11231
+ pub const writev_pos = haiku.writev_pos;
11145
11232
  pub const area_id = haiku.area_id;
11146
11233
  pub const area_info = haiku.area_info;
11147
11234
  pub const directory_which = haiku.directory_which;
@@ -11211,7 +11298,6 @@ pub const login_getcaptime = openbsd.login_getcaptime;
11211
11298
  pub const login_getclass = openbsd.login_getclass;
11212
11299
  pub const login_getstyle = openbsd.login_getstyle;
11213
11300
  pub const pledge = openbsd.pledge;
11214
- pub const pthread_spinlock_t = openbsd.pthread_spinlock_t;
11215
11301
  pub const pw_dup = openbsd.pw_dup;
11216
11302
  pub const setclasscontext = openbsd.setclasscontext;
11217
11303
  pub const setpassent = openbsd.setpassent;
@@ -11449,15 +11535,11 @@ pub const disown = serenity.disown;
11449
11535
  pub const profiling_enable = serenity.profiling_enable;
11450
11536
  pub const profiling_disable = serenity.profiling_disable;
11451
11537
  pub const profiling_free_buffer = serenity.profiling_free_buffer;
11452
- pub const futex_wait = serenity.futex_wait;
11453
- pub const futex_wake = serenity.futex_wake;
11454
11538
  pub const purge = serenity.purge;
11455
11539
  pub const perf_event = serenity.perf_event;
11456
11540
  pub const perf_register_string = serenity.perf_register_string;
11457
11541
  pub const get_stack_bounds = serenity.get_stack_bounds;
11458
11542
  pub const anon_create = serenity.anon_create;
11459
- pub const serenity_readlink = serenity.serenity_readlink;
11460
- pub const serenity_open = serenity.serenity_open;
11461
11543
  pub const getkeymap = serenity.getkeymap;
11462
11544
  pub const setkeymap = serenity.setkeymap;
11463
11545
 
@@ -129,8 +129,7 @@ fn discardDirect(r: *Reader, limit: std.Io.Limit) Reader.Error!usize {
129
129
  }
130
130
  const n = r.stream(&writer, limit) catch |err| switch (err) {
131
131
  error.WriteFailed => unreachable,
132
- error.ReadFailed => return error.ReadFailed,
133
- error.EndOfStream => return error.EndOfStream,
132
+ error.ReadFailed, error.EndOfStream => |e| return e,
134
133
  };
135
134
  assert(n <= @intFromEnum(limit));
136
135
  return n;
@@ -258,7 +257,7 @@ fn streamFallible(d: *Decompress, w: *Writer, limit: std.Io.Limit) Reader.Stream
258
257
  return error.ReadFailed;
259
258
  }
260
259
  },
261
- error.WriteFailed => return error.WriteFailed,
260
+ error.WriteFailed => |e| return e,
262
261
  else => |e| {
263
262
  // In the event of an error, state is unmodified so that it can be
264
263
  // better used to diagnose the failure.
@@ -173,8 +173,7 @@ fn discardDirect(r: *Reader, limit: std.Io.Limit) Reader.Error!usize {
173
173
  }
174
174
  const n = r.stream(&writer, limit) catch |err| switch (err) {
175
175
  error.WriteFailed => unreachable,
176
- error.ReadFailed => return error.ReadFailed,
177
- error.EndOfStream => return error.EndOfStream,
176
+ error.ReadFailed, error.EndOfStream => |e| return e,
178
177
  };
179
178
  assert(n <= @intFromEnum(limit));
180
179
  return n;
@@ -252,8 +251,7 @@ fn stream(d: *Decompress, w: *Writer, limit: Limit) Reader.StreamError!usize {
252
251
  },
253
252
  .in_frame => |*in_frame| {
254
253
  return readInFrame(d, w, limit, in_frame) catch |err| switch (err) {
255
- error.ReadFailed => return error.ReadFailed,
256
- error.WriteFailed => return error.WriteFailed,
254
+ error.ReadFailed, error.WriteFailed => |e| return e,
257
255
  else => |e| {
258
256
  d.err = e;
259
257
  return error.ReadFailed;
@@ -580,7 +580,10 @@ pub fn parseTime(cert: Certificate, elem: der.Element) ParseTimeError!u64 {
580
580
  return error.CertificateTimeInvalid;
581
581
 
582
582
  return Date.toSeconds(.{
583
- .year = @as(u16, 2000) + try parseTimeDigits(bytes[0..2], 0, 99),
583
+ .year = blk: {
584
+ const year = try parseTimeDigits(bytes[0..2], 0, 99);
585
+ break :blk if (year < 50) @as(u16, 2000) + year else @as(u16, 1900) + year;
586
+ },
584
587
  .month = try parseTimeDigits(bytes[2..4], 1, 12),
585
588
  .day = try parseTimeDigits(bytes[4..6], 1, 31),
586
589
  .hour = try parseTimeDigits(bytes[6..8], 0, 23),
@@ -670,6 +673,15 @@ pub fn parseTimeDigits(text: *const [2]u8, min: u8, max: u8) !u8 {
670
673
  return @intCast(result);
671
674
  }
672
675
 
676
+ test "parseTime UTCTime year mapping per RFC 5280" {
677
+ const utc_time_id: der.Identifier = .{ .tag = .utc_time, .pc = .primitive, .class = .universal };
678
+ const elem = der.Element{ .identifier = utc_time_id, .slice = .{ .start = 0, .end = 13 } };
679
+ const cert49 = Certificate{ .buffer = "490101000000Z", .index = 0 };
680
+ try std.testing.expectEqual(@as(u64, 2493072000), try cert49.parseTime(elem));
681
+ const cert99 = Certificate{ .buffer = "990101000000Z", .index = 0 };
682
+ try std.testing.expectEqual(@as(u64, 915148800), try cert99.parseTime(elem));
683
+ }
684
+
673
685
  test parseTimeDigits {
674
686
  const expectEqual = std.testing.expectEqual;
675
687
  try expectEqual(@as(u8, 0), try parseTimeDigits("00", 0, 99));
@@ -681,6 +681,8 @@ pub const AsconXof128 = struct {
681
681
 
682
682
  st: AsconState,
683
683
  squeezed: bool,
684
+ buf: [block_length]u8,
685
+ buf_len: usize,
684
686
 
685
687
  pub const Options = struct {};
686
688
 
@@ -698,7 +700,7 @@ pub const AsconXof128 = struct {
698
700
  const words: [5]u64 = .{ iv, 0, 0, 0, 0 };
699
701
  var st = AsconState.initFromWords(words);
700
702
  st.permuteR(12);
701
- return AsconXof128{ .st = st, .squeezed = false };
703
+ return AsconXof128{ .st = st, .squeezed = false, .buf = @splat(0), .buf_len = 0 };
702
704
  }
703
705
 
704
706
  /// Hash a slice of bytes with variable-length output.
@@ -726,24 +728,26 @@ pub const AsconXof128 = struct {
726
728
 
727
729
  var i: usize = 0;
728
730
 
729
- // Process full 64-bit blocks
730
- while (i + 8 <= b.len) : (i += 8) {
731
- self.st.addBytes(b[i..][0..8]);
731
+ if (self.buf_len > 0) {
732
+ const to_fill = @min(block_length - self.buf_len, b.len);
733
+ @memcpy(self.buf[self.buf_len..][0..to_fill], b[0..to_fill]);
734
+ self.buf_len += to_fill;
735
+ i += to_fill;
736
+ if (self.buf_len == block_length) {
737
+ self.st.addBytes(&self.buf);
738
+ self.st.permuteR(12);
739
+ self.buf_len = 0;
740
+ }
741
+ }
742
+
743
+ while (i + block_length <= b.len) : (i += block_length) {
744
+ self.st.addBytes(b[i..][0..block_length]);
732
745
  self.st.permuteR(12);
733
746
  }
734
747
 
735
- // Store partial block for finalization
736
748
  if (i < b.len) {
737
- var padded: [8]u8 = @splat(0);
738
- const remaining = b.len - i;
739
- @memcpy(padded[0..remaining], b[i..]);
740
- padded[remaining] = 0x01;
741
- self.st.addBytes(&padded);
742
- } else {
743
- // Add padding block
744
- var padded: [8]u8 = @splat(0);
745
- padded[0] = 0x01;
746
- self.st.addBytes(&padded);
749
+ self.buf_len = b.len - i;
750
+ @memcpy(self.buf[0..self.buf_len], b[i..]);
747
751
  }
748
752
  }
749
753
 
@@ -756,7 +760,10 @@ pub const AsconXof128 = struct {
756
760
  /// After first call, no more data can be absorbed with update().
757
761
  pub fn squeeze(self: *AsconXof128, out: []u8) void {
758
762
  if (!self.squeezed) {
759
- // First squeeze - apply final permutation
763
+ var padded: [block_length]u8 = @splat(0);
764
+ @memcpy(padded[0..self.buf_len], self.buf[0..self.buf_len]);
765
+ padded[self.buf_len] = 0x01;
766
+ self.st.addBytes(&padded);
760
767
  self.st.permuteR(12);
761
768
  self.squeezed = true;
762
769
  }
@@ -783,6 +790,8 @@ pub const AsconCxof128 = struct {
783
790
 
784
791
  st: AsconState,
785
792
  squeezed: bool,
793
+ buf: [block_length]u8,
794
+ buf_len: usize,
786
795
 
787
796
  pub const Options = struct { custom: []const u8 = "" };
788
797
 
@@ -804,7 +813,7 @@ pub const AsconCxof128 = struct {
804
813
  var st = AsconState.initFromWords(words);
805
814
  st.permuteR(12);
806
815
 
807
- var self = AsconCxof128{ .st = st, .squeezed = false };
816
+ var self = AsconCxof128{ .st = st, .squeezed = false, .buf = @splat(0), .buf_len = 0 };
808
817
 
809
818
  // Process customization string - always process length and padding
810
819
  // First block: length of customization string
@@ -867,28 +876,30 @@ pub const AsconCxof128 = struct {
867
876
  ///
868
877
  /// Note: Cannot be called after squeeze() has been called
869
878
  pub fn update(self: *AsconCxof128, b: []const u8) void {
870
- debug.assert(!self.squeezed);
879
+ debug.assert(!self.squeezed); // Cannot update after squeezing
871
880
 
872
881
  var i: usize = 0;
873
882
 
874
- // Process full 64-bit blocks
875
- while (i + 8 <= b.len) : (i += 8) {
876
- self.st.addBytes(b[i..][0..8]);
883
+ if (self.buf_len > 0) {
884
+ const to_fill = @min(block_length - self.buf_len, b.len);
885
+ @memcpy(self.buf[self.buf_len..][0..to_fill], b[0..to_fill]);
886
+ self.buf_len += to_fill;
887
+ i += to_fill;
888
+ if (self.buf_len == block_length) {
889
+ self.st.addBytes(&self.buf);
890
+ self.st.permuteR(12);
891
+ self.buf_len = 0;
892
+ }
893
+ }
894
+
895
+ while (i + block_length <= b.len) : (i += block_length) {
896
+ self.st.addBytes(b[i..][0..block_length]);
877
897
  self.st.permuteR(12);
878
898
  }
879
899
 
880
- // Store partial block for finalization
881
900
  if (i < b.len) {
882
- var padded: [8]u8 = @splat(0);
883
- const remaining = b.len - i;
884
- @memcpy(padded[0..remaining], b[i..]);
885
- padded[remaining] = 0x01;
886
- self.st.addBytes(&padded);
887
- } else {
888
- // Add padding block
889
- var padded: [8]u8 = @splat(0);
890
- padded[0] = 0x01;
891
- self.st.addBytes(&padded);
901
+ self.buf_len = b.len - i;
902
+ @memcpy(self.buf[0..self.buf_len], b[i..]);
892
903
  }
893
904
  }
894
905
 
@@ -901,7 +912,10 @@ pub const AsconCxof128 = struct {
901
912
  /// After first call, no more data can be absorbed with update().
902
913
  pub fn squeeze(self: *AsconCxof128, out: []u8) void {
903
914
  if (!self.squeezed) {
904
- // First squeeze - apply final permutation
915
+ var padded: [block_length]u8 = @splat(0);
916
+ @memcpy(padded[0..self.buf_len], self.buf[0..self.buf_len]);
917
+ padded[self.buf_len] = 0x01;
918
+ self.st.addBytes(&padded);
905
919
  self.st.permuteR(12);
906
920
  self.squeezed = true;
907
921
  }
@@ -1267,6 +1281,34 @@ test "Ascon-XOF128 official test vectors" {
1267
1281
  }
1268
1282
  }
1269
1283
 
1284
+ test "Ascon-XOF128/CXOF128 streaming chunking invariance" {
1285
+ const msg = "Hello, World!";
1286
+
1287
+ // XOF128: one-shot vs split must match
1288
+ var out1: [32]u8 = undefined;
1289
+ var out2: [32]u8 = undefined;
1290
+ var xof1 = AsconXof128.init(.{});
1291
+ xof1.update(msg);
1292
+ xof1.squeeze(&out1);
1293
+ var xof2 = AsconXof128.init(.{});
1294
+ xof2.update("Hello, ");
1295
+ xof2.update("World!");
1296
+ xof2.squeeze(&out2);
1297
+ try testing.expectEqualSlices(u8, &out1, &out2);
1298
+
1299
+ // CXOF128: one-shot vs split must match
1300
+ var cout1: [32]u8 = undefined;
1301
+ var cout2: [32]u8 = undefined;
1302
+ var cxof1 = AsconCxof128.init(.{ .custom = "cust" });
1303
+ cxof1.update(msg);
1304
+ cxof1.squeeze(&cout1);
1305
+ var cxof2 = AsconCxof128.init(.{ .custom = "cust" });
1306
+ cxof2.update("Hello, ");
1307
+ cxof2.update("World!");
1308
+ cxof2.squeeze(&cout2);
1309
+ try testing.expectEqualSlices(u8, &cout1, &cout2);
1310
+ }
1311
+
1270
1312
  test "Ascon-CXOF128 official test vectors" {
1271
1313
 
1272
1314
  // Test vector 1: Empty message, empty customization, 64-byte output
@@ -85,6 +85,14 @@ test toDot {
85
85
  }
86
86
  }
87
87
 
88
+ test "malformed OID" {
89
+ var empty: der.Decoder = .{ .bytes = &.{ 0x06, 0x00 } };
90
+ try std.testing.expectError(error.EndOfStream, decodeDer(&empty));
91
+
92
+ var truncated: der.Decoder = .{ .bytes = &.{ 0x06, 0x02, 0x2a, 0x80 } };
93
+ try std.testing.expectError(error.InvalidEncoding, decodeDer(&truncated));
94
+ }
95
+
88
96
  const TestCase = struct {
89
97
  encoded: []const u8,
90
98
  dot_notation: []const u8,
@@ -109,7 +117,10 @@ pub const asn1_tag = asn1.Tag.init(.oid, false, .universal);
109
117
 
110
118
  pub fn decodeDer(decoder: *der.Decoder) !Oid {
111
119
  const ele = try decoder.element(asn1_tag.toExpected());
112
- return Oid{ .encoded = decoder.view(ele) };
120
+ const encoded = decoder.view(ele);
121
+ if (encoded.len == 0) return error.EndOfStream;
122
+ if (encoded[encoded.len - 1] & 0x80 != 0) return error.InvalidEncoding;
123
+ return Oid{ .encoded = encoded };
113
124
  }
114
125
 
115
126
  pub fn encodeDer(self: Oid, encoder: *der.Encoder) !void {
@@ -47,8 +47,7 @@ pub const hex = struct {
47
47
  }
48
48
  _ = decodeAny(bin, encoded, null) catch |err| {
49
49
  switch (err) {
50
- error.InvalidCharacter => return error.InvalidCharacter,
51
- error.InvalidPadding => return error.InvalidPadding,
50
+ error.InvalidCharacter, error.InvalidPadding => |e| return e,
52
51
  else => unreachable,
53
52
  }
54
53
  };
@@ -228,8 +227,7 @@ pub const base64 = struct {
228
227
  pub fn decode(bin: []u8, encoded: []const u8, comptime variant: Variant) error{ InvalidCharacter, InvalidPadding }![]const u8 {
229
228
  return decodeAny(bin, encoded, variant, null) catch |err| {
230
229
  switch (err) {
231
- error.InvalidCharacter => return error.InvalidCharacter,
232
- error.InvalidPadding => return error.InvalidPadding,
230
+ error.InvalidCharacter, error.InvalidPadding => |e| return e,
233
231
  else => unreachable,
234
232
  }
235
233
  };
@@ -1725,15 +1725,8 @@ const NistDRBG = struct {
1725
1725
  v: [16]u8,
1726
1726
 
1727
1727
  fn incV(g: *NistDRBG) void {
1728
- var j: usize = 15;
1729
- while (j >= 0) : (j -= 1) {
1730
- if (g.v[j] == 255) {
1731
- g.v[j] = 0;
1732
- } else {
1733
- g.v[j] += 1;
1734
- break;
1735
- }
1736
- }
1728
+ const val = std.mem.readInt(u128, &g.v, .big);
1729
+ std.mem.writeInt(u128, &g.v, val +% 1, .big);
1737
1730
  }
1738
1731
 
1739
1732
  // AES256_CTR_DRBG_Update(pd, &g.key, &g.v).