]> git.proxmox.com Git - rustc.git/blame - src/libpanic_unwind/windows.rs
New upstream version 1.27.1+dfsg1
[rustc.git] / src / libpanic_unwind / windows.rs
CommitLineData
a7813a04
XL
1// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11#![allow(bad_style)]
12#![allow(dead_code)]
13#![cfg(windows)]
14
7cac9316 15use libc::{c_long, c_ulong, c_void};
a7813a04
XL
16
17pub type DWORD = c_ulong;
18pub type LONG = c_long;
7cac9316 19pub type ULONG_PTR = usize;
a7813a04
XL
20pub type LPVOID = *mut c_void;
21
22pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
23pub const EXCEPTION_NONCONTINUABLE: DWORD = 0x1; // Noncontinuable exception
24pub const EXCEPTION_UNWINDING: DWORD = 0x2; // Unwind is in progress
25pub const EXCEPTION_EXIT_UNWIND: DWORD = 0x4; // Exit unwind is in progress
26pub const EXCEPTION_TARGET_UNWIND: DWORD = 0x20; // Target unwind in progress
27pub const EXCEPTION_COLLIDED_UNWIND: DWORD = 0x40; // Collided exception handler call
3157f602 28pub const EXCEPTION_UNWIND: DWORD = EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND |
a7813a04
XL
29 EXCEPTION_TARGET_UNWIND |
30 EXCEPTION_COLLIDED_UNWIND;
31
32#[repr(C)]
33pub struct EXCEPTION_RECORD {
34 pub ExceptionCode: DWORD,
35 pub ExceptionFlags: DWORD,
36 pub ExceptionRecord: *mut EXCEPTION_RECORD,
37 pub ExceptionAddress: LPVOID,
38 pub NumberParameters: DWORD,
3157f602 39 pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS],
a7813a04
XL
40}
41
42#[repr(C)]
43pub struct EXCEPTION_POINTERS {
44 pub ExceptionRecord: *mut EXCEPTION_RECORD,
45 pub ContextRecord: *mut CONTEXT,
46}
47
48pub enum UNWIND_HISTORY_TABLE {}
49
50#[repr(C)]
51pub struct RUNTIME_FUNCTION {
52 pub BeginAddress: DWORD,
53 pub EndAddress: DWORD,
54 pub UnwindData: DWORD,
55}
56
57pub enum CONTEXT {}
58
59#[repr(C)]
60pub struct DISPATCHER_CONTEXT {
61 pub ControlPc: LPVOID,
62 pub ImageBase: LPVOID,
63 pub FunctionEntry: *const RUNTIME_FUNCTION,
64 pub EstablisherFrame: LPVOID,
65 pub TargetIp: LPVOID,
66 pub ContextRecord: *const CONTEXT,
67 pub LanguageHandler: LPVOID,
68 pub HandlerData: *const u8,
69 pub HistoryTable: *const UNWIND_HISTORY_TABLE,
70}
71
72#[repr(C)]
73pub enum EXCEPTION_DISPOSITION {
74 ExceptionContinueExecution,
75 ExceptionContinueSearch,
76 ExceptionNestedException,
3157f602 77 ExceptionCollidedUnwind,
a7813a04
XL
78}
79pub use self::EXCEPTION_DISPOSITION::*;
80
81extern "system" {
83c7162d 82 #[unwind(allowed)]
a7813a04
XL
83 pub fn RaiseException(dwExceptionCode: DWORD,
84 dwExceptionFlags: DWORD,
85 nNumberOfArguments: DWORD,
86 lpArguments: *const ULONG_PTR);
83c7162d 87 #[unwind(allowed)]
a7813a04
XL
88 pub fn RtlUnwindEx(TargetFrame: LPVOID,
89 TargetIp: LPVOID,
90 ExceptionRecord: *const EXCEPTION_RECORD,
91 ReturnValue: LPVOID,
92 OriginalContext: *const CONTEXT,
93 HistoryTable: *const UNWIND_HISTORY_TABLE);
83c7162d 94 #[unwind(allowed)]
3157f602 95 pub fn _CxxThrowException(pExceptionObject: *mut c_void, pThrowInfo: *mut u8);
a7813a04 96}