示例#1
0
u64 hash(u64 a, u64 b) {
	const u64 mix = 0xc6a4a7935bd1e995ULL;

	u64 h;
	h = _byteswap_uint64(a*mix);
	h = _byteswap_uint64((h+b)*mix);

	return h;
}
示例#2
0
int __cdecl compare64(void *context, const void *a, const void *b)
{
    int i;
    int dim = *(int*)context;
    unsigned __int64 *a64 = (unsigned __int64*)a;
    unsigned __int64 *b64 = (unsigned __int64*)b;

#if 0
    if (a64[0] > b64[0]) return 1;
    if (a64[0] < b64[0]) return -1;
    for (i = 1; i < dim; i++)
    {
        if (a64[i] > b64[i]) return 1;
        if (a64[i] < b64[i]) return -1;
    }
#else
    if (_byteswap_uint64(a64[0]) > _byteswap_uint64(b64[0])) return 1;
    if (_byteswap_uint64(a64[0]) < _byteswap_uint64(b64[0])) return -1;
    for (i = 1; i < dim; i++)
    {
        if (_byteswap_uint64(a64[i]) > _byteswap_uint64(b64[i])) return 1;
        if (_byteswap_uint64(a64[i]) < _byteswap_uint64(b64[i])) return -1;
    }

#endif
    return 0;
}
示例#3
0
/* 
 * read position of index, which is stored in the last 8 bytes of the file 
 * byte order of the number is big endian
 */
uint64_t libmaus::huffman::IndexLoaderBase::getIndexPos(std::string const & filename)
{
	::libmaus::aio::CheckedInputStream indexistr(filename);

	// read position of index (last 8 bytes of file)
	// and convert byte order if necessary
	indexistr.seekg(-8,std::ios::end);
	uint64_t v;
	indexistr.read( reinterpret_cast<char *>(&v) , 8 );
	
	#if defined(LIBMAUS_BYTE_ORDER_LITTLE_ENDIAN)
	#if defined(_WIN32)
	uint64_t const indexpos = _byteswap_uint64(v);
	#elif defined(__FreeBSD__)
	uint64_t const indexpos = bswap64(v);
	#elif defined(__linux__)
	uint64_t const indexpos = bswap_64(v);
	#else
	uint64_t const indexpos = ::libmaus::util::ReverseByteOrder::reverseByteOrder<uint64_t>(v);
	#endif
	#else
	uint64_t const indexpos = v;

	#endif
	// std::cerr << "Index at position " << indexpos << " file length " << ::libmaus::util::GetFileSize::getFileSize(filename) << std::endl;

	return indexpos;
}
示例#4
0
/*
*
* Uncipher 64 bits of the KDBG with 3 keys
*
* @param data data to uncipher
* @param KiWaitNever one key
* @param KiWaitAlways one key
* @param KdpDataBlockEncoded one key
* @return data data unciphered
*/
__inline uint64_t uncipherData(uint64_t Data, uint64_t KiWaitNever, uint64_t KiWaitAlways, uint64_t KdpDataBlockEncoded)
{
    Data = Data^KiWaitNever;
    Data = _rotl64(Data, KiWaitNever & 0xFF);
    Data = Data^KdpDataBlockEncoded;
    Data = _byteswap_uint64(Data);
    Data = Data^KiWaitAlways;
    return Data;
}
示例#5
0
文件: zip.hpp 项目: JaewookYim/salm
		uint64_t uncompressBound(const compress_input_type &src)
		{
			uint64_t length = 0;

			//byte order 처리(리틀 엔디안 값을 시스템에 맞게 읽는다.)
			if (salm::is_big_endian()) length = _byteswap_uint64(*(reinterpret_cast<const uint64_t*>(&src[src.size() - sizeof(uint64_t)])));
			else length = *(reinterpret_cast<const uint64_t*>(&src[src.size() - sizeof(uint64_t)]));
			return length;
		}
示例#6
0
inline uint64_t LoadBigEndian64(uint64_t v)
{
#if defined(__GNUC__)
  return __builtin_bswap64(v);
#elif defined(_MSC_VER)
  return _byteswap_uint64(v);
#else
#error unsupported compiler
#endif
}
示例#7
0
    __INTRIN_INLINE uint64_t byteswap64(uint64_t value)
    {
#if defined(__GNUC__) || defined(__clang__)
        return __builtin_bswap64(value);
#elif defined(_MSC_VER)
        return _byteswap_uint64(value);
#else
#     error Unsupported platform
#endif
    }
