Don't udpate LastOverSpeedTick when using aqua_speed
[ryzomcore.git] / nel / 3rdparty / seven_zip / XzCrc64Opt.c
blobb2852de4d42751ba363cce36d8eaa6302e4736ae
1 /* XzCrc64Opt.c -- CRC64 calculation
2 2017-06-30 : Igor Pavlov : Public domain */
4 #include "Precomp.h"
6 #include "CpuArch.h"
8 #ifndef MY_CPU_BE
10 #define CRC64_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
12 UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table)
14 const Byte *p = (const Byte *)data;
15 for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)
16 v = CRC64_UPDATE_BYTE_2(v, *p);
17 for (; size >= 4; size -= 4, p += 4)
19 UInt32 d = (UInt32)v ^ *(const UInt32 *)p;
20 v = (v >> 32)
21 ^ (table + 0x300)[((d ) & 0xFF)]
22 ^ (table + 0x200)[((d >> 8) & 0xFF)]
23 ^ (table + 0x100)[((d >> 16) & 0xFF)]
24 ^ (table + 0x000)[((d >> 24))];
26 for (; size > 0; size--, p++)
27 v = CRC64_UPDATE_BYTE_2(v, *p);
28 return v;
31 #endif
34 #ifndef MY_CPU_LE
36 #define CRC_UINT64_SWAP(v) \
37 ((v >> 56) \
38 | ((v >> 40) & ((UInt64)0xFF << 8)) \
39 | ((v >> 24) & ((UInt64)0xFF << 16)) \
40 | ((v >> 8) & ((UInt64)0xFF << 24)) \
41 | ((v << 8) & ((UInt64)0xFF << 32)) \
42 | ((v << 24) & ((UInt64)0xFF << 40)) \
43 | ((v << 40) & ((UInt64)0xFF << 48)) \
44 | ((v << 56)))
46 #define CRC64_UPDATE_BYTE_2_BE(crc, b) (table[(Byte)((crc) >> 56) ^ (b)] ^ ((crc) << 8))
48 UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table)
50 const Byte *p = (const Byte *)data;
51 table += 0x100;
52 v = CRC_UINT64_SWAP(v);
53 for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)
54 v = CRC64_UPDATE_BYTE_2_BE(v, *p);
55 for (; size >= 4; size -= 4, p += 4)
57 UInt32 d = (UInt32)(v >> 32) ^ *(const UInt32 *)p;
58 v = (v << 32)
59 ^ (table + 0x000)[((d ) & 0xFF)]
60 ^ (table + 0x100)[((d >> 8) & 0xFF)]
61 ^ (table + 0x200)[((d >> 16) & 0xFF)]
62 ^ (table + 0x300)[((d >> 24))];
64 for (; size > 0; size--, p++)
65 v = CRC64_UPDATE_BYTE_2_BE(v, *p);
66 return CRC_UINT64_SWAP(v);
69 #endif