diff options
| author | bors <bors@rust-lang.org> | 2015-06-28 03:57:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-06-28 03:57:07 +0000 |
| commit | 5da0d415b66733f9a146bbdd6c6cce81430e77c2 (patch) | |
| tree | 538dbf67a23dbd8297576319f4bb0011bb633a65 /src/libstd/sys/windows/stack_overflow.rs | |
| parent | 8fa2185e0babe71699b2c372f8399c27effecd92 (diff) | |
| parent | 10b103af48368c5df644fa61dc417a36083922c8 (diff) | |
| download | rust-5da0d415b66733f9a146bbdd6c6cce81430e77c2.tar.gz rust-5da0d415b66733f9a146bbdd6c6cce81430e77c2.zip | |
Auto merge of #26601 - alexcrichton:xp, r=brson
This series of commits (currently rebased on https://github.com/rust-lang/rust/pull/26569 to avoid conflicts) adds support for the standard library to run on Windows XP. The main motivation behind this PR is that to enable any Rust code in Firefox we need to support Windows XP. This PR doesn't yet intend to be a move to make Windows XP an officially supported platform, but instead simply get Rust code running on it. APIs like condition variables and RWLocks will immediately panic currently on XP, and it's unclear if that story wants to change much. Additionally, we may bind APIs like IOCP which aren't available on XP and would be *very* difficult to provide a fallback implementation. Essentially this PR enables running Rust on XP, but you still have to be careful to avoid non-XP portions of the standard library. The major components of this PR are: * Support for a new `i686-pc-windows-msvc` triple. This primarily involves a lot of build system hackery, but there are also a number of floating point functions which had to get switched up a bit. * All APIs not available on Windows are now accessed through our dynamic-detection mechanism * Mutexes on Windows were rewritten to use SRWLOCK as an optimization but can fall back to CRITICAL_SECTION.
Diffstat (limited to 'src/libstd/sys/windows/stack_overflow.rs')
| -rw-r--r-- | src/libstd/sys/windows/stack_overflow.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/libstd/sys/windows/stack_overflow.rs b/src/libstd/sys/windows/stack_overflow.rs index 79b7de4f341..cf827848db5 100644 --- a/src/libstd/sys/windows/stack_overflow.rs +++ b/src/libstd/sys/windows/stack_overflow.rs @@ -8,12 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rt::util::report_overflow; use core::prelude::*; -use ptr; -use mem; + +use libc::types::os::arch::extra::{LPVOID, DWORD, LONG}; use libc; -use libc::types::os::arch::extra::{LPVOID, DWORD, LONG, BOOL}; +use mem; +use ptr; +use rt::util::report_overflow; +use sys::c; use sys_common::stack; pub struct Handler { @@ -69,8 +71,12 @@ pub unsafe fn cleanup() { } pub unsafe fn make_handler() -> Handler { - if SetThreadStackGuarantee(&mut 0x5000) == 0 { - panic!("failed to reserve stack space for exception handling"); + // This API isn't available on XP, so don't panic in that case and just pray + // it works out ok. + if c::SetThreadStackGuarantee(&mut 0x5000) == 0 { + if libc::GetLastError() as u32 != libc::ERROR_CALL_NOT_IMPLEMENTED as u32 { + panic!("failed to reserve stack space for exception handling"); + } } Handler { _data: 0 as *mut libc::c_void } @@ -103,5 +109,4 @@ extern "system" { fn AddVectoredExceptionHandler(FirstHandler: ULONG, VectoredHandler: PVECTORED_EXCEPTION_HANDLER) -> LPVOID; - fn SetThreadStackGuarantee(StackSizeInBytes: *mut ULONG) -> BOOL; } |