示例#8
0
void XApp::initPakFiles()
{
    wstring binFile = xapp().findFile(L"texture01.pak", XApp::TEXTUREPAK, false);
    if (binFile.size() == 0) {
        Log("pak file texture01.pak not found!" << endl);
        return;
    }
    ifstream bfile(binFile, ios::in | ios::binary);
#if defined(_DEBUG)
    Log("pak file opened: " << binFile << "\n");
#endif

    // basic assumptions about data types:
    assert(sizeof(long long) == 8);
    assert(sizeof(int) == 4);

    long long magic;
    bfile.read((char*)&magic, 8);
    magic = _byteswap_uint64(magic);
    if (magic != 0x5350313250414B30L) {
        // magic "SP12PAK0" not found
        Log("pak file invalid: " << binFile << endl);
        return;
    }
    long long numEntries;
    bfile.read((char*)&numEntries, 8);
    if (numEntries > 30000) {
        Log("pak file invalid: contained number of textures: " << numEntries << endl);
        return;
    }
    int num = (int)numEntries;
    for (int i = 0; i < num; i++) {
        PakEntry pe;
        long long ll;
        bfile.read((char*)&ll, 8);
        pe.offset = (long)ll;
        bfile.read((char*)&ll, 8);
        pe.len = (long)ll;
        int name_len;
        bfile.read((char*)&name_len, 4);

        char *tex_name = new char[108 + 1];
        bfile.read((char*)tex_name, 108);
        tex_name[name_len] = '\0';
        //Log("pak entry name: " << tex_name << "\n");
        pe.name = std::string(tex_name);
        pe.pakname = binFile;
        pak_content[pe.name] = pe;
        delete[] tex_name;
    }
    // check:
    for (auto p : pak_content) {
        Log(" pak file entry: " << p.second.name.c_str() << endl);
    }
}
示例#9
0
文件: zip.hpp 项目: JaewookYim/salm
		void compress(compress_output_type &dst, const compress_input_type &src)
		{
			uint64_t length = dst.size();
			int ok = ::compress(&dst[0], (uLongf *)&length, &src[0], src.size());
			if(Z_OK != ok) throw salm::exception("zip library error", salm::UNKNOWN_ERROR);
						
			dst.resize(length + sizeof(uint64_t));

			//byte order 처리(리틀 엔디안으로 저장한다.)
			if (salm::is_big_endian()) *(reinterpret_cast<uint64_t*>(&dst[length])) = _byteswap_uint64(static_cast<uint64_t>(src.size()));
			else *(reinterpret_cast<uint64_t*>(&dst[length])) = static_cast<uint64_t>(src.size());
		}
示例#10
0
KDPC* TransTimerDpcEx(
	IN PKTIMER InTimer,
	IN ULONGLONG InKiWaitNever,
	IN ULONGLONG InKiWaitAlways)
{
	ULONGLONG			RDX = (ULONGLONG)InTimer->Dpc;
	RDX ^= InKiWaitNever;
	RDX = _rotl64(RDX, (UCHAR)(InKiWaitNever & 0xFF));
	RDX ^= (ULONGLONG)InTimer;
	RDX = _byteswap_uint64(RDX);
	RDX ^= InKiWaitAlways;
	return (KDPC*)RDX;
}
示例#11
0
static inline uint32_t hash_pad(uint8_t padblock[SHA512_BLOCK_SIZE * 2], uint64_t total_len)
{
	uint32_t i = (uint32_t) (total_len & (SHA512_BLOCK_SIZE - 1));

	memclr_fixedlen(&padblock[i], SHA512_BLOCK_SIZE);
	padblock[i] = 0x80;

	// Move i to the end of either 1st or 2nd extra block depending on length
	i += ((SHA512_BLOCK_SIZE - 1) & (0 - (total_len + SHA512_PADLENGTHFIELD_SIZE + 1))) +
	    1 + SHA512_PADLENGTHFIELD_SIZE;

#if SHA512_PADLENGTHFIELD_SIZE == 16
	*((uint64_t *) & padblock[i - 16]) = 0;
#endif

	*((uint64_t *) & padblock[i - 8]) = _byteswap_uint64((uint64_t) total_len << 3);

	return i >> SHA512_LOG2_BLOCK_SIZE;	// Number of extra blocks to hash
}
示例#12
0
				uint64 operator()(uint64 value) const
				{
					return _byteswap_uint64(value);
				}
示例#13
0
u64 BinaryReaderBE::ReadUInt64()
{
	return _byteswap_uint64(BinaryReader::ReadUInt64());
}
示例#14
0
static uint64 byteswap(uint64 value)
{
	return _byteswap_uint64(value);
}
示例#15
0
void g() {
  (void)_byteswap_ushort(42);
  (void)_byteswap_uint64(42LL);
}
示例#16
0
void f() {
  (void)_byteswap_ushort(42); // expected-warning{{implicitly declaring library function '_byteswap_ushort}} \
  // expected-note{{include the header <stdlib.h> or explicitly provide a declaration for '_byteswap_ushort'}}
  (void)_byteswap_uint64(42LL); // expected-warning{{implicitly declaring library function '_byteswap_uint64}} \
  // expected-note{{include the header <stdlib.h> or explicitly provide a declaration for '_byteswap_uint64'}}
}
示例#17
0
s64 BinaryReaderBE::ReadInt64()
{
	return (s64) _byteswap_uint64((u64) BinaryReader::ReadInt64());
}
示例#18
0
double BinaryReaderBE::ReadDouble()
{
	u64 ret = _byteswap_uint64(BinaryReader::ReadUInt64());
	return *((double *) &ret);
}