tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
macros.hpp File Reference
#include <stm/config.h>
Include dependency graph for macros.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CAT2(a, b)   a ## b
 
#define CAT3(a, b, c)   a ## b ## c
 
#define TO_STRING_LITERAL(arg)   #arg
 
#define MAKE_STR(arg)   TO_STRING_LITERAL(arg)
 
#define MAXIMUM(x, y)   (((x)>(y))?(x):(y))
 
#define foreach(TYPE, VAR, COLLECTION)
 
#define FOREACH_REVERSE(TYPE, VAR, COLLECTION)
 
#define STM_WHEN_PROTECT_STACK(S)
 
#define STM_WHEN_ABORT_ON_THROW(S)
 
#define STM_READ_SIG(tx, addr, mask)   TxThread* tx, void** addr
 
#define STM_WRITE_SIG(tx, addr, val, mask)   TxThread* tx, void** addr, void* val
 
#define STM_COMMIT_SIG(tx, stack)   TxThread* tx
 
#define STM_IRREVOC_SIG(tx, stack)   TxThread* tx
 
#define STM_ROLLBACK_SIG(tx, stack, exception, len)   TxThread* tx
 

Macro Definition Documentation

#define CAT2 (   a,
 
)    a ## b

Copyright (C) 2011 University of Rochester Department of Computer Science and Lehigh University Department of Computer Science and Engineering

License: Modified BSD Please see the file LICENSE.RSTM for licensing information This file establishes a few helpful macros. Some of these are obvious. Others are used to simplify some very redundant programming, particularly with regard to declaring STM functions and abort codes.

#define CAT3 (   a,
  b,
 
)    a ## b ## c
#define foreach (   TYPE,
  VAR,
  COLLECTION 
)
Value:
for (TYPE::iterator VAR = COLLECTION.begin(), \
CEND = COLLECTION.end(); \
VAR != CEND; ++VAR)

C++ iterators can get so ugly without c++0x 'auto'. These macros are not a good idea, but it makes it much easier to write 79-column code

#define FOREACH_REVERSE (   TYPE,
  VAR,
  COLLECTION 
)
Value:
for (TYPE::iterator VAR = COLLECTION.end() - 1, \
CAT2(end, __LINE__) = COLLECTION.begin(); \
VAR >= CAT2(end, __LINE__); --VAR)
#define CAT2(a, b)
Definition: macros.hpp:23
#define MAKE_STR (   arg)    TO_STRING_LITERAL(arg)
#define MAXIMUM (   x,
 
)    (((x)>(y))?(x):(y))
#define STM_COMMIT_SIG (   tx,
  stack 
)    TxThread* tx
#define STM_IRREVOC_SIG (   tx,
  stack 
)    TxThread* tx
#define STM_READ_SIG (   tx,
  addr,
  mask 
)    TxThread* tx, void** addr
#define STM_ROLLBACK_SIG (   tx,
  stack,
  exception,
  len 
)    TxThread* tx
#define STM_WHEN_ABORT_ON_THROW (   S)
#define STM_WHEN_PROTECT_STACK (   S)

When we use compiler-based instrumentation, support for sub-word-granularity accesses requires the individual STM read/write functions to take a mask as the third parameter. The following macros let us inject a parameter into the function signature as needed for this purpose. We need to protect the stack from "stale" writes during redo-writeback and undo-undo. This requires some platform-specific functionality to get some stack information.

#define STM_WRITE_SIG (   tx,
  addr,
  val,
  mask 
)    TxThread* tx, void** addr, void* val
#define TO_STRING_LITERAL (   arg)    #arg