From 652c93c8f87d8bb4f14272b20326ebc31dc2fa09 Mon Sep 17 00:00:00 2001 From: Shinya Kitaoka <shinya_kitaoka@dwango.co.jp> Date: Jun 23 2016 06:19:53 +0000 Subject: fix build for windows --- diff --git a/toonz/sources/include/tatomicvar.h b/toonz/sources/include/tatomicvar.h index 201e856..2353a07 100644 --- a/toonz/sources/include/tatomicvar.h +++ b/toonz/sources/include/tatomicvar.h @@ -15,57 +15,31 @@ #include <atomic> -typedef std::atomic<long> atomic_t; - -static __inline__ void atomic_set(atomic_t *v, const int value) { - v->store(value); -} - -static __inline__ int atomic_inc_return(atomic_t *v) { - return v->fetch_add(1) + 1; // post increment atomic -} - -static __inline__ int atomic_dec_return(atomic_t *v) { - return v->fetch_sub(1) - 1; // post decriment atomic -} - -static __inline__ int atomic_read(const atomic_t *v) { return v->load(); } - -static __inline__ int atomic_add(int num, const atomic_t *v) { - return const_cast<atomic_t *>(v)->fetch_add(num) + - num; /* なんで const つけた? */ -} - class DVAPI TAtomicVar { public: + using value_type = long; + +public: TAtomicVar() : m_var(0) {} - long operator++() { - return m_var++ + 1; - } +public: + value_type operator++() { return ++m_var; } + value_type operator--() { return --m_var; } - long operator+=(long value) { - m_var += value; - return m_var; - } + value_type operator+=(value_type value) { return m_var += value; } - long operator--() { - return m_var-- - 1; - } - bool operator<=(const long &rhs) { - return m_var <= rhs; - }; - operator long() const { - return m_var; - }; + bool operator<=(value_type rhs) { return m_var <= rhs; }; - atomic_t m_var; + operator value_type() const { return m_var; }; #if !defined(LINUX) || defined(LINUX) && (__GNUC__ == 3) && (__GNUC_MINOR__ > 1) private: // to avoid well known bug in gcc3 ... fixed in later versions.. #endif - TAtomicVar &operator=(const TAtomicVar &); // not implemented - TAtomicVar(const TAtomicVar &v); // not implemented + TAtomicVar &operator=(const TAtomicVar &) = delete; // not implemented + TAtomicVar(const TAtomicVar &v) = delete; // not implemented + +private: + std::atomic<value_type> m_var; }; #endif