messagepack implementation for embedded systems (mbed / arduino)
Dependents: hello_message_pack
gcc_atomic.hpp
00001 // 00002 // MessagePack for C++ old gcc workaround for atomic operation 00003 // 00004 // Copyright (C) 2008-2013 FURUHASHI Sadayuki and KONDO Takatoshi 00005 // 00006 // Distributed under the Boost Software License, Version 1.0. 00007 // (See accompanying file LICENSE_1_0.txt or copy at 00008 // http://www.boost.org/LICENSE_1_0.txt) 00009 // 00010 00011 #ifndef MSGPACK_GCC_ATOMIC_HPP 00012 #define MSGPACK_GCC_ATOMIC_HPP 00013 00014 #ifdef ENABLE_GCC_CXX_ATOMIC 00015 #if defined(__GNUC__) && ((__GNUC__*10 + __GNUC_MINOR__) < 41) 00016 00017 #include "msgpack/gcc_atomic.h" 00018 #include <bits/atomicity.h> 00019 00020 int _msgpack_sync_decr_and_fetch(volatile _msgpack_atomic_counter_t* ptr) 00021 { 00022 return __gnu_cxx::__exchange_and_add(ptr, -1) - 1; 00023 } 00024 00025 int _msgpack_sync_incr_and_fetch(volatile _msgpack_atomic_counter_t* ptr) 00026 { 00027 return __gnu_cxx::__exchange_and_add(ptr, 1) + 1; 00028 } 00029 00030 #endif // old gcc workaround 00031 #endif // ENABLE_GCC_CXX_ATOMIC 00032 00033 #endif /* gcc_atomic.hpp */
Generated on Tue Jul 12 2022 22:51:45 by 1.7.2