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

Add support for pthread_getattr_np #470

Merged
merged 1 commit into from
Mar 11, 2024
Merged

Conversation

Milek7
Copy link
Contributor

@Milek7 Milek7 commented Feb 8, 2024

Add pthread_getattr_np for getting stack bounds.

} else {
bounds.base = &__global_base;
bounds.size = (size_t)&__global_base;
}
Copy link
Member

Choose a reason for hiding this comment

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

This code only calculates the stack found of the main thread (i.e. the singular stack that the linker produces). Is that intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fills data for main thread, spawned threads have these fields filled in pthread_create.

@@ -20,5 +23,9 @@ int pthread_getattr_np(pthread_t t, pthread_attr_t *a)
l += PAGE_SIZE;
a->_a_stacksize = l;
}
#else
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we can leave the if / else above and just replace the else block.

It looks like that if block covers secondary threads and the else block covers the main thread? We could use the __stack_high / __stack_low globals for the else case I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea was to fill these fields in main thread struct and handle everything the same way. Otherwise this would need to duplicate the logic for getting stack bounds, fallback to __heap_base, etc...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced only else block.

Copy link
Collaborator

@abrown abrown left a comment

Choose a reason for hiding this comment

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

This looks fine to me as well. @yamt, @loganek: does any one want to test this out?

Copy link
Contributor

@yamt yamt left a comment

Choose a reason for hiding this comment

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

looks reasonable to me

@abrown
Copy link
Collaborator

abrown commented Mar 8, 2024

@Milek7, can you rebase to fix the conflicts and then I can merge?

@abrown abrown merged commit c8ef60a into WebAssembly:main Mar 11, 2024
8 checks passed
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.

4 participants