MessagePack for C++
Loading...
Searching...
No Matches
gcc_atomic.hpp
Go to the documentation of this file.
1//
2// MessagePack for C++ old gcc workaround for atomic operation
3//
4// Copyright (C) 2008-2013 FURUHASHI Sadayuki and KONDO Takatoshi
5//
6// Distributed under the Boost Software License, Version 1.0.
7// (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9//
10
11#ifndef MSGPACK_GCC_ATOMIC_HPP
12#define MSGPACK_GCC_ATOMIC_HPP
13
14#if defined(__GNUC__) && ((__GNUC__*10 + __GNUC_MINOR__) < 41)
15
16#include "msgpack/gcc_atomic.h"
17#include <bits/atomicity.h>
18
19int _msgpack_sync_decr_and_fetch(volatile _msgpack_atomic_counter_t* ptr)
20{
21 return __gnu_cxx::__exchange_and_add(ptr, -1) - 1;
22}
23
24int _msgpack_sync_incr_and_fetch(volatile _msgpack_atomic_counter_t* ptr)
25{
26 return __gnu_cxx::__exchange_and_add(ptr, 1) + 1;
27}
28
29#endif // old gcc workaround
30
31#endif /* gcc_atomic.hpp */