Update windows-bindgen to 0.100.0 - #162270
Conversation
|
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Note that I've split this into three commits. The middle commit is purely generated code. |
|
|
||
| /// Like an `as u32` cast except that it asserts the type is i32 before the cast. | ||
| /// This will ensure we can remove casts once they're no longer necessary. | ||
| macro_rules! as_u32 { |
There was a problem hiding this comment.
This macro converts types from i32 to u32. This keeps all the as casts in one place instead of needing them to be spread throughout the code. I also added an assert to ensure we remove them once they're no longer needed (which is my hope).
|
@bors try jobs=msvc,mingw |
This comment has been minimized.
This comment has been minimized.
Update `windows-bindgen` to 0.100.0 try-job: *msvc* try-job: *mingw*
This comment has been minimized.
This comment has been minimized.
1f3b8b5 to
6a839b6
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Just FYI - many of the other functions and structs that are manually declared in c.rs are now included in |
|
I'll look to see if I can clean that up a bit now but there are generally two reasons we manually declare types:
There's also one function that's not in |
| } | ||
|
|
||
| #[cfg(not(target_vendor = "win7"))] | ||
| // Use raw-dylib to import synchronization functions to workaround issues with the older mingw import library. |
There was a problem hiding this comment.
This was introduced to workaround #123999 where the ancient mingw on github's windows server 2019 had an incorrect import library. Github no longer has a 2019 runner and in general this shouldn't be a problem since rust-lang/compiler-team#993. That didn't technically set a requirement for the import libraries but it would be highly unusual for people to be using a newer mingw toolchain with very very old import libraries.
6d72f2b to
3c6b763
Compare
| use core::ffi::{CStr, c_int, c_uint, c_ulong, c_ushort, c_void}; | ||
| use core::ptr; | ||
|
|
||
| #[allow(unused)] |
There was a problem hiding this comment.
Does this imply we're pulling in more bindings than we actually need? Why does windows-bindgen itself not insert the allow if it's always necessary? (Or is it expedience, e.g., we have some targets that need a binding and others don't?)
There was a problem hiding this comment.
It's a mix of things. Indeed some targets use things that others don't and those targets in turn may use things that are unused by other targets. Historically the bindings have also tended to pull in more than we needed but I think that's less of an issue nowadays. One big reason though is that I've also found it annoying for contributors if there's a lot of churn in the bindings so I tend to only remove things occasionally when I'm sure they're not going to be needed again. After all it's basically used as if it's an external crate (similar to libc).
There was a problem hiding this comment.
It would make sense to summarise mostly what you said in a comment.
|
Hm, this probably should get a real review. r? clarfonthey |
3c6b763 to
85be443
Compare
This comment has been minimized.
This comment has been minimized.
85be443 to
a3c6e9d
Compare
This comment has been minimized.
This comment has been minimized.
cd6a8d5 to
c24e47d
Compare
Mingw used to have an incorrect import library for the synchronization functions `WaitOnAddress`, `WakeByAddressSingle` and `WakeByAddressAll`. This was fixed a long time ago and our windows-gnu targets require a much newer mingw in any case.
c24e47d to
a300bc1
Compare
|
I think everything's been addressed, so, r=me minus the note about documenting the allow(unused) bit. |
View all comments
This release represents a major change in the way bindings are generated. See microsoft/windows-rs#4867 for details.
In short, it now more directly follows the C headers. For the standard library's purposes this is mostly reflected in relatively minor type changes or with some
constpointers becomingmut.There is however one big change that affects a lot of types. In the headers there are a lot of
#defines like this:These are constants for the access mode. In this case they're explicitly declared as
L(aka signed long) integer types (in other cases there's no type at all). However, this conflicts with how access mode constants are actually used. E.g., seeCreateFileW:Here
dwDesiredAccessis aDWORD, which in rust equates tou32. The constant being signed but the usage being unsigned is not a problem for C/C++. They will happily convert between types at the drop of a hat. Rust however is stricter, as you know.The old metadata used by
windows-bindgentried to try to fixup this mismatch but the new one goes strictly by what can be inferred from the headers. The hope in the future is that the headers themselves will be updated so better bindings can be directly derived from them.