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 alignment and remove static #67

Merged
merged 2 commits into from
Mar 21, 2022

Conversation

pobrn
Copy link
Contributor

@pobrn pobrn commented Mar 21, 2022

In #19 I forgot to add __attribute__((aligned)) to NVCodec, and for some reason I marked the codec objects static, which looking back, I find a confusing choice.

pobrn added 2 commits March 21, 2022 19:33
Add the `__attribute__((aligned))` attribute to the `NVCodec`
type so that it has "the maximum alignment for the target".
This is needed because these structs are placed into a
section of the executable and the linker will align
the objects to e.g. 16-byte boundaries on x86-64 regardless
of the actual size of the object.

Currently, the size of this struct is just right, so this
is technically not needed, but should it be extended in the
future, this will prevent surprises.
It is probably confusing that these objects are marked `static`
because they are very much different from usual `static` objects.
They are placed in a separate section of the executable and iterated
over when looking up codecs. So remove the `static` specifier
to prevent any potential confusion.
@elFarto
Copy link
Owner

elFarto commented Mar 21, 2022

Ah, that would explain why it crashed when I changed the size of NVCodec a while ago. Anyway, thanks for the PR!

@elFarto elFarto merged commit c60e5ac into elFarto:master Mar 21, 2022
@pobrn pobrn deleted the add_alignment_and_remove_static branch March 21, 2022 19:04
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