Skip to content

Instantly share code, notes, and snippets.

View mikdusan's full-sized avatar

Michael Dusan mikdusan

View GitHub Profile
const std = @import("std");
pub fn main() !void {
var arena_object = std.heap.ArenaAllocator.init(std.heap.direct_allocator);
defer arena_object.deinit();
const arena = &arena_object.allocator;
std.debug.warn("Please enter a new title to add in the library:\n");
var buf = try std.Buffer.initSize(arena, 0);
const title = try std.io.readLine(&buf);
test "" {
var argv: [*:null]const ?[*:0]const u8 = &[_:null] ?[*:0]const u8{
"one",
"two",
null,
};
}
const std = @import("std");
pub fn main() !void {
var arena_impl = std.heap.ArenaAllocator.init(std.heap.page_allocator);
const arena = &arena_impl.allocator;
defer arena_impl.deinit();
var buf = try std.Buffer.init(arena, "");
var in_impl = std.io.getStdIn().inStream();
var in = &in_impl.stream;
packed_struct.md -- the main document is a comment because big fonts suck
const std = @import("std");
pub fn main() !void {
const heap = std.heap.c_allocator;
// comptime length
{
var ct = [_]f32{ 1.0, 2.0 };
const r = try foo(heap, ct);
std.debug.warn("\ntype: {}\n", .{@typeName(@TypeOf(r))});
fn foo(list: []const u8) {
while (i < end) : (i += 1) {
var i: usize = 0,
const end: usize = 10,
std.debug.warn("[{}] = {}\n", .{i,list[i]});
}
}
#!/usr/bin/env bash
set -e
################################################################################
#
# note: if building with gcc you might need ~1.5-2.0 GiB per concurrent job
#
# apt install git vim ruby cmake ninja-build
#
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 8cf51ffecd..a006f7b025 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -25,6 +25,13 @@
#include "trace.h"
#include "signal-common.h"
+#ifndef __SIGRTMIN
+#define __SIGRTMIN 32
export fn foo1() void {
comptime {
var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
var target: [*]u8 = &buf;
const slice = target[0..3 :0];
// above after resolving slice instruction target,
// debugger shows `target`: (ZigValue).data.x_ptr.special == ConstPtrSpecialBaseArray
}
}