annotate libitm/useraction.cc @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Copyright (C) 2008-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
2 Contributed by Richard Henderson <rth@redhat.com>.
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of the GNU Transactional Memory Library (libitm).
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 Libitm is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
7 under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
8 the Free Software Foundation; either version 3 of the License, or
kono
parents:
diff changeset
9 (at your option) any later version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
kono
parents:
diff changeset
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
kono
parents:
diff changeset
14 more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
17 permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
18 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
21 a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
23 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 #include "libitm_i.h"
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 namespace GTM HIDDEN {
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 void
kono
parents:
diff changeset
30 gtm_thread::rollback_user_actions(size_t until_size)
kono
parents:
diff changeset
31 {
kono
parents:
diff changeset
32 for (size_t s = user_actions.size(); s > until_size; s--)
kono
parents:
diff changeset
33 {
kono
parents:
diff changeset
34 user_action *a = user_actions.pop();
kono
parents:
diff changeset
35 if (!a->on_commit)
kono
parents:
diff changeset
36 a->fn (a->arg);
kono
parents:
diff changeset
37 }
kono
parents:
diff changeset
38 }
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 void
kono
parents:
diff changeset
42 gtm_thread::commit_user_actions()
kono
parents:
diff changeset
43 {
kono
parents:
diff changeset
44 for (vector<user_action>::iterator i = user_actions.begin(),
kono
parents:
diff changeset
45 ie = user_actions.end(); i != ie; i++)
kono
parents:
diff changeset
46 {
kono
parents:
diff changeset
47 if (i->on_commit)
kono
parents:
diff changeset
48 i->fn (i->arg);
kono
parents:
diff changeset
49 }
kono
parents:
diff changeset
50 user_actions.clear();
kono
parents:
diff changeset
51 }
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 } // namespace GTM
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 using namespace GTM;
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 void ITM_REGPARM
kono
parents:
diff changeset
58 _ITM_addUserCommitAction(_ITM_userCommitFunction fn,
kono
parents:
diff changeset
59 _ITM_transactionId_t tid, void *arg)
kono
parents:
diff changeset
60 {
kono
parents:
diff changeset
61 gtm_thread *tx = gtm_thr();
kono
parents:
diff changeset
62 if (tid != _ITM_noTransactionId)
kono
parents:
diff changeset
63 GTM_fatal("resumingTransactionId in _ITM_addUserCommitAction must be "
kono
parents:
diff changeset
64 "_ITM_noTransactionId");
kono
parents:
diff changeset
65 gtm_thread::user_action *a = tx->user_actions.push();
kono
parents:
diff changeset
66 a->fn = fn;
kono
parents:
diff changeset
67 a->arg = arg;
kono
parents:
diff changeset
68 a->on_commit = true;
kono
parents:
diff changeset
69 a->resuming_id = tid;
kono
parents:
diff changeset
70 }
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 void ITM_REGPARM
kono
parents:
diff changeset
74 _ITM_addUserUndoAction(_ITM_userUndoFunction fn, void * arg)
kono
parents:
diff changeset
75 {
kono
parents:
diff changeset
76 gtm_thread *tx = gtm_thr();
kono
parents:
diff changeset
77 gtm_thread::user_action *a = tx->user_actions.push();
kono
parents:
diff changeset
78 a->fn = fn;
kono
parents:
diff changeset
79 a->arg = arg;
kono
parents:
diff changeset
80 a->on_commit = false;
kono
parents:
diff changeset
81 }