From owner-svn-src-all@freebsd.org Wed Aug 7 01:41:21 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6FB87BA303; Wed, 7 Aug 2019 01:41:21 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 463Dk937w1z437y; Wed, 7 Aug 2019 01:41:21 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4E1A952BF; Wed, 7 Aug 2019 01:41:21 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x771fLge047909; Wed, 7 Aug 2019 01:41:21 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x771fIhQ047893; Wed, 7 Aug 2019 01:41:18 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201908070141.x771fIhQ047893@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Wed, 7 Aug 2019 01:41:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r350670 - in head/sys: conf contrib/zlib dev/zlib modules/crypto modules/mxge/mxge modules/zfs modules/zlib X-SVN-Group: head X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: in head/sys: conf contrib/zlib dev/zlib modules/crypto modules/mxge/mxge modules/zfs modules/zlib X-SVN-Commit-Revision: 350670 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Aug 2019 01:41:21 -0000 Author: delphij Date: Wed Aug 7 01:41:17 2019 New Revision: 350670 URL: https://svnweb.freebsd.org/changeset/base/350670 Log: Expose zlib's utility functions in Z_SOLO library when building kernel. This allows kernel code to reuse zlib's implementation. PR: 229763 Reviewed by: Yoshihiro Ota Relnotes: yes Differential Revision: https://reviews.freebsd.org/D21156 Modified: head/sys/conf/files head/sys/conf/kern.pre.mk head/sys/conf/kmod.mk head/sys/contrib/zlib/deflate.c head/sys/contrib/zlib/infback.c head/sys/contrib/zlib/inflate.c head/sys/contrib/zlib/zconf.h head/sys/contrib/zlib/zlib.h head/sys/contrib/zlib/zutil.h head/sys/dev/zlib/zcalloc.c head/sys/dev/zlib/zcalloc.h head/sys/modules/crypto/Makefile head/sys/modules/mxge/mxge/Makefile head/sys/modules/zfs/Makefile head/sys/modules/zlib/Makefile Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/conf/files Wed Aug 7 01:41:17 2019 (r350670) @@ -273,7 +273,7 @@ cddl/contrib/opensolaris/uts/common/os/callb.c opti cddl/contrib/opensolaris/uts/common/os/fm.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/os/list.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/os/nvpair_alloc_system.c optional zfs compile-with "${ZFS_C}" -cddl/contrib/opensolaris/uts/common/zmod/zmod.c optional zfs compile-with "${ZFS_C} ${ZLIB_CFLAGS}" +cddl/contrib/opensolaris/uts/common/zmod/zmod.c optional zfs compile-with "${ZFS_C}" # zfs lua support cddl/contrib/opensolaris/uts/common/fs/zfs/lua/lapi.c optional zfs compile-with "${ZFS_C}" cddl/contrib/opensolaris/uts/common/fs/zfs/lua/lauxlib.c optional zfs compile-with "${ZFS_C}" @@ -2443,8 +2443,7 @@ mwlboot.fw optional mwlfw \ compile-with "${NORMAL_FW}" \ no-obj no-implicit-rule \ clean "mwlboot.fw" -dev/mxge/if_mxge.c optional mxge pci \ - compile-with "${ZLIB_C}" +dev/mxge/if_mxge.c optional mxge pci dev/mxge/mxge_eth_z8e.c optional mxge pci dev/mxge/mxge_ethp_z8e.c optional mxge pci dev/mxge/mxge_rss_eth_z8e.c optional mxge pci @@ -3999,35 +3998,32 @@ libkern/timingsafe_bcmp.c standard libkern/zlib.c optional crypto | geom_uzip | ipsec | \ ipsec_support | mxge | netgraph_deflate | ddb_ctf | gzio contrib/zlib/adler32.c optional crypto | geom_uzip | ipsec | \ + ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib +contrib/zlib/compress.c optional crypto | geom_uzip | ipsec | \ ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib \ - compile-with "${ZLIB_C}" + compile-with "${NORMAL_C} -Wno-cast-qual" contrib/zlib/crc32.c optional crypto | geom_uzip | ipsec | \ - ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib \ - compile-with "${ZLIB_C} -Wno-cast-qual" + ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib contrib/zlib/deflate.c optional crypto | geom_uzip | ipsec | \ ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib \ - compile-with "${ZLIB_C} -Wno-cast-qual" + compile-with "${NORMAL_C} -Wno-cast-qual" contrib/zlib/inffast.c optional crypto | geom_uzip | ipsec | \ - ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib \ - compile-with "${ZLIB_C}" + ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib contrib/zlib/inflate.c optional crypto | geom_uzip | ipsec | \ - ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib \ - compile-with "${ZLIB_C}" + ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib contrib/zlib/inftrees.c optional crypto | geom_uzip | ipsec | \ - ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib \ - compile-with "${ZLIB_C}" + ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib contrib/zlib/trees.c optional crypto | geom_uzip | ipsec | \ + ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib +contrib/zlib/uncompr.c optional crypto | geom_uzip | ipsec | \ ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib \ - compile-with "${ZLIB_C}" + compile-with "${NORMAL_C} -Wno-cast-qual" contrib/zlib/zutil.c optional crypto | geom_uzip | ipsec | \ - ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib \ - compile-with "${ZLIB_C}" + ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib dev/zlib/zlib_mod.c optional crypto | geom_uzip | ipsec | \ - ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib \ - compile-with "${ZLIB_C}" + ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib dev/zlib/zcalloc.c optional crypto | geom_uzip | ipsec | \ - ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib \ - compile-with "${ZLIB_C}" + ipsec_support | mxge | ddb_ctf | gzio | zfs | zlib net/altq/altq_cbq.c optional altq net/altq/altq_codel.c optional altq net/altq/altq_hfsc.c optional altq @@ -4780,8 +4776,7 @@ opencrypto/crypto.c optional crypto | ipsec | ipsec_s opencrypto/cryptodev.c optional cryptodev opencrypto/cryptodev_if.m optional crypto | ipsec | ipsec_support opencrypto/cryptosoft.c optional crypto | ipsec | ipsec_support -opencrypto/cryptodeflate.c optional crypto | ipsec | ipsec_support \ - compile-with "${ZLIB_C}" +opencrypto/cryptodeflate.c optional crypto | ipsec | ipsec_support opencrypto/gmac.c optional crypto | ipsec | ipsec_support opencrypto/gfmult.c optional crypto | ipsec | ipsec_support opencrypto/rmd160.c optional crypto | ipsec | ipsec_support Modified: head/sys/conf/kern.pre.mk ============================================================================== --- head/sys/conf/kern.pre.mk Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/conf/kern.pre.mk Wed Aug 7 01:41:17 2019 (r350670) @@ -173,10 +173,6 @@ NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC} NORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \ -m ${LD_EMULATION} -o ${.TARGET} ${.ALLSRC:M*.fw} -# for zlib in the kernel -ZLIB_CFLAGS+= -DZ_SOLO -ZLIB_C= ${CC} -c ${ZLIB_CFLAGS} ${CFLAGS} ${.IMPSRC} - # for ZSTD in the kernel (include zstd/lib/freebsd before other CFLAGS) ZSTD_C= ${CC} -c -DZSTD_HEAPMODE=1 -I$S/contrib/zstd/lib/freebsd ${CFLAGS} -I$S/contrib/zstd/lib -I$S/contrib/zstd/lib/common ${WERROR} -Wno-inline -Wno-missing-prototypes ${PROF} -U__BMI__ ${.IMPSRC} Modified: head/sys/conf/kmod.mk ============================================================================== --- head/sys/conf/kmod.mk Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/conf/kmod.mk Wed Aug 7 01:41:17 2019 (r350670) @@ -104,8 +104,6 @@ __KLD_SHARED=yes __KLD_SHARED=no .endif -ZLIB_CFLAGS+= -DZ_SOLO - .if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing) CFLAGS+= -fno-strict-aliasing .endif Modified: head/sys/contrib/zlib/deflate.c ============================================================================== --- head/sys/contrib/zlib/deflate.c Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/contrib/zlib/deflate.c Wed Aug 7 01:41:17 2019 (r350670) @@ -266,7 +266,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowB strm->msg = Z_NULL; if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO +#if defined(Z_SOLO) && !defined(_KERNEL) return Z_STREAM_ERROR; #else strm->zalloc = zcalloc; @@ -274,7 +274,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowB #endif } if (strm->zfree == (free_func)0) -#ifdef Z_SOLO +#if defined(Z_SOLO) && !defined(_KERNEL) return Z_STREAM_ERROR; #else strm->zfree = zcfree; Modified: head/sys/contrib/zlib/infback.c ============================================================================== --- head/sys/contrib/zlib/infback.c Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/contrib/zlib/infback.c Wed Aug 7 01:41:17 2019 (r350670) @@ -42,7 +42,7 @@ int stream_size; return Z_STREAM_ERROR; strm->msg = Z_NULL; /* in case we return an error */ if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO +#if defined(Z_SOLO) && !defined(_KERNEL) return Z_STREAM_ERROR; #else strm->zalloc = zcalloc; @@ -50,7 +50,7 @@ int stream_size; #endif } if (strm->zfree == (free_func)0) -#ifdef Z_SOLO +#if defined(Z_SOLO) && !defined(_KERNEL) return Z_STREAM_ERROR; #else strm->zfree = zcfree; Modified: head/sys/contrib/zlib/inflate.c ============================================================================== --- head/sys/contrib/zlib/inflate.c Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/contrib/zlib/inflate.c Wed Aug 7 01:41:17 2019 (r350670) @@ -207,7 +207,7 @@ int stream_size; if (strm == Z_NULL) return Z_STREAM_ERROR; strm->msg = Z_NULL; /* in case we return an error */ if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO +#if defined(Z_SOLO) && !defined(_KERNEL) return Z_STREAM_ERROR; #else strm->zalloc = zcalloc; @@ -215,7 +215,7 @@ int stream_size; #endif } if (strm->zfree == (free_func)0) -#ifdef Z_SOLO +#if defined(Z_SOLO) && !defined(_KERNEL) return Z_STREAM_ERROR; #else strm->zfree = zcfree; Modified: head/sys/contrib/zlib/zconf.h ============================================================================== --- head/sys/contrib/zlib/zconf.h Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/contrib/zlib/zconf.h Wed Aug 7 01:41:17 2019 (r350670) @@ -8,6 +8,12 @@ #ifndef ZCONF_H #define ZCONF_H +#ifdef __FreeBSD__ +#ifdef _KERNEL +#define Z_SOLO +#endif +#endif + /* * If you *really* need a unique prefix for all types and library functions, * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. @@ -30,7 +36,7 @@ # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 # define adler32_z z_adler32_z -# ifndef Z_SOLO +# if !defined(Z_SOLO) && !defined(_KERNEL) # define compress z_compress # define compress2 z_compress2 # define compressBound z_compressBound @@ -125,12 +131,12 @@ # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table -# ifndef Z_SOLO +# if !defined(Z_SOLO) && !defined(_KERNEL) # define uncompress z_uncompress # define uncompress2 z_uncompress2 # endif # define zError z_zError -# ifndef Z_SOLO +# if !defined(Z_SOLO) && !defined(_KERNEL) # define zcalloc z_zcalloc # define zcfree z_zcfree # endif Modified: head/sys/contrib/zlib/zlib.h ============================================================================== --- head/sys/contrib/zlib/zlib.h Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/contrib/zlib/zlib.h Wed Aug 7 01:41:17 2019 (r350670) @@ -1213,7 +1213,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); 27-31: 0 (reserved) */ -#ifndef Z_SOLO +#if !defined(Z_SOLO) || defined(_KERNEL) /* utility functions */ @@ -1288,6 +1288,9 @@ ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLo length of the source is *sourceLen. On return, *sourceLen is the number of source bytes consumed. */ +#endif /* !Z_SOLO || _KERNEL */ + +#ifndef Z_SOLO /* gzip file access functions */ Modified: head/sys/contrib/zlib/zutil.h ============================================================================== --- head/sys/contrib/zlib/zutil.h Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/contrib/zlib/zutil.h Wed Aug 7 01:41:17 2019 (r350670) @@ -256,7 +256,7 @@ extern z_const char * const z_errmsg[10]; /* indexed b # define Tracecv(c,x) #endif -#ifndef Z_SOLO +#if !defined(Z_SOLO) || defined(_KERNEL) voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, unsigned size)); void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); Modified: head/sys/dev/zlib/zcalloc.c ============================================================================== --- head/sys/dev/zlib/zcalloc.c Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/dev/zlib/zcalloc.c Wed Aug 7 01:41:17 2019 (r350670) @@ -24,6 +24,13 @@ zcalloc_nowait(void *nil, u_int items, u_int size) return mallocarray(items, size, M_ZLIB, M_NOWAIT); } +void * +zcalloc(void *nil, u_int items, u_int size) +{ + + return zcalloc_nowait(nil, items, size); +} + void zcfree(void *nil, void *ptr) { Modified: head/sys/dev/zlib/zcalloc.h ============================================================================== --- head/sys/dev/zlib/zcalloc.h Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/dev/zlib/zcalloc.h Wed Aug 7 01:41:17 2019 (r350670) @@ -6,8 +6,9 @@ #ifndef _DEV_ZLIB_ZCALLOC_ #define _DEV_ZLIB_ZCALLOC_ -void * zcalloc_waitok(void *nil, u_int items, u_int size); -void * zcalloc_nowait(void *nil, u_int items, u_int size); -void zcfree(void *nil, void *ptr); +#include +#undef local +void *zcalloc_waitok(void *, u_int, u_int); +void *zcalloc_nowait(void *, u_int, u_int); #endif Modified: head/sys/modules/crypto/Makefile ============================================================================== --- head/sys/modules/crypto/Makefile Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/modules/crypto/Makefile Wed Aug 7 01:41:17 2019 (r350670) @@ -23,7 +23,6 @@ KMOD = crypto SRCS = crypto.c cryptodev_if.c SRCS += criov.c cryptosoft.c xform.c SRCS += cast.c cryptodeflate.c rmd160.c rijndael-alg-fst.c rijndael-api.c rijndael-api-fst.c -CFLAGS.cryptodeflate.c += ${ZLIB_CFLAGS} SRCS += skipjack.c bf_enc.c bf_ecb.c bf_skey.c SRCS += camellia.c camellia-api.c SRCS += des_ecb.c des_enc.c des_setkey.c Modified: head/sys/modules/mxge/mxge/Makefile ============================================================================== --- head/sys/modules/mxge/mxge/Makefile Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/modules/mxge/mxge/Makefile Wed Aug 7 01:41:17 2019 (r350670) @@ -5,6 +5,4 @@ KMOD= if_mxge SRCS= if_mxge.c device_if.h bus_if.h pci_if.h opt_inet.h opt_inet6.h -CFLAGS.if_mxge.c+= ${ZLIB_CFLAGS} - .include Modified: head/sys/modules/zfs/Makefile ============================================================================== --- head/sys/modules/zfs/Makefile Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/modules/zfs/Makefile Wed Aug 7 01:41:17 2019 (r350670) @@ -56,7 +56,6 @@ SRCS+= nvpair_alloc_system.c .PATH: ${SUNW}/uts/common/zmod SRCS+= zmod.c -CFLAGS.zmod.c+= ${ZLIB_CFLAGS} .PATH: ${SYSDIR}/crypto/sha2 SRCS+= sha256c.c sha512c.c Modified: head/sys/modules/zlib/Makefile ============================================================================== --- head/sys/modules/zlib/Makefile Wed Aug 7 01:34:41 2019 (r350669) +++ head/sys/modules/zlib/Makefile Wed Aug 7 01:41:17 2019 (r350670) @@ -11,15 +11,15 @@ SRCS= zlib.c SRCS+= zcalloc.c SRCS+= zlib_mod.c SRCS+= adler32.c +SRCS+= compress.c SRCS+= crc32.c SRCS+= deflate.c SRCS+= inffast.c SRCS+= inflate.c SRCS+= inftrees.c SRCS+= trees.c +SRCS+= uncompr.c SRCS+= zutil.c - -CFLAGS+=${ZLIB_CFLAGS} CWARNFLAGS.compress.c+=-Wno-cast-qual # compress:49 CWARNFLAGS.deflate.c+=-Wno-cast-qual # deflate.c:415