usermode/library/mtm/src/intelabi.c

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2011 Computer Sciences Department, 
00003     University of Wisconsin -- Madison
00004 
00005     ----------------------------------------------------------------------
00006 
00007     This file is part of Mnemosyne: Lightweight Persistent Memory, 
00008     originally developed at the University of Wisconsin -- Madison.
00009 
00010     Mnemosyne was originally developed primarily by Haris Volos
00011     with contributions from Andres Jaan Tack.
00012 
00013     ----------------------------------------------------------------------
00014 
00015     Mnemosyne is free software; you can redistribute it and/or
00016     modify it under the terms of the GNU General Public License
00017     as published by the Free Software Foundation, version 2
00018     of the License.
00019  
00020     Mnemosyne is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023     GNU General Public License for more details.
00024 
00025     You should have received a copy of the GNU General Public License
00026     along with this program; if not, write to the Free Software
00027     Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00028     Boston, MA  02110-1301, USA.
00029 
00030 ### END HEADER ###
00031 */
00032 
00040 #include "mtm_i.h"
00041 #include <stdio.h>
00042 #include "init.h"
00043 #include "useraction.h"
00044 
00045 
00046 int _ITM_CALL_CONVENTION
00047 _ITM_versionCompatible (int version)
00048 {
00049         return version == _ITM_VERSION_NO;
00050 }
00051 
00052 
00053 const char * _ITM_CALL_CONVENTION
00054 _ITM_libraryVersion (void)
00055 {
00056         return "Mnemosyne MTM" _ITM_VERSION;
00057 }
00058 
00059 
00060 _ITM_howExecuting _ITM_CALL_CONVENTION
00061 _ITM_inTransaction (mtm_tx_t *tx)
00062 {
00063         if (tx && tx->status != TX_IDLE) {
00064                 if (tx->status & TX_IRREVOCABLE) {
00065                         return inIrrevocableTransaction;
00066                 } else {
00067                         return inRetryableTransaction;
00068                 }
00069         }
00070         return outsideTransaction;
00071 }
00072 
00073 
00074 _ITM_transactionId _ITM_CALL_CONVENTION
00075 _ITM_getTransactionId (mtm_tx_t *td)
00076 {
00077         mtm_tx_t *tx = mtm_get_tx();
00078         return tx ? tx->id : _ITM_noTransactionId;
00079 }
00080 
00081 
00082 mtm_tx_t * _ITM_CALL_CONVENTION
00083 _ITM_getTransaction(void)
00084 {
00085         mtm_tx_t *tx = mtm_get_tx();
00086         
00087         if (tx) {
00088                 return tx;
00089         }
00090         
00091         tx = mtm_init_thread();
00092         return tx;
00093 }
00094 
00095 
00096 int _ITM_CALL_CONVENTION
00097 _ITM_getThreadnum (void)
00098 {
00099         static int   global_num;
00100         mtm_tx_t     *tx = mtm_get_tx();
00101         int          num = (int) tx->thread_num;
00102 
00103         if (num == 0) {
00104                 num = __sync_add_and_fetch (&global_num, 1);
00105                 tx->thread_num = num;
00106         }
00107 
00108         return num;
00109 }
00110 
00111 
00112 void _ITM_CALL_CONVENTION ITM_NORETURN
00113 _ITM_error (const _ITM_srcLocation * loc UNUSED, int errorCode UNUSED)
00114 {
00115         abort ();
00116 }
00117 
00118 
00119 void _ITM_CALL_CONVENTION 
00120 _ITM_userError (const char *errorStr, int errorCode)
00121 {
00122         fprintf (stderr, "A TM fatal error: %s (code = %i).\n", errorStr, errorCode);
00123         exit (errorCode);
00124 }
00125 
00126 
00127 void _ITM_CALL_CONVENTION 
00128 _ITM_dropReferences (mtm_tx_t * td, const void *start, size_t size)
00129 {
00130         //TODO
00131 }
00132 
00133 
00134 void _ITM_CALL_CONVENTION 
00135 _ITM_registerThrownObject(mtm_tx_t *td, 
00136                           const void *exception_object, size_t s)
00137 {
00138 
00139 
00140 }
00141 
00142 
00143 int _ITM_CALL_CONVENTION
00144 _ITM_initializeProcess (void)
00145 {
00146         int          ret;
00147         mtm_tx_t *thr;
00148 
00149         if ((ret = mtm_init_global()) == 0) {
00150                 thr = mtm_init_thread();
00151                 if (thr) {
00152                         return 0;
00153                 } else {
00154                         return -1;
00155                 }
00156         }
00157         return ret;
00158 }
00159 
00160 
00161 void _ITM_CALL_CONVENTION
00162 _ITM_finalizeProcess (void)
00163 {
00164         mtm_fini_global();
00165         return;
00166 }
00167 
00168 
00169 int _ITM_CALL_CONVENTION
00170 _ITM_initializeThread (void)
00171 {
00172         if (mtm_init_thread()) {
00173                 return 0;
00174         } else {
00175                 return -1;
00176         }
00177 }
00178 
00179 
00180 void _ITM_CALL_CONVENTION
00181 _ITM_finalizeThread (void)
00182 {
00183         mtm_fini_thread();
00184 }
00185 
00186 void _ITM_CALL_CONVENTION
00187 _ITM_registerThreadFinalization (void (_ITM_CALL_CONVENTION * thread_fini_func) (void *), void *arg)
00188 {
00189         /* Not yet implemented. */
00190         //abort();
00191 }
00192 
00193 void _ITM_CALL_CONVENTION
00194 _ITM_addUserCommitAction(mtm_tx_t * __td,
00195                          _ITM_userCommitFunction fn,
00196                          _ITM_transactionId tid, 
00197                          void *arg)
00198 {
00199         mtm_useraction_addUserCommitAction(__td, fn, tid, arg);
00200 }
00201 
00202 
00203 void _ITM_CALL_CONVENTION
00204 _ITM_addUserUndoAction(mtm_tx_t * __td,
00205                        const _ITM_userUndoFunction fn, 
00206                        void *arg)
00207 {
00208         mtm_useraction_addUserUndoAction(__td, fn, arg);
00209 }
00210 
00211 
00212 void _ITM_CALL_CONVENTION
00213 _ITM_changeTransactionMode(mtm_tx_t *td,
00214                            _ITM_transactionState __mode,
00215                            const _ITM_srcLocation * __loc)
00216 {
00217         //TODO: Support compiler instructed switching of transaction execution mode
00218         //assert (state == modeSerialIrrevocable);
00219         //MTM_serialmode (false, true);
00220 }

Generated on Sat Apr 23 11:43:36 2011 for Mnemosyne by  doxygen 1.4.7