@zigc/lib 0.16.0 → 0.17.0-dev.135
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/c/fcntl.zig +6 -1
- package/c/inttypes.zig +0 -10
- package/c/math.zig +46 -122
- package/c/pthread.zig +57 -0
- package/c/search.zig +1 -27
- package/c/stdlib/drand48.zig +0 -57
- package/c/stdlib.zig +0 -100
- package/c/string.zig +20 -7
- package/c/strings.zig +0 -38
- package/c/unistd.zig +27 -26
- package/c/wchar.zig +10 -0
- package/c.zig +2 -2
- package/compiler/aro/aro/CodeGen.zig +5 -6
- package/compiler/aro/aro/Compilation.zig +17 -14
- package/compiler/aro/aro/Driver.zig +14 -13
- package/compiler/aro/aro/Parser.zig +20 -15
- package/compiler/aro/aro/Pragma.zig +3 -2
- package/compiler/aro/aro/Preprocessor.zig +9 -6
- package/compiler/aro/aro/pragmas/message.zig +3 -2
- package/compiler/aro/aro/text_literal.zig +3 -2
- package/compiler/aro/assembly_backend/x86_64.zig +4 -4
- package/compiler/build_runner.zig +0 -2
- package/compiler/reduce/Walk.zig +7 -7
- package/compiler/test_runner.zig +2 -2
- package/compiler/translate-c/Translator.zig +6 -2
- package/compiler/translate-c/main.zig +1 -1
- package/compiler_rt/cos.zig +0 -2
- package/compiler_rt/divmodei4.zig +40 -17
- package/compiler_rt/exp.zig +1 -6
- package/compiler_rt/exp2.zig +1 -6
- package/compiler_rt/exp_f128.zig +377 -0
- package/compiler_rt/fabs.zig +0 -2
- package/compiler_rt/fma.zig +0 -2
- package/compiler_rt/fmax.zig +0 -2
- package/compiler_rt/fmin.zig +0 -2
- package/compiler_rt/fmod.zig +0 -2
- package/compiler_rt/limb64.zig +876 -15
- package/compiler_rt/log.zig +0 -2
- package/compiler_rt/log10.zig +0 -2
- package/compiler_rt/log2.zig +0 -2
- package/compiler_rt/mulXi3.zig +1 -1
- package/compiler_rt/round.zig +0 -2
- package/compiler_rt/sin.zig +0 -2
- package/compiler_rt/sincos.zig +0 -2
- package/compiler_rt/sqrt.zig +0 -2
- package/compiler_rt/ssp.zig +1 -1
- package/compiler_rt/tan.zig +0 -2
- package/compiler_rt/trunc.zig +0 -2
- package/compiler_rt/udivmodei4.zig +28 -0
- package/fuzzer.zig +2 -0
- package/libc/include/aarch64-linux-any/asm/hwcap.h +1 -0
- package/libc/include/aarch64-linux-any/asm/unistd_64.h +1 -0
- package/libc/include/any-linux-any/asm-generic/errno.h +2 -0
- package/libc/include/any-linux-any/asm-generic/unistd.h +4 -1
- package/libc/include/any-linux-any/drm/amdgpu_drm.h +20 -6
- package/libc/include/any-linux-any/drm/amdxdna_accel.h +8 -0
- package/libc/include/any-linux-any/drm/drm_fourcc.h +6 -6
- package/libc/include/any-linux-any/drm/panfrost_drm.h +75 -1
- package/libc/include/any-linux-any/drm/panthor_drm.h +154 -3
- package/libc/include/any-linux-any/drm/rocket_accel.h +74 -24
- package/libc/include/any-linux-any/drm/xe_drm.h +89 -6
- package/libc/include/any-linux-any/linux/android/binder.h +1 -1
- package/libc/include/any-linux-any/linux/bpf.h +28 -0
- package/libc/include/any-linux-any/linux/btrfs.h +1 -0
- package/libc/include/any-linux-any/linux/btrfs_tree.h +32 -2
- package/libc/include/any-linux-any/linux/dma-buf.h +1 -0
- package/libc/include/any-linux-any/linux/dpll.h +1 -0
- package/libc/include/any-linux-any/linux/elf.h +2 -0
- package/libc/include/any-linux-any/linux/ethtool.h +21 -5
- package/libc/include/any-linux-any/linux/fs.h +1 -0
- package/libc/include/any-linux-any/linux/hyperv.h +1 -1
- package/libc/include/any-linux-any/linux/idxd.h +134 -134
- package/libc/include/any-linux-any/linux/if_alg.h +1 -1
- package/libc/include/any-linux-any/linux/if_link.h +1 -0
- package/libc/include/any-linux-any/linux/input-event-codes.h +4 -0
- package/libc/include/any-linux-any/linux/io_uring/bpf_filter.h +68 -0
- package/libc/include/any-linux-any/linux/io_uring/query.h +5 -1
- package/libc/include/any-linux-any/linux/io_uring.h +33 -2
- package/libc/include/any-linux-any/linux/iommufd.h +39 -0
- package/libc/include/any-linux-any/linux/kfd_ioctl.h +13 -3
- package/libc/include/any-linux-any/linux/kfd_sysfs.h +2 -1
- package/libc/include/any-linux-any/linux/kvm.h +30 -6
- package/libc/include/any-linux-any/linux/landlock.h +22 -8
- package/libc/include/any-linux-any/linux/magic.h +1 -0
- package/libc/include/any-linux-any/linux/mempolicy.h +3 -0
- package/libc/include/any-linux-any/linux/mount.h +11 -2
- package/libc/include/any-linux-any/linux/mptcp_pm.h +1 -1
- package/libc/include/any-linux-any/linux/mshv.h +2 -0
- package/libc/include/any-linux-any/linux/netfilter_bridge.h +5 -4
- package/libc/include/any-linux-any/linux/netfilter_ipv4.h +4 -5
- package/libc/include/any-linux-any/linux/netfilter_ipv6.h +3 -4
- package/libc/include/any-linux-any/linux/nfs.h +1 -1
- package/libc/include/any-linux-any/linux/nfsd_netlink.h +1 -0
- package/libc/include/any-linux-any/linux/nilfs2_api.h +2 -2
- package/libc/include/any-linux-any/linux/nilfs2_ondisk.h +97 -66
- package/libc/include/any-linux-any/linux/nl80211.h +104 -3
- package/libc/include/any-linux-any/linux/pci.h +7 -0
- package/libc/include/any-linux-any/linux/pci_regs.h +65 -6
- package/libc/include/any-linux-any/linux/pcitest.h +1 -0
- package/libc/include/any-linux-any/linux/perf_event.h +24 -3
- package/libc/include/any-linux-any/linux/pkt_sched.h +1 -0
- package/libc/include/any-linux-any/linux/prctl.h +30 -0
- package/libc/include/any-linux-any/linux/rseq.h +62 -5
- package/libc/include/any-linux-any/linux/shm.h +0 -1
- package/libc/include/any-linux-any/linux/stddef.h +4 -0
- package/libc/include/any-linux-any/linux/sysctl.h +1 -2
- package/libc/include/any-linux-any/linux/taskstats.h +12 -1
- package/libc/include/any-linux-any/linux/tcp.h +23 -3
- package/libc/include/any-linux-any/linux/typelimits.h +8 -0
- package/libc/include/any-linux-any/linux/ublk_cmd.h +120 -1
- package/libc/include/any-linux-any/linux/v4l2-controls.h +63 -0
- package/libc/include/any-linux-any/linux/vbox_vmmdev_types.h +2 -2
- package/libc/include/any-linux-any/linux/vduse.h +80 -5
- package/libc/include/any-linux-any/linux/version.h +3 -3
- package/libc/include/any-linux-any/linux/vfio.h +4 -0
- package/libc/include/any-linux-any/linux/videodev2.h +3 -0
- package/libc/include/any-linux-any/linux/virtio_ring.h +1 -2
- package/libc/include/any-linux-any/linux/vmclock-abi.h +20 -0
- package/libc/include/any-linux-any/rdma/bnxt_re-abi.h +16 -0
- package/libc/include/any-linux-any/rdma/ib_user_ioctl_cmds.h +16 -0
- package/libc/include/any-linux-any/rdma/mana-abi.h +3 -0
- package/libc/include/any-linux-any/scsi/scsi_bsg_ufs.h +8 -9
- package/libc/include/any-linux-any/sound/sof/tokens.h +6 -0
- package/libc/include/arc-linux-any/asm/swab.h +0 -63
- package/libc/include/arc-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/arm-linux-any/asm/ptrace.h +0 -9
- package/libc/include/arm-linux-any/asm/unistd-eabi.h +1 -0
- package/libc/include/arm-linux-any/asm/unistd-oabi.h +1 -0
- package/libc/include/csky-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/hexagon-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/loongarch-linux-any/asm/hwcap.h +1 -0
- package/libc/include/loongarch-linux-any/asm/kvm.h +1 -0
- package/libc/include/loongarch-linux-any/asm/kvm_para.h +1 -0
- package/libc/include/loongarch-linux-any/asm/unistd_32.h +2 -0
- package/libc/include/loongarch-linux-any/asm/unistd_64.h +2 -0
- package/libc/include/m68k-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/mips-linux-any/asm/errno.h +2 -0
- package/libc/include/mips-linux-any/asm/unistd_n32.h +1 -0
- package/libc/include/mips-linux-any/asm/unistd_n64.h +1 -0
- package/libc/include/mips-linux-any/asm/unistd_o32.h +1 -0
- package/libc/include/powerpc-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/powerpc-linux-any/asm/unistd_64.h +1 -0
- package/libc/include/riscv-linux-any/asm/hwprobe.h +4 -0
- package/libc/include/riscv-linux-any/asm/kvm.h +3 -0
- package/libc/include/riscv-linux-any/asm/ptrace.h +37 -0
- package/libc/include/riscv-linux-any/asm/sigcontext.h +1 -0
- package/libc/include/riscv-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/riscv-linux-any/asm/unistd_64.h +1 -0
- package/libc/include/s390x-linux-any/asm/unistd_64.h +1 -0
- package/libc/include/sparc-linux-any/asm/errno.h +2 -0
- package/libc/include/sparc-linux-any/asm/ioctls.h +4 -4
- package/libc/include/sparc-linux-any/asm/unistd_32.h +2 -0
- package/libc/include/sparc-linux-any/asm/unistd_64.h +2 -0
- package/libc/include/x86-linux-any/asm/auxvec.h +0 -4
- package/libc/include/x86-linux-any/asm/kvm.h +13 -8
- package/libc/include/x86-linux-any/asm/svm.h +16 -16
- package/libc/include/x86-linux-any/asm/unistd_32.h +1 -0
- package/libc/include/x86-linux-any/asm/unistd_64.h +1 -0
- package/libc/include/x86-linux-any/asm/unistd_x32.h +1 -0
- package/libc/include/xtensa-linux-any/asm/unistd_32.h +1 -0
- package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
- package/package.json +1 -1
- package/std/Build/Cache.zig +6 -6
- package/std/Build/Step/Compile.zig +0 -1
- package/std/Build/Step/Run.zig +2 -2
- package/std/Build/Step.zig +2 -4
- package/std/Build/WebServer.zig +2 -2
- package/std/Build.zig +0 -3
- package/std/Io/Dir.zig +7 -2
- package/std/Io/Dispatch.zig +3 -13
- package/std/Io/File/Writer.zig +8 -6
- package/std/Io/Reader.zig +8 -9
- package/std/Io/Semaphore.zig +112 -17
- package/std/Io/Terminal.zig +1 -1
- package/std/Io/Threaded.zig +171 -37
- package/std/Io/Uring.zig +13 -15
- package/std/Io/Writer.zig +46 -42
- package/std/Io/net.zig +11 -11
- package/std/Io.zig +90 -26
- package/std/SemanticVersion.zig +1 -1
- package/std/Target/Query.zig +2 -2
- package/std/Target.zig +50 -5
- package/std/array_hash_map.zig +9 -18
- package/std/builtin.zig +4 -0
- package/std/c/haiku.zig +3 -0
- package/std/c/serenity.zig +1 -6
- package/std/c.zig +89 -7
- package/std/compress/flate/Decompress.zig +2 -3
- package/std/compress/zstd/Decompress.zig +2 -4
- package/std/crypto/Certificate.zig +13 -1
- package/std/crypto/ascon.zig +75 -33
- package/std/crypto/codecs/asn1/Oid.zig +12 -1
- package/std/crypto/codecs/base64_hex_ct.zig +2 -4
- package/std/crypto/ml_kem.zig +2 -9
- package/std/crypto/tls/Client.zig +79 -4
- package/std/crypto/tls.zig +1 -1
- package/std/crypto.zig +1 -0
- package/std/debug/Pdb.zig +1 -1
- package/std/debug.zig +4 -3
- package/std/fmt.zig +8 -3
- package/std/fs/path.zig +6 -4
- package/std/heap/BufferFirstAllocator.zig +165 -0
- package/std/heap.zig +2 -126
- package/std/http/Client.zig +21 -24
- package/std/http.zig +3 -4
- package/std/json/Scanner.zig +2 -2
- package/std/os/emscripten.zig +1 -1
- package/std/os/linux/IoUring.zig +2 -0
- package/std/os/linux/aarch64.zig +41 -12
- package/std/os/linux/arc.zig +173 -0
- package/std/os/linux/arm.zig +41 -12
- package/std/os/linux/hexagon.zig +33 -11
- package/std/os/linux/loongarch32.zig +41 -13
- package/std/os/linux/loongarch64.zig +41 -12
- package/std/os/linux/m68k.zig +41 -13
- package/std/os/linux/mips.zig +67 -36
- package/std/os/linux/mips64.zig +60 -29
- package/std/os/linux/mipsn32.zig +60 -29
- package/std/os/linux/or1k.zig +41 -12
- package/std/os/linux/powerpc.zig +41 -12
- package/std/os/linux/powerpc64.zig +41 -12
- package/std/os/linux/riscv32.zig +41 -12
- package/std/os/linux/riscv64.zig +41 -12
- package/std/os/linux/s390x.zig +44 -7
- package/std/os/linux/sparc64.zig +83 -52
- package/std/os/linux/syscalls.zig +26 -1
- package/std/os/linux/thumb.zig +52 -36
- package/std/os/linux/x32.zig +41 -12
- package/std/os/linux/x86.zig +42 -13
- package/std/os/linux/x86_64.zig +41 -12
- package/std/os/linux.zig +412 -436
- package/std/os/uefi/tables/boot_services.zig +9 -8
- package/std/os.zig +41 -0
- package/std/process.zig +1 -1
- package/std/sort.zig +3 -3
- package/std/zig/Ast/Render.zig +3 -3
- package/std/zig/AstGen.zig +44 -98
- package/std/zig/AstRlAnnotate.zig +0 -11
- package/std/zig/BuiltinFn.zig +0 -32
- package/std/zig/LibCInstallation.zig +4 -3
- package/std/zig/Parse.zig +7 -7
- package/std/zig/WindowsSdk.zig +13 -13
- package/std/zig/Zir.zig +50 -63
- package/std/zig/ZonGen.zig +6 -5
- package/std/zig/llvm/Builder.zig +12 -12
- package/std/zig.zig +1 -10
- package/std/zip.zig +5 -5
- package/zig.h +340 -1
- package/libc/include/hexagon-linux-any/asm/signal.h +0 -29
- package/libc/include/s390x-linux-any/asm/tape390.h +0 -103
- package/libc/mingw/math/fdiml.c +0 -24
- package/libc/mingw/winpthreads/spinlock.c +0 -82
- package/libc/musl/src/linux/tee.c +0 -8
- package/libc/musl/src/math/fdimf.c +0 -10
- package/libc/musl/src/math/fdiml.c +0 -18
- package/libc/musl/src/string/strdup.c +0 -10
- package/libc/musl/src/string/strndup.c +0 -12
- package/libc/musl/src/string/wcsdup.c +0 -10
- package/libc/musl/src/thread/pthread_spin_destroy.c +0 -6
- package/libc/musl/src/thread/pthread_spin_init.c +0 -6
- package/libc/musl/src/thread/pthread_spin_lock.c +0 -8
- package/libc/musl/src/thread/pthread_spin_trylock.c +0 -7
- package/libc/musl/src/thread/pthread_spin_unlock.c +0 -7
- package/libc/musl/src/unistd/dup2.c +0 -20
- package/libc/musl/src/unistd/dup3.c +0 -26
- package/libc/wasi/thread-stub/pthread_spin_lock.c +0 -8
- package/libc/wasi/thread-stub/pthread_spin_trylock.c +0 -8
- package/libc/wasi/thread-stub/pthread_spin_unlock.c +0 -7
package/std/Io/Threaded.zig
CHANGED
|
@@ -1943,10 +1943,6 @@ pub fn io(t: *Threaded) Io {
|
|
|
1943
1943
|
.windows => netShutdownWindows,
|
|
1944
1944
|
else => netShutdownPosix,
|
|
1945
1945
|
},
|
|
1946
|
-
.netRead = switch (native_os) {
|
|
1947
|
-
.windows => netReadWindows,
|
|
1948
|
-
else => netReadPosix,
|
|
1949
|
-
},
|
|
1950
1946
|
.netWrite = switch (native_os) {
|
|
1951
1947
|
.windows => netWriteWindows,
|
|
1952
1948
|
else => netWritePosix,
|
|
@@ -2009,7 +2005,7 @@ const have_waitid = switch (native_os) {
|
|
|
2009
2005
|
|
|
2010
2006
|
const have_wait4 = switch (native_os) {
|
|
2011
2007
|
.linux => @hasField(std.os.linux.SYS, "wait4"),
|
|
2012
|
-
.dragonfly, .freebsd, .netbsd, .openbsd, .illumos, .
|
|
2008
|
+
.dragonfly, .freebsd, .netbsd, .openbsd, .illumos, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => true,
|
|
2013
2009
|
else => false,
|
|
2014
2010
|
};
|
|
2015
2011
|
|
|
@@ -2566,6 +2562,12 @@ fn operate(userdata: ?*anyopaque, operation: Io.Operation) Io.Cancelable!Io.Oper
|
|
|
2566
2562
|
};
|
|
2567
2563
|
break :o .{ null, 1 };
|
|
2568
2564
|
} },
|
|
2565
|
+
.net_read => |o| return .{
|
|
2566
|
+
.net_read = netRead(o.socket_handle, o.data) catch |err| switch (err) {
|
|
2567
|
+
error.Canceled => |e| return e,
|
|
2568
|
+
else => |e| e,
|
|
2569
|
+
},
|
|
2570
|
+
},
|
|
2569
2571
|
}
|
|
2570
2572
|
}
|
|
2571
2573
|
|
|
@@ -2621,6 +2623,14 @@ fn batchAwaitAsync(userdata: ?*anyopaque, b: *Io.Batch) Io.Cancelable!void {
|
|
|
2621
2623
|
};
|
|
2622
2624
|
poll_len += 1;
|
|
2623
2625
|
},
|
|
2626
|
+
.net_read => |o| {
|
|
2627
|
+
poll_buffer[poll_len] = .{
|
|
2628
|
+
.fd = o.socket_handle,
|
|
2629
|
+
.events = posix.POLL.IN | posix.POLL.ERR,
|
|
2630
|
+
.revents = 0,
|
|
2631
|
+
};
|
|
2632
|
+
poll_len += 1;
|
|
2633
|
+
},
|
|
2624
2634
|
}
|
|
2625
2635
|
index = submission.node.next;
|
|
2626
2636
|
}
|
|
@@ -2798,6 +2808,7 @@ fn batchAwaitConcurrent(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout
|
|
|
2798
2808
|
storage.* = .{ .completion = .{ .node = .{ .next = .none }, .result = result } };
|
|
2799
2809
|
b.completed.tail = index;
|
|
2800
2810
|
},
|
|
2811
|
+
.net_read => |o| try poll_storage.add(o.socket_handle, posix.POLL.IN | posix.POLL.ERR),
|
|
2801
2812
|
}
|
|
2802
2813
|
index = submission.node.next;
|
|
2803
2814
|
}
|
|
@@ -2993,6 +3004,7 @@ fn batchApc(
|
|
|
2993
3004
|
.file_write_streaming => .{ .file_write_streaming = ntWriteFileResult(iosb) },
|
|
2994
3005
|
.device_io_control => .{ .device_io_control = iosb.* },
|
|
2995
3006
|
.net_receive => unreachable,
|
|
3007
|
+
.net_read => unreachable,
|
|
2996
3008
|
};
|
|
2997
3009
|
storage.* = .{ .completion = .{ .node = .{ .next = .none }, .result = result } };
|
|
2998
3010
|
},
|
|
@@ -3201,6 +3213,16 @@ fn batchDrainSubmittedWindows(t: *Threaded, b: *Io.Batch, concurrency: bool) (Io
|
|
|
3201
3213
|
.net_receive = netReceiveWindows(t, o.socket_handle, o.message_buffer, o.data_buffer, o.flags),
|
|
3202
3214
|
});
|
|
3203
3215
|
},
|
|
3216
|
+
.net_read => |*o| {
|
|
3217
|
+
// TODO integrate with overlapped I/O or equivalent to avoid this error
|
|
3218
|
+
if (concurrency) return error.ConcurrencyUnavailable;
|
|
3219
|
+
batchCompleteBlockingWindows(b, operation_userdata, .{
|
|
3220
|
+
.net_read = netRead(o.socket_handle, o.data) catch |err| switch (err) {
|
|
3221
|
+
error.Canceled => |e| return e,
|
|
3222
|
+
else => |e| e,
|
|
3223
|
+
},
|
|
3224
|
+
});
|
|
3225
|
+
},
|
|
3204
3226
|
}
|
|
3205
3227
|
index = submission.node.next;
|
|
3206
3228
|
}
|
|
@@ -5345,7 +5367,7 @@ fn dirOpenDirHaiku(
|
|
|
5345
5367
|
.NOMEM => return error.SystemResources,
|
|
5346
5368
|
.NOTDIR => return error.NotDir,
|
|
5347
5369
|
.PERM => return error.PermissionDenied,
|
|
5348
|
-
.BUSY => return
|
|
5370
|
+
.BUSY => |err| return errnoBug(err),
|
|
5349
5371
|
else => |err| return posix.unexpectedErrno(err),
|
|
5350
5372
|
}
|
|
5351
5373
|
},
|
|
@@ -5462,7 +5484,7 @@ fn dirReadLinux(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir
|
|
|
5462
5484
|
}
|
|
5463
5485
|
const syscall: Syscall = try .start();
|
|
5464
5486
|
const n = while (true) {
|
|
5465
|
-
const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, dr.buffer.len);
|
|
5487
|
+
const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, @min(dr.buffer.len, std.math.maxInt(c_uint)));
|
|
5466
5488
|
switch (linux.errno(rc)) {
|
|
5467
5489
|
.SUCCESS => {
|
|
5468
5490
|
syscall.finish();
|
|
@@ -5791,10 +5813,119 @@ fn dirReadIllumos(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) D
|
|
|
5791
5813
|
}
|
|
5792
5814
|
|
|
5793
5815
|
fn dirReadHaiku(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir.Reader.Error!usize {
|
|
5794
|
-
|
|
5795
|
-
_ =
|
|
5796
|
-
|
|
5797
|
-
|
|
5816
|
+
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
|
5817
|
+
_ = t;
|
|
5818
|
+
var buffer_index: usize = 0;
|
|
5819
|
+
while (buffer.len - buffer_index != 0) {
|
|
5820
|
+
if (dr.end - dr.index == 0) {
|
|
5821
|
+
// Refill the buffer, unless we've already created references to
|
|
5822
|
+
// buffered data.
|
|
5823
|
+
if (buffer_index != 0) break;
|
|
5824
|
+
if (dr.state == .reset) {
|
|
5825
|
+
const syscall: Syscall = try .start();
|
|
5826
|
+
while (true) {
|
|
5827
|
+
const rc = posix.system._kern_rewind_dir(dr.dir.handle);
|
|
5828
|
+
switch (@as(posix.E, @enumFromInt(@min(rc, 0)))) {
|
|
5829
|
+
.SUCCESS => {
|
|
5830
|
+
syscall.finish();
|
|
5831
|
+
break;
|
|
5832
|
+
},
|
|
5833
|
+
.INTR => {
|
|
5834
|
+
try syscall.checkCancel();
|
|
5835
|
+
continue;
|
|
5836
|
+
},
|
|
5837
|
+
else => |e| {
|
|
5838
|
+
syscall.finish();
|
|
5839
|
+
switch (e) {
|
|
5840
|
+
else => |err| return posix.unexpectedErrno(err),
|
|
5841
|
+
}
|
|
5842
|
+
},
|
|
5843
|
+
}
|
|
5844
|
+
}
|
|
5845
|
+
dr.state = .reading;
|
|
5846
|
+
}
|
|
5847
|
+
const syscall: Syscall = try .start();
|
|
5848
|
+
const n: usize = while (true) {
|
|
5849
|
+
const rc = posix.system._kern_read_dir(dr.dir.handle, dr.buffer.ptr, dr.buffer.len, @truncate(dr.buffer.len / @sizeOf(posix.system.DirEnt)));
|
|
5850
|
+
switch (@as(posix.E, @enumFromInt(@min(rc, 0)))) {
|
|
5851
|
+
.SUCCESS => {
|
|
5852
|
+
syscall.finish();
|
|
5853
|
+
break @intCast(rc);
|
|
5854
|
+
},
|
|
5855
|
+
.INTR => {
|
|
5856
|
+
try syscall.checkCancel();
|
|
5857
|
+
continue;
|
|
5858
|
+
},
|
|
5859
|
+
else => |e| {
|
|
5860
|
+
syscall.finish();
|
|
5861
|
+
switch (e) {
|
|
5862
|
+
else => |err| return posix.unexpectedErrno(err),
|
|
5863
|
+
}
|
|
5864
|
+
},
|
|
5865
|
+
}
|
|
5866
|
+
};
|
|
5867
|
+
if (n == 0) {
|
|
5868
|
+
dr.state = .finished;
|
|
5869
|
+
return 0;
|
|
5870
|
+
}
|
|
5871
|
+
dr.index = 0;
|
|
5872
|
+
// _kern_read_dir returns entry count, but Dir.Reader is designed for byte count
|
|
5873
|
+
dr.end = 0;
|
|
5874
|
+
var i: usize = 0;
|
|
5875
|
+
while (i < n) : (i += 1) {
|
|
5876
|
+
const entry = @as(*align(1) posix.system.DirEnt, @ptrCast(&dr.buffer[dr.end]));
|
|
5877
|
+
dr.end += entry.reclen;
|
|
5878
|
+
}
|
|
5879
|
+
}
|
|
5880
|
+
const entry = @as(*align(1) posix.system.DirEnt, @ptrCast(&dr.buffer[dr.index]));
|
|
5881
|
+
const next_index = dr.index + entry.reclen;
|
|
5882
|
+
dr.index = next_index;
|
|
5883
|
+
|
|
5884
|
+
const name = std.mem.sliceTo(@as([*:0]u8, @ptrCast(&entry.name)), 0);
|
|
5885
|
+
if (std.mem.eql(u8, name, ".") or std.mem.eql(u8, name, "..") or entry.ino == 0) continue;
|
|
5886
|
+
|
|
5887
|
+
// haiku dirent doesn't expose type, so we have to call stat to get it.
|
|
5888
|
+
var stat: std.c.Stat = undefined;
|
|
5889
|
+
{
|
|
5890
|
+
const syscall: Syscall = try .start();
|
|
5891
|
+
while (true) {
|
|
5892
|
+
const rc = posix.system._kern_read_stat(dr.dir.handle, name, false, &stat, @sizeOf(std.c.Stat));
|
|
5893
|
+
switch (@as(posix.E, @enumFromInt(@min(rc, 0)))) {
|
|
5894
|
+
.SUCCESS => {
|
|
5895
|
+
syscall.finish();
|
|
5896
|
+
break;
|
|
5897
|
+
},
|
|
5898
|
+
.INTR => {
|
|
5899
|
+
try syscall.checkCancel();
|
|
5900
|
+
continue;
|
|
5901
|
+
},
|
|
5902
|
+
else => |e| {
|
|
5903
|
+
syscall.finish();
|
|
5904
|
+
switch (e) {
|
|
5905
|
+
else => |err| return posix.unexpectedErrno(err),
|
|
5906
|
+
}
|
|
5907
|
+
},
|
|
5908
|
+
}
|
|
5909
|
+
}
|
|
5910
|
+
}
|
|
5911
|
+
|
|
5912
|
+
const entry_kind: File.Kind = switch (stat.mode & posix.S.IFMT) {
|
|
5913
|
+
posix.S.IFBLK => .block_device,
|
|
5914
|
+
posix.S.IFCHR => .character_device,
|
|
5915
|
+
posix.S.IFDIR => .directory,
|
|
5916
|
+
posix.S.IFIFO => .named_pipe,
|
|
5917
|
+
posix.S.IFLNK => .sym_link,
|
|
5918
|
+
posix.S.IFREG => .file,
|
|
5919
|
+
else => .unknown,
|
|
5920
|
+
};
|
|
5921
|
+
buffer[buffer_index] = .{
|
|
5922
|
+
.name = name,
|
|
5923
|
+
.kind = entry_kind,
|
|
5924
|
+
.inode = entry.ino,
|
|
5925
|
+
};
|
|
5926
|
+
buffer_index += 1;
|
|
5927
|
+
}
|
|
5928
|
+
return buffer_index;
|
|
5798
5929
|
}
|
|
5799
5930
|
|
|
5800
5931
|
fn dirReadWindows(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir.Reader.Error!usize {
|
|
@@ -9812,7 +9943,10 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea
|
|
|
9812
9943
|
if (have_preadv) {
|
|
9813
9944
|
const syscall: Syscall = try .start();
|
|
9814
9945
|
while (true) {
|
|
9815
|
-
const rc =
|
|
9946
|
+
const rc = if (native_os == .haiku)
|
|
9947
|
+
posix.system.readv_pos(file.handle, @bitCast(offset), dest.ptr, @intCast(dest.len))
|
|
9948
|
+
else
|
|
9949
|
+
preadv_sym(file.handle, dest.ptr, @intCast(dest.len), @bitCast(offset));
|
|
9816
9950
|
switch (posix.errno(rc)) {
|
|
9817
9951
|
.SUCCESS => {
|
|
9818
9952
|
syscall.finish();
|
|
@@ -9846,7 +9980,7 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea
|
|
|
9846
9980
|
|
|
9847
9981
|
const syscall: Syscall = try .start();
|
|
9848
9982
|
while (true) {
|
|
9849
|
-
const rc =
|
|
9983
|
+
const rc = pread_sym(file.handle, dest[0].base, @intCast(dest[0].len), @bitCast(offset));
|
|
9850
9984
|
switch (posix.errno(rc)) {
|
|
9851
9985
|
.SUCCESS => {
|
|
9852
9986
|
syscall.finish();
|
|
@@ -10035,10 +10169,10 @@ fn fileSeekBy(userdata: ?*anyopaque, file: File, offset: i64) File.SeekError!voi
|
|
|
10035
10169
|
if (posix.SEEK == void) return error.Unseekable;
|
|
10036
10170
|
|
|
10037
10171
|
if (native_os == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
|
|
10038
|
-
var result:
|
|
10172
|
+
var result: i64 = undefined;
|
|
10039
10173
|
const syscall: Syscall = try .start();
|
|
10040
10174
|
while (true) {
|
|
10041
|
-
switch (posix.errno(posix.system.llseek(file.handle,
|
|
10175
|
+
switch (posix.errno(posix.system.llseek(file.handle, offset, &result, posix.SEEK.CUR))) {
|
|
10042
10176
|
.SUCCESS => {
|
|
10043
10177
|
syscall.finish();
|
|
10044
10178
|
return;
|
|
@@ -10149,8 +10283,8 @@ fn posixSeekTo(fd: posix.fd_t, offset: u64) File.SeekError!void {
|
|
|
10149
10283
|
if (native_os == .linux and !builtin.link_libc and @sizeOf(usize) == 4) {
|
|
10150
10284
|
const syscall: Syscall = try .start();
|
|
10151
10285
|
while (true) {
|
|
10152
|
-
var result:
|
|
10153
|
-
switch (posix.errno(posix.system.llseek(fd, offset, &result, posix.SEEK.SET))) {
|
|
10286
|
+
var result: i64 = undefined;
|
|
10287
|
+
switch (posix.errno(posix.system.llseek(fd, @bitCast(offset), &result, posix.SEEK.SET))) {
|
|
10154
10288
|
.SUCCESS => {
|
|
10155
10289
|
syscall.finish();
|
|
10156
10290
|
return;
|
|
@@ -10550,7 +10684,10 @@ fn fileWritePositional(
|
|
|
10550
10684
|
|
|
10551
10685
|
const syscall: Syscall = try .start();
|
|
10552
10686
|
while (true) {
|
|
10553
|
-
const rc =
|
|
10687
|
+
const rc = if (native_os == .haiku)
|
|
10688
|
+
posix.system.writev_pos(file.handle, @bitCast(offset), &iovecs, @intCast(iovlen))
|
|
10689
|
+
else
|
|
10690
|
+
pwritev_sym(file.handle, &iovecs, @intCast(iovlen), @bitCast(offset));
|
|
10554
10691
|
switch (posix.errno(rc)) {
|
|
10555
10692
|
.SUCCESS => {
|
|
10556
10693
|
syscall.finish();
|
|
@@ -12549,11 +12686,14 @@ fn deferAcceptAfd(t: *Threaded, listen_handle: net.Socket.Handle, info: windows.
|
|
|
12549
12686
|
}
|
|
12550
12687
|
}
|
|
12551
12688
|
|
|
12552
|
-
fn
|
|
12689
|
+
fn netRead(socket_handle: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
|
|
12553
12690
|
if (!have_networking) return error.NetworkDown;
|
|
12554
|
-
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
|
12555
|
-
_ = t;
|
|
12556
12691
|
|
|
12692
|
+
if (is_windows) return netReadWindows(socket_handle, data);
|
|
12693
|
+
return netReadPosix(socket_handle, data);
|
|
12694
|
+
}
|
|
12695
|
+
|
|
12696
|
+
fn netReadPosix(fd: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
|
|
12557
12697
|
var iovecs_buffer: [max_iovecs_len]posix.iovec = undefined;
|
|
12558
12698
|
var i: usize = 0;
|
|
12559
12699
|
for (data) |buf| {
|
|
@@ -12590,7 +12730,6 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.
|
|
|
12590
12730
|
.NOMEM => return error.SystemResources,
|
|
12591
12731
|
.NOTCONN => return error.SocketUnconnected,
|
|
12592
12732
|
.CONNRESET => return error.ConnectionResetByPeer,
|
|
12593
|
-
.TIMEDOUT => return error.Timeout,
|
|
12594
12733
|
.NOTCAPABLE => return error.AccessDenied,
|
|
12595
12734
|
else => |err| return posix.unexpectedErrno(err),
|
|
12596
12735
|
}
|
|
@@ -12622,7 +12761,6 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.
|
|
|
12622
12761
|
.NOMEM => return error.SystemResources,
|
|
12623
12762
|
.NOTCONN => return error.SocketUnconnected,
|
|
12624
12763
|
.CONNRESET => return error.ConnectionResetByPeer,
|
|
12625
|
-
.TIMEDOUT => return error.Timeout,
|
|
12626
12764
|
.PIPE => return error.SocketUnconnected,
|
|
12627
12765
|
.NETDOWN => return error.NetworkDown,
|
|
12628
12766
|
else => |err| return posix.unexpectedErrno(err),
|
|
@@ -12632,11 +12770,7 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.
|
|
|
12632
12770
|
}
|
|
12633
12771
|
}
|
|
12634
12772
|
|
|
12635
|
-
fn netReadWindows(
|
|
12636
|
-
if (!have_networking) return error.NetworkDown;
|
|
12637
|
-
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
|
12638
|
-
_ = t;
|
|
12639
|
-
|
|
12773
|
+
fn netReadWindows(socket_handle: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
|
|
12640
12774
|
var iovecs: [max_iovecs_len]windows.AFD.WSABUF(.@"var") = undefined;
|
|
12641
12775
|
var len: u32 = 0;
|
|
12642
12776
|
for (data) |buf| {
|
|
@@ -14063,7 +14197,7 @@ pub fn posixSocketModeProtocol(family: posix.sa_family_t, mode: net.Socket.Mode,
|
|
|
14063
14197
|
.dgram => posix.SOCK.DGRAM,
|
|
14064
14198
|
.seqpacket => posix.SOCK.SEQPACKET,
|
|
14065
14199
|
.raw => posix.SOCK.RAW,
|
|
14066
|
-
.rdm => posix.SOCK.RDM,
|
|
14200
|
+
.rdm => if (@hasDecl(posix.SOCK, "RDM")) posix.SOCK.RDM else return error.OptionUnsupported,
|
|
14067
14201
|
},
|
|
14068
14202
|
if (protocol) |p| @intFromEnum(p) else if (is_windows) switch (family) {
|
|
14069
14203
|
posix.AF.UNIX => switch (mode) {
|
|
@@ -14455,7 +14589,7 @@ fn lookupDns(
|
|
|
14455
14589
|
}
|
|
14456
14590
|
}
|
|
14457
14591
|
if (recv_err) |err| switch (err) {
|
|
14458
|
-
error.Canceled => return
|
|
14592
|
+
error.Canceled => |e| return e,
|
|
14459
14593
|
error.Timeout => continue :send,
|
|
14460
14594
|
else => continue,
|
|
14461
14595
|
};
|
|
@@ -14592,13 +14726,13 @@ fn lookupHostsReader(
|
|
|
14592
14726
|
const line = reader.takeDelimiterExclusive('\n') catch |err| switch (err) {
|
|
14593
14727
|
error.StreamTooLong => {
|
|
14594
14728
|
// Skip lines that are too long.
|
|
14595
|
-
_ = reader.discardDelimiterInclusive('\n') catch |
|
|
14729
|
+
_ = reader.discardDelimiterInclusive('\n') catch |er| switch (er) {
|
|
14596
14730
|
error.EndOfStream => break,
|
|
14597
|
-
error.ReadFailed => return
|
|
14731
|
+
error.ReadFailed => |e| return e,
|
|
14598
14732
|
};
|
|
14599
14733
|
continue;
|
|
14600
14734
|
},
|
|
14601
|
-
error.ReadFailed => return
|
|
14735
|
+
error.ReadFailed => |e| return e,
|
|
14602
14736
|
error.EndOfStream => break,
|
|
14603
14737
|
};
|
|
14604
14738
|
reader.toss(@min(1, reader.bufferedLen()));
|
|
@@ -15247,7 +15381,7 @@ fn childWaitPosix(child: *process.Child) process.Child.WaitError!process.Child.T
|
|
|
15247
15381
|
const ru_ptr = if (child.request_resource_usage_statistics) &ru else null;
|
|
15248
15382
|
|
|
15249
15383
|
if (have_wait4) {
|
|
15250
|
-
var status: if (builtin.link_libc) c_int else
|
|
15384
|
+
var status: if (builtin.link_libc) c_int else i32 = undefined;
|
|
15251
15385
|
const syscall: Syscall = try .start();
|
|
15252
15386
|
while (true) switch (posix.errno(posix.system.wait4(pid, &status, 0, ru_ptr))) {
|
|
15253
15387
|
.SUCCESS => {
|
|
@@ -15290,7 +15424,7 @@ fn childWaitPosix(child: *process.Child) process.Child.WaitError!process.Child.T
|
|
|
15290
15424
|
};
|
|
15291
15425
|
}
|
|
15292
15426
|
|
|
15293
|
-
var status: if (builtin.link_libc) c_int else
|
|
15427
|
+
var status: if (builtin.link_libc) c_int else i32 = undefined;
|
|
15294
15428
|
const syscall: Syscall = try .start();
|
|
15295
15429
|
while (true) switch (posix.errno(posix.system.waitpid(pid, &status, 0))) {
|
|
15296
15430
|
.SUCCESS => {
|
|
@@ -15332,7 +15466,7 @@ fn childKillPosix(child: *process.Child) !void {
|
|
|
15332
15466
|
};
|
|
15333
15467
|
|
|
15334
15468
|
if (have_wait4) {
|
|
15335
|
-
var status: if (builtin.link_libc) c_int else
|
|
15469
|
+
var status: if (builtin.link_libc) c_int else i32 = undefined;
|
|
15336
15470
|
while (true) switch (posix.errno(posix.system.wait4(pid, &status, 0, null))) {
|
|
15337
15471
|
.SUCCESS => return,
|
|
15338
15472
|
.INTR => continue,
|
|
@@ -15352,7 +15486,7 @@ fn childKillPosix(child: *process.Child) !void {
|
|
|
15352
15486
|
};
|
|
15353
15487
|
}
|
|
15354
15488
|
|
|
15355
|
-
var status: if (builtin.link_libc) c_int else
|
|
15489
|
+
var status: if (builtin.link_libc) c_int else i32 = undefined;
|
|
15356
15490
|
while (true) switch (posix.errno(posix.system.waitpid(pid, &status, 0))) {
|
|
15357
15491
|
.SUCCESS => return,
|
|
15358
15492
|
.INTR => continue,
|
package/std/Io/Uring.zig
CHANGED
|
@@ -779,7 +779,6 @@ pub fn io(ev: *Evented) Io {
|
|
|
779
779
|
.netConnectUnix = netConnectUnixUnavailable,
|
|
780
780
|
.netSocketCreatePair = netSocketCreatePairUnavailable,
|
|
781
781
|
.netSend = netSendUnavailable,
|
|
782
|
-
.netRead = netReadUnavailable,
|
|
783
782
|
.netWrite = netWriteUnavailable,
|
|
784
783
|
.netWriteFile = netWriteFileUnavailable,
|
|
785
784
|
.netClose = netClose,
|
|
@@ -2105,6 +2104,12 @@ fn operate(userdata: ?*anyopaque, operation: Io.Operation) Io.Cancelable!Io.Oper
|
|
|
2105
2104
|
};
|
|
2106
2105
|
},
|
|
2107
2106
|
},
|
|
2107
|
+
.net_read => |o| .{
|
|
2108
|
+
.net_read = r: {
|
|
2109
|
+
_ = o;
|
|
2110
|
+
break :r error.NetworkDown; // TODO
|
|
2111
|
+
},
|
|
2112
|
+
},
|
|
2108
2113
|
};
|
|
2109
2114
|
}
|
|
2110
2115
|
|
|
@@ -2392,6 +2397,10 @@ fn batchDrainSubmitted(
|
|
|
2392
2397
|
_ = o;
|
|
2393
2398
|
@panic("TODO implement batchDrainSubmitted for net_receive");
|
|
2394
2399
|
},
|
|
2400
|
+
.net_read => |o| {
|
|
2401
|
+
_ = o;
|
|
2402
|
+
@panic("TODO implement batchDrainSubmitted for net_read");
|
|
2403
|
+
},
|
|
2395
2404
|
})) |result| {
|
|
2396
2405
|
switch (batch.completed.tail) {
|
|
2397
2406
|
.none => batch.completed.head = index,
|
|
@@ -2493,6 +2502,7 @@ fn batchDrainReady(batch: *Io.Batch) Io.Timeout.Error!void {
|
|
|
2493
2502
|
},
|
|
2494
2503
|
.device_io_control => unreachable,
|
|
2495
2504
|
.net_receive => @panic("TODO"),
|
|
2505
|
+
.net_read => @panic("TODO"),
|
|
2496
2506
|
})) |result| {
|
|
2497
2507
|
switch (batch.completed.tail) {
|
|
2498
2508
|
.none => batch.completed.head = index,
|
|
@@ -3060,7 +3070,7 @@ fn dirRead(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir.Read
|
|
|
3060
3070
|
}
|
|
3061
3071
|
const n = while (true) {
|
|
3062
3072
|
try sync.cancel_region.await(.nothing);
|
|
3063
|
-
const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, dr.buffer.len);
|
|
3073
|
+
const rc = linux.getdents64(dr.dir.handle, dr.buffer.ptr, @min(dr.buffer.len, std.math.maxInt(c_uint)));
|
|
3064
3074
|
switch (linux.errno(rc)) {
|
|
3065
3075
|
.SUCCESS => break rc,
|
|
3066
3076
|
.INTR => {},
|
|
@@ -4948,7 +4958,7 @@ fn randomSecure(userdata: ?*anyopaque, buffer: []u8) Io.RandomSecureError!void {
|
|
|
4948
4958
|
var cancel_region: CancelRegion = .init();
|
|
4949
4959
|
defer cancel_region.deinit();
|
|
4950
4960
|
ev.urandomReadAll(&cancel_region, buffer) catch |err| switch (err) {
|
|
4951
|
-
error.Canceled => return
|
|
4961
|
+
error.Canceled => |e| return e,
|
|
4952
4962
|
else => return error.EntropyUnavailable,
|
|
4953
4963
|
};
|
|
4954
4964
|
}
|
|
@@ -5142,18 +5152,6 @@ fn netReceive(
|
|
|
5142
5152
|
}
|
|
5143
5153
|
}
|
|
5144
5154
|
|
|
5145
|
-
fn netReadUnavailable(
|
|
5146
|
-
userdata: ?*anyopaque,
|
|
5147
|
-
fd: net.Socket.Handle,
|
|
5148
|
-
data: [][]u8,
|
|
5149
|
-
) net.Stream.Reader.Error!usize {
|
|
5150
|
-
const ev: *Evented = @ptrCast(@alignCast(userdata));
|
|
5151
|
-
_ = ev;
|
|
5152
|
-
_ = fd;
|
|
5153
|
-
_ = data;
|
|
5154
|
-
return error.NetworkDown;
|
|
5155
|
-
}
|
|
5156
|
-
|
|
5157
5155
|
fn netWriteUnavailable(
|
|
5158
5156
|
userdata: ?*anyopaque,
|
|
5159
5157
|
handle: net.Socket.Handle,
|
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
|
|
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
|
|
559
|
-
/// this format:
|
|
560
|
-
///
|
|
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
|
|
562
|
+
/// Above, each word including its surrounding [ and ] is a parameter to be replaced with:
|
|
563
563
|
///
|
|
564
|
-
/// -
|
|
565
|
-
/// -
|
|
566
|
-
/// brackets, e.g. {[score]...} as opposed to the numeric index form which can be written e.g. {2...}
|
|
567
|
-
/// -
|
|
568
|
-
/// -
|
|
569
|
-
/// -
|
|
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
|
|
573
|
-
///
|
|
574
|
-
/// -
|
|
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
|
-
///
|
|
577
|
-
///
|
|
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
|
-
///
|
|
581
|
-
/// required at the same time as
|
|
582
|
-
///
|
|
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
|
-
///
|
|
586
|
-
/// - `x` and `X`:
|
|
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`:
|
|
594
|
-
/// - `e`:
|
|
595
|
-
/// - `d`:
|
|
596
|
-
/// - `b`:
|
|
597
|
-
/// - `o`:
|
|
598
|
-
/// - `c`:
|
|
599
|
-
/// - `u`:
|
|
600
|
-
/// - `
|
|
601
|
-
/// - `
|
|
602
|
-
/// -
|
|
603
|
-
///
|
|
604
|
-
/// - `!`:
|
|
605
|
-
///
|
|
606
|
-
///
|
|
607
|
-
/// -
|
|
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
|
|
612
|
+
/// A user type may be a struct, vector, union or enum type.
|
|
610
613
|
///
|
|
611
|
-
///
|
|
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);
|
package/std/Io/net.zig
CHANGED
|
@@ -1245,6 +1245,15 @@ pub const Stream = struct {
|
|
|
1245
1245
|
|
|
1246
1246
|
const max_iovecs_len = 8;
|
|
1247
1247
|
|
|
1248
|
+
/// This is a low-level API that calls the `Io` interface function directly.
|
|
1249
|
+
/// For a higher level API, see `reader`.
|
|
1250
|
+
pub fn read(s: *const Stream, io: Io, data: [][]u8) Reader.Error!usize {
|
|
1251
|
+
return (try io.operate(.{ .net_read = .{
|
|
1252
|
+
.socket_handle = s.socket.handle,
|
|
1253
|
+
.data = data,
|
|
1254
|
+
} })).net_read;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1248
1257
|
pub fn close(s: *const Stream, io: Io) void {
|
|
1249
1258
|
io.vtable.netClose(io.userdata, (&s.socket.handle)[0..1]);
|
|
1250
1259
|
}
|
|
@@ -1259,16 +1268,7 @@ pub const Stream = struct {
|
|
|
1259
1268
|
stream: Stream,
|
|
1260
1269
|
err: ?Error,
|
|
1261
1270
|
|
|
1262
|
-
pub const Error =
|
|
1263
|
-
SystemResources,
|
|
1264
|
-
ConnectionResetByPeer,
|
|
1265
|
-
Timeout,
|
|
1266
|
-
SocketUnconnected,
|
|
1267
|
-
/// The file descriptor does not hold the required rights to read
|
|
1268
|
-
/// from it.
|
|
1269
|
-
AccessDenied,
|
|
1270
|
-
NetworkDown,
|
|
1271
|
-
} || Io.Cancelable || Io.UnexpectedError;
|
|
1271
|
+
pub const Error = Io.Operation.NetRead.Error || Io.Cancelable;
|
|
1272
1272
|
|
|
1273
1273
|
pub fn init(stream: Stream, io: Io, buffer: []u8) Reader {
|
|
1274
1274
|
return .{
|
|
@@ -1302,7 +1302,7 @@ pub const Stream = struct {
|
|
|
1302
1302
|
const dest_n, const data_size = try io_r.writableVector(&iovecs_buffer, data);
|
|
1303
1303
|
const dest = iovecs_buffer[0..dest_n];
|
|
1304
1304
|
assert(dest[0].len > 0);
|
|
1305
|
-
const n =
|
|
1305
|
+
const n = r.stream.read(io, dest) catch |err| {
|
|
1306
1306
|
r.err = err;
|
|
1307
1307
|
return error.ReadFailed;
|
|
1308
1308
|
};
|