X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/b0d623f7f2ae71ed96e60569f61f9a9a27016e80..7ee9d059c4eecf68ae4f8b0fb99ae2471eda79af:/libkern/mkext.c diff --git a/libkern/mkext.c b/libkern/mkext.c index e1fc062e1..86238fc35 100644 --- a/libkern/mkext.c +++ b/libkern/mkext.c @@ -25,12 +25,13 @@ * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ +#include // For uintptr_t. #include #include + #define BASE 65521L /* largest prime smaller than 65536 */ -#define NMAX 5000 -// NMAX (was 5521) the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 +#define NMAX 5552 // the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 #define DO1(buf,i) {s1 += buf[i]; s2 += s1;} #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); @@ -45,6 +46,23 @@ mkext_adler32(uint8_t *buf, int32_t len) unsigned long s2 = 0; // (adler >> 16) & 0xffff; int k; +#if defined _ARM_ARCH_6 + + /* align buf to 16-byte boundary */ + while ((((uintptr_t)buf)&15)&&(len>0)) { /* not on a 16-byte boundary */ + len--; + s1 += *buf++; + s2 += s1; + if (s1 >= BASE) s1 -= BASE; + } + s2 %= BASE; + + if (len>=16) { + return adler32_vec(s1, s2, buf, len); + } + +#endif + while (len > 0) { k = len < NMAX ? len : NMAX; len -= k;