--- .libs/performance_counters.o ports clang 3.9 +++ .libs/performance_counters.o base clang 4.0 @@ -1,7 +1,7 @@ # 1 "performance_counters.cpp" # 1 "" 1 # 1 "" 3 -# 335 "" 3 +# 336 "" 3 # 1 "" 1 # 1 "" 2 # 1 "performance_counters.cpp" 2 @@ -1637,8 +1637,6 @@ # 1 "/usr/include/c++/v1/inttypes.h" 1 3 # 238 "/usr/include/c++/v1/inttypes.h" 3 # 247 "/usr/include/c++/v1/inttypes.h" 3 -# 1 "/usr/local/llvm39/bin/../lib/clang/3.9.1/include/inttypes.h" 1 3 4 -# 30 "/usr/local/llvm39/bin/../lib/clang/3.9.1/include/inttypes.h" 3 4 # 1 "/usr/include/inttypes.h" 1 3 4 # 32 "/usr/include/inttypes.h" 3 4 # 1 "/usr/include/machine/_inttypes.h" 1 3 4 @@ -1713,7 +1711,6 @@ uintmax_t wcstoumax(const wchar_t * , wchar_t ** , int); } -# 31 "/usr/local/llvm39/bin/../lib/clang/3.9.1/include/inttypes.h" 2 3 4 # 248 "/usr/include/c++/v1/inttypes.h" 2 3 @@ -6153,21 +6150,21 @@ void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void * _Nonnull, const void *)); void *calloc(size_t, size_t) __attribute__((__malloc__)) __attribute__((__warn_unused_result__)) - ; + __attribute__((__alloc_size__(1))) __attribute__((__alloc_size__(2))); div_t div(int, int) __attribute__((__const__)); [[noreturn]] void exit(int); void free(void *); char *getenv(const char *); long labs(long) __attribute__((__const__)); ldiv_t ldiv(long, long) __attribute__((__const__)); -void *malloc(size_t) __attribute__((__malloc__)) __attribute__((__warn_unused_result__)) ; +void *malloc(size_t) __attribute__((__malloc__)) __attribute__((__warn_unused_result__)) __attribute__((__alloc_size__(1))); int mblen(const char *, size_t); size_t mbstowcs(wchar_t * , const char * , size_t); int mbtowc(wchar_t * , const char * , size_t); void qsort(void *, size_t, size_t, int (* _Nonnull)(const void *, const void *)); int rand(void); -void *realloc(void *, size_t) __attribute__((__warn_unused_result__)) ; +void *realloc(void *, size_t) __attribute__((__warn_unused_result__)) __attribute__((__alloc_size__(2))); void srand(unsigned); double strtod(const char * , char ** ); float strtof(const char * , char ** ); @@ -6209,7 +6206,7 @@ void * aligned_alloc(size_t, size_t) __attribute__((__malloc__)) - ; + __attribute__((__alloc_size__(2))); int at_quick_exit(void (*)(void)); [[noreturn]] void quick_exit(int); @@ -6320,9 +6317,9 @@ int (*)(void *, const void *, const void *)); int radixsort(const unsigned char **, int, const unsigned char *, unsigned); -void *reallocarray(void *, size_t, size_t) __attribute__((__warn_unused_result__)) - ; -void *reallocf(void *, size_t) ; +void *reallocarray(void *, size_t, size_t) __attribute__((__warn_unused_result__)) __attribute__((__alloc_size__(2))) + __attribute__((__alloc_size__(3))); +void *reallocf(void *, size_t) __attribute__((__alloc_size__(2))); int rpmatch(const char *); void setprogname(const char *); int sradixsort(const unsigned char **, int, const unsigned char *, @@ -22154,9 +22151,7 @@ if (__n == 0) return 0; - - - return memcmp(__s1, __s2, __n); + return __builtin_memcmp(__s1, __s2, __n); # 260 "/usr/include/c++/v1/__string" 3 } @@ -22167,9 +22162,7 @@ if (__n == 0) return nullptr; - - - return (const char_type*) memchr(__s, to_int_type(__a), __n); + return __builtin_char_memchr(__s, to_int_type(__a), __n); # 281 "/usr/include/c++/v1/__string" 3 } @@ -22227,9 +22220,7 @@ if (__n == 0) return 0; - - - return wmemcmp(__s1, __s2, __n); + return __builtin_wmemcmp(__s1, __s2, __n); # 350 "/usr/include/c++/v1/__string" 3 } @@ -22238,15 +22229,8 @@ char_traits::length(const char_type* __s) noexcept { - - - return wcslen(__s); - - - - - - + return __builtin_wcslen(__s); +# 366 "/usr/include/c++/v1/__string" 3 } inline @@ -22256,9 +22240,7 @@ if (__n == 0) return nullptr; - - - return wmemchr(__s, __a, __n); + return __builtin_wmemchr(__s, __a, __n); # 387 "/usr/include/c++/v1/__string" 3 } @@ -42106,51 +42088,6 @@ } } # 21 "/usr/local/include/boost/atomic/detail/ops_gcc_atomic.hpp" 2 -# 33 "/usr/local/include/boost/atomic/detail/ops_gcc_atomic.hpp" -# 1 "/usr/local/include/boost/atomic/detail/ops_extending_cas_based.hpp" 1 -# 26 "/usr/local/include/boost/atomic/detail/ops_extending_cas_based.hpp" -namespace boost { -namespace atomics { -namespace detail { - -template< typename Base, std::size_t Size, bool Signed > -struct extending_cas_based_operations : - public Base -{ - typedef typename Base::storage_type storage_type; - typedef typename make_storage_type< Size, Signed >::type emulated_storage_type; - - static inline __attribute__ ((__always_inline__)) storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order order) noexcept - { - storage_type old_val; - atomics::detail::non_atomic_load(storage, old_val); - emulated_storage_type new_val; - do - { - new_val = static_cast< emulated_storage_type >(old_val) + static_cast< emulated_storage_type >(v); - } - while (!Base::compare_exchange_weak(storage, old_val, static_cast< storage_type >(new_val), order, memory_order_relaxed)); - return old_val; - } - - static inline __attribute__ ((__always_inline__)) storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) noexcept - { - storage_type old_val; - atomics::detail::non_atomic_load(storage, old_val); - emulated_storage_type new_val; - do - { - new_val = static_cast< emulated_storage_type >(old_val) - static_cast< emulated_storage_type >(v); - } - while (!Base::compare_exchange_weak(storage, old_val, static_cast< storage_type >(new_val), order, memory_order_relaxed)); - return old_val; - } -}; - -} -} -} -# 34 "/usr/local/include/boost/atomic/detail/ops_gcc_atomic.hpp" 2 # 48 "/usr/local/include/boost/atomic/detail/ops_gcc_atomic.hpp" namespace boost { namespace atomics { @@ -42250,6 +42187,13 @@ return __atomic_is_lock_free(sizeof(storage_type), &storage); } }; +# 222 "/usr/local/include/boost/atomic/detail/ops_gcc_atomic.hpp" +template< bool Signed > +struct operations< 8u, Signed > : + public gcc_atomic_operations< typename make_storage_type< 8u, Signed >::type > +{ + typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type; +}; # 263 "/usr/local/include/boost/atomic/detail/ops_gcc_atomic.hpp" template< bool Signed > struct operations< 4u, Signed > : @@ -44096,9 +44040,18 @@ void blend_stats_counter(int c, boost::int64_t value, int ratio); private: -# 459 "../include/libtorrent/performance_counters.hpp" - mutable mutex m_mutex; - boost::int64_t m_stats_counter[num_counters]; + + + + + + + boost::atomic m_stats_counter[num_counters]; + + + + + }; } @@ -44116,41 +44069,41 @@ counters::counters() { + for (int i = 0; i < sizeof(m_stats_counter) + / sizeof(m_stats_counter[0]); ++i) + m_stats_counter[i].store(0, boost::memory_order_relaxed); - - memset(m_stats_counter, 0, sizeof(m_stats_counter)); - } counters::counters(counters const& c) { + for (int i = 0; i < sizeof(m_stats_counter) + / sizeof(m_stats_counter[0]); ++i) + m_stats_counter[i].store( + c.m_stats_counter[i].load(boost::memory_order_relaxed) + , boost::memory_order_relaxed); - - - mutex::scoped_lock l(c.m_mutex); - memcpy(m_stats_counter, c.m_stats_counter, sizeof(m_stats_counter)); - } counters& counters::operator=(counters const& c) { + for (int i = 0; i < sizeof(m_stats_counter) + / sizeof(m_stats_counter[0]); ++i) + m_stats_counter[i].store( + c.m_stats_counter[i].load(boost::memory_order_relaxed) + , boost::memory_order_relaxed); - - mutex::scoped_lock l(m_mutex); - mutex::scoped_lock l2(c.m_mutex); - memcpy(m_stats_counter, c.m_stats_counter, sizeof(m_stats_counter)); - return *this; } @@ -44163,10 +44116,10 @@ + return m_stats_counter[i].load(boost::memory_order_relaxed); + - mutex::scoped_lock l(m_mutex); - return m_stats_counter[i]; } @@ -44182,13 +44135,13 @@ do {} while (0); + boost::int64_t pv = m_stats_counter[c].fetch_add(value, boost::memory_order_relaxed); + do {} while (0); + return pv + value; - mutex::scoped_lock l(m_mutex); - do {} while (0); - return m_stats_counter[c] += value; } @@ -44200,29 +44153,31 @@ do {} while (0); do {} while (0); do {} while (0); -# 142 "performance_counters.cpp" - mutex::scoped_lock l(m_mutex); - boost::int64_t current = m_stats_counter[c]; - m_stats_counter[c] = (current * (100-ratio) + value * ratio) / 100; - } - void counters::set_value(int c, boost::int64_t value) - { - do {} while (0); - do {} while (0); + boost::int64_t current = m_stats_counter[c].load(boost::memory_order_relaxed); + boost::int64_t new_value = (current * (100-ratio) + value * ratio) / 100; + while (!m_stats_counter[c].compare_exchange_weak(current, new_value + , boost::memory_order_relaxed)) + { + new_value = (current * (100-ratio) + value * ratio) / 100; + } - mutex::scoped_lock l(m_mutex); + } + void counters::set_value(int c, boost::int64_t value) + { + do {} while (0); do {} while (0); - m_stats_counter[c] = value; + m_stats_counter[c].store(value); +# 164 "performance_counters.cpp" } }