1 /******************************************************************************
4 * Interface definitions for software transactional memory (STM).
6 * Copyright (c) 2002-2003, K A Fraser
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are
12 * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution. Neither the name of the Keir Fraser
18 * nor the names of its contributors may be used to endorse or
19 * promote products derived from this software without specific
20 * prior written permission.
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 typedef struct stm_st stm
;
39 typedef struct stm_blk_st stm_blk
;
40 typedef struct stm_tx_st stm_tx
;
42 stm
*new_stm(ptst_t
*ptst
, int blk_size
);
43 void free_stm(ptst_t
*ptst
, stm
*mem
);
45 stm_blk
*new_stm_blk(ptst_t
*ptst
, stm
*mem
);
46 void free_stm_blk(ptst_t
*ptst
, stm
*mem
, stm_blk
*b
);
47 void *init_stm_blk(ptst_t
*ptst
, stm
*mem
, stm_blk
*b
);
48 int sizeof_stm_blk(ptst_t
*ptst
, stm
*mem
, stm_blk
*b
);
50 stm_tx
*new_stm_tx(ptst_t
*ptst
, stm
*mem
, sigjmp_buf
*penv
);
51 bool_t
commit_stm_tx(ptst_t
*ptst
, stm_tx
*t
);
52 bool_t
validate_stm_tx(ptst_t
*ptst
, stm_tx
*t
);
53 /* NB. Must still call commit after abort, but it's guaranteed to fail. */
54 void abort_stm_tx(ptst_t
*ptst
, stm_tx
*t
);
56 void *read_stm_blk(ptst_t
*ptst
, stm_tx
*t
, stm_blk
*b
);
57 void *write_stm_blk(ptst_t
*ptst
, stm_tx
*t
, stm_blk
*b
);
59 void remove_from_tx(ptst_t
*ptst
, stm_tx
*t
, stm_blk
*b
);
61 void _init_stm_subsystem(int pad_data
);
63 #define new_stm_tx(_tx, _ptst, _mem) \
67 (_tx) = new_stm_tx((_ptst), (_mem), &env); \