mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-11 05:26:24 +02:00
Move native/util, native/data and native/i18 to Common/Data.
Also move colorutil.cpp/h linking build fix experiment Delete a bunch of unused CMakeLists.txt files CMakeLists.txt linking fix Don't include NativeApp.h from any headers. Android.mk buildfix Half of the UWP fix Buildfix Minor project file cleanup Buildfixes Guess what? More buildfixes!
This commit is contained in:
1 parent
5c9b7bb859
commit
ff8148dd92
191 files changed
+583
-797
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#include <cstdint>
|
||||
#include "Common/Data/Hash/Hash.h"
|
||||
|
||||
namespace hash {
|
||||
|
||||
// Implementation from Wikipedia
|
||||
#define MOD_ADLER 65521
|
||||
// data: Pointer to the data to be summed; len is in bytes
|
||||
uint32_t Adler32(const uint8_t *data, size_t len) {
|
||||
uint32_t a = 1, b = 0;
|
||||
while (len) {
|
||||
size_t tlen = len > 5550 ? 5550 : len;
|
||||
len -= tlen;
|
||||
do {
|
||||
a += *data++;
|
||||
b += a;
|
||||
} while (--tlen);
|
||||
|
||||
a = (a & 0xffff) + (a >> 16) * (65536 - MOD_ADLER);
|
||||
b = (b & 0xffff) + (b >> 16) * (65536 - MOD_ADLER);
|
||||
}
|
||||
|
||||
// It can be shown that a <= 0x1013a here, so a single subtract will do.
|
||||
if (a >= MOD_ADLER) {
|
||||
a -= MOD_ADLER;
|
||||
}
|
||||
|
||||
// It can be shown that b can reach 0xfff87 here.
|
||||
b = (b & 0xffff) + (b >> 16) * (65536 - MOD_ADLER);
|
||||
|
||||
if (b >= MOD_ADLER) {
|
||||
b -= MOD_ADLER;
|
||||
}
|
||||
return (b << 16) | a;
|
||||
}
|
||||
|
||||
} // namespace hash
|
||||
Reference in new issue
Block a user