Skip to content

Commit 1a0a263

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

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed

src/libstd/sys/windows/c.rs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,6 @@ pub const WAIT_OBJECT_0: DWORD = 0x00000000;
260260
pub const WAIT_TIMEOUT: DWORD = 258;
261261
pub const WAIT_FAILED: DWORD = 0xFFFFFFFF;
262262

263-
pub const EXCEPTION_CONTINUE_SEARCH: LONG = 0;
264-
pub const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
265-
pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
266-
267263
pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
268264
pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002;
269265
pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000;
@@ -448,25 +444,6 @@ pub struct REPARSE_MOUNTPOINT_DATA_BUFFER {
448444
pub ReparseTarget: WCHAR,
449445
}
450446

451-
#[repr(C)]
452-
pub struct EXCEPTION_RECORD {
453-
pub ExceptionCode: DWORD,
454-
pub ExceptionFlags: DWORD,
455-
pub ExceptionRecord: *mut EXCEPTION_RECORD,
456-
pub ExceptionAddress: LPVOID,
457-
pub NumberParameters: DWORD,
458-
pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS]
459-
}
460-
461-
#[repr(C)]
462-
pub struct EXCEPTION_POINTERS {
463-
pub ExceptionRecord: *mut EXCEPTION_RECORD,
464-
pub ContextRecord: *mut CONTEXT,
465-
}
466-
467-
pub type PVECTORED_EXCEPTION_HANDLER = extern "system"
468-
fn(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG;
469-
470447
#[repr(C)]
471448
pub struct GUID {
472449
pub Data1: DWORD,
@@ -549,8 +526,6 @@ pub enum ADDRESS_MODE {
549526
AddrModeFlat,
550527
}
551528

552-
pub enum CONTEXT {}
553-
554529
#[repr(C)]
555530
pub struct SOCKADDR_STORAGE_LH {
556531
pub ss_family: ADDRESS_FAMILY,
@@ -635,6 +610,31 @@ pub struct timeval {
635610
// Functions forbidden when targeting UWP
636611
#[cfg(not(target_vendor = "uwp"))]
637612
ifdef! {
613+
pub const EXCEPTION_CONTINUE_SEARCH: LONG = 0;
614+
pub const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
615+
pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
616+
617+
#[repr(C)]
618+
pub struct EXCEPTION_RECORD {
619+
pub ExceptionCode: DWORD,
620+
pub ExceptionFlags: DWORD,
621+
pub ExceptionRecord: *mut EXCEPTION_RECORD,
622+
pub ExceptionAddress: LPVOID,
623+
pub NumberParameters: DWORD,
624+
pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS]
625+
}
626+
627+
pub enum CONTEXT {}
628+
629+
#[repr(C)]
630+
pub struct EXCEPTION_POINTERS {
631+
pub ExceptionRecord: *mut EXCEPTION_RECORD,
632+
pub ContextRecord: *mut CONTEXT,
633+
}
634+
635+
pub type PVECTORED_EXCEPTION_HANDLER = extern "system"
636+
fn(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG;
637+
638638
#[repr(C)]
639639
#[derive(Copy, Clone)]
640640
pub struct CONSOLE_READCONSOLE_CONTROL {
@@ -698,6 +698,9 @@ ifdef! {
698698
pub fn SetHandleInformation(hObject: HANDLE,
699699
dwMask: DWORD,
700700
dwFlags: DWORD) -> BOOL;
701+
pub fn AddVectoredExceptionHandler(FirstHandler: ULONG,
702+
VectoredHandler: PVECTORED_EXCEPTION_HANDLER)
703+
-> LPVOID;
701704
pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
702705
lpTargetFileName: LPCWSTR,
703706
lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
@@ -806,9 +809,6 @@ extern "system" {
806809
lpData: LPVOID,
807810
pbCancel: LPBOOL,
808811
dwCopyFlags: DWORD) -> BOOL;
809-
pub fn AddVectoredExceptionHandler(FirstHandler: ULONG,
810-
VectoredHandler: PVECTORED_EXCEPTION_HANDLER)
811-
-> LPVOID;
812812
pub fn FormatMessageW(flags: DWORD,
813813
lpSrc: LPVOID,
814814
msgId: DWORD,
@@ -1017,6 +1017,7 @@ compat_fn! {
10171017
_dwFlags: DWORD) -> DWORD {
10181018
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
10191019
}
1020+
#[cfg(not(target_vendor = "uwp"))]
10201021
pub fn SetThreadStackGuarantee(_size: *mut c_ulong) -> BOOL {
10211022
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
10221023
}

src/libstd/sys/windows/mod.rs

Lines changed: 3 additions & 1 deletion
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! {
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

Lines changed: 13 additions & 0 deletions
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)