mirror of
https://github.com/kevinbentley/Descent3.git
synced 2026-04-05 23:00:03 -04:00
clang-format on everything.
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
Andreas Jonsson
|
||||
andreas@angelcode.com
|
||||
*/
|
||||
|
||||
|
||||
//
|
||||
// as_gc.cpp
|
||||
//
|
||||
@@ -38,54 +38,37 @@
|
||||
|
||||
BEGIN_AS_NAMESPACE
|
||||
|
||||
asCAtomic::asCAtomic()
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
asCAtomic::asCAtomic() { value = 0; }
|
||||
|
||||
asDWORD asCAtomic::get() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
asDWORD asCAtomic::get() const { return value; }
|
||||
|
||||
void asCAtomic::set(asDWORD val)
|
||||
{
|
||||
value = val;
|
||||
}
|
||||
void asCAtomic::set(asDWORD val) { value = val; }
|
||||
|
||||
//
|
||||
// The following code implements the atomicInc and atomicDec on different platforms
|
||||
//
|
||||
#ifdef AS_NO_THREADS
|
||||
|
||||
asDWORD asCAtomic::atomicInc()
|
||||
{
|
||||
return ++value;
|
||||
}
|
||||
asDWORD asCAtomic::atomicInc() { return ++value; }
|
||||
|
||||
asDWORD asCAtomic::atomicDec()
|
||||
{
|
||||
return --value;
|
||||
}
|
||||
asDWORD asCAtomic::atomicDec() { return --value; }
|
||||
|
||||
#elif defined(AS_NO_ATOMIC)
|
||||
|
||||
asDWORD asCAtomic::atomicInc()
|
||||
{
|
||||
asDWORD v;
|
||||
ENTERCRITICALSECTION(cs);
|
||||
v = ++value;
|
||||
LEAVECRITICALSECTION(cs);
|
||||
return v;
|
||||
asDWORD asCAtomic::atomicInc() {
|
||||
asDWORD v;
|
||||
ENTERCRITICALSECTION(cs);
|
||||
v = ++value;
|
||||
LEAVECRITICALSECTION(cs);
|
||||
return v;
|
||||
}
|
||||
|
||||
asDWORD asCAtomic::atomicDec()
|
||||
{
|
||||
asDWORD v;
|
||||
ENTERCRITICALSECTION(cs);
|
||||
v = --value;
|
||||
LEAVECRITICALSECTION(cs);
|
||||
return v;
|
||||
asDWORD asCAtomic::atomicDec() {
|
||||
asDWORD v;
|
||||
ENTERCRITICALSECTION(cs);
|
||||
v = --value;
|
||||
LEAVECRITICALSECTION(cs);
|
||||
return v;
|
||||
}
|
||||
|
||||
#elif defined(AS_WIN)
|
||||
@@ -95,39 +78,29 @@ END_AS_NAMESPACE
|
||||
#include <windows.h>
|
||||
BEGIN_AS_NAMESPACE
|
||||
|
||||
asDWORD asCAtomic::atomicInc()
|
||||
{
|
||||
return InterlockedIncrement((LONG*)&value);
|
||||
}
|
||||
asDWORD asCAtomic::atomicInc() { return InterlockedIncrement((LONG *)&value); }
|
||||
|
||||
asDWORD asCAtomic::atomicDec()
|
||||
{
|
||||
asASSERT(value > 0);
|
||||
return InterlockedDecrement((LONG*)&value);
|
||||
asDWORD asCAtomic::atomicDec() {
|
||||
asASSERT(value > 0);
|
||||
return InterlockedDecrement((LONG *)&value);
|
||||
}
|
||||
|
||||
#elif defined(AS_LINUX) || defined(AS_BSD)
|
||||
|
||||
//
|
||||
// atomic_inc_and_test() and atomic_dec_and_test() from asm/atomic.h is not meant
|
||||
// to be used outside the Linux kernel. Instead we should use the GNUC provided
|
||||
// atomic_inc_and_test() and atomic_dec_and_test() from asm/atomic.h is not meant
|
||||
// to be used outside the Linux kernel. Instead we should use the GNUC provided
|
||||
// __sync_add_and_fetch() and __sync_sub_and_fetch() functions.
|
||||
//
|
||||
// Reference: http://golubenco.org/blog/atomic-operations/
|
||||
//
|
||||
// These are only available in GCC 4.1 and above, so for older versions we
|
||||
// These are only available in GCC 4.1 and above, so for older versions we
|
||||
// use the critical sections, though it is a lot slower.
|
||||
//
|
||||
//
|
||||
|
||||
asDWORD asCAtomic::atomicInc()
|
||||
{
|
||||
return __sync_add_and_fetch(&value, 1);
|
||||
}
|
||||
asDWORD asCAtomic::atomicInc() { return __sync_add_and_fetch(&value, 1); }
|
||||
|
||||
asDWORD asCAtomic::atomicDec()
|
||||
{
|
||||
return __sync_sub_and_fetch(&value, 1);
|
||||
}
|
||||
asDWORD asCAtomic::atomicDec() { return __sync_sub_and_fetch(&value, 1); }
|
||||
|
||||
#elif defined(AS_MAC)
|
||||
|
||||
@@ -135,23 +108,16 @@ END_AS_NAMESPACE
|
||||
#include <libkern/OSAtomic.h>
|
||||
BEGIN_AS_NAMESPACE
|
||||
|
||||
asDWORD asCAtomic::atomicInc()
|
||||
{
|
||||
return OSAtomicIncrement32((int32_t*)&value);
|
||||
}
|
||||
asDWORD asCAtomic::atomicInc() { return OSAtomicIncrement32((int32_t *)&value); }
|
||||
|
||||
asDWORD asCAtomic::atomicDec()
|
||||
{
|
||||
return OSAtomicDecrement32((int32_t*)&value);
|
||||
}
|
||||
asDWORD asCAtomic::atomicDec() { return OSAtomicDecrement32((int32_t *)&value); }
|
||||
|
||||
#else
|
||||
|
||||
// If we get here, then the configuration in as_config.h
|
||||
// is wrong for the compiler/platform combination.
|
||||
// is wrong for the compiler/platform combination.
|
||||
int ERROR_PleaseFixTheConfig[-1];
|
||||
|
||||
#endif
|
||||
|
||||
END_AS_NAMESPACE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user