Index: head/sys/conf/files =================================================================== --- head/sys/conf/files +++ head/sys/conf/files @@ -273,7 +273,7 @@ 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 @@ 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/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/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 Index: head/sys/conf/kern.pre.mk =================================================================== --- head/sys/conf/kern.pre.mk +++ head/sys/conf/kern.pre.mk @@ -173,10 +173,6 @@ 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} Index: head/sys/conf/kmod.mk =================================================================== --- head/sys/conf/kmod.mk +++ head/sys/conf/kmod.mk @@ -104,8 +104,6 @@ __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 Index: head/sys/contrib/zlib/deflate.c =================================================================== --- head/sys/contrib/zlib/deflate.c +++ head/sys/contrib/zlib/deflate.c @@ -266,7 +266,7 @@ 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 @@ #endif } if (strm->zfree == (free_func)0) -#ifdef Z_SOLO +#if defined(Z_SOLO) && !defined(_KERNEL) return Z_STREAM_ERROR; #else strm->zfree = zcfree; Index: head/sys/contrib/zlib/infback.c =================================================================== --- head/sys/contrib/zlib/infback.c +++ head/sys/contrib/zlib/infback.c @@ -42,7 +42,7 @@ 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 @@ #endif } if (strm->zfree == (free_func)0) -#ifdef Z_SOLO +#if defined(Z_SOLO) && !defined(_KERNEL) return Z_STREAM_ERROR; #else strm->zfree = zcfree; Index: head/sys/contrib/zlib/inflate.c =================================================================== --- head/sys/contrib/zlib/inflate.c +++ head/sys/contrib/zlib/inflate.c @@ -207,7 +207,7 @@ 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 @@ #endif } if (strm->zfree == (free_func)0) -#ifdef Z_SOLO +#if defined(Z_SOLO) && !defined(_KERNEL) return Z_STREAM_ERROR; #else strm->zfree = zcfree; Index: head/sys/contrib/zlib/zconf.h =================================================================== --- head/sys/contrib/zlib/zconf.h +++ head/sys/contrib/zlib/zconf.h @@ -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 Index: head/sys/contrib/zlib/zlib.h =================================================================== --- head/sys/contrib/zlib/zlib.h +++ head/sys/contrib/zlib/zlib.h @@ -1213,7 +1213,7 @@ 27-31: 0 (reserved) */ -#ifndef Z_SOLO +#if !defined(Z_SOLO) || defined(_KERNEL) /* utility functions */ @@ -1288,6 +1288,9 @@ 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 */ Index: head/sys/contrib/zlib/zutil.h =================================================================== --- head/sys/contrib/zlib/zutil.h +++ head/sys/contrib/zlib/zutil.h @@ -256,7 +256,7 @@ # 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)); Index: head/sys/dev/zlib/zcalloc.h =================================================================== --- head/sys/dev/zlib/zcalloc.h +++ head/sys/dev/zlib/zcalloc.h @@ -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 Index: head/sys/dev/zlib/zcalloc.c =================================================================== --- head/sys/dev/zlib/zcalloc.c +++ head/sys/dev/zlib/zcalloc.c @@ -24,6 +24,13 @@ 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) { Index: head/sys/modules/crypto/Makefile =================================================================== --- head/sys/modules/crypto/Makefile +++ head/sys/modules/crypto/Makefile @@ -23,7 +23,6 @@ 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 Index: head/sys/modules/mxge/mxge/Makefile =================================================================== --- head/sys/modules/mxge/mxge/Makefile +++ head/sys/modules/mxge/mxge/Makefile @@ -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 Index: head/sys/modules/zfs/Makefile =================================================================== --- head/sys/modules/zfs/Makefile +++ head/sys/modules/zfs/Makefile @@ -56,7 +56,6 @@ .PATH: ${SUNW}/uts/common/zmod SRCS+= zmod.c -CFLAGS.zmod.c+= ${ZLIB_CFLAGS} .PATH: ${SYSDIR}/crypto/sha2 SRCS+= sha256c.c sha512c.c Index: head/sys/modules/zlib/Makefile =================================================================== --- head/sys/modules/zlib/Makefile +++ head/sys/modules/zlib/Makefile @@ -11,15 +11,15 @@ 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