When using transactional memory, a common challenge is that functions in standard libraries cannot be called from transactions. Sometimes, the incompatibility is unavoidable (for example, because the library does something that cannot be rolled back). But in other cases, the implementation is not transaction safe, when other (less performant) implementations could be.
The "transaction_wrap" attribute allows you to specify that function w() should be called in place of o() whenever o() is called from within a transaction. The syntax is not too cumbersome, but there are a few gotchas. Here's an example to show how it all works:
Compile the code like this:
And as suggested in the comments, the output will depend on the ITM_DEFAULT_METHOD you choose: