Clang-format!!!

This commit is contained in:
Adam Ierymenko 2024-09-26 08:52:29 -04:00
parent f190df8621
commit 96ba1079b2
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
122 changed files with 41245 additions and 39820 deletions

View file

@ -25,49 +25,56 @@ namespace ZeroTier {
/**
* Simple atomic counter supporting increment and decrement
*/
class AtomicCounter
{
public:
AtomicCounter() { _v = 0; }
class AtomicCounter {
public:
AtomicCounter()
{
_v = 0;
}
inline int load() const
{
inline int load() const
{
#ifdef __GNUC__
return __sync_or_and_fetch(const_cast<int *>(&_v),0);
return __sync_or_and_fetch(const_cast<int*>(&_v), 0);
#else
return _v.load();
return _v.load();
#endif
}
}
inline int operator++()
{
inline int operator++()
{
#ifdef __GNUC__
return __sync_add_and_fetch(&_v,1);
return __sync_add_and_fetch(&_v, 1);
#else
return ++_v;
return ++_v;
#endif
}
}
inline int operator--()
{
inline int operator--()
{
#ifdef __GNUC__
return __sync_sub_and_fetch(&_v,1);
return __sync_sub_and_fetch(&_v, 1);
#else
return --_v;
return --_v;
#endif
}
}
private:
AtomicCounter(const AtomicCounter &) {}
const AtomicCounter &operator=(const AtomicCounter &) { return *this; }
private:
AtomicCounter(const AtomicCounter&)
{
}
const AtomicCounter& operator=(const AtomicCounter&)
{
return *this;
}
#ifdef __GNUC__
int _v;
int _v;
#else
std::atomic_int _v;
std::atomic_int _v;
#endif
};
} // namespace ZeroTier
} // namespace ZeroTier
#endif