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

manual bitfield in TermList to improve portability #524

Merged
merged 3 commits into from
Mar 18, 2024

Conversation

MichaelRawson
Copy link
Contributor

In TermList we use a bitfield for some metadata, which for pointer-tagging reasons we really need not to shift around: this could happen by the compiler either inserting padding or by moving members around. This has worked so far, but the standard doesn't say that it will continue to work. In #512 we see that indeed it doesn't work on some architectures.

As I'm not aware of a better way to do it, I have implemented manual bit-twiddling to replace the current bitfield. I have attempted to make this as safe/portable as possible.

@quickbeam123
Copy link
Collaborator

While having a look, does this help fixing #512 ?

@MichaelRawson
Copy link
Contributor Author

Probably not directly - there seems to be something wrong on PowerPC even if you fix the bitfield layout "manually", but it won't make it worse.

@quickbeam123
Copy link
Collaborator

I think I actually like this! Looks quite robust at a careful glance!

I am just tempted to suggest a "@joe-hauns"-style trick to create a macro which expands to create both the getter and the setter. Maybe that's too evil. But, on the other hand, if this solution is a bit fragile than it's because of the loose-ish connection between the _BIT_START and _BIT_END constants and the getter and the setter.

@MichaelRawson
Copy link
Contributor Author

I am just tempted to suggest a Joe-style trick to create a macro which expands to create both the getter and the setter.

Your wish is my command! Coming up.

@MichaelRawson
Copy link
Contributor Author

I was hopeful to also macro-ify the bitfield layout itself, but you can't recursively call macros so that got messy. If you're happy, go ahead and merge.

@quickbeam123
Copy link
Collaborator

Thank you. I went one step further. Is that OK?

@MichaelRawson
Copy link
Contributor Author

Yes! I missed that completely, sorry.

@quickbeam123 quickbeam123 merged commit 4455f14 into master Mar 18, 2024
1 check passed
@quickbeam123 quickbeam123 deleted the michael-termlist-portability branch March 18, 2024 16:28
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

2 participants