]> gcc.gnu.org Git - gcc.git/blame - libitm/eh_cpp.cc
Update copyright years.
[gcc.git] / libitm / eh_cpp.cc
CommitLineData
5624e564 1/* Copyright (C) 2009-2015 Free Software Foundation, Inc.
0a35513e
AH
2 Contributed by Richard Henderson <rth@redhat.com>.
3
4 This file is part of the GNU Transactional Memory Library (libitm).
5
6 Libitm is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
19
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
24
25#include "libitm_i.h"
26
27using namespace GTM;
28
29/* Everything from libstdc++ is weak, to avoid requiring that library
30 to be linked into plain C applications using libitm.so. */
31
32#define WEAK __attribute__((weak))
33
34extern "C" {
35
36extern void *__cxa_allocate_exception (size_t) WEAK;
37extern void __cxa_throw (void *, void *, void *) WEAK;
38extern void *__cxa_begin_catch (void *) WEAK;
f2f9a097 39extern void __cxa_end_catch (void) WEAK;
0a35513e
AH
40extern void __cxa_tm_cleanup (void *, void *, unsigned int) WEAK;
41
6c59ffd1 42#if !defined (HAVE_ELF_STYLE_WEAKREF)
d846e425
RO
43void *__cxa_allocate_exception (size_t) { return NULL; }
44void __cxa_throw (void *, void *, void *) { return; }
45void *__cxa_begin_catch (void *) { return NULL; }
f2f9a097 46void __cxa_end_catch (void) { return; }
d846e425 47void __cxa_tm_cleanup (void *, void *, unsigned int) { return; }
8377e5e5 48void _Unwind_DeleteException (_Unwind_Exception *) { return; }
8cf36bb3 49#endif /* HAVE_ELF_STYLE_WEAKREF */
d846e425 50
0a35513e
AH
51}
52
53
54void *
55_ITM_cxa_allocate_exception (size_t size)
56{
57 void *r = __cxa_allocate_exception (size);
58 gtm_thr()->cxa_unthrown = r;
59 return r;
60}
61
62void
63_ITM_cxa_throw (void *obj, void *tinfo, void *dest)
64{
65 gtm_thr()->cxa_unthrown = NULL;
66 __cxa_throw (obj, tinfo, dest);
67}
68
69void *
70_ITM_cxa_begin_catch (void *exc_ptr)
71{
72 gtm_thr()->cxa_catch_count++;
73 return __cxa_begin_catch (exc_ptr);
74}
75
76void
77_ITM_cxa_end_catch (void)
78{
79 gtm_thr()->cxa_catch_count--;
80 __cxa_end_catch ();
81}
82
83void
84GTM::gtm_thread::revert_cpp_exceptions (gtm_transaction_cp *cp)
85{
86 if (cp)
87 {
88 // If rolling back a nested transaction, only clean up unthrown
89 // exceptions since the last checkpoint. Always reset eh_in_flight
90 // because it just contains the argument provided to
91 // _ITM_commitTransactionEH
92 void *unthrown =
93 (cxa_unthrown != cp->cxa_unthrown ? cxa_unthrown : NULL);
94 assert (cxa_catch_count >= cp->cxa_catch_count);
95 uint32_t catch_count = cxa_catch_count - cp->cxa_catch_count;
96 if (unthrown || catch_count)
97 {
98 __cxa_tm_cleanup (unthrown, this->eh_in_flight, catch_count);
99 cxa_catch_count = cp->cxa_catch_count;
100 cxa_unthrown = cp->cxa_unthrown;
101 this->eh_in_flight = NULL;
102 }
103 }
104 else
105 {
106 // Both cxa_catch_count and cxa_unthrown are maximal because EH regions
107 // and transactions are properly nested.
108 if (this->cxa_unthrown || this->cxa_catch_count)
109 {
110 __cxa_tm_cleanup (this->cxa_unthrown, this->eh_in_flight,
111 this->cxa_catch_count);
112 this->cxa_catch_count = 0;
113 this->cxa_unthrown = NULL;
114 this->eh_in_flight = NULL;
115 }
116 }
117}
This page took 0.316726 seconds and 5 git commands to generate.