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

Use reserved bytes in OSThread structs for wut related thread specifics #323

Closed
wants to merge 1 commit into from

Conversation

Maschell
Copy link
Contributor

Open for discussion.

Recently __wut_getreent got implemented which uses OSGetThreadSpecific/OSSetThreadSpecific to store some thread specific data. This works fine for regular homebrew, but for WUPS/WUMS (Plugin/Module system) we might end up using a reent within a (Cafe OS) thread we do not control (e.g. due to function replacing/patching). In this case using/overriding the "regular" thread specifics might then result in undefined behaviour. To avoid this I propose to the use the "reserved" bytes of the OSThread struct for custom thread specifics which are exclusively reserved for wut.

Contra:

  • Using the reserved bytes is/feels quite hacky. Forcing every homebrew do this this feels even more hacky.
  • If Nintendo drops an update and decides to use this reserved bytes all homebrew break

Pro:

  • wut homebrew can again use all "regular" thread specifcs
  • Using these reserved bytes is documented in wut. If this won't get merged I probably end up using the bytes anyway for WUPS/WUMS, but then it's less obvious they are actually used by something.
  • We won't need separate getreent implementations for WUPS/WUMS.

I am personally not really sure how to fix it. Using these reserved bytes feels indeed very hacky but seems overall to be the easiest and cleanest solution.

@Maschell
Copy link
Contributor Author

Maschell commented Jun 20, 2023

closed in favour of #324

@Maschell Maschell closed this Jun 20, 2023
@fincs
Copy link
Member

fincs commented Jun 20, 2023

Superseded by #324. The "hacky" bits will not be part of wut, instead they will be user provided through overrides.

@Maschell Maschell deleted the thread_specific branch June 20, 2023 19:38
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.

2 participants