*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
+#include <stdint.h> // For uintptr_t.
#include <string.h>
#include <libkern/mkext.h>
+
#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);
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;