diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-01-15 21:51:45 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-15 21:51:45 +0900 |
| commit | be1ecce01feddf3c81e0a1215a7dc21814d35862 (patch) | |
| tree | 098ec6815fdb19966d5c5c7b92d92edeab550a05 /src/librustc_interface | |
| parent | 89b065dbd2b953ea3ae15ebfb67a799e8b0a3ecc (diff) | |
| parent | 7b564c67deb6f5e9d7102871d63a9ad3d7161278 (diff) | |
| download | rust-be1ecce01feddf3c81e0a1215a7dc21814d35862.tar.gz rust-be1ecce01feddf3c81e0a1215a7dc21814d35862.zip | |
Rollup merge of #68141 - euclio:replace-bindings-with-winapi, r=alexcrichton
use winapi for non-stdlib Windows bindings
Diffstat (limited to 'src/librustc_interface')
| -rw-r--r-- | src/librustc_interface/Cargo.toml | 3 | ||||
| -rw-r--r-- | src/librustc_interface/util.rs | 14 |
2 files changed, 9 insertions, 8 deletions
diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml index 98f7def7e36..7baae90beab 100644 --- a/src/librustc_interface/Cargo.toml +++ b/src/librustc_interface/Cargo.toml @@ -43,6 +43,9 @@ rustc_resolve = { path = "../librustc_resolve" } tempfile = "3.0.5" once_cell = "1" +[target.'cfg(windows)'.dependencies] +winapi = { version = "0.3", features = ["libloaderapi"] } + [dev-dependencies] rustc_target = { path = "../librustc_target" } diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 2fafd3af7a5..21f9fa48165 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -340,19 +340,17 @@ fn sysroot_candidates() -> Vec<PathBuf> { fn current_dll_path() -> Option<PathBuf> { use std::ffi::OsString; use std::os::windows::prelude::*; + use std::ptr; - extern "system" { - fn GetModuleHandleExW(dwFlags: u32, lpModuleName: usize, phModule: *mut usize) -> i32; - fn GetModuleFileNameW(hModule: usize, lpFilename: *mut u16, nSize: u32) -> u32; - } - - const GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS: u32 = 0x00000004; + use winapi::um::libloaderapi::{ + GetModuleFileNameW, GetModuleHandleExW, GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, + }; unsafe { - let mut module = 0; + let mut module = ptr::null_mut(); let r = GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, - current_dll_path as usize, + current_dll_path as usize as *mut _, &mut module, ); if r == 0 { |
