fix cpuid use (apparently it's not appropriate to use in an inlined function)
This commit is contained in:
parent
a15bc13392
commit
d128d36faa
|
@ -19,6 +19,7 @@ set(sources
|
||||||
chained_buffer
|
chained_buffer
|
||||||
choker
|
choker
|
||||||
close_reason
|
close_reason
|
||||||
|
cpuid
|
||||||
crc32c
|
crc32c
|
||||||
create_torrent
|
create_torrent
|
||||||
disk_buffer_holder
|
disk_buffer_holder
|
||||||
|
|
1
Jamfile
1
Jamfile
|
@ -584,6 +584,7 @@ SOURCES =
|
||||||
chained_buffer
|
chained_buffer
|
||||||
choker
|
choker
|
||||||
close_reason
|
close_reason
|
||||||
|
cpuid
|
||||||
crc32c
|
crc32c
|
||||||
create_torrent
|
create_torrent
|
||||||
disk_buffer_holder
|
disk_buffer_holder
|
||||||
|
|
|
@ -30,7 +30,6 @@ nobase_include_HEADERS = \
|
||||||
config.hpp \
|
config.hpp \
|
||||||
ConvertUTF.h \
|
ConvertUTF.h \
|
||||||
copy_ptr.hpp \
|
copy_ptr.hpp \
|
||||||
cpuid.hpp \
|
|
||||||
crc32c.hpp \
|
crc32c.hpp \
|
||||||
create_torrent.hpp \
|
create_torrent.hpp \
|
||||||
deadline_timer.hpp \
|
deadline_timer.hpp \
|
||||||
|
@ -157,15 +156,16 @@ nobase_include_HEADERS = \
|
||||||
tommath_superclass.h \
|
tommath_superclass.h \
|
||||||
\
|
\
|
||||||
aux_/alert_manager_variadic_emplace.hpp \
|
aux_/alert_manager_variadic_emplace.hpp \
|
||||||
|
aux_/cpuid.hpp \
|
||||||
|
aux_/disable_warnings_push.hpp \
|
||||||
|
aux_/disable_warnings_pop.hpp \
|
||||||
|
aux_/escape_string.hpp \
|
||||||
|
aux_/merkle.hpp \
|
||||||
aux_/session_call.hpp \
|
aux_/session_call.hpp \
|
||||||
aux_/session_impl.hpp \
|
aux_/session_impl.hpp \
|
||||||
aux_/session_settings.hpp \
|
aux_/session_settings.hpp \
|
||||||
aux_/session_interface.hpp \
|
aux_/session_interface.hpp \
|
||||||
aux_/time.hpp \
|
aux_/time.hpp \
|
||||||
aux_/escape_string.hpp \
|
|
||||||
aux_/disable_warnings_push.hpp \
|
|
||||||
aux_/disable_warnings_pop.hpp \
|
|
||||||
aux_/merkle.hpp \
|
|
||||||
\
|
\
|
||||||
extensions/lt_trackers.hpp \
|
extensions/lt_trackers.hpp \
|
||||||
extensions/metadata_transfer.hpp \
|
extensions/metadata_transfer.hpp \
|
||||||
|
|
|
@ -34,31 +34,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_CPUID_HPP_INCLUDED
|
#define TORRENT_CPUID_HPP_INCLUDED
|
||||||
|
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#if defined _MSC_VER && TORRENT_HAS_SSE
|
namespace libtorrent { namespace aux
|
||||||
#include <intrin.h>
|
|
||||||
#include <nmmintrin.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace libtorrent
|
|
||||||
{
|
{
|
||||||
// internal
|
// initialized by static initializers (in cpuid.cpp)
|
||||||
inline void cpuid(unsigned int info[4], int type)
|
extern bool sse42_support;
|
||||||
{
|
extern bool mmx_support;
|
||||||
#if TORRENT_HAS_SSE && defined _MSC_VER
|
} }
|
||||||
__cpuid((int*)info, type);
|
|
||||||
|
|
||||||
#elif TORRENT_HAS_SSE && defined __GNUC__
|
|
||||||
asm volatile
|
|
||||||
("cpuid" : "=a" (info[0]), "=b" (info[1]), "=c" (info[2]), "=d" (info[3])
|
|
||||||
: "a" (type), "c" (0));
|
|
||||||
#else
|
|
||||||
// for non-x86 and non-amd64, just return zeroes
|
|
||||||
std::memset(&info[0], 0, sizeof(unsigned int) * 4);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TORRENT_CPUID_HPP_INCLUDED
|
#endif // TORRENT_CPUID_HPP_INCLUDED
|
||||||
|
|
|
@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/byteswap.hpp"
|
#include "libtorrent/byteswap.hpp"
|
||||||
#include "libtorrent/cpuid.hpp"
|
#include "libtorrent/aux_/cpuid.hpp"
|
||||||
|
|
||||||
#include <cstring> // for memset and memcpy
|
#include <cstring> // for memset and memcpy
|
||||||
#include <cstdlib> // for malloc, free and realloc
|
#include <cstdlib> // for malloc, free and realloc
|
||||||
|
@ -171,9 +171,7 @@ namespace libtorrent
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
const int words = num_words();
|
const int words = num_words();
|
||||||
#if TORRENT_HAS_SSE
|
#if TORRENT_HAS_SSE
|
||||||
unsigned int cpui[4];
|
if (aux::mmx_support)
|
||||||
cpuid(cpui, 1);
|
|
||||||
if (cpui[2] & (1 << 23))
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < words; ++i)
|
for (int i = 0; i < words; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,6 +53,7 @@ libtorrent_rasterbar_la_SOURCES = \
|
||||||
choker.cpp \
|
choker.cpp \
|
||||||
close_reason.cpp \
|
close_reason.cpp \
|
||||||
ConvertUTF.cpp \
|
ConvertUTF.cpp \
|
||||||
|
cpuid.cpp \
|
||||||
crc32c.cpp \
|
crc32c.cpp \
|
||||||
create_torrent.cpp \
|
create_torrent.cpp \
|
||||||
disk_buffer_holder.cpp \
|
disk_buffer_holder.cpp \
|
||||||
|
|
|
@ -31,8 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libtorrent/crc32c.hpp"
|
#include "libtorrent/crc32c.hpp"
|
||||||
#include "libtorrent/cpuid.hpp"
|
#include "libtorrent/aux_/cpuid.hpp"
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
#include <boost/crc.hpp>
|
#include <boost/crc.hpp>
|
||||||
|
@ -41,27 +40,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
namespace {
|
|
||||||
|
|
||||||
bool supports_sse42()
|
|
||||||
{
|
|
||||||
#if TORRENT_HAS_SSE
|
|
||||||
unsigned int cpui[4];
|
|
||||||
cpuid(cpui, 1);
|
|
||||||
return cpui[2] & (1 << 20);
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool sse42_support = supports_sse42();
|
|
||||||
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
boost::uint32_t crc32c_32(boost::uint32_t v)
|
boost::uint32_t crc32c_32(boost::uint32_t v)
|
||||||
{
|
{
|
||||||
#if TORRENT_HAS_SSE
|
#if TORRENT_HAS_SSE
|
||||||
if (sse42_support)
|
if (aux::sse42_support)
|
||||||
{
|
{
|
||||||
boost::uint32_t ret = 0xffffffff;
|
boost::uint32_t ret = 0xffffffff;
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
@ -86,7 +68,7 @@ namespace libtorrent
|
||||||
boost::uint32_t crc32c(boost::uint64_t const* buf, int num_words)
|
boost::uint32_t crc32c(boost::uint64_t const* buf, int num_words)
|
||||||
{
|
{
|
||||||
#if TORRENT_HAS_SSE
|
#if TORRENT_HAS_SSE
|
||||||
if (sse42_support)
|
if (aux::sse42_support)
|
||||||
{
|
{
|
||||||
#if defined _M_AMD64 || defined __x86_64__ \
|
#if defined _M_AMD64 || defined __x86_64__ \
|
||||||
|| defined __x86_64 || defined _M_X64 || defined __amd64__
|
|| defined __x86_64 || defined _M_X64 || defined __amd64__
|
||||||
|
|
Loading…
Reference in New Issue