1592N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1592N/A * This code is free software; you can redistribute it and/or modify it 1592N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 1592N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 1592N/A * This code is distributed in the hope that it will be useful, but WITHOUT 1592N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1592N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1592N/A * version 2 for more details (a copy is included in the LICENSE file that 1592N/A * You should have received a copy of the GNU General Public License version 1592N/A * 2 along with this work; if not, write to the Free Software Foundation, 1592N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1592N/A * Copyright (C) 1995-2004 Mark Adler 1592N/A * For conditions of distribution and use, see copyright notice in zlib.h 1592N/A#
define BASE 65521UL /* largest prime smaller than 65536 */ 1592N/A/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 1592N/A/* use NO_DIVIDE if your processor does not do division in hardware */ 1592N/A/* ========================================================================= */ 1592N/A /* split Adler-32 into component sums */ 1592N/A /* in case user likes doing a byte at a time, keep it fast */ 1592N/A /* initial Adler-32 value (deferred check for len == 1 speed) */ 1592N/A /* in case short lengths are provided, keep it somewhat fast */ 1592N/A /* do length NMAX blocks -- requires just one modulo operation */ 1592N/A /* do remaining bytes (less than NMAX, still just one modulo) */ 1592N/A if (
len) {
/* avoid modulos if none remaining */ 1592N/A /* return recombined sums */ 1592N/A/* ========================================================================= */ 1592N/A /* the derivation of this formula is left as an exercise for the reader */