Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__wasi_thread_spawn: stop truncating the return value #353

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

yamt
Copy link
Contributor

@yamt yamt commented Dec 7, 2022

as __wasi_errno_t is uint16_t, with the current coding, __pthread_create will never see negative return values from wasi:thread_spawn.
eg. (int)(uint16_t)-1 == 65535.

Copy link
Member

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So negative values here correspond to -errno values here?

int32_t ret = __imported_wasi_thread_spawn((int32_t) start_arg);
return (uint16_t) ret;
int32_t __wasi_thread_spawn(void* start_arg) {
return __imported_wasi_thread_spawn((int32_t) start_arg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we match the indentation that is used in the rest of this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, fixed

as __wasi_errno_t is uint16_t, with the current coding,
__pthread_create will never see negative return values from
wasi:thread_spawn.
eg. (int)(uint16_t)-1 == 65535.
@yamt yamt force-pushed the wasi_thread_spawn-error branch from f2af4dc to f194c40 Compare December 7, 2022 05:55
@yamt
Copy link
Contributor Author

yamt commented Dec 7, 2022

So negative values here correspond to -errno values here?

it's documented as `a negative error code.'

Copy link
Contributor

@loganek loganek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@abrown abrown merged commit 0b3b1bb into WebAssembly:main Dec 7, 2022
john-sharratt pushed a commit to john-sharratt/wasix-libc that referenced this pull request Mar 6, 2023
as __wasi_errno_t is uint16_t, with the current coding,
__pthread_create will never see negative return values from
wasi:thread_spawn.
eg. (int)(uint16_t)-1 == 65535.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants