diff --git a/include/boost/log/detail/intptr_t.hpp b/include/boost/log/detail/intptr_t.hpp new file mode 100644 index 0000000..f5151c8 --- /dev/null +++ b/include/boost/log/detail/intptr_t.hpp @@ -0,0 +1,64 @@ +/* + * Copyright Andrey Semashev 2007 - 2013. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ +/*! + * \file intptr_t.hpp + * \author Andrey Semashev + * \date 06.05.2013 + * + * \brief This header is the Boost.Log library implementation, see the library documentation + * at http://www.boost.org/libs/log/doc/log.html. + */ + +#ifndef BOOST_LOG_DETAIL_INTPTR_T_HPP_INCLUDED_ +#define BOOST_LOG_DETAIL_INTPTR_T_HPP_INCLUDED_ + +#include +#include +#include + +#ifdef BOOST_LOG_HAS_PRAGMA_ONCE +#pragma once +#endif + +namespace boost { + +BOOST_LOG_OPEN_NAMESPACE + +namespace aux { + +// PGI seems to not support intptr_t/uintptr_t properly. BOOST_HAS_STDINT_H is not defined for this compiler by Boost.Config. +#if !defined(__PGIC__) + +#if (defined(BOOST_WINDOWS) && !defined(_WIN32_WCE)) \ + || (defined(_XOPEN_UNIX) && (_XOPEN_UNIX+0 > 0) && !defined(__UCLIBC__)) \ + || defined(__CYGWIN__) \ + || defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) \ + || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) + +typedef ::intptr_t intptr_t; +typedef ::uintptr_t uintptr_t; +#define BOOST_LOG_HAS_INTPTR_T + +#elif (defined(__GNUC__) || defined(__clang__)) && defined(__INTPTR_TYPE__) && defined(__UINTPTR_TYPE__) + +typedef __INTPTR_TYPE__ intptr_t; +typedef __UINTPTR_TYPE__ uintptr_t; +#define BOOST_LOG_HAS_INTPTR_T + +#endif + +#endif + +} // namespace aux + +BOOST_LOG_CLOSE_NAMESPACE // namespace log + +} // namespace boost + +#include + +#endif // BOOST_LOG_DETAIL_INTPTR_T_HPP_INCLUDED_ diff --git a/src/dump_avx2.cpp b/src/dump_avx2.cpp index dd31b8d..9ca0aae 100644 --- a/src/dump_avx2.cpp +++ b/src/dump_avx2.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include namespace boost { @@ -132,7 +133,7 @@ BOOST_LOG_FORCEINLINE void dump_data_avx2(const void* data, std::size_t size, st char_type buf_storage[stride * 3u + 16u]; // Align the temporary buffer at 16 bytes - char_type* const buf = buf_storage + (16u - ((std::size_t)(char_type*)buf_storage & 15u)); + char_type* const buf = reinterpret_cast< char_type* >((uint8_t*)buf_storage + (16u - (((uintptr_t)(char_type*)buf_storage) & 15u))); char_type* buf_begin = buf + 1u; // skip the first space of the first chunk char_type* buf_end = buf + stride * 3u; @@ -144,7 +145,7 @@ BOOST_LOG_FORCEINLINE void dump_data_avx2(const void* data, std::size_t size, st // First, check the input alignment const uint8_t* p = static_cast< const uint8_t* >(data); - if (const std::size_t prealign_size = ((16u - ((std::size_t)p & 15u)) & 15u)) + if (const std::size_t prealign_size = ((16u - ((uintptr_t)p & 15u)) & 15u)) { __m128i mm_input = _mm_lddqu_si128(reinterpret_cast< const __m128i* >(p)); __m128i mm_output1, mm_output2, mm_output3; @@ -169,9 +170,9 @@ BOOST_LOG_FORCEINLINE void dump_data_avx2(const void* data, std::size_t size, st __m128i mm_input = _mm_load_si128(reinterpret_cast< const __m128i* >(p)); __m128i mm_output1, mm_output2, mm_output3; dump_pack(mm_char_10_to_a, mm_input, mm_output1, mm_output2, mm_output3); - store_characters(mm_output1, buf); - store_characters(mm_output2, buf + 16u); - store_characters(mm_output3, buf + 32u); + store_characters(mm_output1, b); + store_characters(mm_output2, b + 16u); + store_characters(mm_output3, b + 32u); } strm.write(buf_begin, buf_end - buf_begin); @@ -186,9 +187,9 @@ BOOST_LOG_FORCEINLINE void dump_data_avx2(const void* data, std::size_t size, st __m128i mm_input = _mm_load_si128(reinterpret_cast< const __m128i* >(p)); __m128i mm_output1, mm_output2, mm_output3; dump_pack(mm_char_10_to_a, mm_input, mm_output1, mm_output2, mm_output3); - store_characters(mm_output1, buf); - store_characters(mm_output2, buf + 16u); - store_characters(mm_output3, buf + 32u); + store_characters(mm_output1, b); + store_characters(mm_output2, b + 16u); + store_characters(mm_output3, b + 32u); b += 3u * 16u; p += 16u; tail_size -= 16u; diff --git a/src/dump_ssse3.cpp b/src/dump_ssse3.cpp index 8d80ad4..4f5e172 100644 --- a/src/dump_ssse3.cpp +++ b/src/dump_ssse3.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include namespace boost { @@ -132,7 +133,7 @@ BOOST_LOG_FORCEINLINE void dump_data_ssse3(const void* data, std::size_t size, s char_type buf_storage[stride * 3u + 16u]; // Align the temporary buffer at 16 bytes - char_type* const buf = buf_storage + (16u - ((std::size_t)(char_type*)buf_storage & 15u)); + char_type* const buf = reinterpret_cast< char_type* >((uint8_t*)buf_storage + (16u - (((uintptr_t)(char_type*)buf_storage) & 15u))); char_type* buf_begin = buf + 1u; // skip the first space of the first chunk char_type* buf_end = buf + stride * 3u; @@ -144,7 +145,7 @@ BOOST_LOG_FORCEINLINE void dump_data_ssse3(const void* data, std::size_t size, s // First, check the input alignment const uint8_t* p = static_cast< const uint8_t* >(data); - if (const std::size_t prealign_size = ((16u - ((std::size_t)p & 15u)) & 15u)) + if (const std::size_t prealign_size = ((16u - ((uintptr_t)p & 15u)) & 15u)) { __m128i mm_input = _mm_lddqu_si128(reinterpret_cast< const __m128i* >(p)); __m128i mm_output1, mm_output2, mm_output3; @@ -169,9 +170,9 @@ BOOST_LOG_FORCEINLINE void dump_data_ssse3(const void* data, std::size_t size, s __m128i mm_input = _mm_load_si128(reinterpret_cast< const __m128i* >(p)); __m128i mm_output1, mm_output2, mm_output3; dump_pack(mm_char_10_to_a, mm_input, mm_output1, mm_output2, mm_output3); - store_characters(mm_output1, buf); - store_characters(mm_output2, buf + 16u); - store_characters(mm_output3, buf + 32u); + store_characters(mm_output1, b); + store_characters(mm_output2, b + 16u); + store_characters(mm_output3, b + 32u); } strm.write(buf_begin, buf_end - buf_begin); @@ -186,9 +187,9 @@ BOOST_LOG_FORCEINLINE void dump_data_ssse3(const void* data, std::size_t size, s __m128i mm_input = _mm_load_si128(reinterpret_cast< const __m128i* >(p)); __m128i mm_output1, mm_output2, mm_output3; dump_pack(mm_char_10_to_a, mm_input, mm_output1, mm_output2, mm_output3); - store_characters(mm_output1, buf); - store_characters(mm_output2, buf + 16u); - store_characters(mm_output3, buf + 32u); + store_characters(mm_output1, b); + store_characters(mm_output2, b + 16u); + store_characters(mm_output3, b + 32u); b += 3u * 16u; p += 16u; tail_size -= 16u;