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

@ -18,68 +18,69 @@
#ifdef __UNIX_LIKE__
#include <pthread.h>
#include <stdint.h>
#include <stdlib.h>
#include <pthread.h>
namespace ZeroTier {
// libpthread based mutex lock
class Mutex
{
public:
Mutex()
{
pthread_mutex_init(&_mh,(const pthread_mutexattr_t *)0);
}
class Mutex {
public:
Mutex()
{
pthread_mutex_init(&_mh, (const pthread_mutexattr_t*)0);
}
~Mutex()
{
pthread_mutex_destroy(&_mh);
}
~Mutex()
{
pthread_mutex_destroy(&_mh);
}
inline void lock() const
{
pthread_mutex_lock(&((const_cast <Mutex *> (this))->_mh));
}
inline void lock() const
{
pthread_mutex_lock(&((const_cast<Mutex*>(this))->_mh));
}
inline void unlock() const
{
pthread_mutex_unlock(&((const_cast <Mutex *> (this))->_mh));
}
inline void unlock() const
{
pthread_mutex_unlock(&((const_cast<Mutex*>(this))->_mh));
}
class Lock
{
public:
Lock(Mutex &m) :
_m(&m)
{
m.lock();
}
class Lock {
public:
Lock(Mutex& m) : _m(&m)
{
m.lock();
}
Lock(const Mutex &m) :
_m(const_cast<Mutex *>(&m))
{
_m->lock();
}
Lock(const Mutex& m) : _m(const_cast<Mutex*>(&m))
{
_m->lock();
}
~Lock()
{
_m->unlock();
}
~Lock()
{
_m->unlock();
}
private:
Mutex *const _m;
};
private:
Mutex* const _m;
};
private:
Mutex(const Mutex &) {}
const Mutex &operator=(const Mutex &) { return *this; }
private:
Mutex(const Mutex&)
{
}
const Mutex& operator=(const Mutex&)
{
return *this;
}
pthread_mutex_t _mh;
pthread_mutex_t _mh;
};
} // namespace ZeroTier
} // namespace ZeroTier
#endif
@ -91,72 +92,73 @@ private:
namespace ZeroTier {
// Windows critical section based lock
class Mutex
{
public:
Mutex()
{
InitializeCriticalSection(&_cs);
}
class Mutex {
public:
Mutex()
{
InitializeCriticalSection(&_cs);
}
~Mutex()
{
DeleteCriticalSection(&_cs);
}
~Mutex()
{
DeleteCriticalSection(&_cs);
}
inline void lock()
{
EnterCriticalSection(&_cs);
}
inline void lock()
{
EnterCriticalSection(&_cs);
}
inline void unlock()
{
LeaveCriticalSection(&_cs);
}
inline void unlock()
{
LeaveCriticalSection(&_cs);
}
inline void lock() const
{
(const_cast <Mutex *> (this))->lock();
}
inline void lock() const
{
(const_cast<Mutex*>(this))->lock();
}
inline void unlock() const
{
(const_cast <Mutex *> (this))->unlock();
}
inline void unlock() const
{
(const_cast<Mutex*>(this))->unlock();
}
class Lock
{
public:
Lock(Mutex &m) :
_m(&m)
{
m.lock();
}
class Lock {
public:
Lock(Mutex& m) : _m(&m)
{
m.lock();
}
Lock(const Mutex &m) :
_m(const_cast<Mutex *>(&m))
{
_m->lock();
}
Lock(const Mutex& m) : _m(const_cast<Mutex*>(&m))
{
_m->lock();
}
~Lock()
{
_m->unlock();
}
~Lock()
{
_m->unlock();
}
private:
Mutex *const _m;
};
private:
Mutex* const _m;
};
private:
Mutex(const Mutex &) {}
const Mutex &operator=(const Mutex &) { return *this; }
private:
Mutex(const Mutex&)
{
}
const Mutex& operator=(const Mutex&)
{
return *this;
}
CRITICAL_SECTION _cs;
CRITICAL_SECTION _cs;
};
} // namespace ZeroTier
} // namespace ZeroTier
#endif // _WIN32
#endif // _WIN32
#endif