Skip to content

Commit

Permalink
Add sem_init, sem_wait, puts
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Jan 26, 2024
1 parent 084fbe4 commit 99d1d4a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Binary file modified docs/tcc-wasm.wasm
Binary file not shown.
Binary file modified tcc-wasm.wasm
Binary file not shown.
18 changes: 11 additions & 7 deletions zig/tcc-wasm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ var fd: c_int = 3;

export fn sem_init(sem: *sem_t, pshared: c_int, value: c_uint) c_int {
debug("sem_init: sem={*}, pshared={}, value={}", .{ sem, pshared, value });
@panic("TODO: sem_init");
return 0;
}

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

const sem_t = opaque {};
Expand Down Expand Up @@ -111,6 +116,11 @@ var memory_buffer = std.mem.zeroes([1024 * 1024]u8);
///////////////////////////////////////////////////////////////////////////////
// Logging

export fn puts(s: [*:0]const u8) callconv(.C) c_int {
debug("{s}", .{s});
return 0;
}

/// TODO: Doesn't work, missing references in Standard Library
/// Called by Zig for `std.log.debug`, `std.log.info`, `std.log.err`, ...
/// https://gist.github.com/leecannon/d6f5d7e5af5881c466161270347ce84d
Expand Down Expand Up @@ -319,9 +329,6 @@ pub export fn lseek(_: c_int) c_int {
pub export fn printf(_: c_int) c_int {
@panic("TODO: printf");
}
pub export fn puts(_: c_int) c_int {
@panic("TODO: puts");
}
pub export fn qsort(_: c_int) c_int {
@panic("TODO: qsort");
}
Expand All @@ -334,9 +341,6 @@ pub export fn remove(_: c_int) c_int {
pub export fn sem_post(_: c_int) c_int {
@panic("TODO: sem_post");
}
pub export fn sem_wait(_: c_int) c_int {
@panic("TODO: sem_wait");
}
pub export fn snprintf(_: c_int) c_int {
@panic("TODO: snprintf");
}
Expand Down

0 comments on commit 99d1d4a

Please sign in to comment.