Make use of increment/decrement operators of std::atomic.

This commit is contained in:
Tsuda Kageyu 2016-12-09 09:56:37 +09:00
parent 250c59f783
commit a19a623d4b
2 changed files with 6 additions and 6 deletions

View 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)

View 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)