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/sys/gsb_crc32.h

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 /*-
    2  *  COPYRIGHT (C) 1986 Gary S. Brown.  You may use this program, or
    3  *  code or tables extracted from it, as desired without restriction.
    4  *
    5  * $FreeBSD$
    6  */
    7 
    8 #ifndef _SYS_GSB_CRC32_H_
    9 #define _SYS_GSB_CRC32_H_
   10 
   11 #include <sys/types.h>
   12 
   13 #ifdef _KERNEL
   14 
   15 extern const uint32_t crc32_tab[];
   16 
   17 static __inline uint32_t
   18 crc32_raw(const void *buf, size_t size, uint32_t crc)
   19 {
   20         const uint8_t *p = (const uint8_t *)buf;
   21 
   22         while (size--)
   23                 crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
   24         return (crc);
   25 }
   26 
   27 static __inline uint32_t
   28 crc32(const void *buf, size_t size)
   29 {
   30         uint32_t crc;
   31 
   32         crc = crc32_raw(buf, size, ~0U);
   33         return (crc ^ ~0U);
   34 }
   35 #endif
   36 
   37 uint32_t calculate_crc32c(uint32_t crc32c, const unsigned char *buffer,
   38     unsigned int length);
   39 
   40 #if defined(__amd64__) || defined(__i386__)
   41 uint32_t sse42_crc32c(uint32_t, const unsigned char *, unsigned);
   42 #endif
   43 #if defined(__aarch64__)
   44 uint32_t armv8_crc32c(uint32_t, const unsigned char *, unsigned int);
   45 #endif
   46 
   47 #ifdef TESTING
   48 uint32_t singletable_crc32c(uint32_t, const void *, size_t);
   49 uint32_t multitable_crc32c(uint32_t, const void *, size_t);
   50 #endif
   51 
   52 #endif /* !_SYS_GSB_CRC32_H_ */

Cache object: 94485d8ae96b404fa42b7e58deb2a6e7


[ 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.