-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…ng#1901, rust-lang#1903) This addresses the underlying issue identified in rust-lang#1671, that size_t (integer that can hold any object size) isn't guaranteed to match usize, which is defined more like uintptr_t (integer that can hold any pointer). However, on almost all platforms, this is true, and in fact Rust already uses usize extensively in contexts where size_t would be more appropriate, such as slice indexing. So, it's better for ergonomics when interfacing with C code to map the C size_t type to usize. (See also discussion in rust-lang/rust#65473 about how usize really should be defined as size_t, not uintptr_t.) The previous fix for rust-lang#1671 removed the special case for size_t and defaulted to binding it as a normal typedef. This change effectively reverts that and goes back to mapping size_t to usize (and ssize_t to isize), but also ensures that if size_t is emitted, the typedef'd type of size_t in fact is compatible with usize (defined by checking that the size and alignment match the target pointer width). For (hypothetical) platforms where this is not true, or for compatibility with the default behavior of bindgen between 0.53 and this commit, onwards, you can disable this mapping with --no-size_t-is-usize.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
for name in (rg -lF addr_of! tests/expectations | sd '.*/(.*).rs' '$1') | ||
set path (fd --glob "$name.*" tests/headers) | ||
if test -n "$path" | ||
|
||
set flags (rg -F "// bindgen-flags" $path) | ||
if test -n "$flags" | ||
set minor (rg ".*\-\-rust\-target[ =]1.(\d+).*" $path -r '$1') | ||
if test -n "$minor" | ||
if test $minor -gt 47 | ||
echo $path needs to change the version from 1.$minor to 1.47 | ||
sd -s "1.$minor" "1.47" $path | ||
else | ||
echo $path uses version 1.$minor and that is fine | ||
end | ||
else | ||
echo $path does not have the `--rust-target` flag | ||
sd "// bindgen-flags: (.*)" '// bindgen-flags: --rust-target 1.47 $1' $path | ||
end | ||
else | ||
echo $path does not have the flags at all | ||
set contents (echo -e "// bindgen-flags: --rust-target 1.47\n"; cat $path) | ||
rm $path | ||
touch $path | ||
for line in $contents | ||
echo $line >> $path | ||
end | ||
end | ||
else | ||
echo $name headers not found | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.