]> granicus.if.org Git - taglib/commitdiff
Make use of increment/decrement operators of std::atomic.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Fri, 9 Dec 2016 00:56:37 +0000 (09:56 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Fri, 9 Dec 2016 01:09:31 +0000 (10:09 +0900)
ConfigureChecks.cmake
taglib/toolkit/trefcounter.cpp

index 253af335681b40179892a159473ab3c5c3929317..4b55f273e7d28d1cbfe22208337f1d096db10a08 100644 (file)
@@ -46,9 +46,9 @@ endif()
 check_cxx_source_compiles("
   #include <atomic>
   int main() {
-    std::atomic<unsigned int> x;
-    x.fetch_add(1);
-    x.fetch_sub(1);
+    std::atomic_int x;
+    ++x;
+    --x;
     return 0;
   }
 " HAVE_STD_ATOMIC)
index eb2aa69f4ab2beabdce26679508aa21fe6136a81..6638fcaa56f980937b9e68c4d4c3943aeb29f0ca 100644 (file)
@@ -31,9 +31,9 @@
 
 #if defined(HAVE_STD_ATOMIC)
 # include <atomic>
-# define ATOMIC_INT std::atomic<unsigned int>
-# define ATOMIC_INC(x) x.fetch_add(1)
-# define ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
+# define ATOMIC_INT std::atomic_int
+# define ATOMIC_INC(x) (++x)
+# define ATOMIC_DEC(x) (--x)
 #elif defined(HAVE_GCC_ATOMIC)
 # define ATOMIC_INT int
 # define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)