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

Update signal_handler, removing bitflags #967

Merged

Conversation

hecatia-elegua
Copy link
Contributor

@hecatia-elegua hecatia-elegua commented Jun 2, 2023

First I wanted to change that piece of code to use bilge, but I'm not even sure why this wasn't an enum in the first case.
It's just some commented out code, btw.
Also using variant_count.
#963

@kevinaboos
Copy link
Member

variant_count is cool, thanks for informing me about that feature! Didn't know that existed; we should definitely be using that.

Regarding the set of exception vectors, it's purposefully not an enum because we want to be able to specify a union of multiple variants at the same time, mostly for the purpose of registering a single handler that covers multiple distinct exception variants. While I know that code isn't used yet, that's why we used bitflags there. In fact, the only time we prefer bitflags is in this kind of scenario where we want to allow multiple variants to be selectable using only the space of a single primitive type, e.g., u32.

In general, I'm excited to experiment with bilge and highly in favor of replacing bitflags (and other related crates). This PR doesn't seem to include bilge; was that planned for an upcoming changeset?

@hecatia-elegua
Copy link
Contributor Author

Well I can change it to use a struct with bools instead, just didn't seem like the right thing to do

@kevinaboos
Copy link
Member

Well I can change it to use a struct with bools instead, just didn't seem like the right thing to do

Do you mean a struct of bools that uses bilge (or another crate) for bitpacking? Because a regular struct of bools would be much larger -- at one byte per bool, that's 32 bytes instead of 32 bits. That's also another reason why we use bitflags, to pack a lot of booleans into a small space.

@hecatia-elegua
Copy link
Contributor Author

hecatia-elegua commented Jun 6, 2023

Edit: yes, I mean a bilge struct, which is bitpacked

@kevinaboos
Copy link
Member

Edit: yes, I mean a bilge struct, which is bitpacked

Ah i see, ok that does make sense.

For this PR, I think it's best to accept it with just the variant_count addition. I do want to use bilge, but the right place to experiment with that is the pte_flags crate, which is actually used in tons of other places and would be a much better proving ground for bilge. In contrast, if we add usage of bilge here in the signal handler crates, there's no easy way to actually test it thoroughly because this code isn't used and it also doesn't require any complex features like pte_flags do.

@hecatia-elegua
Copy link
Contributor Author

hecatia-elegua commented Jun 7, 2023

Please look at #963. It lists all places with bitfiddle/field/flags, some of those are just tiny changes or notes, though.
As discussed shortly on discord, pte_flags is a bit special due to how bitflags works, so we want to look into other usecases too.

Copy link
Member

@kevinaboos kevinaboos left a comment

Choose a reason for hiding this comment

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

Thanks!

@kevinaboos kevinaboos merged commit 59fcfd3 into theseus-os:theseus_main Jun 7, 2023
github-actions bot pushed a commit to Ramla-I/Theseus that referenced this pull request Jun 7, 2023
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