1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2025-02-19 12:04:54 +00:00

Buildfix on ARM raspberry pi

This commit is contained in:
King_DuckZ 2016-02-02 20:56:27 +01:00
parent c5824c36bd
commit 58c7e917c5
6 changed files with 80 additions and 24 deletions

View file

@ -79,5 +79,8 @@ target_compile_definitions(${PROJECT_NAME}
INTERFACE BOOST_SPIRIT_USE_PHOENIX_V3=1
#workaround for a bug in gcc 5.3 that is causing exceptions to slip
#through try/catch blocks.
#WARNING: this will likely cause linking erros with boost and
#yaml-cpp unless they are also built with this option or with an
#older version of gcc.
INTERFACE _GLIBCXX_USE_CXX11_ABI=0
)

View file

@ -168,7 +168,7 @@ namespace pq {
//Hack to make some sort of "static pimpl"
struct StorageStruct { int a; int b[2 * 6]; void* c[2]; };
static constexpr std::size_t DATA_SIZE = sizeof(StorageStruct);
using storage = std::aligned_storage<DATA_SIZE, alignof(uint64_t)>::type;
using storage = std::aligned_storage<DATA_SIZE, alignof(int)>::type;
void push_param ( const char* parFormat, ... );
storage m_storage;
PGParams m_par;

View file

@ -664,7 +664,7 @@ void tiger_chunk(const char *str, t_word length, t_res res)
void tiger_last_chunk(const char *str, t_word length, t_word reallength, t_res res, char pad)
{
t_block tmp;
t_word i;
t_word i;
i=length & 63;
//Padding on last block
@ -707,20 +707,12 @@ void tiger(const char *str, t_word length, t_res res, char pad)
tiger_last_chunk(str + proc_length, length - proc_length, length, res, pad);
}
void tiger_2(const char *str1, const char *str2, t_word length, t_res res1, t_res res2)
void tiger_2_chunk(const char *str1, const char *str2, t_word length, t_res res1, t_res res2)
{
t_block tmp1;
t_block tmp2;
const char * end = str1 + (length&(-64));
t_word i;
endianvars_2;
res1[0]=0x0123456789ABCDEFULL;
res2[0]=0x0123456789ABCDEFULL;
res1[1]=0xFEDCBA9876543210ULL;
res2[1]=0xFEDCBA9876543210ULL;
res1[2]=0xF096A5B4C3B2E187ULL;
res2[2]=0xF096A5B4C3B2E187ULL;
while(str1<end)
{
@ -746,6 +738,14 @@ void tiger_2(const char *str1, const char *str2, t_word length, t_res res1, t_re
#endif
#endif
}
}
void tiger_2_last_chunk (const char *str1, const char *str2, t_word length, t_word reallength1, t_word reallength2, t_res res1, t_res res2, char pad)
{
t_word i;
t_block tmp1;
t_block tmp2;
endianvars_2;
i=length & 63;
//Padding on last block
//add 0x01 afterwards.
@ -754,8 +754,8 @@ void tiger_2(const char *str1, const char *str2, t_word length, t_res res1, t_re
//Finally add message size at the end of the block.
memcpy(tmp1,str1,(size_t)i);
memcpy(tmp2,str2,(size_t)i);
uc(tmp1)[i]=0x01;
uc(tmp2)[i++]=0x01;
uc(tmp1)[i]=pad;
uc(tmp2)[i++]=pad;
memset(uc(tmp1)+i,0,(size_t)((8-i)&7));
memset(uc(tmp2)+i,0,(size_t)((8-i)&7));
i+=(8-i)&7;
@ -786,6 +786,20 @@ void tiger_2(const char *str1, const char *str2, t_word length, t_res res1, t_re
fixresendian_2;
}
void tiger_2(const char *str1, const char *str2, t_word length, t_res res1, t_res res2, char pad)
{
const t_word aligned_length = (length&(-64));
res1[0]=0x0123456789ABCDEFULL;
res2[0]=0x0123456789ABCDEFULL;
res1[1]=0xFEDCBA9876543210ULL;
res2[1]=0xFEDCBA9876543210ULL;
res1[2]=0xF096A5B4C3B2E187ULL;
res2[2]=0xF096A5B4C3B2E187ULL;
tiger_2_chunk(str1, str2, aligned_length, res1, res2);
tiger_2_last_chunk(str1 + aligned_length, str2 + aligned_length, length - aligned_length, length, length, res1, res2, pad);
}
#ifdef __SSE2__
void tiger_sse2_chunk(const char *str1, const char *str2, t_word length, t_res res1, t_res res2)
{
@ -835,7 +849,7 @@ void tiger_sse2_last_chunk (const char *str1, const char *str2, t_word length, t
void tiger_sse2(const char *str1, const char *str2, t_word length, t_res res1, t_res res2, char pad)
{
const t_word aligned_length = (length&(-64));
const t_word aligned_length = (length&(-64));
res1[0]=0x0123456789ABCDEFULL;
res2[0]=0x0123456789ABCDEFULL;
res1[1]=0xFEDCBA9876543210ULL;
@ -843,8 +857,8 @@ void tiger_sse2(const char *str1, const char *str2, t_word length, t_res res1, t
res1[2]=0xF096A5B4C3B2E187ULL;
res2[2]=0xF096A5B4C3B2E187ULL;
tiger_sse2_chunk(str1, str2, aligned_length, res1, res2);
tiger_sse2_last_chunk(str1 + aligned_length, str2 + aligned_length, length - aligned_length, length, length, res1, res2, pad);
tiger_sse2_chunk(str1, str2, aligned_length, res1, res2);
tiger_sse2_last_chunk(str1 + aligned_length, str2 + aligned_length, length - aligned_length, length, length, res1, res2, pad);
}
#endif

View file

@ -25,13 +25,18 @@
#include <sstream>
#include <iomanip>
#if defined(__SSE2__)
extern "C" void tiger_sse2_chunk ( const char* parStr1, const char* parStr2, uint64_t parLength, uint64_t parRes1[3], uint64_t parRes2[3] );
extern "C" void tiger_sse2_last_chunk ( const char* parStr1, const char* parStr2, uint64_t parLength, uint64_t parRealLength1, uint64_t parRealLength2, uint64_t parRes1[3], uint64_t parRes2[3], char parPadding );
extern "C" void tiger ( const char* parStr, uint64_t parLength, uint64_t parHash[3], char parPadding );
#if defined(__SSE2__)
# define USE_TIGER_SSE2
#endif
#if defined(USE_TIGER_SSE2)
extern "C" void tiger_sse2_chunk ( const char* parStr1, const char* parStr2, uint64_t parLength, uint64_t parRes1[3], uint64_t parRes2[3] );
extern "C" void tiger_sse2_last_chunk ( const char* parStr1, const char* parStr2, uint64_t parLength, uint64_t parRealLength1, uint64_t parRealLength2, uint64_t parRes1[3], uint64_t parRes2[3], char parPadding );
#else
# error "Not implemented without SSE2"
extern "C" void tiger_2_chunk ( const char* parStr1, const char* parStr2, uint64_t parLength, uint64_t parRes1[3], uint64_t parRes2[3] );
extern "C" void tiger_2_last_chunk ( const char* parStr1, const char* parStr2, uint64_t parLength, uint64_t parRealLength1, uint64_t parRealLength2, uint64_t parRes1[3], uint64_t parRes2[3], char parPadding );
#endif
namespace mchlib {
@ -81,7 +86,11 @@ namespace mchlib {
std::fill(buff_ptr + sizeof(hash_dir), buff_ptr + hash_size, 0);
TigerHash dummy {};
tiger_init_hash(hash_dir);
#if defined(USE_TIGER_SSE2)
tiger_sse2_chunk(buff_ptr, buff_ptr, hash_size, dummy.data, hash_dir.data);
#else
tiger_2_chunk(buff_ptr, buff_ptr, hash_size, dummy.data, hash_dir.data);
#endif
}
auto remaining = file_size;
@ -91,7 +100,11 @@ namespace mchlib {
assert(buffsize % 64 == 0);
remaining -= buffsize;
src.read(buff_ptr, buffsize);
#if defined(USE_TIGER_SSE2)
tiger_sse2_chunk(buff_ptr, buff_ptr, buffsize, parHashFile.data, hash_dir.data);
#else
tiger_2_chunk(buff_ptr, buff_ptr, buffsize, parHashFile.data, hash_dir.data);
#endif
}
{
@ -102,7 +115,11 @@ namespace mchlib {
assert(aligned_size <= buffsize);
const char* read_from_buff = buff_ptr;
if (aligned_size) {
#if defined(USE_TIGER_SSE2)
tiger_sse2_chunk(buff_ptr, buff_ptr, aligned_size, parHashFile.data, hash_dir.data);
#else
tiger_2_chunk(buff_ptr, buff_ptr, aligned_size, parHashFile.data, hash_dir.data);
#endif
assert((remaining & 63) == remaining - aligned_size);
remaining -= aligned_size;
read_from_buff += aligned_size;
@ -110,7 +127,11 @@ namespace mchlib {
//Remember to pass the augmented data size for the second reallength value: we passed the initial
//dir's hash value (64 bytes) as if they were part of the data.
#if defined(USE_TIGER_SSE2)
tiger_sse2_last_chunk(read_from_buff, read_from_buff, remaining, file_size, file_size + hash_size, parHashFile.data, hash_dir.data, g_tiger_padding);
#else
tiger_2_last_chunk(read_from_buff, read_from_buff, remaining, file_size, file_size + hash_size, parHashFile.data, hash_dir.data, g_tiger_padding);
#endif
}
parSizeOut = static_cast<uint64_t>(file_size);
@ -140,3 +161,7 @@ namespace mchlib {
tiger (parData.data(), parData.size(), parHash.data, g_tiger_padding);
}
} //namespace mchlib
#if defined(USE_TIGER_SSE2)
# undef USE_TIGER_SSE2
#endif

View file

@ -97,7 +97,7 @@ typedef t_word t_block[8];
/** Standard tiger calculation, put your string in str and the string length on length and get the result on res **/
void tiger(const char *str, t_word length, t_res res, char pad);
/** Similar to tiger but interleaving accesses to both equally sized strings to reduce overhead and pipeline stalls you get the result of str1 on res1 and the one of str2 on res2 **/
void tiger_2(const char *str1, const char *str2, t_word length, t_res res1, t_res res2);
void tiger_2(const char *str1, const char *str2, t_word length, t_res res1, t_res res2, char pad);
#ifdef __SSE2__
/** This is equivalent to tiger_2 but uses SSE2 for the key schduling making it faster **/
void tiger_sse2(const char *str1, const char *str2, t_word length, t_res res1, t_res res2, char pad);

View file

@ -27,6 +27,21 @@
namespace pq {
namespace implem {
template <
typename Expected,
typename Struct,
std::size_t ES=sizeof(Expected),
std::size_t EA=alignof(Expected),
std::size_t SS=sizeof(Struct),
std::size_t SA=alignof(Struct)
>
void static_assert_size() {
//static_assert(sizeof(PGparam*) == sizeof(void*), "Unexpected pointer size");
//static_assert(sizeof(PGresult*) == sizeof(void*), "Unexpected pointer size");
static_assert(ES == SS, "Wrong size for static memory");
static_assert(EA == SA, "Wrong alignment for static memory");
}
auto get_pqlib_c_type_struct<std::chrono::system_clock::time_point>::conv (const std::chrono::system_clock::time_point& parParam) -> type {
static_assert(sizeof(storage) == sizeof(PGtimestamp), "Wrong size for timestamp, please update DATA_SIZE");
static_assert(alignof(storage) == alignof(PGtimestamp), "Wrong alignment for timestamp, please update type");
@ -64,8 +79,7 @@ namespace pq {
get_pqlib_c_type_struct_arr::get_pqlib_c_type_struct_arr (const Connection& parConn) :
m_par(parConn.make_empty_params())
{
static_assert(sizeof(storage) == sizeof(PGarray), "Wrong size for PGarray's static memory");
static_assert(alignof(storage) == alignof(PGarray), "Wrong alignment for PGarray's static memory");
static_assert_size<PGarray, storage>();
PGarray arr;
std::fill(reinterpret_cast<char*>(&arr), reinterpret_cast<char*>(&arr) + sizeof(PGarray), '\0');