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.
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.
6d72f2b to
3c6b763
Compare
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.