about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-10-02 08:25:11 +0900
committerGitHub <noreply@github.com>2020-10-02 08:25:11 +0900
commit00b3450bbcd1c745eb2f4e6c1ddd9f480da2b584 (patch)
tree201b0c1bee29b2b00f62371ae3aef49b71f171c2 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent1fa5f8f05b85a22bb9fb94e5d2f026b124c514f8 (diff)
parent63b6007d5b68023e02a43c2f9c2ed21762cd8011 (diff)
downloadrust-00b3450bbcd1c745eb2f4e6c1ddd9f480da2b584.tar.gz
rust-00b3450bbcd1c745eb2f4e6c1ddd9f480da2b584.zip
Rollup merge of #76979 - fusion-engineering-forks:windows-fallback-check, r=dtolnay
Improve std::sys::windows::compat

Improves the compat_fn macro in sys::windows, which is used for conditionally loading APIs that might not be available.

- The module (dll) name can now be any string, not just an ident. (Not all Windows api modules are valid Rust identifiers. E.g. `WaitOnAddress` comes from `API-MS-Win-Core-Synch-l1-2-0.dll`.)
- Adds `FuncName::is_available()` for checking if a function is really available without having to do a duplicate lookup.
- Add comment explaining the lack of locking.
- Use `$_:block` to simplify the macro_rules.
- Apply `allow(unused_variables)` only to the fallback instead of everything.

---

The second point (`is_available()`) simplifies code that needs to pick an implementation depening on what is available, like `sys/windows/mutex.rs`. Before this change, it'd do its own lookup and keep its own `AtomicUsize` to track the result. Now it can just use `c::AcquireSRWLockExclusive::is_available()` directly.

This will also be useful when park/unpark/CondVar/etc. get improved implementations (e.g. from parking_lot or something else), as the best APIs for those are not available before Windows 8.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions