This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const os = std.os; | |
pub fn main() !void { | |
const alloc = std.testing.allocator; | |
const pipe = try os.pipe(); // read end [0], write end [1] | |
const read_dup = try os.dup(pipe[0]); | |
const write_dup = try os.dup(pipe[1]); // for simplicity | |
const pid_result = try os.fork(); | |
if (pid_result == 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test "canonicalize path Unix" { | |
if (builtin.os.tag == .windows) // symlinks are not portable | |
return error.SkipZigTest; | |
// TODO testing partial solution to https://github.com/ziglang/zig/issues/4812 | |
const alloc = testing.allocator; | |
var tmp = testing.tmpDir(.{ .no_follow = true }); // ie zig-cache/tmp/8DLgoSEqz593PAEE | |
defer tmp.cleanup(); | |
const tmpdirpath = try tmp.getFullPath(alloc); | |
defer alloc.free(tmpdirpath); | |
var cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined; // maximum size of a UTF-8 encoded file path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Memory concistency and atomicity | |
#include <atomic> | |
#include <cassert> | |
#include <iostream> | |
#include <mutex> | |
#include <thread> | |
// assume: init of data = 0, flag != SET | |
// hint: L1 and B1 can repeat many times |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!zig test union.zig | |
1/1 test "testme123"... thread 571747 panic: access of inactive union field | |
/home/user/dev/git/zig/tryzig/union.zig:40:27: 0x208295 in TcpIo.setup (test) | |
tcpio.ctrl.client = try tcp.Client.init(.ip, .{ .close_on_exec = true }); | |
^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#qemu-img create -f qcow2 NOME.img XG | |
qemu-img create -f qcow2 nixos-test.img 20G | |
#qemu-system-x86_64 -boot d -cdrom image.iso -m 512 -hda mydisk.img | |
qemu-system-x86_64 -enable-kvm -boot d \ | |
-cdrom nixos-minimal-21.11-x86_64-linux.iso \ | |
-m 2G -cpu host -smp 2 -hda nixos-test.img | |
#usage | |
qemu-system-x86_64 -enable-kvm -boot d \ | |
-m 2G -cpu host -smp 2 -hda nixos-test.img |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! client started by server as subprocess | |
const std = @import("std"); | |
const builtin = @import("builtin"); | |
const net = std.x.net; | |
const os = std.x.os; | |
const testing = std.testing; | |
const tcp = net.tcp; | |
const ip = net.ip; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! client started by server as subprocess | |
const std = @import("std"); | |
const builtin = @import("builtin"); | |
const net = std.x.net; | |
const os = std.x.os; | |
const testing = std.testing; | |
const tcp = net.tcp; | |
const ip = net.ip; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/std/fmt/parse_float.zig b/lib/std/fmt/parse_float.zig | |
index 585c23ed5..585400587 100644 | |
--- a/lib/std/fmt/parse_float.zig | |
+++ b/lib/std/fmt/parse_float.zig | |
@@ -1,36 +1,1111 @@ | |
-// Adapted from https://github.com/grzegorz-kraszewski/stringtofloat. | |
+// Code ported from musl libc 8f12c4e110acb3bbbdc8abfb3a552c3ced718039 | |
+// and then modified to use softfloat and to assume f128 for everything | |
-// MIT License |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:!/usr/bin/time -v zig test % | |
1/1 test "build and call child_process"... cwd_str: /home/misterspoon/dev/git/zig/zig/pipe | |
tmpDir: vCWMmOLRT0RiWAMe | |
child_zig: zig-cache/tmp/vCWMmOLRT0RiWAMe/child.zig | |
emit_bin: -femit-bin=zig-cache/tmp/vCWMmOLRT0RiWAMe/child | |
child_path: zig-cache/tmp/vCWMmOLRT0RiWAMe/child | |
OK | |
All 1 tests passed. | |
Command being timed: "zig test tst_childprocess.zig" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const childstr = | |
\\ const std = @import("std"); | |
\\ const builtin = @import("builtin"); | |
\\ const os = std.os; | |
\\ pub fn main() !void { | |
\\ var arena_inst = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
\\ defer arena_inst.deinit(); | |
\\ const arena = arena_inst.allocator(); | |
\\ var it = try std.process.argsWithAllocator(arena); |