/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to src/utility/unwind-cxx.h

  • Committer: edam
  • Date: 2012-02-28 16:50:26 UTC
  • Revision ID: edam@waxworlds.org-20120228165026-pwnwo300xx2e2kg6
removed ulibc, fixed button, added text rendering

Show diffs side-by-side

added added

removed removed

1
 
// -*- C++ -*- Exception handling and frame unwind runtime interface routines.
2
 
// Copyright (C) 2001 Free Software Foundation, Inc.
3
 
//
4
 
// This file is part of GCC.
5
 
//
6
 
// GCC is free software; you can redistribute it and/or modify
7
 
// it under the terms of the GNU General Public License as published by
8
 
// the Free Software Foundation; either version 2, or (at your option)
9
 
// any later version.
10
 
//
11
 
// GCC is distributed in the hope that it will be useful,
12
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
// GNU General Public License for more details.
15
 
//
16
 
// You should have received a copy of the GNU General Public License
17
 
// along with GCC; see the file COPYING.  If not, write to
18
 
// the Free Software Foundation, 59 Temple Place - Suite 330,
19
 
// Boston, MA 02111-1307, USA.
20
 
 
21
 
// As a special exception, you may use this file as part of a free software
22
 
// library without restriction.  Specifically, if other files instantiate
23
 
// templates or use macros or inline functions from this file, or you compile
24
 
// this file and link it with other files to produce an executable, this
25
 
// file does not by itself cause the resulting executable to be covered by
26
 
// the GNU General Public License.  This exception does not however
27
 
// invalidate any other reasons why the executable file might be covered by
28
 
// the GNU General Public License.
29
 
 
30
 
// This is derived from the C++ ABI for IA-64.  Where we diverge
31
 
// for cross-architecture compatibility are noted with "@@@".
32
 
 
33
 
#ifndef _UNWIND_CXX_H
34
 
#define _UNWIND_CXX_H 1
35
 
 
36
 
// Level 2: C++ ABI
37
 
 
38
 
#include <typeinfo>
39
 
#include <exception>
40
 
#include <cstddef>
41
 
#include "unwind.h"
42
 
 
43
 
#pragma GCC visibility push(default)
44
 
 
45
 
namespace __cxxabiv1
46
 
{
47
 
 
48
 
// A primary C++ exception object consists of a header, which is a wrapper
49
 
// around an unwind object header with additional C++ specific information,
50
 
// followed by the exception object itself.
51
 
 
52
 
struct __cxa_exception
53
 
54
 
  // Manage the exception object itself.
55
 
  std::type_info *exceptionType;
56
 
  void (*exceptionDestructor)(void *); 
57
 
 
58
 
  // The C++ standard has entertaining rules wrt calling set_terminate
59
 
  // and set_unexpected in the middle of the exception cleanup process.
60
 
  std::unexpected_handler unexpectedHandler;
61
 
  std::terminate_handler terminateHandler;
62
 
 
63
 
  // The caught exception stack threads through here.
64
 
  __cxa_exception *nextException;
65
 
 
66
 
  // How many nested handlers have caught this exception.  A negated
67
 
  // value is a signal that this object has been rethrown.
68
 
  int handlerCount;
69
 
 
70
 
  // Cache parsed handler data from the personality routine Phase 1
71
 
  // for Phase 2 and __cxa_call_unexpected.
72
 
  int handlerSwitchValue;
73
 
  const unsigned char *actionRecord;
74
 
  const unsigned char *languageSpecificData;
75
 
  _Unwind_Ptr catchTemp;
76
 
  void *adjustedPtr;
77
 
 
78
 
  // The generic exception header.  Must be last.
79
 
  _Unwind_Exception unwindHeader;
80
 
};
81
 
 
82
 
 
83
 
// A dependent C++ exception object consists of a header, which is a wrapper
84
 
// around an unwind object header with additional C++ specific information,
85
 
// followed by the exception object itself.
86
 
struct __cxa_dependent_exception
87
 
{
88
 
  // The primary exception
89
 
  void *primaryException;
90
 
 
91
 
  // The C++ standard has entertaining rules wrt calling set_terminate
92
 
  // and set_unexpected in the middle of the exception cleanup process.
93
 
  std::unexpected_handler unexpectedHandler;
94
 
  std::terminate_handler terminateHandler;
95
 
 
96
 
  // The caught exception stack threads through here.
97
 
  __cxa_exception *nextException;
98
 
 
99
 
  // How many nested handlers have caught this exception.  A negated
100
 
  // value is a signal that this object has been rethrown.
101
 
  int handlerCount;
102
 
 
103
 
  // Cache parsed handler data from the personality routine Phase 1
104
 
  // for Phase 2 and __cxa_call_unexpected.
105
 
  int handlerSwitchValue;
106
 
  const unsigned char *actionRecord;
107
 
  const unsigned char *languageSpecificData;
108
 
  _Unwind_Ptr catchTemp;
109
 
  void *adjustedPtr;
110
 
 
111
 
  // The generic exception header.  Must be last.
112
 
  _Unwind_Exception unwindHeader;
113
 
};
114
 
 
115
 
 
116
 
