src/inc/txc/txc.h

Go to the documentation of this file.
00001 
00009 #ifndef _TXC_TXC_H
00010 #define _TXC_TXC_H
00011 
00012 /* Abort reason */
00013 #ifndef TYPEDEF_TXC_TX_ABORTREASON_T
00014 #define TYPEDEF_TXC_TX_ABORTREASON_T
00015 typedef enum {
00016         TXC_ABORTREASON_TMCONFLICT = 0, 
00017     TXC_ABORTREASON_USERABORT = 1, 
00018         TXC_ABORTREASON_USERRETRY = 2, 
00019         TXC_ABORTREASON_BUSYSENTINEL = 4, 
00020         TXC_ABORTREASON_INCONSISTENCY = 8, 
00021         TXC_ABORTREASON_BUSYTXLOCK = 16, 
00022 } txc_tx_abortreason_t;
00023 #endif /* TYPEDEF_TXC_TX_ABORTREASON_T */
00024 
00025 /* Transactional State */
00026 #ifndef TYPEDEF_TXC_TX_XACTSTATE_T
00027 #define TYPEDEF_TXC_TX_XACTSTATE_T
00028 typedef enum {
00029         TXC_XACTSTATE_NONTRANSACTIONAL = 0, 
00030     TXC_XACTSTATE_TRANSACTIONAL_RETRYABLE = 1, 
00031         TXC_XACTSTATE_TRANSACTIONAL_IRREVOCABLE = 2 
00032 } txc_tx_xactstate_t;
00033 #endif /* TYPEDEF_TXC_TX_XACTSTATE_T */
00034 
00035 /* Failure manager flags */
00036 #ifndef TXC_FM_FLAGS
00037 # define TXC_FM_FLAGS
00038 # define TXC_FM_NO_RETRY 0x1
00039 #endif
00040 
00041 
00042 #define __TXC_XSTR(s) __TXC_STR(s)
00043 #define __TXC_STR(s) #s
00044 
00045 #define SRCLOC_STR(file,line) file ":" __TXC_XSTR(line)
00046 
00047 
00048 #define XACT_BEGIN(tag)                                                      \
00049   _TXC_transaction_pre_begin(SRCLOC_STR(__FILE__, __LINE__),                 \
00050                              __FILE__,                                       \
00051                              __FUNCTION__,                                   \
00052                              __LINE__);                                      \
00053   __tm_atomic                                                                \
00054   {                                                                          \
00055     _TXC_transaction_post_begin();
00056 
00057 
00058 #define XACT_END(tag)                                                        \
00059   }
00060 
00061 
00062 #define XACT_WAIVER __tm_waiver
00063 
00064 #define XACT_ABORT(abortreason)  _TXC_transaction_abort(abortreason);
00065 
00066 #define TM_WAIVER   __attribute__ ((tm_pure)) 
00067 #define TM_PURE     __attribute__ ((tm_pure)) 
00068 #define TM_CALLABLE __attribute__ ((tm_callable)) 
00069 
00070 
00071 typedef unsigned int txc_result_t;
00072 
00073 TM_WAIVER int _TXC_global_init();
00074 TM_WAIVER int _TXC_global_shutdown();
00075 TM_WAIVER int _TXC_thread_init();
00076 TM_WAIVER void _TXC_transaction_abort(txc_tx_abortreason_t);
00077 TM_WAIVER txc_tx_xactstate_t _TXC_get_xactstate();
00078 TM_WAIVER void _TXC_transaction_pre_begin(const char *srcloc_str, const char *src_file, const char *src_fun, int src_line);
00079 TM_WAIVER int _TXC_transaction_post_begin();
00080 TM_WAIVER void _TXC_fm_register(int flags, int *err);
00081 
00089 #include <sys/types.h>
00090 #include <sys/stat.h>
00091 #include <fcntl.h>
00092 
00093 #define XCALL_DEF(xcall) _TXC_##xcall 
00094 #define _XCALL(xcall) _TXC_##xcall 
00095 
00096 TM_WAIVER int     XCALL_DEF(x_close)(int fildes, int *result);
00097 TM_WAIVER int     XCALL_DEF(x_create)(const char *, mode_t, int *);
00098 TM_WAIVER int     XCALL_DEF(x_dup)(int oldfd, int *result);
00099 TM_WAIVER int     XCALL_DEF(x_fsync)(int fildes, int *result);
00100 TM_WAIVER off_t   XCALL_DEF(x_lseek)(int fd, off_t offset, int whence, int *result);
00101 TM_WAIVER int     XCALL_DEF(x_open)(const char *pathname, int flags, mode_t mode, int *result); 
00102 TM_WAIVER int     XCALL_DEF(x_pipe)(int fildes[2], int *result);
00103 TM_WAIVER ssize_t XCALL_DEF(x_printf)(const char *format, ...);
00104 TM_WAIVER int     XCALL_DEF(x_pthread_create)(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg, int *result);
00105 TM_WAIVER int     XCALL_DEF(x_pthread_mutex_init)(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr, int *result);
00106 TM_WAIVER int     XCALL_DEF(x_pthread_mutex_lock)(pthread_mutex_t *mutex, int *result);
00107 TM_WAIVER int     XCALL_DEF(x_pthread_mutex_unlock)(pthread_mutex_t *mutex, int *result);
00108 TM_WAIVER ssize_t XCALL_DEF(x_read)(int fd, void *buf, size_t nbyte, int *result);
00109 TM_WAIVER ssize_t XCALL_DEF(x_read_pipe)(int fd, void *buf, size_t nbyte, int *result);
00110 TM_WAIVER ssize_t XCALL_DEF(x_recvmsg)(int s, struct msghdr *msg, int flags, int *result);
00111 TM_WAIVER int     XCALL_DEF(x_rename)(const char *oldpath, const char *newpath, int *result);
00112 TM_WAIVER int     XCALL_DEF(x_socket)(int domain, int type, int protocol, int *result); 
00113 TM_WAIVER ssize_t XCALL_DEF(x_sendmsg)(int fd, const struct msghdr *msg, int flags, int *result);
00114 TM_WAIVER ssize_t XCALL_DEF(x_write_ovr)(int fd, const void *buf, size_t nbyte, int *result);
00115 TM_WAIVER ssize_t XCALL_DEF(x_write_ovr_save)(int fd, const void *buf, size_t nbyte, int *result);
00116 TM_WAIVER ssize_t XCALL_DEF(x_write_ovr_ignore)(int fd, const void *buf, size_t nbyte, int *result);
00117 TM_WAIVER ssize_t XCALL_DEF(x_write_pipe)(int fd, const void *buf, size_t nbyte, int *result);
00118 TM_WAIVER ssize_t XCALL_DEF(x_write_seq)(int fd, const void *buf, size_t nbyte, int *result);
00119 TM_WAIVER int     XCALL_DEF(x_unlink)(const char *pathname, int *result);
00120 
00121 /*
00122  * Transactional safe conditional variables API
00123  */
00124 
00125 #include <xcalls/condvar/condvar.h>
00126 
00127 
00128 #endif /* _TXC_TXC_H */

Generated on Wed Dec 9 20:32:39 2009 for xCalls by  doxygen 1.4.7