00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "pwb_i.h"
00034 #include "mode/pwb-common/beginend-bits.h"
00035
00036
00037 uint32_t
00038 mtm_pwbnl_beginTransaction_internal (mtm_tx_t *tx,
00039 uint32_t prop,
00040 _ITM_srcLocation *srcloc)
00041 {
00042 return beginTransaction_internal (tx, prop, srcloc, 0);
00043 }
00044
00045
00046 void _ITM_CALL_CONVENTION
00047 mtm_pwbnl_rollbackTransaction (mtm_tx_t *tx, const _ITM_srcLocation *loc)
00048 {
00049 #if (!defined(ALLOW_ABORTS))
00050 assert(0 && "Aborts disabled but want to abort.\n");
00051 #endif
00052
00053 assert ((tx->prop & pr_hasNoAbort) == 0);
00054
00055
00056 rollback_transaction (tx);
00057
00058 }
00059
00060
00061 void _ITM_CALL_CONVENTION
00062 mtm_pwbnl_abortTransaction (mtm_tx_t *tx,
00063 _ITM_abortReason reason,
00064 const _ITM_srcLocation *loc)
00065 {
00066 #if (!defined(ALLOW_ABORTS))
00067 assert(0 && "Aborts disabled but want to abort.\n");
00068 #endif
00069
00070 assert (reason == userAbort || reason == userRetry);
00071
00072 assert ((reason == userAbort && (tx->prop & pr_hasNoAbort) == 0) ||
00073 (reason == userRetry && 1));
00074
00075
00076 if (tx->status & TX_IRREVOCABLE) {
00077 abort ();
00078 }
00079
00080 if (reason == userAbort) {
00081 rollback_transaction (tx);
00082
00083
00084
00085
00086
00087
00088
00089 mtm_longjmp (&tx->jb, a_abortTransaction | a_restoreLiveVariables);
00090 } else if (reason == userRetry) {
00091 mtm_pwb_restart_transaction(tx, RESTART_USER_RETRY);
00092 }
00093 }
00094
00095
00096 bool _ITM_CALL_CONVENTION
00097 mtm_pwbnl_tryCommitTransaction (mtm_tx_t *tx, const _ITM_srcLocation *loc)
00098 {
00099 return trycommit_transaction(tx, 0);
00100 }
00101
00102
00103 void _ITM_CALL_CONVENTION
00104 mtm_pwbnl_commitTransaction(mtm_tx_t *tx, const _ITM_srcLocation *loc)
00105 {
00106 MTM_DEBUG_PRINT("==> mtm_pwb_commitTransaction(%p)\n", tx);
00107 if (!trycommit_transaction(tx, 0)) {
00108 #if (!defined(ALLOW_ABORTS))
00109 assert(0 && "Aborts disabled but want to rollback...\n");
00110 #endif
00111 mtm_pwb_restart_transaction(tx, RESTART_VALIDATE_COMMIT);
00112 }
00113 if (tx->status == TX_COMMITTED) {
00114 tx->status = TX_IDLE;
00115
00116
00117
00118 }
00119
00120 MTM_DEBUG_PRINT("==> mtm_pwb_commitTransaction(%p): DONE\n", tx);
00121 }
00122
00123
00124 void _ITM_CALL_CONVENTION
00125 mtm_pwbnl_commitTransactionToId(mtm_tx_t *tx,
00126 const _ITM_transactionId tid,
00127 const _ITM_srcLocation *loc)
00128 {
00129
00130 assert(0);
00131 }