]> git.lizzy.rs Git - rust.git/blob - src/libpanic_unwind/windows.rs
Rollup merge of #58440 - gnzlbg:v6, r=japaric
[rust.git] / src / libpanic_unwind / windows.rs
1 #![allow(nonstandard_style)]
2 #![allow(dead_code)]
3 #![cfg(windows)]
4
5 use libc::{c_long, c_ulong, c_void};
6
7 pub type DWORD = c_ulong;
8 pub type LONG = c_long;
9 pub type ULONG_PTR = usize;
10 pub type LPVOID = *mut c_void;
11
12 pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
13 pub const EXCEPTION_NONCONTINUABLE: DWORD = 0x1;   // Noncontinuable exception
14 pub const EXCEPTION_UNWINDING: DWORD = 0x2;        // Unwind is in progress
15 pub const EXCEPTION_EXIT_UNWIND: DWORD = 0x4;      // Exit unwind is in progress
16 pub const EXCEPTION_TARGET_UNWIND: DWORD = 0x20;   // Target unwind in progress
17 pub const EXCEPTION_COLLIDED_UNWIND: DWORD = 0x40; // Collided exception handler call
18 pub const EXCEPTION_UNWIND: DWORD = EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND |
19                                     EXCEPTION_TARGET_UNWIND |
20                                     EXCEPTION_COLLIDED_UNWIND;
21
22 #[repr(C)]
23 pub struct EXCEPTION_RECORD {
24     pub ExceptionCode: DWORD,
25     pub ExceptionFlags: DWORD,
26     pub ExceptionRecord: *mut EXCEPTION_RECORD,
27     pub ExceptionAddress: LPVOID,
28     pub NumberParameters: DWORD,
29     pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS],
30 }
31
32 #[repr(C)]
33 pub struct EXCEPTION_POINTERS {
34     pub ExceptionRecord: *mut EXCEPTION_RECORD,
35     pub ContextRecord: *mut CONTEXT,
36 }
37
38 pub enum UNWIND_HISTORY_TABLE {}
39
40 #[repr(C)]
41 pub struct RUNTIME_FUNCTION {
42     pub BeginAddress: DWORD,
43     pub EndAddress: DWORD,
44     pub UnwindData: DWORD,
45 }
46
47 pub enum CONTEXT {}
48
49 #[repr(C)]
50 pub struct DISPATCHER_CONTEXT {
51     pub ControlPc: LPVOID,
52     pub ImageBase: LPVOID,
53     pub FunctionEntry: *const RUNTIME_FUNCTION,
54     pub EstablisherFrame: LPVOID,
55     pub TargetIp: LPVOID,
56     pub ContextRecord: *const CONTEXT,
57     pub LanguageHandler: LPVOID,
58     pub HandlerData: *const u8,
59     pub HistoryTable: *const UNWIND_HISTORY_TABLE,
60 }
61
62 #[repr(C)]
63 pub enum EXCEPTION_DISPOSITION {
64     ExceptionContinueExecution,
65     ExceptionContinueSearch,
66     ExceptionNestedException,
67     ExceptionCollidedUnwind,
68 }
69 pub use self::EXCEPTION_DISPOSITION::*;
70
71 extern "system" {
72     #[unwind(allowed)]
73     pub fn RaiseException(dwExceptionCode: DWORD,
74                           dwExceptionFlags: DWORD,
75                           nNumberOfArguments: DWORD,
76                           lpArguments: *const ULONG_PTR);
77     #[unwind(allowed)]
78     pub fn RtlUnwindEx(TargetFrame: LPVOID,
79                        TargetIp: LPVOID,
80                        ExceptionRecord: *const EXCEPTION_RECORD,
81                        ReturnValue: LPVOID,
82                        OriginalContext: *const CONTEXT,
83                        HistoryTable: *const UNWIND_HISTORY_TABLE);
84     #[unwind(allowed)]
85     pub fn _CxxThrowException(pExceptionObject: *mut c_void, pThrowInfo: *mut u8);
86 }