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

POC: Retrieve the actual alignment of max_align_t #554

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Dec 4, 2022

  1. Retrieve the actual alignment of max_align_t

    The code had a hard-coded maximum alignment of 16 (128 bits) which may
    have potentially wasted memory and cause memory unsafety if it was ever
    compiled with larger alignment (unlikely).
    
    This change implements a trick to retrieve the actual alignment from C.
    To achieve this a newly added C file defines a symbol initialized to
    `_Alignof(max_align_t)`. It is then compiled (as a separate object), the
    contents of the symbol is extracted and converted to decimal string
    which is injected into the `AlignedType` definition. The definition is
    generated as a separate `.rs` file in `OUT_DIR` and included into
    `types.rs`.
    Kixunil committed Dec 4, 2022
    Configuration menu
    Copy the full SHA
    dbe3a34 View commit details
    Browse the repository at this point in the history