Skip to content

Commit 7fa18b2

Browse files
Add atomic increment
Add support for atomic increment. PiperOrigin-RevId: 288368488 Change-Id: I4e6c8131d360e9b96c935262a57c12572e28432a
1 parent f84ab59 commit 7fa18b2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

asylo/platform/core/atomic.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ inline T CompareAndSwap(volatile T *location, T expected, T desired) {
3838
return previous;
3939
}
4040

41+
// Atomically increments the value at `location`, returning the value at
42+
// `location` prior to being incremented.
43+
template <typename T>
44+
inline T AtomicIncrement(volatile T *location) {
45+
return __atomic_fetch_add(location, 1, __ATOMIC_SEQ_CST);
46+
}
47+
4148
// Atomically decrements the value at `location`, returning the value at
4249
// `location` prior to being decremented.
4350
template <typename T>

0 commit comments

Comments
 (0)