The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/lib/libz/crc32.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: crc32.c,v 1.7 2005/02/26 22:58:57 perry Exp $ */
    2 
    3 /* crc32.c -- compute the CRC-32 of a data stream
    4  * Copyright (C) 1995-2002 Mark Adler
    5  * For conditions of distribution and use, see copyright notice in zlib.h
    6  */
    7 
    8 /* @(#) $Id: crc32.c,v 1.7 2005/02/26 22:58:57 perry Exp $ */
    9 
   10 #include "zlib.h"
   11 
   12 #define local static
   13 
   14 local const uLongf crc_table[16] = {
   15   0x00000000L, 0x1db71064L, 0x3b6e20c8L, 0x26d930acL,
   16   0x76dc4190L, 0x6b6b51f4L, 0x4db26158L, 0x5005713cL,
   17   0xedb88320L, 0xf00f9344L, 0xd6d6a3e8L, 0xcb61b38cL,
   18   0x9b64c2b0L, 0x86d3d2d4L, 0xa00ae278L, 0xbdbdf21cL
   19 };
   20 
   21 /* ========================================================================= */
   22 #define DO1(buf) do { crc ^= *buf++; crc = (crc >> 4) ^ crc_table[crc & 0xf]; crc = (crc >> 4) ^ crc_table[crc & 0xf]; } while (0)
   23 #define DO2(buf)  DO1(buf); DO1(buf);
   24 #define DO4(buf)  DO2(buf); DO2(buf);
   25 #define DO8(buf)  DO4(buf); DO4(buf);
   26 
   27 /* ========================================================================= */
   28 uLong ZEXPORT crc32(crc, buf, len)
   29     uLong crc;
   30     const Bytef *buf;
   31     uInt len;
   32 {
   33     if (buf == Z_NULL) return 0L;
   34     crc = crc ^ 0xffffffffL;
   35     while (len >= 8)
   36     {
   37       DO8(buf);
   38       len -= 8;
   39     }
   40     if (len) do {
   41       DO1(buf);
   42     } while (--len);
   43     return crc ^ 0xffffffffL;
   44 }

Cache object: e313ee65ba2c0d951156daa0b3d28034


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.