Skip to content

Add support for pthread_getattr_np#470

Merged
abrown merged 1 commit into
WebAssembly:mainfrom
Milek7:getattr
Mar 11, 2024
Merged

Add support for pthread_getattr_np#470
abrown merged 1 commit into
WebAssembly:mainfrom
Milek7:getattr

Conversation

@Milek7

@Milek7 Milek7 commented Feb 8, 2024

Copy link
Copy Markdown
Contributor

Add pthread_getattr_np for getting stack bounds.

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

Copy link
Copy Markdown
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
Copy Markdown
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.

l += PAGE_SIZE;
a->_a_stacksize = l;
}
#else

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@abrown abrown left a comment

Copy link
Copy Markdown
Collaborator

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?

@yamt yamt left a comment

Copy link
Copy Markdown
Contributor

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

abrown commented Mar 8, 2024

Copy link
Copy Markdown
Collaborator

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

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