MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / hdr_atomic_add_fetch_64

Function hdr_atomic_add_fetch_64

deps/hdr_histogram/hdr_atomic.h:59–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59static int64_t __inline hdr_atomic_add_fetch_64(volatile int64_t* field, int64_t value)
60{
61#if defined(_WIN64)
62 return _InterlockedExchangeAdd64(field, value) + value;
63#else
64 int64_t comparand;
65 int64_t initial_value = *field;
66 do
67 {
68 comparand = initial_value;
69 initial_value = _InterlockedCompareExchange64(field, comparand + value, comparand);
70 }
71 while (comparand != initial_value);
72
73 return initial_value + value;
74#endif
75}
76
77static bool __inline hdr_atomic_compare_exchange_64(volatile int64_t* field, int64_t* expected, int64_t desired)
78{

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected