diff options
| author | klutzy <klutzytheklutzy@gmail.com> | 2015-01-10 22:53:22 +0900 |
|---|---|---|
| committer | klutzy <klutzytheklutzy@gmail.com> | 2015-01-19 00:12:45 +0900 |
| commit | d053ccb45fafc12a52629f209122c1ce9bbfabed (patch) | |
| tree | f51caa00a27c5f369b7044f54ea2c5539793e3b1 /src/libstd/sys/windows | |
| parent | dcaeb6aa23ecba2dc2af870668a9239136d20fa3 (diff) | |
| download | rust-d053ccb45fafc12a52629f209122c1ce9bbfabed.tar.gz rust-d053ccb45fafc12a52629f209122c1ce9bbfabed.zip | |
std::dynamic_lib: Fix Windows error handling
This is a [breaking-change] since `std::dynamic_lib::dl` is now private. When `LoadLibraryW()` fails, original code called `errno()` to get error code. However, there was local allocation of `Vec` before `LoadLibraryW()`, and it drops before `errno()`, and the drop (deallocation) changed `errno`! Therefore `dynamic_lib::open()` thought it always succeeded. This commit fixes the issue. This commit also sets Windows error mode during `LoadLibrary()` to prevent "dll load failed" dialog.
Diffstat (limited to 'src/libstd/sys/windows')
| -rw-r--r-- | src/libstd/sys/windows/c.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index 37ed32fa367..da3b7ee2f2f 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -226,6 +226,7 @@ pub mod compat { /// * `CreateSymbolicLinkW`: Windows XP, Windows Server 2003 /// * `GetFinalPathNameByHandleW`: Windows XP, Windows Server 2003 pub mod kernel32 { + use libc::c_uint; use libc::types::os::arch::extra::{DWORD, LPCWSTR, BOOLEAN, HANDLE}; use libc::consts::os::extra::ERROR_CALL_NOT_IMPLEMENTED; @@ -249,6 +250,12 @@ pub mod compat { unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0 } } } + + compat_fn! { + kernel32::SetThreadErrorMode(_dwNewMode: DWORD, _lpOldMode: *mut DWORD) -> c_uint { + unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0 } + } + } } } |
