From 3d28b8b98e6e4f55ef4ecd8babf0a050f48a3d11 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 2 Nov 2015 16:23:22 -0800 Subject: std: Migrate to the new libc * Delete `sys::unix::{c, sync}` as these are now all folded into libc itself * Update all references to use `libc` as a result. * Update all references to the new flat namespace. * Moves all windows bindings into sys::c --- src/libstd/sys/common/net.rs | 149 +++++++++++++----------------- src/libstd/sys/common/unwind/seh.rs | 43 ++------- src/libstd/sys/common/unwind/seh64_gnu.rs | 140 +++++++--------------------- 3 files changed, 103 insertions(+), 229 deletions(-) (limited to 'src/libstd/sys/common') diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 37379596251..449cd9d8c97 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -13,13 +13,13 @@ use prelude::v1::*; use ffi::{CStr, CString}; use fmt; use io::{self, Error, ErrorKind}; -use libc::{self, c_int, c_char, c_void, socklen_t}; +use libc::{c_int, c_char, c_void}; use mem; use net::{SocketAddr, Shutdown, IpAddr}; use ptr; use str::from_utf8; -use sys::c; use sys::net::{cvt, cvt_r, cvt_gai, Socket, init, wrlen_t}; +use sys::net::netc as c; use sys_common::{AsInner, FromInner, IntoInner}; use time::Duration; @@ -31,8 +31,8 @@ pub fn setsockopt(sock: &Socket, opt: c_int, val: c_int, payload: T) -> io::Result<()> { unsafe { let payload = &payload as *const T as *const c_void; - try!(cvt(libc::setsockopt(*sock.as_inner(), opt, val, payload, - mem::size_of::() as socklen_t))); + try!(cvt(c::setsockopt(*sock.as_inner(), opt, val, payload, + mem::size_of::() as c::socklen_t))); Ok(()) } } @@ -41,7 +41,7 @@ pub fn getsockopt(sock: &Socket, opt: c_int, val: c_int) -> io::Result { unsafe { let mut slot: T = mem::zeroed(); - let mut len = mem::size_of::() as socklen_t; + let mut len = mem::size_of::() as c::socklen_t; try!(cvt(c::getsockopt(*sock.as_inner(), opt, val, &mut slot as *mut _ as *mut _, &mut len))); @@ -51,29 +51,29 @@ pub fn getsockopt(sock: &Socket, opt: c_int, } fn sockname(f: F) -> io::Result - where F: FnOnce(*mut libc::sockaddr, *mut socklen_t) -> c_int + where F: FnOnce(*mut c::sockaddr, *mut c::socklen_t) -> c_int { unsafe { - let mut storage: libc::sockaddr_storage = mem::zeroed(); - let mut len = mem::size_of_val(&storage) as socklen_t; + let mut storage: c::sockaddr_storage = mem::zeroed(); + let mut len = mem::size_of_val(&storage) as c::socklen_t; try!(cvt(f(&mut storage as *mut _ as *mut _, &mut len))); sockaddr_to_addr(&storage, len as usize) } } -fn sockaddr_to_addr(storage: &libc::sockaddr_storage, +fn sockaddr_to_addr(storage: &c::sockaddr_storage, len: usize) -> io::Result { - match storage.ss_family as libc::c_int { - libc::AF_INET => { - assert!(len as usize >= mem::size_of::()); + match storage.ss_family as c_int { + c::AF_INET => { + assert!(len as usize >= mem::size_of::()); Ok(SocketAddr::V4(FromInner::from_inner(unsafe { - *(storage as *const _ as *const libc::sockaddr_in) + *(storage as *const _ as *const c::sockaddr_in) }))) } - libc::AF_INET6 => { - assert!(len as usize >= mem::size_of::()); + c::AF_INET6 => { + assert!(len as usize >= mem::size_of::()); Ok(SocketAddr::V6(FromInner::from_inner(unsafe { - *(storage as *const _ as *const libc::sockaddr_in6) + *(storage as *const _ as *const c::sockaddr_in6) }))) } _ => { @@ -86,16 +86,9 @@ fn sockaddr_to_addr(storage: &libc::sockaddr_storage, // get_host_addresses //////////////////////////////////////////////////////////////////////////////// -extern "system" { - fn getaddrinfo(node: *const c_char, service: *const c_char, - hints: *const libc::addrinfo, - res: *mut *mut libc::addrinfo) -> c_int; - fn freeaddrinfo(res: *mut libc::addrinfo); -} - pub struct LookupHost { - original: *mut libc::addrinfo, - cur: *mut libc::addrinfo, + original: *mut c::addrinfo, + cur: *mut c::addrinfo, } impl Iterator for LookupHost { @@ -105,7 +98,7 @@ impl Iterator for LookupHost { if self.cur.is_null() { return None } let ret = sockaddr_to_addr(mem::transmute((*self.cur).ai_addr), (*self.cur).ai_addrlen as usize); - self.cur = (*self.cur).ai_next as *mut libc::addrinfo; + self.cur = (*self.cur).ai_next as *mut c::addrinfo; Some(ret) } } @@ -116,7 +109,7 @@ unsafe impl Send for LookupHost {} impl Drop for LookupHost { fn drop(&mut self) { - unsafe { freeaddrinfo(self.original) } + unsafe { c::freeaddrinfo(self.original) } } } @@ -126,8 +119,8 @@ pub fn lookup_host(host: &str) -> io::Result { let c_host = try!(CString::new(host)); let mut res = ptr::null_mut(); unsafe { - try!(cvt_gai(getaddrinfo(c_host.as_ptr(), ptr::null(), ptr::null(), - &mut res))); + try!(cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), ptr::null(), + &mut res))); Ok(LookupHost { original: res, cur: res }) } } @@ -136,26 +129,18 @@ pub fn lookup_host(host: &str) -> io::Result { // lookup_addr //////////////////////////////////////////////////////////////////////////////// -extern "system" { - fn getnameinfo(sa: *const libc::sockaddr, salen: socklen_t, - host: *mut c_char, hostlen: libc::size_t, - serv: *mut c_char, servlen: libc::size_t, - flags: c_int) -> c_int; -} - -const NI_MAXHOST: usize = 1025; - pub fn lookup_addr(addr: &IpAddr) -> io::Result { init(); let saddr = SocketAddr::new(*addr, 0); let (inner, len) = saddr.into_inner(); - let mut hostbuf = [0 as c_char; NI_MAXHOST]; + let mut hostbuf = [0 as c_char; c::NI_MAXHOST as usize]; let data = unsafe { - try!(cvt_gai(getnameinfo(inner, len, - hostbuf.as_mut_ptr(), NI_MAXHOST as libc::size_t, - ptr::null_mut(), 0, 0))); + try!(cvt_gai(c::getnameinfo(inner, len, + hostbuf.as_mut_ptr(), + c::NI_MAXHOST, + ptr::null_mut(), 0, 0))); CStr::from_ptr(hostbuf.as_ptr()) }; @@ -179,10 +164,10 @@ impl TcpStream { pub fn connect(addr: &SocketAddr) -> io::Result { init(); - let sock = try!(Socket::new(addr, libc::SOCK_STREAM)); + let sock = try!(Socket::new(addr, c::SOCK_STREAM)); let (addrp, len) = addr.into_inner(); - try!(cvt_r(|| unsafe { libc::connect(*sock.as_inner(), addrp, len) })); + try!(cvt_r(|| unsafe { c::connect(*sock.as_inner(), addrp, len) })); Ok(TcpStream { inner: sock }) } @@ -191,19 +176,19 @@ impl TcpStream { pub fn into_socket(self) -> Socket { self.inner } pub fn set_read_timeout(&self, dur: Option) -> io::Result<()> { - self.inner.set_timeout(dur, libc::SO_RCVTIMEO) + self.inner.set_timeout(dur, c::SO_RCVTIMEO) } pub fn set_write_timeout(&self, dur: Option) -> io::Result<()> { - self.inner.set_timeout(dur, libc::SO_SNDTIMEO) + self.inner.set_timeout(dur, c::SO_SNDTIMEO) } pub fn read_timeout(&self) -> io::Result> { - self.inner.timeout(libc::SO_RCVTIMEO) + self.inner.timeout(c::SO_RCVTIMEO) } pub fn write_timeout(&self) -> io::Result> { - self.inner.timeout(libc::SO_SNDTIMEO) + self.inner.timeout(c::SO_SNDTIMEO) } pub fn read(&self, buf: &mut [u8]) -> io::Result { @@ -212,36 +197,28 @@ impl TcpStream { pub fn write(&self, buf: &[u8]) -> io::Result { let ret = try!(cvt(unsafe { - libc::send(*self.inner.as_inner(), - buf.as_ptr() as *const c_void, - buf.len() as wrlen_t, - 0) + c::send(*self.inner.as_inner(), + buf.as_ptr() as *const c_void, + buf.len() as wrlen_t, + 0) })); Ok(ret as usize) } pub fn peer_addr(&self) -> io::Result { sockname(|buf, len| unsafe { - libc::getpeername(*self.inner.as_inner(), buf, len) + c::getpeername(*self.inner.as_inner(), buf, len) }) } pub fn socket_addr(&self) -> io::Result { sockname(|buf, len| unsafe { - libc::getsockname(*self.inner.as_inner(), buf, len) + c::getsockname(*self.inner.as_inner(), buf, len) }) } pub fn shutdown(&self, how: Shutdown) -> io::Result<()> { - use libc::consts::os::bsd44::SHUT_RDWR; - - let how = match how { - Shutdown::Write => libc::SHUT_WR, - Shutdown::Read => libc::SHUT_RD, - Shutdown::Both => SHUT_RDWR, - }; - try!(cvt(unsafe { libc::shutdown(*self.inner.as_inner(), how) })); - Ok(()) + self.inner.shutdown(how) } pub fn duplicate(&self) -> io::Result { @@ -285,22 +262,22 @@ impl TcpListener { pub fn bind(addr: &SocketAddr) -> io::Result { init(); - let sock = try!(Socket::new(addr, libc::SOCK_STREAM)); + let sock = try!(Socket::new(addr, c::SOCK_STREAM)); // On platforms with Berkeley-derived sockets, this allows // to quickly rebind a socket, without needing to wait for // the OS to clean up the previous one. if !cfg!(windows) { - try!(setsockopt(&sock, libc::SOL_SOCKET, libc::SO_REUSEADDR, + try!(setsockopt(&sock, c::SOL_SOCKET, c::SO_REUSEADDR, 1 as c_int)); } // Bind our new socket let (addrp, len) = addr.into_inner(); - try!(cvt(unsafe { libc::bind(*sock.as_inner(), addrp, len) })); + try!(cvt(unsafe { c::bind(*sock.as_inner(), addrp, len) })); // Start listening - try!(cvt(unsafe { libc::listen(*sock.as_inner(), 128) })); + try!(cvt(unsafe { c::listen(*sock.as_inner(), 128) })); Ok(TcpListener { inner: sock }) } @@ -310,13 +287,13 @@ impl TcpListener { pub fn socket_addr(&self) -> io::Result { sockname(|buf, len| unsafe { - libc::getsockname(*self.inner.as_inner(), buf, len) + c::getsockname(*self.inner.as_inner(), buf, len) }) } pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> { - let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() }; - let mut len = mem::size_of_val(&storage) as socklen_t; + let mut storage: c::sockaddr_storage = unsafe { mem::zeroed() }; + let mut len = mem::size_of_val(&storage) as c::socklen_t; let sock = try!(self.inner.accept(&mut storage as *mut _ as *mut _, &mut len)); let addr = try!(sockaddr_to_addr(&storage, len as usize)); @@ -360,9 +337,9 @@ impl UdpSocket { pub fn bind(addr: &SocketAddr) -> io::Result { init(); - let sock = try!(Socket::new(addr, libc::SOCK_DGRAM)); + let sock = try!(Socket::new(addr, c::SOCK_DGRAM)); let (addrp, len) = addr.into_inner(); - try!(cvt(unsafe { libc::bind(*sock.as_inner(), addrp, len) })); + try!(cvt(unsafe { c::bind(*sock.as_inner(), addrp, len) })); Ok(UdpSocket { inner: sock }) } @@ -372,19 +349,19 @@ impl UdpSocket { pub fn socket_addr(&self) -> io::Result { sockname(|buf, len| unsafe { - libc::getsockname(*self.inner.as_inner(), buf, len) + c::getsockname(*self.inner.as_inner(), buf, len) }) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() }; - let mut addrlen = mem::size_of_val(&storage) as socklen_t; + let mut storage: c::sockaddr_storage = unsafe { mem::zeroed() }; + let mut addrlen = mem::size_of_val(&storage) as c::socklen_t; let n = try!(cvt(unsafe { - libc::recvfrom(*self.inner.as_inner(), - buf.as_mut_ptr() as *mut c_void, - buf.len() as wrlen_t, 0, - &mut storage as *mut _ as *mut _, &mut addrlen) + c::recvfrom(*self.inner.as_inner(), + buf.as_mut_ptr() as *mut c_void, + buf.len() as wrlen_t, 0, + &mut storage as *mut _ as *mut _, &mut addrlen) })); Ok((n as usize, try!(sockaddr_to_addr(&storage, addrlen as usize)))) } @@ -392,9 +369,9 @@ impl UdpSocket { pub fn send_to(&self, buf: &[u8], dst: &SocketAddr) -> io::Result { let (dstp, dstlen) = dst.into_inner(); let ret = try!(cvt(unsafe { - libc::sendto(*self.inner.as_inner(), - buf.as_ptr() as *const c_void, buf.len() as wrlen_t, - 0, dstp, dstlen) + c::sendto(*self.inner.as_inner(), + buf.as_ptr() as *const c_void, buf.len() as wrlen_t, + 0, dstp, dstlen) })); Ok(ret as usize) } @@ -404,19 +381,19 @@ impl UdpSocket { } pub fn set_read_timeout(&self, dur: Option) -> io::Result<()> { - self.inner.set_timeout(dur, libc::SO_RCVTIMEO) + self.inner.set_timeout(dur, c::SO_RCVTIMEO) } pub fn set_write_timeout(&self, dur: Option) -> io::Result<()> { - self.inner.set_timeout(dur, libc::SO_SNDTIMEO) + self.inner.set_timeout(dur, c::SO_SNDTIMEO) } pub fn read_timeout(&self) -> io::Result> { - self.inner.timeout(libc::SO_RCVTIMEO) + self.inner.timeout(c::SO_RCVTIMEO) } pub fn write_timeout(&self) -> io::Result> { - self.inner.timeout(libc::SO_SNDTIMEO) + self.inner.timeout(c::SO_SNDTIMEO) } } diff --git a/src/libstd/sys/common/unwind/seh.rs b/src/libstd/sys/common/unwind/seh.rs index a89e8b499ac..7296194efda 100644 --- a/src/libstd/sys/common/unwind/seh.rs +++ b/src/libstd/sys/common/unwind/seh.rs @@ -52,45 +52,14 @@ use prelude::v1::*; use any::Any; -use libc::{c_ulong, DWORD, c_void}; use ptr; use sys_common::thread_local::StaticKey; +use sys::c; -// 0x R U S T -const RUST_PANIC: DWORD = 0x52555354; +// 0x R U S T +const RUST_PANIC: c::DWORD = 0x52555354; static PANIC_DATA: StaticKey = StaticKey::new(None); -// This function is provided by kernel32.dll -extern "system" { - #[unwind] - fn RaiseException(dwExceptionCode: DWORD, - dwExceptionFlags: DWORD, - nNumberOfArguments: DWORD, - lpArguments: *const c_ulong); -} - -#[repr(C)] -pub struct EXCEPTION_POINTERS { - ExceptionRecord: *mut EXCEPTION_RECORD, - ContextRecord: *mut CONTEXT, -} - -enum CONTEXT {} - -#[repr(C)] -struct EXCEPTION_RECORD { - ExceptionCode: DWORD, - ExceptionFlags: DWORD, - ExceptionRecord: *mut _EXCEPTION_RECORD, - ExceptionAddress: *mut c_void, - NumberParameters: DWORD, - ExceptionInformation: [*mut c_ulong; EXCEPTION_MAXIMUM_PARAMETERS], -} - -enum _EXCEPTION_RECORD {} - -const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15; - pub unsafe fn panic(data: Box) -> ! { // See module docs above for an explanation of why `data` is stored in a // thread local instead of being passed as an argument to the @@ -100,14 +69,14 @@ pub unsafe fn panic(data: Box) -> ! { rtassert!(PANIC_DATA.get().is_null()); PANIC_DATA.set(Box::into_raw(exception) as *mut u8); - RaiseException(RUST_PANIC, 0, 0, ptr::null()); + c::RaiseException(RUST_PANIC, 0, 0, ptr::null()); rtabort!("could not unwind stack"); } pub unsafe fn cleanup(ptr: *mut u8) -> Box { // The `ptr` here actually corresponds to the code of the exception, and our // real data is stored in our thread local. - rtassert!(ptr as DWORD == RUST_PANIC); + rtassert!(ptr as c::DWORD == RUST_PANIC); let data = PANIC_DATA.get() as *mut Box; PANIC_DATA.set(ptr::null_mut()); @@ -139,7 +108,7 @@ fn rust_eh_personality() { #[lang = "msvc_try_filter"] #[linkage = "external"] #[allow(private_no_mangle_fns)] -extern fn __rust_try_filter(eh_ptrs: *mut EXCEPTION_POINTERS, +extern fn __rust_try_filter(eh_ptrs: *mut c::EXCEPTION_POINTERS, _rbp: *mut u8) -> i32 { unsafe { ((*(*eh_ptrs).ExceptionRecord).ExceptionCode == RUST_PANIC) as i32 diff --git a/src/libstd/sys/common/unwind/seh64_gnu.rs b/src/libstd/sys/common/unwind/seh64_gnu.rs index 92f059d68e1..26c2cee9222 100644 --- a/src/libstd/sys/common/unwind/seh64_gnu.rs +++ b/src/libstd/sys/common/unwind/seh64_gnu.rs @@ -17,12 +17,10 @@ use prelude::v1::*; use any::Any; -use self::EXCEPTION_DISPOSITION::*; use sys_common::dwarf::eh; use core::mem; use core::ptr; -use libc::{c_void, c_ulonglong, DWORD, LPVOID}; -type ULONG_PTR = c_ulonglong; +use sys::c; // Define our exception codes: // according to http://msdn.microsoft.com/en-us/library/het71c37(v=VS.80).aspx, @@ -32,80 +30,10 @@ type ULONG_PTR = c_ulonglong; // we define bits: // [24:27] = type // [0:23] = magic -const ETYPE: DWORD = 0b1110_u32 << 28; -const MAGIC: DWORD = 0x525354; // "RST" +const ETYPE: c::DWORD = 0b1110_u32 << 28; +const MAGIC: c::DWORD = 0x525354; // "RST" -const RUST_PANIC: DWORD = ETYPE | (1 << 24) | MAGIC; - -const EXCEPTION_NONCONTINUABLE: DWORD = 0x1; // Noncontinuable exception -const EXCEPTION_UNWINDING: DWORD = 0x2; // Unwind is in progress -const EXCEPTION_EXIT_UNWIND: DWORD = 0x4; // Exit unwind is in progress -const EXCEPTION_STACK_INVALID: DWORD = 0x8; // Stack out of limits or unaligned -const EXCEPTION_NESTED_CALL: DWORD = 0x10; // Nested exception handler call -const EXCEPTION_TARGET_UNWIND: DWORD = 0x20; // Target unwind in progress -const EXCEPTION_COLLIDED_UNWIND: DWORD = 0x40; // Collided exception handler call -const EXCEPTION_UNWIND: DWORD = EXCEPTION_UNWINDING | - EXCEPTION_EXIT_UNWIND | - EXCEPTION_TARGET_UNWIND | - EXCEPTION_COLLIDED_UNWIND; - -#[repr(C)] -pub struct EXCEPTION_RECORD { - ExceptionCode: DWORD, - ExceptionFlags: DWORD, - ExceptionRecord: *const EXCEPTION_RECORD, - ExceptionAddress: LPVOID, - NumberParameters: DWORD, - ExceptionInformation: [ULONG_PTR; 15], -} - -pub enum CONTEXT {} -pub enum UNWIND_HISTORY_TABLE {} - -#[repr(C)] -pub struct RUNTIME_FUNCTION { - BeginAddress: DWORD, - EndAddress: DWORD, - UnwindData: DWORD, -} - -#[repr(C)] -pub struct DISPATCHER_CONTEXT { - ControlPc: LPVOID, - ImageBase: LPVOID, - FunctionEntry: *const RUNTIME_FUNCTION, - EstablisherFrame: LPVOID, - TargetIp: LPVOID, - ContextRecord: *const CONTEXT, - LanguageHandler: LPVOID, - HandlerData: *const u8, - HistoryTable: *const UNWIND_HISTORY_TABLE, -} - -#[repr(C)] -#[derive(Copy, Clone)] -pub enum EXCEPTION_DISPOSITION { - ExceptionContinueExecution, - ExceptionContinueSearch, - ExceptionNestedException, - ExceptionCollidedUnwind -} - -// From kernel32.dll -extern "system" { - #[unwind] - fn RaiseException(dwExceptionCode: DWORD, - dwExceptionFlags: DWORD, - nNumberOfArguments: DWORD, - lpArguments: *const ULONG_PTR); - - fn RtlUnwindEx(TargetFrame: LPVOID, - TargetIp: LPVOID, - ExceptionRecord: *const EXCEPTION_RECORD, - ReturnValue: LPVOID, - OriginalContext: *const CONTEXT, - HistoryTable: *const UNWIND_HISTORY_TABLE); -} +const RUST_PANIC: c::DWORD = ETYPE | (1 << 24) | MAGIC; #[repr(C)] struct PanicData { @@ -114,11 +42,11 @@ struct PanicData { pub unsafe fn panic(data: Box) -> ! { let panic_ctx = Box::new(PanicData { data: data }); - let params = [Box::into_raw(panic_ctx) as ULONG_PTR]; - RaiseException(RUST_PANIC, - EXCEPTION_NONCONTINUABLE, - params.len() as DWORD, - ¶ms as *const ULONG_PTR); + let params = [Box::into_raw(panic_ctx) as c::ULONG_PTR]; + c::RaiseException(RUST_PANIC, + c::EXCEPTION_NONCONTINUABLE, + params.len() as c::DWORD, + ¶ms as *const c::ULONG_PTR); rtabort!("could not unwind stack"); } @@ -152,11 +80,11 @@ pub unsafe fn cleanup(ptr: *mut u8) -> Box { #[lang = "eh_personality_catch"] #[cfg(not(test))] unsafe extern fn rust_eh_personality_catch( - exceptionRecord: *mut EXCEPTION_RECORD, - establisherFrame: LPVOID, - contextRecord: *mut CONTEXT, - dispatcherContext: *mut DISPATCHER_CONTEXT -) -> EXCEPTION_DISPOSITION + exceptionRecord: *mut c::EXCEPTION_RECORD, + establisherFrame: c::LPVOID, + contextRecord: *mut c::CONTEXT, + dispatcherContext: *mut c::DISPATCHER_CONTEXT +) -> c::EXCEPTION_DISPOSITION { rust_eh_personality(exceptionRecord, establisherFrame, contextRecord, dispatcherContext) @@ -165,44 +93,44 @@ unsafe extern fn rust_eh_personality_catch( #[lang = "eh_personality"] #[cfg(not(test))] unsafe extern fn rust_eh_personality( - exceptionRecord: *mut EXCEPTION_RECORD, - establisherFrame: LPVOID, - contextRecord: *mut CONTEXT, - dispatcherContext: *mut DISPATCHER_CONTEXT -) -> EXCEPTION_DISPOSITION + exceptionRecord: *mut c::EXCEPTION_RECORD, + establisherFrame: c::LPVOID, + contextRecord: *mut c::CONTEXT, + dispatcherContext: *mut c::DISPATCHER_CONTEXT +) -> c::EXCEPTION_DISPOSITION { let er = &*exceptionRecord; let dc = &*dispatcherContext; - if er.ExceptionFlags & EXCEPTION_UNWIND == 0 { // we are in the dispatch phase + if er.ExceptionFlags & c::EXCEPTION_UNWIND == 0 { // we are in the dispatch phase if er.ExceptionCode == RUST_PANIC { if let Some(lpad) = find_landing_pad(dc) { - RtlUnwindEx(establisherFrame, - lpad as LPVOID, - exceptionRecord, - er.ExceptionInformation[0] as LPVOID, // pointer to PanicData - contextRecord, - dc.HistoryTable); + c::RtlUnwindEx(establisherFrame, + lpad as c::LPVOID, + exceptionRecord, + er.ExceptionInformation[0] as c::LPVOID, // pointer to PanicData + contextRecord, + dc.HistoryTable); rtabort!("could not unwind"); } } } - ExceptionContinueSearch + c::ExceptionContinueSearch } #[cfg(not(test))] #[lang = "eh_unwind_resume"] #[unwind] -unsafe extern fn rust_eh_unwind_resume(panic_ctx: LPVOID) -> ! { - let params = [panic_ctx as ULONG_PTR]; - RaiseException(RUST_PANIC, - EXCEPTION_NONCONTINUABLE, - params.len() as DWORD, - ¶ms as *const ULONG_PTR); +unsafe extern fn rust_eh_unwind_resume(panic_ctx: c::LPVOID) -> ! { + let params = [panic_ctx as c::ULONG_PTR]; + c::RaiseException(RUST_PANIC, + c::EXCEPTION_NONCONTINUABLE, + params.len() as c::DWORD, + ¶ms as *const c::ULONG_PTR); rtabort!("could not resume unwind"); } -unsafe fn find_landing_pad(dc: &DISPATCHER_CONTEXT) -> Option { +unsafe fn find_landing_pad(dc: &c::DISPATCHER_CONTEXT) -> Option { let eh_ctx = eh::EHContext { ip: dc.ControlPc as usize, func_start: dc.ImageBase as usize + (*dc.FunctionEntry).BeginAddress as usize, -- cgit 1.4.1-3-g733a5