Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mozilla/cbindgen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.11.1
Choose a base ref
...
head repository: mozilla/cbindgen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.12.0
Choose a head ref
  • 9 commits
  • 41 files changed
  • 2 contributors

Commits on Dec 15, 2019

  1. ir: {enum,struct,union}: check ReprStyle correctly

    The equality checks for Repr to effectively check ReprStyle didn't make
    much sense -- it would result in Repr comparisons failing if ReprType
    was set. This becomes important when we add alignment information to
    Repr.
    
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar authored and emilio committed Dec 15, 2019
    Configuration menu
    Copy the full SHA
    19e685c View commit details
    Browse the repository at this point in the history
  2. ir: repr: support #[repr(align(...))] and #[repr(packed)] parsing

    While #[repr(packed)] matches the rest of the currently-implemented
    reprs, #[repr(align(...))] adds another level of nesting and so it's
    necessary to handle arguments for nested #[repr(...)]s. However,
    arguments are only permitted for #[repr(align(...))] and any further
    nesting is ignored as before.
    
    It should be noted that #[repr(packed(...))] is also valid in Rust, but
    due to some complications with translating it to C, it is currently
    unsupported.
    
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar authored and emilio committed Dec 15, 2019
    Configuration menu
    Copy the full SHA
    377d93e View commit details
    Browse the repository at this point in the history
  3. ir: struct: support #[repr(align(...))] and #[repr(packed)]

    As with #[must_use], this new support requires users to specify what
    annotations they would like to apply when an alignment-related repr is
    encountered. However, unlike #[must_use] all compilers appear to use the
    same attributes to indicate layout settings so there is just a single
    configuration for this new feature in a separate [layout] TOML table.
    
    In order to facilitate the fact that #[repr(align(...))] takes an
    argument which will likely need to be included in the final annotation,
    the user must specify a function-like macro which takes the alignment
    value as an argument.
    
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar authored and emilio committed Dec 15, 2019
    Configuration menu
    Copy the full SHA
    89781e2 View commit details
    Browse the repository at this point in the history
  4. ir: union: support #[repr(align(...))] and #[repr(packed)]

    Users configure the annotations for this feature using the same [layout]
    settings as for structures (because -- unlike #[must_use] -- all
    well-known compilers use the same annotations for all types).
    
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar authored and emilio committed Dec 15, 2019
    Configuration menu
    Copy the full SHA
    b95df2b View commit details
    Browse the repository at this point in the history
  5. {struct,union}: do not generate unsafe layouts

    If the user has not specified a corresponding annotation for types that
    carry #[repr(packed)] or #[repr(align(...))] we must not generate the
    layout because it can cause interoperability issues (and possible memory
    unsafety) between C and Rust code.
    
    This unfortunately required some less-than-pretty plumbing changes so
    that the load phase of the parser has access to the complete Config
    object (luckily this does make the overall code look a bit cleaner
    IMHO). The individual IR loaders only get their corresponding structs,
    to avoid introducing confusing semantics.
    
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar authored and emilio committed Dec 15, 2019
    Configuration menu
    Copy the full SHA
    725378d View commit details
    Browse the repository at this point in the history
  6. tests: add tests for #[repr(packed)] and #[repr(align(...))]

    The tests are very straightforward, and effecitvely are just ensuring
    that the formatting works correctly and is included in all of the
    important cases.
    
    It's also very important to ensure we do not generate laid-out structs
    for layouts which we cannot reasonably represent in C (such as in cases
    where we weren't told what annotation to use for packed and
    specifically-aligned structures). Thus, add some tests to verify that
    this is the case.
    
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar authored and emilio committed Dec 15, 2019
    Configuration menu
    Copy the full SHA
    f23d4ee View commit details
    Browse the repository at this point in the history
  7. docs: add documentation for new alignment config knobs

    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar authored and emilio committed Dec 15, 2019
    Configuration menu
    Copy the full SHA
    2b2ab90 View commit details
    Browse the repository at this point in the history

Commits on Dec 16, 2019

  1. enum: Add an option to generate copy-assignments.

    And recommend its usage if copy-constructors are being generated, as otherwise
    C++ in its whole glory would do a bitwise copy, which is not really what you
    want if you have constructors / destructors around.
    emilio committed Dec 16, 2019
    Configuration menu
    Copy the full SHA
    48f1038 View commit details
    Browse the repository at this point in the history
  2. v0.12.0

     * Added support for #[repr(align)] and #[repr(packed)] on structs and unions. #431
     * Added support to generate copy-assignment operators for tagged enums. #434
    emilio committed Dec 16, 2019
    Configuration menu
    Copy the full SHA
    38fda6b View commit details
    Browse the repository at this point in the history
Loading