about summary refs log tree commit diff
path: root/src/libnative
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-06-12 21:34:32 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-06-13 13:53:55 -0700
commitb7af25060a1b0451cb06085ba5893980bc4e5333 (patch)
tree2a5a941e0da26795babf286edf77f9f225bc906d /src/libnative
parentf907d9772c55d942fb178622b0b2b5a8ca103c11 (diff)
downloadrust-b7af25060a1b0451cb06085ba5893980bc4e5333.tar.gz
rust-b7af25060a1b0451cb06085ba5893980bc4e5333.zip
Rolling up PRs in the queue
Closes #14797 (librustc: Fix the issue with labels shadowing variable names by making)
Closes #14823 (Improve error messages for io::fs)
Closes #14827 (libsyntax: Allow `+` to separate trait bounds from objects.)
Closes #14834 (configure: Don't sync unused submodules)
Closes #14838 (Remove typo on collections::treemap::UnionItems)
Closes #14839 (Fix the unused struct field lint for struct variants)
Closes #14840 (Clarify `Any` docs)
Closes #14846 (rustc: [T, ..N] and [T, ..N+1] are not the same)
Closes #14847 (Audit usage of NativeMutex)
Closes #14850 (remove unnecessary PaX detection)
Closes #14856 (librustc: Take in account mutability when casting array to raw ptr.)
Closes #14859 (librustc: Forbid `transmute` from being called on types whose size is)
Closes #14860 (Fix `quote_pat!` & parse outer attributes in `quote_item!`)
Diffstat (limited to 'src/libnative')
-rw-r--r--src/libnative/io/c_win32.rs25
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),*)
                     }
                 }