source: mainline/uspace/lib/cpp/src/internal/unwind.cpp@ 9dfdb03

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9dfdb03 was 858a51f, checked in by Dzejrou <dzejrou@…>, 7 years ago

cpp: added unwind to makefile and a missing declaration to unwind level 1

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * Copyright (c) 2017 Jaroslav Jindrak
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <cstdint>
30
31namespace __cxxabiv1
32{
33 /**
34 * Stack unwinding functionality - Level 1.
35 */
36
37 enum _Unwind_Reason_Code
38 {
39 _URC_NO_REASON = 0,
40 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
41 _URC_FATAL_PHASE2_ERROR = 2,
42 _URC_FATAL_PHASE1_ERROR = 3,
43 _URC_NORMAL_STOP = 4,
44 _URC_END_OF_STACK = 5,
45 _URC_HANDLER_FOUND = 6,
46 _URC_INSTALL_CONTEXT = 7,
47 _URC_CONTINUE_UNWIND = 8
48 };
49
50 struct _Unwind_Exception;
51 using _Unwind_Exception_Cleanup_Fn = void (*)(_Unwind_Reason_Code, _Unwind_Exception*);
52
53 struct _Unwind_Exception
54 {
55 std::uint64_t exception_class;
56 _Unwind_Exception_Cleanup_Fn exception_cleanup;
57 std::uint64_t private_1;
58 std::uint64_t private_2;
59 };
60
61 /* Opaque structure. */
62 struct _Unwind_Context;
63
64 using _Unwind_Action = int;
65 namespace
66 {
67 const _Unwind_Action _UA_SEARCH_PHASE = 1;
68 const _Unwind_Action _UA_CLEANUP_PHASE = 2;
69 const _Unwind_Action _UA_HANDLER_FRAME = 4;
70 const _Unwind_Action _UA_FORCE_HANDLER = 8;
71 }
72
73 /**
74 * TODO: Explain parameter semantics.
75 */
76 using _Unwind_Stop_Fn = _Unwind_Reason_Code(*)(
77 int, _Unwind_Action, std::uint64_t, _Unwind_Exception*,
78 _Unwind_Context*, void*
79 );
80
81 _Unwind_Reason_Code _Unwind_ForcedUnwind(_Unwind_Exception*, _Unwind_Stop_Fn, void*)
82 {
83 // TODO: implement
84 }
85
86 void _Unwind_Resume(_Unwind_Exception*)
87 {
88 // TODO: implement
89 }
90
91 void _Unwind_DeleteException(_Unwind_Exception*)
92 {
93 // TODO: implement
94 }
95
96 std::uint64_t _Unwind_GetGR(_Unwind_Context*, int)
97 {
98 // TODO: implement
99 }
100
101 void _Unwind_SetGR(_Unwind_Context*, int, std::uint64_t)
102 {
103 // TODO: implement
104 }
105
106 std::uint64_t _Unwind_GetIP(_Unwind_Context*)
107 {
108 // TODO: implement
109 }
110
111 void _Unwind_SetIP(_Unwind_Context*, std::uint64_t)
112 {
113 // TODO: implement
114 }
115
116 std::uint64_t _Unwind_GetLanguageSpecificData(_Unwind_Context*)
117 {
118 // TODO: implement
119 }
120
121 std::uint64_t _Unwind_GetRegionStart(_Unwind_Context*)
122 {
123 // TODO: implement
124 }
125
126 /**
127 * TODO: Explain parameter semantics.
128 */
129 using __personality_routine = _Unwind_Reason_Code(*)(
130 int, _Unwind_Action, std::uint64_t, _Unwind_Exception*,
131 _Unwind_Context*, void*
132 );
133
134 /**
135 * Stack unwinding functionality - Level 2.
136 */
137 // TODO:
138}
Note: See TracBrowser for help on using the repository browser.