mirror of
https://github.com/boostorg/log.git
synced 2026-01-28 19:22:16 +00:00
Fixed incorrect target buffer alignment and filling.
[SVN r84176]
This commit is contained in:
64
include/boost/log/detail/intptr_t.hpp
Normal file
64
include/boost/log/detail/intptr_t.hpp
Normal file
@@ -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 <boost/cstdint.hpp>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
#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 <boost/log/detail/footer.hpp>
|
||||
|
||||
#endif // BOOST_LOG_DETAIL_INTPTR_T_HPP_INCLUDED_
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <immintrin.h>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#include <boost/log/detail/intptr_t.hpp>
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
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;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <tmmintrin.h>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#include <boost/log/detail/intptr_t.hpp>
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user