mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
Separate kernel crc32() implementation to its own header (gsb_crc32.h) and
rename the source to gsb_crc32.c. This is a prerequisite of unifying kernel zlib instances. PR: 229763 Submitted by: Yoshihiro Ota <ota at j.email.ne.jp> Differential Revision: https://reviews.freebsd.org/D20193
This commit is contained in:
parent
2d4a74d7a0
commit
f89d207279
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349151
|
@ -5,7 +5,8 @@ LIB= ufs
|
||||||
SHLIBDIR?= /lib
|
SHLIBDIR?= /lib
|
||||||
SHLIB_MAJOR= 7
|
SHLIB_MAJOR= 7
|
||||||
|
|
||||||
SRCS= block.c cgroup.c crc32.c inode.c sblock.c type.c ffs_subr.c ffs_tables.c
|
SRCS= block.c cgroup.c gsb_crc32.c inode.c sblock.c type.c ffs_subr.c
|
||||||
|
SRCS+= ffs_tables.c
|
||||||
INCS= libufs.h
|
INCS= libufs.h
|
||||||
|
|
||||||
MAN= bread.3 cgread.3 getinode.3 libufs.3 sbread.3 ufs_disk_close.3
|
MAN= bread.3 cgread.3 getinode.3 libufs.3 sbread.3 ufs_disk_close.3
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
|
|
||||||
#include "../../sys/libkern/crc32.c"
|
#include "../../sys/libkern/gsb_crc32.c"
|
||||||
|
|
|
@ -3982,9 +3982,9 @@ crypto/chacha20/chacha.c standard
|
||||||
libkern/asprintf.c standard
|
libkern/asprintf.c standard
|
||||||
libkern/bcd.c standard
|
libkern/bcd.c standard
|
||||||
libkern/bsearch.c standard
|
libkern/bsearch.c standard
|
||||||
libkern/crc32.c standard
|
|
||||||
libkern/explicit_bzero.c standard
|
libkern/explicit_bzero.c standard
|
||||||
libkern/fnmatch.c standard
|
libkern/fnmatch.c standard
|
||||||
|
libkern/gsb_crc32.c standard
|
||||||
libkern/iconv.c optional libiconv
|
libkern/iconv.c optional libiconv
|
||||||
libkern/iconv_converter_if.m optional libiconv
|
libkern/iconv_converter_if.m optional libiconv
|
||||||
libkern/iconv_ucs.c optional libiconv
|
libkern/iconv_ucs.c optional libiconv
|
||||||
|
|
|
@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <sys/capsicum.h>
|
#include <sys/capsicum.h>
|
||||||
#include <sys/condvar.h>
|
#include <sys/condvar.h>
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/kthread.h>
|
#include <sys/kthread.h>
|
||||||
|
|
|
@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/ctype.h>
|
#include <sys/ctype.h>
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#define __LIO_BSD_H__
|
#define __LIO_BSD_H__
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/eventhandler.h>
|
#include <sys/eventhandler.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/eventhandler.h>
|
#include <sys/eventhandler.h>
|
||||||
#include <sys/stdint.h>
|
#include <sys/stdint.h>
|
||||||
#include <sys/stddef.h>
|
#include <sys/stddef.h>
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include <sys/buf.h>
|
#include <sys/buf.h>
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
|
||||||
#include <fs/ext2fs/fs.h>
|
#include <fs/ext2fs/fs.h>
|
||||||
|
|
|
@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/lock.h>
|
#include <sys/lock.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
|
|
|
@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/namei.h>
|
#include <sys/namei.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
|
|
|
@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/fcntl.h>
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/lock.h>
|
#include <sys/lock.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
|
|
|
@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/bio.h>
|
#include <sys/bio.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/disklabel.h>
|
#include <sys/disklabel.h>
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
#include <sys/gpt.h>
|
#include <sys/gpt.h>
|
||||||
|
|
|
@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/bio.h>
|
#include <sys/bio.h>
|
||||||
#include <sys/diskmbr.h>
|
#include <sys/diskmbr.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
#include <sys/gpt.h>
|
#include <sys/gpt.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
|
|
|
@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/bio.h>
|
#include <sys/bio.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/kobj.h>
|
#include <sys/kobj.h>
|
||||||
|
|
|
@ -66,6 +66,7 @@ SET_DECLARE(compressors, struct compressor_methods);
|
||||||
|
|
||||||
#ifdef GZIO
|
#ifdef GZIO
|
||||||
|
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/zutil.h>
|
#include <sys/zutil.h>
|
||||||
|
|
||||||
struct gz_stream {
|
struct gz_stream {
|
||||||
|
|
|
@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
#include <sys/libkern.h>
|
#include <sys/libkern.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
|
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
#include <machine/md_var.h>
|
#include <machine/md_var.h>
|
|
@ -29,14 +29,14 @@ __FBSDID("$FreeBSD$");
|
||||||
/*
|
/*
|
||||||
* This file is compiled in userspace in order to run ATF unit tests.
|
* This file is compiled in userspace in order to run ATF unit tests.
|
||||||
*/
|
*/
|
||||||
#ifdef USERSPACE_TESTING
|
#ifndef _KERNEL
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
|
|
||||||
static __inline uint32_t
|
static __inline uint32_t
|
||||||
_mm_crc32_u8(uint32_t x, uint8_t y)
|
_mm_crc32_u8(uint32_t x, uint8_t y)
|
||||||
|
@ -199,7 +199,7 @@ crc32c_shift(uint32_t zeros[][256], uint32_t crc)
|
||||||
|
|
||||||
/* Initialize tables for shifting crcs. */
|
/* Initialize tables for shifting crcs. */
|
||||||
static void
|
static void
|
||||||
#ifdef USERSPACE_TESTING
|
#ifndef _KERNEL
|
||||||
__attribute__((__constructor__))
|
__attribute__((__constructor__))
|
||||||
#endif
|
#endif
|
||||||
crc32c_init_hw(void)
|
crc32c_init_hw(void)
|
||||||
|
@ -214,9 +214,6 @@ SYSINIT(crc32c_sse42, SI_SUB_LOCK, SI_ORDER_ANY, crc32c_init_hw, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Compute CRC-32C using the Intel hardware instruction. */
|
/* Compute CRC-32C using the Intel hardware instruction. */
|
||||||
#ifdef USERSPACE_TESTING
|
|
||||||
uint32_t sse42_crc32c(uint32_t, const unsigned char *, unsigned);
|
|
||||||
#endif
|
|
||||||
uint32_t
|
uint32_t
|
||||||
sse42_crc32c(uint32_t crc, const unsigned char *buf, unsigned len)
|
sse42_crc32c(uint32_t crc, const unsigned char *buf, unsigned len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
#include <machine/stdarg.h>
|
#include <machine/stdarg.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/module.h>
|
#include <sys/module.h>
|
||||||
|
|
|
@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include "opt_sctp.h"
|
#include "opt_sctp.h"
|
||||||
|
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#ifdef SCTP
|
#ifdef SCTP
|
||||||
#include <netinet/sctp_os.h>
|
#include <netinet/sctp_os.h>
|
||||||
#include <netinet/sctp.h>
|
#include <netinet/sctp.h>
|
||||||
|
|
|
@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/bus.h>
|
#include <sys/bus.h>
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/hash.h>
|
#include <sys/hash.h>
|
||||||
#include <sys/interrupt.h>
|
#include <sys/interrupt.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
|
|
47
sys/sys/gsb_crc32.h
Normal file
47
sys/sys/gsb_crc32.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*-
|
||||||
|
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
|
||||||
|
* code or tables extracted from it, as desired without restriction.
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SYS_GSB_CRC32_H_
|
||||||
|
#define _SYS_GSB_CRC32_H_
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#ifdef _KERNEL
|
||||||
|
|
||||||
|
extern const uint32_t crc32_tab[];
|
||||||
|
|
||||||
|
static __inline uint32_t
|
||||||
|
crc32_raw(const void *buf, size_t size, uint32_t crc)
|
||||||
|
{
|
||||||
|
const uint8_t *p = (const uint8_t *)buf;
|
||||||
|
|
||||||
|
while (size--)
|
||||||
|
crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
|
||||||
|
return (crc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline uint32_t
|
||||||
|
crc32(const void *buf, size_t size)
|
||||||
|
{
|
||||||
|
uint32_t crc;
|
||||||
|
|
||||||
|
crc = crc32_raw(buf, size, ~0U);
|
||||||
|
return (crc ^ ~0U);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t calculate_crc32c(uint32_t crc32c, const unsigned char *buffer,
|
||||||
|
unsigned int length);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
|
uint32_t sse42_crc32c(uint32_t, const unsigned char *, unsigned);
|
||||||
|
#endif
|
||||||
|
#if defined(__aarch64__)
|
||||||
|
uint32_t armv8_crc32c(uint32_t, const unsigned char *, unsigned int);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !_SYS_GSB_CRC32_H_ */
|
|
@ -190,39 +190,6 @@ size_t strspn(const char *, const char *);
|
||||||
char *strstr(const char *, const char *);
|
char *strstr(const char *, const char *);
|
||||||
int strvalid(const char *, size_t);
|
int strvalid(const char *, size_t);
|
||||||
|
|
||||||
extern const uint32_t crc32_tab[];
|
|
||||||
|
|
||||||
static __inline uint32_t
|
|
||||||
crc32_raw(const void *buf, size_t size, uint32_t crc)
|
|
||||||
{
|
|
||||||
const uint8_t *p = (const uint8_t *)buf;
|
|
||||||
|
|
||||||
while (size--)
|
|
||||||
crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
|
|
||||||
return (crc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline uint32_t
|
|
||||||
crc32(const void *buf, size_t size)
|
|
||||||
{
|
|
||||||
uint32_t crc;
|
|
||||||
|
|
||||||
crc = crc32_raw(buf, size, ~0U);
|
|
||||||
return (crc ^ ~0U);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
|
||||||
calculate_crc32c(uint32_t crc32c, const unsigned char *buffer,
|
|
||||||
unsigned int length);
|
|
||||||
#ifdef _KERNEL
|
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
|
||||||
uint32_t sse42_crc32c(uint32_t, const unsigned char *, unsigned);
|
|
||||||
#endif
|
|
||||||
#if defined(__aarch64__)
|
|
||||||
uint32_t armv8_crc32c(uint32_t, const unsigned char *, unsigned int);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static __inline char *
|
static __inline char *
|
||||||
index(const char *p, int ch)
|
index(const char *p, int ch)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
* in the range 5 to 9.
|
* in the range 5 to 9.
|
||||||
*/
|
*/
|
||||||
#undef __FreeBSD_version
|
#undef __FreeBSD_version
|
||||||
#define __FreeBSD_version 1300031 /* Master, propagated to newvers */
|
#define __FreeBSD_version 1300032 /* Master, propagated to newvers */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
|
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
|
||||||
|
|
|
@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/capsicum.h>
|
#include <sys/capsicum.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/bio.h>
|
#include <sys/bio.h>
|
||||||
#include <sys/buf.h>
|
#include <sys/buf.h>
|
||||||
|
|
|
@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/bio.h>
|
#include <sys/bio.h>
|
||||||
#include <sys/buf.h>
|
#include <sys/buf.h>
|
||||||
#include <sys/fcntl.h>
|
#include <sys/fcntl.h>
|
||||||
|
|
|
@ -59,6 +59,7 @@ struct malloc_type;
|
||||||
|
|
||||||
#else /* _KERNEL */
|
#else /* _KERNEL */
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/lock.h>
|
#include <sys/lock.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
|
|
@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include "opt_ddb.h"
|
#include "opt_ddb.h"
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/namei.h>
|
#include <sys/namei.h>
|
||||||
#include <sys/priv.h>
|
#include <sys/priv.h>
|
||||||
|
|
|
@ -46,7 +46,6 @@ LIBADD.mqueue_test+= rt
|
||||||
${MACHINE_ARCH} == "i386" || \
|
${MACHINE_ARCH} == "i386" || \
|
||||||
${MACHINE_ARCH} == "aarch64"
|
${MACHINE_ARCH} == "aarch64"
|
||||||
ATF_TESTS_C+= libkern_crc32
|
ATF_TESTS_C+= libkern_crc32
|
||||||
CFLAGS.libkern_crc32+= -DUSERSPACE_TESTING
|
|
||||||
.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
|
.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
|
||||||
LDADD.libkern_crc32+= ${SRCTOP}/sys/libkern/x86/crc32_sse42.c
|
LDADD.libkern_crc32+= ${SRCTOP}/sys/libkern/x86/crc32_sse42.c
|
||||||
.else
|
.else
|
||||||
|
|
|
@ -27,16 +27,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/gsb_crc32.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <atf-c.h>
|
#include <atf-c.h>
|
||||||
|
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if !defined(__amd64__) && !defined(__i386__) && !defined(__aarch64__)
|
||||||
extern uint32_t sse42_crc32c(uint32_t, const unsigned char *, unsigned);
|
|
||||||
#elif defined(__aarch64__)
|
|
||||||
extern uint32_t armv8_crc32c(uint32_t, const unsigned char *, unsigned);
|
|
||||||
#else
|
|
||||||
#error These tests are not supported on this platform
|
#error These tests are not supported on this platform
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue