summaryrefslogtreecommitdiff
path: root/targets
diff options
context:
space:
mode:
Diffstat (limited to 'targets')
-rw-r--r--targets/emit.zig14
-rw-r--r--targets/fib.c12
2 files changed, 26 insertions, 0 deletions
diff --git a/targets/emit.zig b/targets/emit.zig
new file mode 100644
index 0000000..e1b0b72
--- /dev/null
+++ b/targets/emit.zig
@@ -0,0 +1,14 @@
+//! A target that carries its own producer: emits N marks through the ring
+//! (argv[1], default 1000) and one write, then exits 7. The host test and
+//! the ring's throughput number run on it.
+const std = @import("std");
+const zt = @import("ztrace");
+
+pub fn main(init: std.process.Init.Minimal) u8 {
+ var args = init.args.iterate();
+ _ = args.skip();
+ const n = if (args.next()) |arg| std.fmt.parseInt(u64, arg, 10) catch 1000 else 1000;
+ zt.client.emit(.mem_write, 0, .{ 0x1000, 5, 0, 0, 0, 0 }, "hello");
+ for (0..n) |i| zt.client.emit(.mark, 0, .{ i, 0, 0, 0, 0, 0 }, "");
+ return 7;
+}
diff --git a/targets/fib.c b/targets/fib.c
new file mode 100644
index 0000000..5be9998
--- /dev/null
+++ b/targets/fib.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+static unsigned long fib(unsigned n) {
+ return n < 2 ? n : fib(n - 1) + fib(n - 2);
+}
+
+int main(int argc, char **argv) {
+ unsigned n = argc > 1 ? (unsigned)atoi(argv[1]) : 10;
+ printf("fib(%u) = %lu\n", n, fib(n));
+ return 0;
+}