mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
e0bc7ce732
I havn't tested it yet, but I can almost guarantee that atleast `goalc` will not work in the slightest! But the project is atleast fully compiling. My hope is to start translating some AVX to NEON next / get `goalc` working...eventually.
42 lines
720 B
C++
42 lines
720 B
C++
#include "crc32.h"
|
|
|
|
#include <cstring>
|
|
|
|
#ifdef __aarch64__
|
|
#include <arm_acle.h>
|
|
u32 crc32(const u8* data, size_t size) {
|
|
u32 result = 0xffffffff;
|
|
while (size >= 4) {
|
|
u32 x;
|
|
memcpy(&x, data, 4);
|
|
data += 4;
|
|
size -= 4;
|
|
result = __crc32w(result, x);
|
|
}
|
|
while (size) {
|
|
result = __crc32b(result, *data);
|
|
data++;
|
|
size--;
|
|
}
|
|
return ~result;
|
|
}
|
|
#else
|
|
#include <immintrin.h>
|
|
u32 crc32(const u8* data, size_t size) {
|
|
u32 result = 0xffffffff;
|
|
while (size >= 4) {
|
|
u32 x;
|
|
memcpy(&x, data, 4);
|
|
data += 4;
|
|
size -= 4;
|
|
result = _mm_crc32_u32(result, x);
|
|
}
|
|
while (size) {
|
|
result = _mm_crc32_u8(result, *data);
|
|
data++;
|
|
size--;
|
|
}
|
|
return ~result;
|
|
}
|
|
#endif
|