-
Notifications
You must be signed in to change notification settings - Fork 373
Comparing changes
Open a pull request
base repository: mozilla/cbindgen
base: v0.11.1
head repository: mozilla/cbindgen
compare: v0.12.0
- 9 commits
- 41 files changed
- 2 contributors
Commits on Dec 15, 2019
-
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>
Configuration menu - View commit details
-
Copy full SHA for 19e685c - Browse repository at this point
Copy the full SHA 19e685cView commit details -
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>
Configuration menu - View commit details
-
Copy full SHA for 377d93e - Browse repository at this point
Copy the full SHA 377d93eView commit details -
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>
Configuration menu - View commit details
-
Copy full SHA for 89781e2 - Browse repository at this point
Copy the full SHA 89781e2View commit details -
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>
Configuration menu - View commit details
-
Copy full SHA for b95df2b - Browse repository at this point
Copy the full SHA b95df2bView commit details -
{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>
Configuration menu - View commit details
-
Copy full SHA for 725378d - Browse repository at this point
Copy the full SHA 725378dView commit details -
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>
Configuration menu - View commit details
-
Copy full SHA for f23d4ee - Browse repository at this point
Copy the full SHA f23d4eeView commit details -
docs: add documentation for new alignment config knobs
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
Configuration menu - View commit details
-
Copy full SHA for 2b2ab90 - Browse repository at this point
Copy the full SHA 2b2ab90View commit details
Commits on Dec 16, 2019
-
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.
Configuration menu - View commit details
-
Copy full SHA for 48f1038 - Browse repository at this point
Copy the full SHA 48f1038View commit details -
Configuration menu - View commit details
-
Copy full SHA for 38fda6b - Browse repository at this point
Copy the full SHA 38fda6bView commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff v0.11.1...v0.12.0