Skip to content

Commit 547759d

Browse files
committed
Add fputs
1 parent 8615120 commit 547759d

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

docs/tcc-wasm.wasm

1.61 KB
Binary file not shown.

docs/tcc.js

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function main() {
6868
const data_len = new Uint8Array(memory.buffer, ptr, 4);
6969
const len = data_len[0] | data_len[1] << 8 | data_len[2] << 16 | data_len[3] << 24;
7070
console.log(`main: len=${len}`);
71+
if (len <= 0) { return; }
7172

7273
// Encode the `a.out` data from the rest of the bytes returned
7374
const data = new Uint8Array(memory.buffer, ptr + 4, len);

tcc-wasm.wasm

1.61 KB
Binary file not shown.

zig/tcc-wasm.zig

+7-5
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,17 @@ var memory_buffer = std.mem.zeroes([16 * 1024 * 1024]u8);
298298
///////////////////////////////////////////////////////////////////////////////
299299
// Logging
300300

301-
export fn puts(s: [*:0]const u8) callconv(.C) c_int {
301+
export fn puts(s: [*:0]const u8) c_int {
302302
debug("{s}", .{s});
303303
return 0;
304304
}
305305

306-
pub export fn fflush(_: c_int) c_int {
306+
export fn fputs(s: [*:0]const u8, stream: *FILE) c_int {
307+
debug("fputs: s={s}, stream={*}", .{ s, stream });
308+
return 0;
309+
}
310+
311+
export fn fflush(_: c_int) c_int {
307312
return 0;
308313
}
309314

@@ -464,9 +469,6 @@ pub export fn exit(_: c_int) c_int {
464469
pub export fn fopen(_: c_int) c_int {
465470
@panic("TODO: fopen");
466471
}
467-
pub export fn fputs(_: c_int) c_int {
468-
@panic("TODO: fputs");
469-
}
470472
pub export fn fread(_: c_int) c_int {
471473
@panic("TODO: fread");
472474
}

0 commit comments

Comments
 (0)