Skip to content

Commit

Permalink
Add fputc
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Jan 27, 2024
1 parent 9104479 commit 679d28b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Binary file modified docs/tcc-wasm.wasm
Binary file not shown.
Binary file modified tcc-wasm.wasm
Binary file not shown.
10 changes: 6 additions & 4 deletions zig/tcc-wasm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@ export fn read(fd0: c_int, buf: [*:0]u8, nbyte: size_t) isize {
return @intCast(strlen(s));
}

export fn fputc(c: c_int, stream: *FILE) c_int {
debug("fputc: c=0x{X:0>2}, stream={*}", .{ @as(u8, @intCast(c)), stream });
return c;
}

export fn fwrite(ptr: [*:0]const u8, size: usize, nmemb: usize, stream: *FILE) usize {
debug("fwrite: ptr={s}, size={}, nmemb={}, stream={*}", .{ ptr, size, nmemb, stream });
debug("fwrite: size={}, nmemb={}, stream={*}", .{ size, nmemb, stream });
hexdump.hexdump(ptr, size * nmemb);
return nmemb;
}
Expand Down Expand Up @@ -390,9 +395,6 @@ pub export fn fclose(_: c_int) c_int {
pub export fn fopen(_: c_int) c_int {
@panic("TODO: fopen");
}
pub export fn fputc(_: c_int) c_int {
@panic("TODO: fputc");
}
pub export fn fputs(_: c_int) c_int {
@panic("TODO: fputs");
}
Expand Down

0 comments on commit 679d28b

Please sign in to comment.