diff options
Diffstat (limited to 'libs/backends/wavesaudio/wavesapi/akupara')
4 files changed, 0 insertions, 847 deletions
diff --git a/libs/backends/wavesaudio/wavesapi/akupara/basics.hpp b/libs/backends/wavesaudio/wavesapi/akupara/basics.hpp deleted file mode 100644 index 33808ede8d..0000000000 --- a/libs/backends/wavesaudio/wavesapi/akupara/basics.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * basics.hpp - * Akupara - * - * Created by Udi on 12/19/06. - * Copyright 2006 __MyCompanyName__. All rights reserved. - * - */ -#if !defined(_AKUPARA_BASICS_HPP__INCLUDED_) -#define _AKUPARA_BASICS_HPP__INCLUDED_ - -#include "WavesPublicAPI/wstdint.h" - -namespace Akupara -{ - // The ultimate nothingness - // This is useful for writing constructors that nullify their object, and for testing nullness - struct null_type - { - null_type() {} - null_type(const null_type *) {} // this allows 0 to be implicitly converted to null_type - }; - inline null_type null() { return null_type(); } - - - // This is a byte, guaranteed to be unsigned regardless of your compiler's char signedness - typedef uint8_t byte_type; - - - // derive from this if your class needs to be noncopyable - class noncopyable_type - { - private: - noncopyable_type(const noncopyable_type &); - noncopyable_type &operator=(const noncopyable_type &); - public: - noncopyable_type() {} - }; - - -} // namespace Akupara - - -#if defined(__GNUC__) -#define AKUPARA_EXPECT_FALSE(x) __builtin_expect(x,false) -#define AKUPARA_EXPECT_TRUE(x) __builtin_expect(x,true ) -#else -#define AKUPARA_EXPECT_FALSE(x) x -#define AKUPARA_EXPECT_TRUE(x) x -#endif // __GNUC__ - - -#endif // _AKUPARA_BASICS_HPP__INCLUDED_ diff --git a/libs/backends/wavesaudio/wavesapi/akupara/compiletime_functions.hpp b/libs/backends/wavesaudio/wavesapi/akupara/compiletime_functions.hpp deleted file mode 100644 index 14c5f96523..0000000000 --- a/libs/backends/wavesaudio/wavesapi/akupara/compiletime_functions.hpp +++ /dev/null @@ -1,205 +0,0 @@ -/* -* compiletime_functions.hpp -* Akupara -* -* Created by Udi on 12/19/06. -* -*/ -#if !defined(_AKUPARA_COMPILETIME_FUNCTIONS_HPP__INCLUDED_) -#define _AKUPARA_COMPILETIME_FUNCTIONS_HPP__INCLUDED_ - -//#include "WavesPublicAPIs/wstdint.h" - -namespace Akupara -{ - // For templates that "return" a value, use template_name<arguments>::value - // For templates that "return" a type, use template_name<arguments>::type - - - // Integer log2 functions - //------------------------------------------------------------------------ - template<unsigned int n> - struct compiletime_bit_count_to_represent { static const unsigned int value = 1+compiletime_bit_count_to_represent<(n>>1)>::value; }; - - template<> - struct compiletime_bit_count_to_represent<0> { static const unsigned int value = 0; }; - //------------------------------------------------------------------------ - template<unsigned int n> - struct compiletime_log2_ceiling { static const unsigned int value=compiletime_bit_count_to_represent<n-1>::value; }; - - template<> - struct compiletime_log2_ceiling<0> {}; // no value for 0 argument - //------------------------------------------------------------------------ - template<unsigned int n> - struct compiletime_log2_floor { static const unsigned int value=compiletime_bit_count_to_represent<n>::value-1; }; - - template<> - struct compiletime_log2_floor<0> {}; // no value for 0 argument - //------------------------------------------------------------------------ - - - - // Assertion - accessing 'value' will generate a compile-time error if the argument evaluates to false - //------------------------------------------------------------------------ - template<bool> - struct compiletime_assert; - - template<> - struct compiletime_assert<true> { static const bool value=true; }; - - template<> - struct compiletime_assert<false> {}; // no value member for false assertion -> compile time error - //------------------------------------------------------------------------ - - - // Select type - selects one of two types based on a boolean - //------------------------------------------------------------------------ - template<bool, typename, typename> - struct compiletime_select_type; - - template<typename _true_type, typename _false_type> - struct compiletime_select_type<true, _true_type, _false_type> { typedef _true_type type; }; - - template<typename _true_type, typename _false_type> - struct compiletime_select_type<false, _true_type, _false_type> { typedef _false_type type; }; - //------------------------------------------------------------------------ - - - - - - // Integer types by byte count - //------------------------------------------------------------------------ - namespace detail - { - template<unsigned int _size, bool _signed> - struct integer_with_byte_count_base; - - template<> - struct integer_with_byte_count_base<1,true> { typedef int8_t type; }; - - template<> - struct integer_with_byte_count_base<2,true> { typedef int16_t type; }; - - template<> - struct integer_with_byte_count_base<4,true> { typedef int32_t type; }; - - template<> - struct integer_with_byte_count_base<8,true> { typedef int64_t type; }; - - template<> - struct integer_with_byte_count_base<1,false> { typedef uint8_t type; }; - - template<> - struct integer_with_byte_count_base<2,false> { typedef uint16_t type; }; - - template<> - struct integer_with_byte_count_base<4,false> { typedef uint32_t type; }; - - template<> - struct integer_with_byte_count_base<8,false> { typedef uint64_t type; }; - } // namespace detail - //------------------------------------------------------------------------ - template<unsigned int _size, bool _signed=true> - struct integer_with_byte_count : public detail::integer_with_byte_count_base<_size,_signed> - { - typedef typename detail::integer_with_byte_count_base<_size,_signed>::type type; // not required but makes the statement below less messy - static const bool s_correct_size = compiletime_assert<sizeof(type)==_size>::value; // if you get a compilation error here then integer_with_byte_count is not defined correctly - }; - //------------------------------------------------------------------------ - template<unsigned int _size> - struct signed_integer_with_byte_count : public integer_with_byte_count<_size,true> {}; - - template<unsigned int _size> - struct unsigned_integer_with_byte_count : public integer_with_byte_count<_size,false> {}; - //------------------------------------------------------------------------ - - - - // The following are TR1 compatible, until we get decent TR1 library support on all platforms - //------------------------------------------------------------------------ - template<typename _T, _T _v> - struct integral_constant - { - static const _T value = _v; - typedef _T value_type; - typedef integral_constant<_T, _v> type; - }; // struct integral_constant - typedef integral_constant<bool, false> false_type; - typedef integral_constant<bool, true > true_type; - //------------------------------------------------------------------------ - template<typename _T, typename _U> struct is_same : public false_type {}; - template<typename _T> struct is_same<_T,_T> : public true_type {}; - //------------------------------------------------------------------------ - - - - // These are NOT TR1 but make use of some TR1 stuff - //------------------------------------------------------------------------ - namespace detail - { - struct no_type; // if you end up getting this type, it means that you asked for something that doesn't exist - template<unsigned int _pair_index> struct signed_unsigned_pair; -#define AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(index, base_type_name) \ - template<> struct signed_unsigned_pair<index> { typedef signed base_type_name signed_type; typedef unsigned base_type_name unsigned_type; }; -#define AKUPARA_SIGNED_UNSIGNED_FLOAT_PAIR(index, type_name) \ - template<> struct signed_unsigned_pair<index> { typedef type_name signed_type; typedef no_type unsigned_type; }; - AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(1, char ) - AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(2, short ) - AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(3, int ) - - //AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(4, int32_t )// 64BitConversion - template<> - struct - signed_unsigned_pair<4> - { - typedef int32_t signed_type; - typedef uint32_t unsigned_type; - }; - - - AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(5, long long) - AKUPARA_SIGNED_UNSIGNED_FLOAT_PAIR (6, float ) - AKUPARA_SIGNED_UNSIGNED_FLOAT_PAIR (7, double ) - AKUPARA_SIGNED_UNSIGNED_FLOAT_PAIR (8, long double) - const unsigned int k_signed_unsigned_pair_count = 8; - - // eliminate the no_type type - template<typename _T> struct filtered_type { typedef _T type; }; - template<> struct filtered_type<no_type> {}; // no type defined - - // search for _T in signed type list - template<unsigned int _index, typename _T> struct find_in_signed_type_list_from_index - { - static const unsigned int value = is_same< _T, typename signed_unsigned_pair<_index>::signed_type >::value ? _index : find_in_signed_type_list_from_index<_index-1,_T>::value; - }; - template<typename _T> struct find_in_signed_type_list_from_index<0, _T> { static const unsigned int value = 0; }; - template<typename _T> struct find_in_signed_type_list : public find_in_signed_type_list_from_index<k_signed_unsigned_pair_count, _T> {}; - - // search for _T in unsigned type list - template<unsigned int _index, typename _T> struct find_in_unsigned_type_list_from_index - { - static const unsigned int value = is_same< _T, typename signed_unsigned_pair<_index>::unsigned_type >::value ? _index : find_in_unsigned_type_list_from_index<_index-1,_T>::value; - }; - template<typename _T> struct find_in_unsigned_type_list_from_index<0, _T> { static const unsigned int value = 0; }; - template<typename _T> struct find_in_unsigned_type_list : public find_in_unsigned_type_list_from_index<k_signed_unsigned_pair_count, _T> {}; - - template<bool _is_signed, bool _is_unsigned, typename _T> struct equivalent_signed_type; - template<typename _T> struct equivalent_signed_type <true, false, _T> { typedef _T type; }; - template<typename _T> struct equivalent_signed_type <false, true, _T> { typedef typename filtered_type< typename signed_unsigned_pair< find_in_unsigned_type_list<_T>::value >::signed_type >::type type; }; - - template<bool _is_signed, bool _is_unsigned, typename _T> struct equivalent_unsigned_type; - template<typename _T> struct equivalent_unsigned_type<true, false, _T> { typedef typename filtered_type< typename signed_unsigned_pair< find_in_signed_type_list<_T>::value >::unsigned_type >::type type; }; - template<typename _T> struct equivalent_unsigned_type<false, true, _T> { typedef _T type; }; - } // namespace detail - //------------------------------------------------------------------------ - template<typename _T> struct is_signed { static const bool value = detail::find_in_signed_type_list <_T>::value != 0; }; - template<typename _T> struct is_unsigned { static const bool value = detail::find_in_unsigned_type_list<_T>::value != 0; }; - //------------------------------------------------------------------------ - template<typename _T> struct equivalent_signed_type : public detail::equivalent_signed_type < is_signed<_T>::value, is_unsigned<_T>::value, _T > {}; - template<typename _T> struct equivalent_unsigned_type : public detail::equivalent_unsigned_type< is_signed<_T>::value, is_unsigned<_T>::value, _T > {}; - //------------------------------------------------------------------------ - -} // namespace Akupara - -#endif // _AKUPARA_COMPILETIME_FUNCTIONS_HPP__INCLUDED_ diff --git a/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops.hpp b/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops.hpp deleted file mode 100644 index 2111026d0b..0000000000 --- a/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops.hpp +++ /dev/null @@ -1,388 +0,0 @@ -/* -* Akupara/threading/atomic_ops.hpp -* -* -* Created by Udi Barzilai on 06/06. -* Copyright 2006 __MyCompanyName__. All rights reserved. -* -*/ -#if !defined(_AKUPARA_THREADING_ATOMIC_OPS_HPP__INCLUDED_) -#define _AKUPARA_THREADING_ATOMIC_OPS_HPP__INCLUDED_ - -#include "Akupara/basics.hpp" // for EXPECT macro -#include "Akupara/compiletime_functions.hpp" // for TR1 stuff, signed/unsigned stuff - -namespace Akupara -{ - namespace threading - { - namespace atomic - { - namespace machine - { - // Machine capabilities - // The following templates are specialized by the machine-specific headers to indicate - // the capabilities of the machine being compiled for. A true 'value' member for a given - // byte count means that there is an implementation of the corresponding atomic operation. - //------------------------------------- - template<unsigned int _byte_count> struct implements_load : public false_type {}; // simple assignment from memory (assumes naturally aligned address) - template<unsigned int _byte_count> struct implements_store : public false_type {}; // simple assignment to memory (assumes naturally aligned address) - template<unsigned int _byte_count> struct implements_CAS : public false_type {}; // compare_and_store() - template<unsigned int _byte_count> struct implements_LL_SC : public false_type {}; // load_linked(), store_conditional() - template<unsigned int _byte_count> struct implements_add : public false_type {}; // add(), subtract() - template<unsigned int _byte_count> struct implements_fetch_and_add : public false_type {}; // fetch_and_add(), fetch_and_subtract() - template<unsigned int _byte_count> struct implements_add_and_fetch : public false_type {}; // add_and_fetch(), subtract_and_fetch() - //------------------------------------- - - - //------------------------------------- - // functions in this namespace may or may not be implemented, for any integer types, as specified by the machine capabilities templates above - template<typename _integer_type> bool compare_and_store(volatile _integer_type * operand_address, const _integer_type & expected_value, const _integer_type & value_to_store); - - template<typename _integer_type> _integer_type load_linked(volatile _integer_type * operand_address); - template<typename _integer_type> bool store_conditional(volatile _integer_type * operand_address, const _integer_type & value_to_store); - - template<typename _integer_type> void add(volatile _integer_type * operand_address, const _integer_type & addend); - template<typename _integer_type> void subtract(volatile _integer_type * operand_address, const _integer_type & subtrahend); - - template<typename _integer_type> _integer_type fetch_and_add(volatile _integer_type * operand_address, const _integer_type & addend); - template<typename _integer_type> _integer_type fetch_and_subtract(volatile _integer_type * operand_address, const _integer_type & subtrahend); - - template<typename _integer_type> _integer_type add_and_fetch(volatile _integer_type * operand_address, const _integer_type & addend); - template<typename _integer_type> _integer_type subtract_and_fetch(volatile _integer_type * operand_address, const _integer_type & subtrahend); - - void memory_barrier_read(); - void memory_barrier_write(); - void memory_barrier_readwrite(); - //------------------------------------- - - } // namespace machine - } // namespace atomic - } // namespace threading -} // namespace Akupara - -// Include the machine-specific implementations; these only implement the templates above for some of the _signed_ integer types -#if defined(__GNUC__) && defined(__POWERPC__) -#include "atomic_ops_gcc_ppc.hpp" -#endif // defined(__GNUC__) && defined(__POWERPC__) - -#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) -#include "atomic_ops_gcc_x86.hpp" -#endif // defined(__GNUC__) && defined(__i386__) - -#if defined(_MSC_VER) && defined(_M_IX86) -#include "atomic_ops_msvc_x86.hpp" -#endif // defined(_MSC_VER) && defined(_M_IX86) - -#if defined(_MSC_VER) && defined(_M_X64) -#include "atomic_ops_msvc_x86_64.hpp" -#endif // defined(_MSC_VER) && defined(_M_X64) - -namespace Akupara -{ - namespace threading - { - namespace atomic - { - - - // Select the most convenient atomic integer type based on the machine's ability to load/store atomically - // The definition below selects that largest atomically accessible integer up to the size of int - //---------------------------------------------------------------------------------------- - namespace detail - { - template<unsigned int _byte_count> - struct largest_atomic_byte_count_upto - { - static const unsigned int value = - machine::implements_load<_byte_count>::value && machine::implements_store<_byte_count>::value ? -_byte_count : - largest_atomic_byte_count_upto<_byte_count/2>::value; - }; - - template<> - struct largest_atomic_byte_count_upto<0> { static const unsigned int value = 0; }; - - const unsigned int k_byte_count_best_atomic = largest_atomic_byte_count_upto<sizeof(int)>::value; - } - typedef signed_integer_with_byte_count< detail::k_byte_count_best_atomic >::type signed_integer_type; - typedef unsigned_integer_with_byte_count< detail::k_byte_count_best_atomic >::type unsigned_integer_type; - typedef signed_integer_type integer_type; - //---------------------------------------------------------------------------------------- - - //---------------------------------------------------------------------------------------- - // These need to be implemented by all machines - using machine::memory_barrier_read; - using machine::memory_barrier_write; - using machine::memory_barrier_readwrite; - //---------------------------------------------------------------------------------------- - - //---------------------------------------------------------------------------------------- - // These may or may not be implemented, but if they aren't, we can't help much - using machine::load_linked; - using machine::store_conditional; - //---------------------------------------------------------------------------------------- - - - //---------------------------------------------------------------------------------------- - // CAS implementation - namespace detail - { - template< - typename _integer_type, - bool _implements_CAS = machine::implements_CAS <sizeof(_integer_type)>::value, - bool _implements_LL_SC = machine::implements_LL_SC<sizeof(_integer_type)>::value> - struct implementation_CAS - { - static const bool s_exists = false; - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // specialization for native CAS support - template<typename _integer_type, bool _implements_LL_SC> - struct implementation_CAS<_integer_type, true, _implements_LL_SC> - { - static const bool s_exists = true; - static inline bool compare_and_store(volatile _integer_type * operand_address, const _integer_type & expected_value, const _integer_type & value_to_store) - { - return machine::compare_and_store(operand_address, expected_value, value_to_store); - } - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // specialization for cases with no CAS but with LL/SC - template<typename _integer_type> - struct implementation_CAS<_integer_type, false, true> - { - static const bool s_exists = true; - static inline bool compare_and_store(volatile _integer_type * operand_address, const _integer_type & expected_value, const _integer_type & value_to_store) - { - while (machine::load_linked(operand_address) == expected_value) - if (AKUPARA_EXPECT_TRUE(machine::store_conditional(operand_address, value_to_store))) - return true; - return false; - } - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } // namespace detail - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - template<typename _integer_type> - inline bool compare_and_store(volatile _integer_type * operand_address, const _integer_type & expected_value, const _integer_type & value_to_store) - { - // if your compiler can't find the function to call here then there is no implementation available for your machine - return detail::implementation_CAS<_integer_type>::compare_and_store(operand_address, expected_value, value_to_store); - } - //---------------------------------------------------------------------------------------- - - - - - - //---------------------------------------------------------------------------------------- - // fetch_and_add - namespace detail - { - template< - typename _integer_type, - bool _0 = machine::implements_fetch_and_add<sizeof(_integer_type)>::value, - bool _1 = machine::implements_add_and_fetch<sizeof(_integer_type)>::value, - bool _2 = machine::implements_LL_SC <sizeof(_integer_type)>::value, - bool _3 = machine::implements_CAS <sizeof(_integer_type)>::value> - struct implementation_FAA - { - static const bool s_exists = false; - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // specialization for native support - template<typename _integer_type, bool _1, bool _2, bool _3> - struct implementation_FAA<_integer_type, true, _1, _2, _3> - { - static const bool s_exists = true; - static inline _integer_type fetch_and_add(volatile _integer_type * operand_address, const _integer_type & addend) - { - return machine::fetch_and_add(operand_address, addend); - } - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // specialization using add_and_fetch - template<typename _integer_type, bool _2, bool _3> - struct implementation_FAA<_integer_type, false, true, _2, _3> - { - static const bool s_exists = true; - static inline _integer_type fetch_and_add(volatile _integer_type * operand_address, const _integer_type & addend) - { - return machine::add_and_fetch(operand_address, addend) - addend; - } - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // specialization using LL/SC - template<typename _integer_type, bool _3> - struct implementation_FAA<_integer_type, false, false, true, _3> - { - static const bool s_exists = true; - static inline _integer_type fetch_and_add(volatile _integer_type * operand_address, const _integer_type & addend) - { - _integer_type old_value; - do - old_value = machine::load_linked(operand_address); - while (!machine::store_conditional(operand_address, old_value+addend)); - return old_value; - } - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // specialization using CAS - template<typename _integer_type> - struct implementation_FAA<_integer_type, false, false, false, true> - { - static const bool s_exists = true; - static inline _integer_type fetch_and_add(volatile _integer_type * operand_address, const _integer_type & addend) - { - _integer_type old_value; - do - old_value = *operand_address; - while (!machine::compare_and_store(operand_address, old_value, old_value+addend)); - return old_value; - } - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } // namespace detail - template<typename _integer_type> - inline _integer_type fetch_and_add(volatile _integer_type * operand_address, const _integer_type & addend) - { - // if your compiler can't find the function to call here then there is no implementation available for your machine - return detail::implementation_FAA<_integer_type>::fetch_and_add(operand_address, addend); - } - //---------------------------------------------------------------------------------------- - - - - - //---------------------------------------------------------------------------------------- - // add_and_fetch - namespace detail - { - template< - typename _integer_type, - bool _0 = machine::implements_add_and_fetch<sizeof(_integer_type)>::value, - bool _1 = machine::implements_fetch_and_add<sizeof(_integer_type)>::value, - bool _2 = machine::implements_LL_SC <sizeof(_integer_type)>::value, - bool _3 = machine::implements_CAS <sizeof(_integer_type)>::value> - struct implementation_AAF - { - static const bool s_exists = false; - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // specialization for native support - template<typename _integer_type, bool _1, bool _2, bool _3> - struct implementation_AAF<_integer_type, true, _1, _2, _3> - { - static const bool s_exists = true; - static inline _integer_type add_and_fetch(volatile _integer_type * operand_address, const _integer_type & addend) - { - return machine::add_and_fetch(operand_address, addend); - } - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // specialization using add_and_fetch - template<typename _integer_type, bool _2, bool _3> - struct implementation_AAF<_integer_type, false, true, _2, _3> - { - static const bool s_exists = true; - static inline _integer_type add_and_fetch(volatile _integer_type * operand_address, const _integer_type & addend) - { - return machine::fetch_and_add(operand_address, addend) + addend; - } - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // specialization using LL/SC - template<typename _integer_type, bool _3> - struct implementation_AAF<_integer_type, false, false, true, _3> - { - static const bool s_exists = true; - static inline _integer_type add_and_fetch(volatile _integer_type * operand_address, const _integer_type & addend) - { - _integer_type new_value; - do - new_value = machine::load_linked(operand_address)+addend; - while (!machine::store_conditional(operand_address, new_value)); - return new_value; - } - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // specialization using CAS - template<typename _integer_type> - struct implementation_AAF<_integer_type, false, false, false, true> - { - static const bool s_exists = true; - static inline _integer_type add_and_fetch(volatile _integer_type * operand_address, const _integer_type & addend) - { - _integer_type old_value, new_value; - do - old_value = *operand_address, new_value = old_value + addend; - while (!machine::compare_and_store(operand_address, old_value, new_value)); - return new_value; - } - }; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } // namespace detail - template<typename _integer_type> - inline _integer_type add_and_fetch(volatile _integer_type * operand_address, const _integer_type & addend) - { - // if your compiler can't find the function to call here then there is no implementation available for your machine - return detail::implementation_AAF<_integer_type>::add_and_fetch(operand_address, addend); - } - //---------------------------------------------------------------------------------------- - - - - //---------------------------------------------------------------------------------------- - // add - template<typename _integer_type> - inline void add(volatile _integer_type * operand_address, const _integer_type & addend) - { - if (machine::implements_add<sizeof(_integer_type)>::value) - machine::add(operand_address, addend); - else if (machine::implements_fetch_and_add<sizeof(_integer_type)>::value) - machine::fetch_and_add(operand_address, addend); - else if (machine::implements_add_and_fetch<sizeof(_integer_type)>::value) - machine::add_and_fetch(operand_address, addend); - else - fetch_and_add(operand_address, addend); // this will simulate using CAS or LL/SC (or it will fail the compilation if neither is available) - } - //---------------------------------------------------------------------------------------- - - - - //---------------------------------------------------------------------------------------- - // TODO: this is where we add implementations for: - // - functions not implemented by the machine - // - functions that take unsigned types (routed to call the signed versions with appropriate conversions) - // For now we add nothing, so developers will need to stick to what their machine can do, and use signed - // integers only. - using machine::subtract; - using machine::subtract_and_fetch; - using machine::fetch_and_subtract; - //---------------------------------------------------------------------------------------- - - - - //--------------------------------------------------------------------- - template<class _base_type, unsigned int _bytes_per_cache_line=machine::k_bytes_per_cache_line> - struct pad_to_cache_line : public _base_type - { - private: - typedef pad_to_cache_line this_type; - typedef _base_type base_type; - public: - static const unsigned int s_bytes_per_cache_line = _bytes_per_cache_line; - private: - int m_padding[(s_bytes_per_cache_line - sizeof(base_type))/sizeof(int)]; - public: - pad_to_cache_line() {} - template<typename _arg_type> pad_to_cache_line(_arg_type arg) : base_type(arg) {} - }; - //--------------------------------------------------------------------- - - } // namespace atomic - } // namespace threading -} // namespace Akupara - -#endif // _AKUPARA_THREADING_ATOMIC_OPS_HPP__INCLUDED_ diff --git a/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops_gcc_x86.hpp b/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops_gcc_x86.hpp deleted file mode 100644 index 74d73106f8..0000000000 --- a/libs/backends/wavesaudio/wavesapi/akupara/threading/atomic_ops_gcc_x86.hpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Akupara/threading/atomic_ops_gcc_x86.hpp - * - * - * Created by Udi Barzilai on 06/06. - * Copyright 2006 __MyCompanyName__. All rights reserved. - * - */ -#if !defined(_AKUPARA_THREADING_ATOMIC_OPS_GCC_X86_HPP__INCLUDED_) -# define _AKUPARA_THREADING_ATOMIC_OPS_GCC_X86_HPP__INCLUDED_ -# if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - -namespace Akupara -{ - namespace threading - { - namespace atomic - { - namespace machine - { - const unsigned int k_bytes_per_cache_line = 64; // this is true for P4 & K8 - - - // Flags for operations supported by this machine - //------------------------------------- - template<> struct implements_load <4> : public true_type {}; - template<> struct implements_store <4> : public true_type {}; - template<> struct implements_CAS <4> : public true_type {}; - template<> struct implements_CAS <8> : public true_type {}; - template<> struct implements_add <4> : public true_type {}; - template<> struct implements_fetch_and_add<4> : public true_type {}; - //------------------------------------- - - - - // CAS - //-------------------------------------------------------------------------------- - template<> - inline bool compare_and_store<int64_t>(volatile int64_t * p, const int64_t & x, const int64_t & y) - { - register int32_t evh=int32_t(x>>32), evl=int32_t(x); - register const int32_t nvh=int32_t(y>>32), nvl=int32_t(y); - register bool result; - __asm__ __volatile__ ( - "# CAS64\n" - " lock \n" - " cmpxchg8b %[location] \n" - " sete %[result] \n" - : [location] "+m" (*p), [result] "=qm" (result), [expected_value_high] "+d" (evh), [expected_value_low] "+a" (evl) - : [new_value_high] "c" (nvh), [new_value_low] "b" (nvl) - : "cc" - ); - return result; - } - //-------------------------------------------------------------------------------- - template<> - inline bool compare_and_store<int32_t>(volatile int32_t *p, const int32_t & x, const int32_t & y) - { - register int32_t expected_value = x; - register bool result; - __asm__ __volatile__ ( - "# CAS32\n" - " lock \n" - " cmpxchgl %[new_value],%[operand] \n" - " sete %[result] \n" - : [operand] "+m" (*p), [result] "=qm" (result), [expected_value] "+a" (expected_value) - : [new_value] "r" (y) - : "cc" - ); - return result; - } - //-------------------------------------------------------------------------------- - - - - - // Atomic add/sub - //-------------------------------------------------------------------------------- - inline void increment(volatile int32_t * operand_address) - { - __asm__ __volatile__ ( - "# atomic_increment_32\n" - " lock; \n" - " incl %[operand]; \n" - : [operand] "+m" (*operand_address) - : - : "cc" - ); - } - //-------------------------------------------------------------------------------- - inline void decrement(volatile int32_t * operand_address) - { - __asm__ __volatile__ ( - "# atomic_decrement_32\n" - " lock; \n" - " decl %[operand]; \n" - : [operand] "+m" (*operand_address) - : - : "cc" - ); - } - //-------------------------------------------------------------------------------- - template<> - inline void add<int32_t>(volatile int32_t * operand_address, const int32_t & addend) - { - if (__builtin_constant_p(addend) && addend==1) - increment(operand_address); - else if (__builtin_constant_p(addend) && addend==-1) - decrement(operand_address); - else - __asm__ __volatile__ ( - "# atomic_add_32 \n" - " lock \n" - " addl %[addend], %[operand] \n" - : [operand] "+m" (*operand_address) - : [addend] "ir" (addend) - : "cc" - ); - } - //-------------------------------------------------------------------------------- - template<> - inline void subtract<int32_t>(volatile int32_t * operand_address, const int32_t & subtrahend) - { - if (__builtin_constant_p(subtrahend) && subtrahend==1) - decrement(operand_address); - else if (__builtin_constant_p(subtrahend) && subtrahend==-1) - increment(operand_address); - else - __asm__ __volatile__ ( - "# atomic_subtract_32 \n" - " lock \n" - " subl %[subtrahend], %[operand] \n" - : [operand] "+m" (*operand_address) - : [subtrahend] "ir" (subtrahend) - : "cc" - ); - } - //-------------------------------------------------------------------------------- - - - - // Atomic fetch and add/sub - //-------------------------------------------------------------------------------- - template<> - inline int32_t fetch_and_add<int32_t>(volatile int32_t * operand_address, const int32_t & addend) - { - register int32_t addend_and_fetched = addend; - __asm__ __volatile__ ( - "# atomic_fetch_and_add_32 \n" - " lock; \n" - " xaddl %[addend], %[operand]; \n" - : [operand] "+m" (*operand_address), [addend] "+r" (addend_and_fetched) - : - : "cc" - ); - return addend_and_fetched; - } - //-------------------------------------------------------------------------------- - template<> - inline int32_t fetch_and_subtract<int32_t>(volatile int32_t * operand_address, const int32_t & subtrahend) - { - return fetch_and_add(operand_address, -subtrahend); - } - //-------------------------------------------------------------------------------- - - - - - // Memory barriers - //-------------------------------------------------------------------------------- - inline void memory_barrier_readwrite() - { - #if _AKUPARA_X86_SSE_NOT_AVAILABLE - __asm__ __volatile__ (" lock; addl $0,0(%%esp); # memory_barrier_readwrite" : : : "memory"); - #else - __asm__ __volatile__ (" mfence; # memory_barrier_readwrite" : : : "memory"); - #endif // _LOCKFREE_ATOMIC_OPS_X86_LFENCE_NOT_AVAILABLE - } - //-------------------------------------------------------------------------------- - inline void memory_barrier_read() - { - #if _AKUPARA_X86_SSE_NOT_AVAILABLE - __asm__ __volatile__ (" lock; addl $0,0(%%esp); # memory_barrier_read" : : : "memory"); - #else - __asm__ __volatile__ (" lfence; # memory_barrier_read" : : : "memory"); - #endif // _LOCKFREE_ATOMIC_OPS_X86_LFENCE_NOT_AVAILABLE - } - //-------------------------------------------------------------------------------- - inline void memory_barrier_write() - { - __asm__ __volatile__ (" sfence; # memory_barrier_write" : : : "memory"); - } - //-------------------------------------------------------------------------------- - - } // namespace machine - } // namespace atomic - } // namespace threading -} // namespace Akupara - -# endif // defined(__GNUC__) && defined(__i386__) -#endif // _AKUPARA_THREADING_ATOMIC_OPS_GCC_X86_HPP__INCLUDED_ |