1/* ThreadSanitizer
2 * Copyright (c) 2011, Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 *     * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 *     * Neither the name of Google Inc. nor the names of its
10 * contributors may be used to endorse or promote products derived from
11 * this software without specific prior written permission.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
16 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
17 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef TS_ATOMIC_H_INCLUDED
27#define TS_ATOMIC_H_INCLUDED
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33
34// These constants mostly mimic ones from C++0x standard draft.
35// The most recent version of the draft (as of now) can be found here:
36// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf
37// Check out fresh versions here:
38// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/
39// Refer to sections 1.10 and 29.
40//
41// tsan_memory_order_invalid has no meaning other than invalid enum value.
42// tsan_memory_order_natomic stands for "non atomic" and expresses
43// as if plain memory access that is not intended to race
44// with other accesses.
45typedef enum tsan_memory_order {
46  tsan_memory_order_invalid = 0,
47  tsan_memory_order_natomic = 1 << 0,
48  tsan_memory_order_relaxed = 1 << 1,
49  tsan_memory_order_consume = 1 << 2,
50  tsan_memory_order_acquire = 1 << 3,
51  tsan_memory_order_release = 1 << 4,
52  tsan_memory_order_acq_rel = 1 << 5,
53  tsan_memory_order_seq_cst = 1 << 6
54} tsan_memory_order;
55
56
57// These constants express types of atomic memory operations
58// as defined by C++0x standard draft (section 29).
59//
60// tsan_atomic_op_invalid has no meaning other than invalid enum value.
61// compare_exchange_weak differs from compare_exchange_strong in that
62// it can fail spuriously.
63typedef enum tsan_atomic_op {
64  tsan_atomic_op_invalid = 0,
65  tsan_atomic_op_fence = 1 << 0,
66  tsan_atomic_op_load = 1 << 1,
67  tsan_atomic_op_store = 1 << 2,
68  tsan_atomic_op_exchange = 1 << 3,
69  tsan_atomic_op_fetch_add = 1 << 4,
70  tsan_atomic_op_fetch_sub = 1 << 5,
71  tsan_atomic_op_fetch_and  = 1 << 6,
72  tsan_atomic_op_fetch_xor = 1 << 7,
73  tsan_atomic_op_fetch_or = 1 << 8,
74  tsan_atomic_op_compare_exchange_weak = 1 << 9,
75  tsan_atomic_op_compare_exchange_strong = 1 << 10
76} tsan_atomic_op;
77
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif // #ifndef TS_ATOMIC_H_INCLUDED
84
85
86