// Each thread in a C++ program has access to a __cxa_eh_globals object.
117
 
struct __cxa_eh_globals
118
 
{
119
 
  __cxa_exception *caughtExceptions;
120
 
  unsigned int uncaughtExceptions;
121
 
};
122
 
 
123
 
 
124
 
// The __cxa_eh_globals for the current thread can be obtained by using
125
 
// either of the following functions.  The "fast" version assumes at least
126
 
// one prior call of __cxa_get_globals has been made from the current
127
 
// thread, so no initialization is necessary.
128
 
extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
129
 
extern "C" __cxa_eh_globals *__cxa_get_globals_fast () throw();
130
 
 
131
 
// Allocate memory for the primary exception plus the thrown object.
132
 
extern "C" void *__cxa_allocate_exception(std::size_t thrown_size) throw();
133
 
// Allocate memory for dependent exception.
134
 
extern "C" __cxa_dependent_exception *__cxa_allocate_dependent_exception() throw();
135
 
 
136
 
// Free the space allocated for the primary exception.
137
 
extern "C" void __cxa_free_exception(void *thrown_exception) throw();
138
 
// Free the space allocated for the dependent exception.
139
 
extern "C" void __cxa_free_dependent_exception(__cxa_dependent_exception *dependent_exception) throw();
140
 
 
141
 
// Throw the exception.
142
 
extern "C" void __cxa_throw (void *thrown_exception,
143
 
                             std::type_info *tinfo,
144
 
                             void (*dest) (void *))
145
 
     __attribute__((noreturn));
146
 
 
147
 
// Used to implement exception handlers.
148
 
extern "C" void *__cxa_begin_catch (void *) throw();
149
 
extern "C" void __cxa_end_catch ();
150
 
extern "C" void __cxa_rethrow () __attribute__((noreturn));
151
 
 
152
 
// These facilitate code generation for recurring situations.
153
 
extern "C" void __cxa_bad_cast ();
154
 
extern "C" void __cxa_bad_typeid ();
155
 
 
156
 
// @@@ These are not directly specified by the IA-64 C++ ABI.
157
 
 
158
 
// Handles re-checking the exception specification if unexpectedHandler
159
 
// throws, and if bad_exception needs to be thrown.  Called from the
160
 
// compiler.
161
 
extern "C" void __cxa_call_unexpected (void *) __attribute__((noreturn));
162
 
 
163
 
// Invokes given handler, dying appropriately if the user handler was
164
 
// so inconsiderate as to return.
165
 
extern void __terminate(std::terminate_handler) __attribute__((noreturn));
166
 
extern void __unexpected(std::unexpected_handler) __attribute__((noreturn));
167
 
 
168
 
// The current installed user handlers.
169
 
extern std::terminate_handler __terminate_handler;
170
 
extern std::unexpected_handler __unexpected_handler;
171
 
 
172
 
// These are explicitly GNU C++ specific.
173
 
 
174
 
// This is the exception class we report -- "GNUCC++\0".
175
 
const _Unwind_Exception_Class __gxx_exception_class
176
 
= ((((((((_Unwind_Exception_Class) 'G' 
177
 
         << 8 | (_Unwind_Exception_Class) 'N')
178
 
        << 8 | (_Unwind_Exception_Class) 'U')
179
 
       << 8 | (_Unwind_Exception_Class) 'C')
180
 
      << 8 | (_Unwind_Exception_Class) 'C')
181
 
     << 8 | (_Unwind_Exception_Class) '+')
182
 
    << 8 | (_Unwind_Exception_Class) '+')
183
 
   << 8 | (_Unwind_Exception_Class) '\0');
184
 
 
185
 
// GNU C++ personality routine, Version 0.
186
 
extern "C" _Unwind_Reason_Code __gxx_personality_v0
187
 
     (int, _Unwind_Action, _Unwind_Exception_Class,
188
 
      struct _Unwind_Exception *, struct _Unwind_Context *);
189
 
 
190
 
// GNU C++ sjlj personality routine, Version 0.
191
 
extern "C" _Unwind_Reason_Code __gxx_personality_sj0
192
 
     (int, _Unwind_Action, _Unwind_Exception_Class,
193
 
      struct _Unwind_Exception *, struct _Unwind_Context *);
194
 
 
195
 
// Acquire the C++ exception header from the C++ object.
196
 
static inline __cxa_exception *
197
 
__get_exception_header_from_obj (void *ptr)
198
 
{
199
 
  return reinterpret_cast<__cxa_exception *>(ptr) - 1;
200
 
}
201
 
 
202
 
// Acquire the C++ exception header from the generic exception header.
203
 
static inline __cxa_exception *
204
 
__get_exception_header_from_ue (_Unwind_Exception *exc)
205
 
{
206
 
  return reinterpret_cast<__cxa_exception *>(exc + 1) - 1;
207
 
}
208
 
 
209
 
} /* namespace __cxxabiv1 */
210
 
 
211
 
#pragma GCC visibility pop
212
 
 
213
 
#endif // _UNWIND_CXX_H