Skip to content

Commit e88a4ce

Browse files
committed
std: win: Disable stack overflow handling on UWP
The required functions are not available, so hope for the best
1 parent 668f0d3 commit e88a4ce

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed

Diff for: src/libstd/sys/windows/c.rs

+29-28
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,6 @@ pub const WAIT_OBJECT_0: DWORD = 0x00000000;
256256
pub const WAIT_TIMEOUT: DWORD = 258;
257257
pub const WAIT_FAILED: DWORD = 0xFFFFFFFF;
258258

259-
pub const EXCEPTION_CONTINUE_SEARCH: LONG = 0;
260-
pub const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
261-
pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
262-
263259
pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
264260
pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002;
265261
pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000;
@@ -444,25 +440,6 @@ pub struct REPARSE_MOUNTPOINT_DATA_BUFFER {
444440
pub ReparseTarget: WCHAR,
445441
}
446442

447-
#[repr(C)]
448-
pub struct EXCEPTION_RECORD {
449-
pub ExceptionCode: DWORD,
450-
pub ExceptionFlags: DWORD,
451-
pub ExceptionRecord: *mut EXCEPTION_RECORD,
452-
pub ExceptionAddress: LPVOID,
453-
pub NumberParameters: DWORD,
454-
pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS]
455-
}
456-
457-
#[repr(C)]
458-
pub struct EXCEPTION_POINTERS {
459-
pub ExceptionRecord: *mut EXCEPTION_RECORD,
460-
pub ContextRecord: *mut CONTEXT,
461-
}
462-
463-
pub type PVECTORED_EXCEPTION_HANDLER = extern "system"
464-
fn(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG;
465-
466443
#[repr(C)]
467444
pub struct GUID {
468445
pub Data1: DWORD,
@@ -545,8 +522,6 @@ pub enum ADDRESS_MODE {
545522
AddrModeFlat,
546523
}
547524

548-
pub enum CONTEXT {}
549-
550525
#[repr(C)]
551526
pub struct SOCKADDR_STORAGE_LH {
552527
pub ss_family: ADDRESS_FAMILY,
@@ -631,6 +606,31 @@ pub struct timeval {
631606
// Functions forbidden when targeting UWP
632607
cfg_if::cfg_if! {
633608
if #[cfg(not(target_vendor = "uwp"))] {
609+
pub const EXCEPTION_CONTINUE_SEARCH: LONG = 0;
610+
pub const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
611+
pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
612+
613+
#[repr(C)]
614+
pub struct EXCEPTION_RECORD {
615+
pub ExceptionCode: DWORD,
616+
pub ExceptionFlags: DWORD,
617+
pub ExceptionRecord: *mut EXCEPTION_RECORD,
618+
pub ExceptionAddress: LPVOID,
619+
pub NumberParameters: DWORD,
620+
pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS]
621+
}
622+
623+
pub enum CONTEXT {}
624+
625+
#[repr(C)]
626+
pub struct EXCEPTION_POINTERS {
627+
pub ExceptionRecord: *mut EXCEPTION_RECORD,
628+
pub ContextRecord: *mut CONTEXT,
629+
}
630+
631+
pub type PVECTORED_EXCEPTION_HANDLER = extern "system"
632+
fn(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG;
633+
634634
#[repr(C)]
635635
#[derive(Copy, Clone)]
636636
pub struct CONSOLE_READCONSOLE_CONTROL {
@@ -694,6 +694,9 @@ if #[cfg(not(target_vendor = "uwp"))] {
694694
pub fn SetHandleInformation(hObject: HANDLE,
695695
dwMask: DWORD,
696696
dwFlags: DWORD) -> BOOL;
697+
pub fn AddVectoredExceptionHandler(FirstHandler: ULONG,
698+
VectoredHandler: PVECTORED_EXCEPTION_HANDLER)
699+
-> LPVOID;
697700
pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
698701
lpTargetFileName: LPCWSTR,
699702
lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
@@ -804,9 +807,6 @@ extern "system" {
804807
lpData: LPVOID,
805808
pbCancel: LPBOOL,
806809
dwCopyFlags: DWORD) -> BOOL;
807-
pub fn AddVectoredExceptionHandler(FirstHandler: ULONG,
808-
VectoredHandler: PVECTORED_EXCEPTION_HANDLER)
809-
-> LPVOID;
810810
pub fn FormatMessageW(flags: DWORD,
811811
lpSrc: LPVOID,
812812
msgId: DWORD,
@@ -1015,6 +1015,7 @@ compat_fn! {
10151015
_dwFlags: DWORD) -> DWORD {
10161016
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
10171017
}
1018+
#[cfg(not(target_vendor = "uwp"))]
10181019
pub fn SetThreadStackGuarantee(_size: *mut c_ulong) -> BOOL {
10191020
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
10201021
}

Diff for: src/libstd/sys/windows/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@ pub mod pipe;
3333
pub mod process;
3434
pub mod rand;
3535
pub mod rwlock;
36-
pub mod stack_overflow;
3736
pub mod thread;
3837
pub mod thread_local;
3938
pub mod time;
4039
cfg_if::cfg_if! {
4140
if #[cfg(not(target_vendor = "uwp"))] {
4241
pub mod stdio;
42+
pub mod stack_overflow;
4343
} else {
4444
pub mod stdio_uwp;
45+
pub mod stack_overflow_uwp;
4546
pub use self::stdio_uwp as stdio;
47+
pub use self::stack_overflow_uwp as stack_overflow;
4648
}
4749
}
4850

Diff for: src/libstd/sys/windows/stack_overflow_uwp.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![cfg_attr(test, allow(dead_code))]
2+
3+
pub struct Handler;
4+
5+
impl Handler {
6+
pub fn new() -> Handler {
7+
Handler
8+
}
9+
}
10+
11+
pub unsafe fn init() {}
12+
13+
pub unsafe fn cleanup() {}

0 commit comments

Comments
 (0)