49 #ifndef API_LIBRARY_HPP__
50 #define API_LIBRARY_HPP__
53 #include <stm/config.h>
84 casptr((
volatile uintptr_t*)&tx->
scope, (uintptr_t)0, (uintptr_t)s);
111 #ifdef STM_PROTECT_STACK
142 inline void*
tx_alloc(
size_t size) {
return Self->allocator.txAlloc(size); }
149 inline void tx_free(
void*
p) { Self->allocator.txFree(p); }
165 void*
operator new(
size_t size) {
return tx_alloc(size); }
170 void operator delete(
void*
ptr)
188 void sys_init(
void (*abort_handler)(TxThread*) = NULL);
215 #ifdef STM_PROTECT_STACK
216 # define TM_BECOME_IRREVOC() ({ \
217 void* top_of_stack; \
218 stm::become_irrevoc(&top_of_stack); })
220 # define TM_BECOME_IRREVOC() stm::become_irrevoc()
238 template <
typename T>
244 template <
typename T>
254 #define TM_READ(var) stm::stm_read(&var, tx)
255 #define TM_WRITE(var, val) stm::stm_write(&var, val, tx)
260 #define TM_BEGIN(TYPE) \
262 stm::TxThread* tx = (stm::TxThread*)stm::Self; \
264 uint32_t abort_flags = setjmp(_jmpbuf); \
265 stm::begin(tx, &_jmpbuf, abort_flags); \
281 #define TM_GET_THREAD() stm::TxThread* tx = (stm::TxThread*)stm::Self
282 #define TM_ARG_ALONE stm::TxThread* tx
283 #define TM_ARG , TM_ARG_ALONE
284 #define TM_PARAM , tx
285 #define TM_PARAM_ALONE tx
290 #define TM_SYS_INIT() stm::sys_init()
291 #define TM_THREAD_INIT stm::thread_init
292 #define TM_THREAD_SHUTDOWN() stm::thread_shutdown()
293 #define TM_SYS_SHUTDOWN stm::sys_shutdown
294 #define TM_ALLOC stm::tx_alloc
295 #define TM_FREE stm::tx_free
296 #define TM_SET_POLICY(P) stm::set_policy(P)
298 #define TM_GET_ALGNAME() stm::get_algname()
318 # define TM_BEGIN_FAST_INITIALIZATION()
319 # define TM_END_FAST_INITIALIZATION()
321 # define TM_BEGIN_FAST_INITIALIZATION() \
322 const char* __config_string__ = TM_GET_ALGNAME(); \
323 TM_SET_POLICY("CGL"); \
325 # define TM_END_FAST_INITIALIZATION() \
326 TM_SET_POLICY(__config_string__)
329 #endif // API_LIBRARY_HPP__
void *volatile ptr
Definition: counted_ptr.hpp:57
Definition: library.hpp:163
Definition: stm_fraser.c:61
void tx_free(void *p)
Definition: library.hpp:149
static void thread_init()
Definition: txthread.cpp:177
Definition: my_thread.hpp:41
scope_t *volatile scope
Definition: txthread.hpp:57
TM_INLINE void begin(TxThread *tx, scope_t *s, uint32_t)
Definition: library.hpp:71
void sys_init(void(*abort_handler)(TxThread *)=NULL)
uint64_t end_txn_time
Definition: txthread.hpp:92
Definition: library_inst.hpp:46
TM_INLINE void commit(TxThread *tx)
Definition: library.hpp:104
void thread_shutdown()
Definition: library.hpp:199
void stm_write(T *addr, T val, TxThread *thread)
Definition: library.hpp:245
TM_FASTCALL void(* tmcommit)(STM_COMMIT_SIG(,))
Definition: txthread.hpp:118
void scope_t
Definition: metadata.hpp:39
T stm_read(T *addr, TxThread *thread)
Definition: library.hpp:239
stm_tx * tx
Definition: stmskip.cc:245
virtual ~Object()
Definition: library.hpp:175
uint64_t total_nontxn_time
Definition: txthread.hpp:93
void sys_shutdown()
Definition: txthread.cpp:203
uint32_t nesting_depth
Definition: txthread.hpp:51
bool become_irrevoc(STM_WHEN_PROTECT_STACK(void **top_of_stack))
void thread_init()
Definition: library.hpp:196
Definition: txthread.hpp:47
void NORETURN UNRECOVERABLE(const char *)
Definition: txthread.cpp:155
const char * get_algname()
Definition: txthread.cpp:386
void * tx_alloc(size_t size)
Definition: library.hpp:142
static TM_FASTCALL bool(*volatile tmbegin)(TxThread *)
Definition: txthread.hpp:115
#define STM_WHEN_PROTECT_STACK(S)
Definition: macros.hpp:71
void set_policy(const char *)
Definition: txthread.cpp:261
void restart()
Definition: txthread.cpp:189
static void thread_shutdown()
Definition: txthread.hpp:147