Skip to content

Commit

Permalink
Add close, sem_post, unlink
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Jan 26, 2024
1 parent 7fe054b commit 812eaa1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ Then we...

- [Add fprintf](https://github.com/lupyuen/tcc-riscv32-wasm/commit/36d591ea197eb87eb5f14e9632512cfecc99cbaf)

- [Add read](https://github.com/lupyuen/tcc-riscv32-wasm/commit/7309abf30c12ade7db89a59539d4e3e04956562a)
- [Add read](https://github.com/lupyuen/tcc-riscv32-wasm/commit/7fe054b38cb52a289f1f512ba1e4ab07823b2ca4)

- [Add sprintf, snprintf](https://github.com/lupyuen/tcc-riscv32-wasm/commit/dd0161168815d570259e08d4bf0370a363e6e6e7)

Expand Down
Binary file modified docs/tcc-wasm.wasm
Binary file not shown.
Binary file modified tcc-wasm.wasm
Binary file not shown.
24 changes: 15 additions & 9 deletions zig/tcc-wasm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ export fn read(fd0: c_int, buf: [*:0]u8, nbyte: size_t) isize {
return @intCast(strlen(s));
}

export fn close(fd0: c_int) c_int {
debug("close: fd={}", .{fd0});
return 0;
}

export fn unlink(path: [*:0]const u8) c_int {
debug("unlink: path={s}", .{path});
return 0;
}

var fd: c_int = 3;
var first_read: bool = true;

Expand All @@ -88,6 +98,11 @@ export fn sem_wait(sem: *sem_t) c_int {
return 0;
}

export fn sem_post(sem: *sem_t) c_int {
debug("sem_post: sem={*}", .{sem});
return 0;
}

const sem_t = opaque {};

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -350,9 +365,6 @@ pub export var stderr: c_int = 2;
pub export fn atoi(_: c_int) c_int {
@panic("TODO: atoi");
}
pub export fn close(_: c_int) c_int {
@panic("TODO: close");
}
pub export fn exit(_: c_int) c_int {
@panic("TODO: exit");
}
Expand Down Expand Up @@ -407,9 +419,6 @@ pub export fn qsort(_: c_int) c_int {
pub export fn remove(_: c_int) c_int {
@panic("TODO: remove");
}
pub export fn sem_post(_: c_int) c_int {
@panic("TODO: sem_post");
}
pub export fn strcat(_: c_int) c_int {
@panic("TODO: strcat");
}
Expand Down Expand Up @@ -449,6 +458,3 @@ pub export fn strtoull(_: c_int) c_int {
pub export fn time(_: c_int) c_int {
@panic("TODO: time");
}
pub export fn unlink(_: c_int) c_int {
@panic("TODO: unlink");
}

0 comments on commit 812eaa1

Please sign in to comment.