diff --git a/src/Makefile.am b/src/Makefile.am index cd7fb243..4bfc9ff8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,8 +46,7 @@ liblolcore_headers = \ lol/algorithm/sort.h lol/algorithm/portal.h lol/algorithm/aabb_tree.h \ \ lol/sys/all.h \ - lol/sys/init.h lol/sys/file.h lol/sys/thread.h lol/sys/atomic.h \ - lol/sys/timer.h \ + lol/sys/init.h lol/sys/file.h lol/sys/thread.h lol/sys/timer.h \ \ lol/image/all.h \ lol/image/pixel.h lol/image/color.h lol/image/image.h \ diff --git a/src/lol/sys/all.h b/src/lol/sys/all.h index 64c45df8..c816107d 100644 --- a/src/lol/sys/all.h +++ b/src/lol/sys/all.h @@ -12,7 +12,6 @@ #define __LOL_SYS_ALL_H__ #include -#include #include #include #include diff --git a/src/lol/sys/atomic.h b/src/lol/sys/atomic.h deleted file mode 100644 index 26306e1b..00000000 --- a/src/lol/sys/atomic.h +++ /dev/null @@ -1,78 +0,0 @@ -// -// Lol Engine -// -// Copyright: (c) 2010-2013 Sam Hocevar -// 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 class Atomic -{ -public: - inline Atomic() : m_value(0) {} - 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__ - diff --git a/src/lolcore.vcxproj b/src/lolcore.vcxproj index be86a707..c32e38ae 100644 --- a/src/lolcore.vcxproj +++ b/src/lolcore.vcxproj @@ -328,7 +328,6 @@ - diff --git a/src/lolcore.vcxproj.filters b/src/lolcore.vcxproj.filters index 659ae78b..ef17e4a0 100644 --- a/src/lolcore.vcxproj.filters +++ b/src/lolcore.vcxproj.filters @@ -633,9 +633,6 @@ lol\base - - lol\sys - lol\math diff --git a/src/sys/file.cpp b/src/sys/file.cpp index 28be4df5..ac9892e9 100644 --- a/src/sys/file.cpp +++ b/src/sys/file.cpp @@ -27,6 +27,7 @@ # include #endif +#include #include #include "core.h" @@ -242,9 +243,9 @@ class FileData #elif HAVE_STDIO_H FILE *m_fd; #endif - Atomic m_refcount; - StreamType m_type; - struct stat m_stat; + std::atomic m_refcount; + StreamType m_type; + struct stat m_stat; }; //-- FILE -- @@ -475,7 +476,7 @@ class DirectoryData #elif HAVE_STDIO_H DIR *m_dd; #endif - Atomic m_refcount; + std::atomic m_refcount; StreamType m_type; }; diff --git a/test/Makefile.am b/test/Makefile.am index 55157eba..cf9eab50 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -19,9 +19,9 @@ testsuite_SOURCES = testsuite.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/array.cpp unit/array2d.cpp unit/array3d.cpp unit/rotation.cpp \ - unit/string.cpp unit/map.cpp unit/color.cpp unit/atomic.cpp \ + unit/string.cpp unit/map.cpp unit/color.cpp unit/enum.cpp \ unit/interp.cpp unit/box.cpp unit/rand.cpp unit/thread.cpp \ - unit/camera.cpp unit/enum.cpp + unit/camera.cpp testsuite_CPPFLAGS = $(AM_CPPFLAGS) testsuite_DEPENDENCIES = @LOL_DEPS@ noinst_DATA = data/gradient.png diff --git a/test/unit/atomic.cpp b/test/unit/atomic.cpp deleted file mode 100644 index 16783b1d..00000000 --- a/test/unit/atomic.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// -// Lol Engine -// -// Copyright: (c) 2010-2013 Sam Hocevar -// 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 HAVE_CONFIG_H -# include "config.h" -#endif - -#include - -#include "core.h" -#include "lol/unit.h" - -namespace lol -{ - -LOLUNIT_FIXTURE(AtomicTest) -{ - LOLUNIT_TEST(SingleThread) - { - Atomic i = 0; - - LOLUNIT_ASSERT_EQUAL(0, (int)i); - - int a1 = i++; - LOLUNIT_ASSERT_EQUAL(0, a1); - LOLUNIT_ASSERT_EQUAL(1, (int)i); - - int a2 = i--; - LOLUNIT_ASSERT_EQUAL(1, a2); - LOLUNIT_ASSERT_EQUAL(0, (int)i); - - int a3 = ++i; - LOLUNIT_ASSERT_EQUAL(1, a3); - LOLUNIT_ASSERT_EQUAL(1, (int)i); - - int a4 = --i; - LOLUNIT_ASSERT_EQUAL(0, a4); - LOLUNIT_ASSERT_EQUAL(0, (int)i); - } -}; - -} /* namespace lol */ -