structures.legacy
@@ -42,7 +42,8 @@ liblol_headers = \ | |||||
lol/math/remez.h lol/math/math.h lol/math/geometry.h \ | lol/math/remez.h lol/math/math.h lol/math/geometry.h \ | ||||
\ | \ | ||||
lol/sys/sys.h \ | lol/sys/sys.h \ | ||||
lol/sys/init.h lol/sys/file.h lol/sys/thread.h lol/sys/timer.h \ | |||||
lol/sys/init.h lol/sys/file.h lol/sys/thread.h lol/sys/atomic.h \ | |||||
lol/sys/timer.h \ | |||||
\ | \ | ||||
lol/image/image.h \ | lol/image/image.h \ | ||||
lol/image/color.h \ | lol/image/color.h \ | ||||
@@ -0,0 +1,77 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://www.wtfpl.net/ for more details. | |||||
// | |||||
#if !defined __LOL_SYS_ATOMIC_H__ | |||||
#define __LOL_SYS_ATOMIC_H__ | |||||
namespace lol | |||||
{ | |||||
/* | |||||
* TODO: we should use real atomic stuff here. | |||||
*/ | |||||
template<typename T> class Atomic | |||||
{ | |||||
public: | |||||
inline Atomic(T const &value) : m_value(value) {} | |||||
operator T() const | |||||
{ | |||||
return m_value; | |||||
} | |||||
inline T operator =(T const &value) | |||||
{ | |||||
m_mutex.Lock(); | |||||
m_value = value; | |||||
m_mutex.Unlock(); | |||||
} | |||||
inline T operator++(int) | |||||
{ | |||||
m_mutex.Lock(); | |||||
T ret = m_value++; | |||||
m_mutex.Unlock(); | |||||
return ret; | |||||
} | |||||
inline T& operator++() | |||||
{ | |||||
m_mutex.Lock(); | |||||
T ret = ++m_value; | |||||
m_mutex.Unlock(); | |||||
return ret; | |||||
} | |||||
inline T operator--(int) | |||||
{ | |||||
m_mutex.Lock(); | |||||
T ret = m_value--; | |||||
m_mutex.Unlock(); | |||||
return ret; | |||||
} | |||||
inline T& operator--() | |||||
{ | |||||
m_mutex.Lock(); | |||||
T ret = --m_value; | |||||
m_mutex.Unlock(); | |||||
return ret; | |||||
} | |||||
private: | |||||
Mutex m_mutex; /* FIXME: this shouldn't be needed */ | |||||
T m_value; | |||||
}; | |||||
} /* namespace lol */ | |||||
#endif // __LOL_SYS_ATOMIC_H__ | |||||
@@ -11,9 +11,10 @@ | |||||
#if !defined __LOL_SYS_SYS_H__ | #if !defined __LOL_SYS_SYS_H__ | ||||
#define __LOL_SYS_SYS_H__ | #define __LOL_SYS_SYS_H__ | ||||
#include <lol/sys/thread.h> | |||||
#include <lol/sys/atomic.h> | |||||
#include <lol/sys/init.h> | #include <lol/sys/init.h> | ||||
#include <lol/sys/file.h> | #include <lol/sys/file.h> | ||||
#include <lol/sys/thread.h> | |||||
#include <lol/sys/timer.h> | #include <lol/sys/timer.h> | ||||
#endif // __LOL_SYS_SYS_H__ | #endif // __LOL_SYS_SYS_H__ | ||||
@@ -606,6 +606,7 @@ | |||||
<ClInclude Include="lol\math\real.h" /> | <ClInclude Include="lol\math\real.h" /> | ||||
<ClInclude Include="lol\math\remez.h" /> | <ClInclude Include="lol\math\remez.h" /> | ||||
<ClInclude Include="lol\math\vector.h" /> | <ClInclude Include="lol\math\vector.h" /> | ||||
<ClInclude Include="lol\sys\atomic.h" /> | |||||
<ClInclude Include="lol\sys\file.h" /> | <ClInclude Include="lol\sys\file.h" /> | ||||
<ClInclude Include="lol\sys\init.h" /> | <ClInclude Include="lol\sys\init.h" /> | ||||
<ClInclude Include="lol\sys\sys.h" /> | <ClInclude Include="lol\sys\sys.h" /> | ||||
@@ -23,7 +23,7 @@ testsuite_SOURCES = testsuite.cpp \ | |||||
unit/vector.cpp unit/matrix.cpp unit/half.cpp unit/trig.cpp \ | unit/vector.cpp unit/matrix.cpp unit/half.cpp unit/trig.cpp \ | ||||
unit/build.cpp unit/real.cpp unit/image.cpp unit/quat.cpp unit/cmplx.cpp \ | unit/build.cpp unit/real.cpp unit/image.cpp unit/quat.cpp unit/cmplx.cpp \ | ||||
unit/array.cpp unit/rotation.cpp unit/string.cpp unit/map.cpp \ | unit/array.cpp unit/rotation.cpp unit/string.cpp unit/map.cpp \ | ||||
unit/color.cpp | |||||
unit/color.cpp unit/atomic.cpp | |||||
testsuite_CPPFLAGS = @LOL_CFLAGS@ | testsuite_CPPFLAGS = @LOL_CFLAGS@ | ||||
testsuite_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ | testsuite_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ | ||||
testsuite_DEPENDENCIES = $(top_builddir)/src/liblol.a | testsuite_DEPENDENCIES = $(top_builddir)/src/liblol.a | ||||