Skip to content

Commit 724d866

Browse files
authored
Use __wasilibc_subtask_await helper in more locations (WebAssembly#769)
Minor refactoring, avoids some conditional logic in one or two locations.
1 parent c8e37c6 commit 724d866

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

libc-bottom-half/cloudlibc/src/libc/time/clock_nanosleep.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
6262
if (flags & TIMER_ABSTIME) {
6363
monotonic_clock_wait_until(duration);
6464
} else {
65-
wasip3_subtask_status_t status = monotonic_clock_wait_for(duration);
66-
if (WASIP3_SUBTASK_STATE(status) != WASIP3_SUBTASK_RETURNED)
67-
__wasilibc_subtask_block_on_and_drop(WASIP3_SUBTASK_HANDLE(status));
65+
__wasilibc_subtask_await(monotonic_clock_wait_for(duration));
6866
}
6967
#endif
7068
return 0;

libc-bottom-half/cloudlibc/src/libc/unistd/pwrite.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset) {
8787
// Wait for the subtask to resolve now that the writer half is closed and if
8888
// we failed to write bytes (0 bytes written) and the result is an error we
8989
// can return -1.
90-
if (WASIP3_SUBTASK_STATE(subtask_status) != WASIP3_SUBTASK_RETURNED)
91-
__wasilibc_subtask_block_on_and_drop(WASIP3_SUBTASK_HANDLE(subtask_status));
90+
__wasilibc_subtask_await(subtask_status);
9291
if (ret == 0 && result.is_err) {
9392
translate_error(result.val.err);
9493
return -1;

0 commit comments

Comments
 (0)