aboutsummaryrefslogtreecommitdiff
path: root/mod/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'mod/io.c')
-rw-r--r--mod/io.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/mod/io.c b/mod/io.c
new file mode 100644
index 0000000..380566f
--- /dev/null
+++ b/mod/io.c
@@ -0,0 +1,31 @@
+#include <stdint.h>
+#include <assert.h>
+#include <stdio.h>
+
+#include <fwd/mod.h>
+
+long print_nl(fwd_extern_args_t args)
+{
+ assert(args.argc == 0);
+ putchar('\n');
+ return 0;
+}
+
+long print_i64(fwd_extern_args_t args)
+{
+ assert(args.argc == 1);
+ int64_t n = FWD_ARG_T(args, 0, int64_t);
+ printf("%lld", (long long)n);
+ return 0;
+}
+
+int fwdopen(fwd_state_t *state)
+{
+ FWD_REGISTER(state, print_nl,
+ FWD_VOID);
+
+ FWD_REGISTER(state, print_i64,
+ FWD_VOID, FWD_T(int64_t));
+
+ return 0;
+}