diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/Makefile | 4 | ||||
-rw-r--r-- | mod/io.c | 31 |
2 files changed, 35 insertions, 0 deletions
diff --git a/mod/Makefile b/mod/Makefile new file mode 100644 index 0000000..0a0c045 --- /dev/null +++ b/mod/Makefile @@ -0,0 +1,4 @@ +all: libfwdio.so + +libfwdio.so: io.c ../include/fwd/mod.h + $(CC) -I../include -fPIC -O2 -g -Wall -Wextra -shared io.c -o libfwdio.so 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; +} |