diff options
| author | bors <bors@rust-lang.org> | 2014-06-13 20:57:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-06-13 20:57:30 +0000 |
| commit | 63dcc9a4df50680686bee852e82a52fbc59b3c27 (patch) | |
| tree | 2a5a941e0da26795babf286edf77f9f225bc906d /src/libnative | |
| parent | e7f11f20e5e72a3b22863a9913df94303321a5ce (diff) | |
| parent | b7af25060a1b0451cb06085ba5893980bc4e5333 (diff) | |
| download | rust-63dcc9a4df50680686bee852e82a52fbc59b3c27.tar.gz rust-63dcc9a4df50680686bee852e82a52fbc59b3c27.zip | |
auto merge of #14867 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/io/c_win32.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/libnative/io/c_win32.rs b/src/libnative/io/c_win32.rs index e855b8bd4f2..1b6525c6e38 100644 --- a/src/libnative/io/c_win32.rs +++ b/src/libnative/io/c_win32.rs @@ -77,15 +77,20 @@ pub mod compat { fn GetProcAddress(hModule: HMODULE, lpProcName: LPCSTR) -> LPVOID; } - // store_func() is idempotent, so using relaxed ordering for the atomics should be enough. - // This way, calling a function in this compatibility layer (after it's loaded) shouldn't - // be any slower than a regular DLL call. - unsafe fn store_func<T: Copy>(ptr: *mut T, module: &str, symbol: &str, fallback: T) { + // store_func() is idempotent, so using relaxed ordering for the atomics + // should be enough. This way, calling a function in this compatibility + // layer (after it's loaded) shouldn't be any slower than a regular DLL + // call. + unsafe fn store_func(ptr: *mut uint, module: &str, symbol: &str, fallback: uint) { let module = module.to_utf16().append_one(0); symbol.with_c_str(|symbol| { let handle = GetModuleHandleW(module.as_ptr()); - let func: Option<T> = transmute(GetProcAddress(handle, symbol)); - atomic_store_relaxed(ptr, func.unwrap_or(fallback)) + let func: uint = transmute(GetProcAddress(handle, symbol)); + atomic_store_relaxed(ptr, if func == 0 { + fallback + } else { + func + }) }) } @@ -109,10 +114,10 @@ pub mod compat { extern "system" fn thunk($($argname: $argtype),*) -> $rettype { unsafe { - ::io::c::compat::store_func(&mut ptr, - stringify!($module), - stringify!($symbol), - fallback); + ::io::c::compat::store_func(&mut ptr as *mut _ as *mut uint, + stringify!($module), + stringify!($symbol), + fallback as uint); ::std::intrinsics::atomic_load_relaxed(&ptr)($($argname),*) } } |
