1 //===-- tsan_vector_clock.h -------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file is a part of ThreadSanitizer (TSan), a race detector.
11 //===----------------------------------------------------------------------===//
12 #ifndef TSAN_VECTOR_CLOCK_H
13 #define TSAN_VECTOR_CLOCK_H
15 #include "tsan_defs.h"
19 // Fixed-size vector clock, used both for threads and sync objects.
24 Epoch
Get(Sid sid
) const;
25 void Set(Sid sid
, Epoch v
);
28 void Acquire(const VectorClock
* src
);
29 void Release(VectorClock
** dstp
) const;
30 void ReleaseStore(VectorClock
** dstp
) const;
31 void ReleaseStoreAcquire(VectorClock
** dstp
);
32 void ReleaseAcquire(VectorClock
** dstp
);
34 VectorClock
& operator=(const VectorClock
& other
);
37 Epoch clk_
[kThreadSlotCount
] VECTOR_ALIGNED
;
40 ALWAYS_INLINE Epoch
VectorClock::Get(Sid sid
) const {
41 return clk_
[static_cast<u8
>(sid
)];
44 ALWAYS_INLINE
void VectorClock::Set(Sid sid
, Epoch v
) {
45 DCHECK_GE(v
, clk_
[static_cast<u8
>(sid
)]);
46 clk_
[static_cast<u8
>(sid
)] = v
;
51 #endif // TSAN_VECTOR_CLOCK_H