This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=863af2464d7bf20ad458ee51e2d187a9845214ca commit 863af2464d7bf20ad458ee51e2d187a9845214ca Author: Guillem Jover <[email protected]> AuthorDate: Tue Dec 21 22:52:17 2021 +0100 build: Add zlib-ng support The zlib-ng library is a fork of zlib with its code modernized and lots of optimizations for various modern CPUs giving it a substantial performance boost. This library provides either an API (and in theory ABI) compatible interface, or a cleaned up API with namespaced and with better types. We add support for the latter, via a compatibility header mapping symbol names. --- configure.ac | 2 +- lib/compat/Makefile.am | 1 + lib/compat/{strerror.c => compat-zlib.h} | 45 ++++++++++++++------------------ lib/dpkg/compress.c | 10 ++++--- m4/dpkg-libs.m4 | 17 ++++++++++-- 5 files changed, 43 insertions(+), 32 deletions(-) diff --git a/configure.ac b/configure.ac index 1dd8d7870..0c15c8b90 100644 --- a/configure.ac +++ b/configure.ac @@ -285,7 +285,7 @@ Configuration: libkvm . . . . . . . . . . . : ${have_libkvm:-no} libselinux . . . . . . . . . : $have_libselinux libmd . . . . . . . . . . . . : $have_libmd - libz . . . . . . . . . . . . : $have_libz + libz . . . . . . . . . . . . : $have_libz_impl liblzma . . . . . . . . . . . : $have_liblzma libbz2 . . . . . . . . . . . : $have_libbz2 libcurses . . . . . . . . . . : ${have_libcurses:-no} diff --git a/lib/compat/Makefile.am b/lib/compat/Makefile.am index cc9267389..d87d298ab 100644 --- a/lib/compat/Makefile.am +++ b/lib/compat/Makefile.am @@ -36,6 +36,7 @@ endif libcompat_la_SOURCES = \ empty.c \ compat.h \ + compat-zlib.h \ gettext.h \ # EOL diff --git a/lib/compat/strerror.c b/lib/compat/compat-zlib.h similarity index 57% copy from lib/compat/strerror.c copy to lib/compat/compat-zlib.h index e35ffc149..654b36692 100644 --- a/lib/compat/strerror.c +++ b/lib/compat/compat-zlib.h @@ -1,7 +1,8 @@ /* * libcompat - system compatibility library + * compat-zlib.h - zlib compatibility declarations * - * Copyright © 1995 Ian Jackson <[email protected]> + * Copyright © 2021 Guillem Jover <[email protected]> * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,32 +18,26 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include <config.h> +#ifndef COMPAT_ZLIB_H +#define COMPAT_ZLIB_H -#include <errno.h> -#include <stdio.h> -#include <gettext.h> - -#include "compat.h" - -#define _(str) gettext(str) - -#if !HAVE_DECL_SYS_ERRLIST -extern const char *const sys_errlist[]; +#ifdef WITH_LIBZ_NG +#include <zlib-ng.h> +#else +#ifdef WITH_LIBZ +#include <zlib.h> #endif -#if !HAVE_DECL_SYS_NERR -extern const int sys_nerr; #endif -const char * -strerror(int e) -{ - static char buf[100]; - - if (e >= 0 && e < sys_nerr) - return sys_errlist[e]; - - sprintf(buf, _("Unknown error %d"), e); +#ifdef WITH_LIBZ_NG +/* Compatibility symbols for zlib-ng. */ +#define gzdopen zng_gzdopen +#define gzopen zng_gzopen +#define gzread zng_gzread +#define gzwrite zng_gzwrite +#define gzerror zng_gzerror +#define gzclose zng_gzclose +#define zError zng_zError +#endif - return buf; -} +#endif /* COMPAT_ZLIB_H */ diff --git a/lib/dpkg/compress.c b/lib/dpkg/compress.c index 41991317a..3a264d399 100644 --- a/lib/dpkg/compress.c +++ b/lib/dpkg/compress.c @@ -29,8 +29,8 @@ #include <stdbool.h> #include <stdlib.h> -#ifdef WITH_LIBZ -#include <zlib.h> +#if defined(WITH_LIBZ) || defined(WITH_LIBZ_NG) +#include <compat-zlib.h> #endif #ifdef WITH_LIBLZMA #include <lzma.h> @@ -47,7 +47,9 @@ #include <dpkg/buffer.h> #include <dpkg/command.h> #include <dpkg/compress.h> -#if !defined(WITH_LIBZ) || !defined(WITH_LIBLZMA) || !defined(WITH_LIBBZ2) +#if !(defined(WITH_LIBZ_NG) || defined(WITH_LIBZ)) || \ + !defined(WITH_LIBLZMA) || \ + !defined(WITH_LIBBZ2) #include <dpkg/subproc.h> static void DPKG_ATTR_SENTINEL @@ -145,7 +147,7 @@ fixup_gzip_params(struct compress_params *params) params->type = COMPRESSOR_TYPE_NONE; } -#ifdef WITH_LIBZ +#if defined(WITH_LIBZ_NG) || defined(WITH_LIBZ) static void decompress_gzip(int fd_in, int fd_out, const char *desc) { diff --git a/m4/dpkg-libs.m4 b/m4/dpkg-libs.m4 index f5c90c4d6..2c301ebca 100644 --- a/m4/dpkg-libs.m4 +++ b/m4/dpkg-libs.m4 @@ -69,10 +69,23 @@ AC_DEFUN([DPKG_WITH_COMPRESS_LIB], [ ])# DPKG_WITH_COMPRESS_LIB # DPKG_LIB_Z -# ------------- -# Check for z library. +# ---------- +# Check for z-ng and z libraries. AC_DEFUN([DPKG_LIB_Z], [ DPKG_WITH_COMPRESS_LIB([z], [zlib.h], [gzdopen]) + DPKG_WITH_COMPRESS_LIB([z-ng], [zlib-ng.h], [zng_gzdopen]) + + # If we have been requested the stock zlib, override the auto-detection. + AS_IF([test "x$with_libz" != "xyes" && test "x$have_libz_ng" = "xyes"], [ + AC_DEFINE([WITH_GZFILEOP], [yes], + [Define to yes to use zlib-ng gzFile IO support]) + Z_LIBS=$Z_NG_LIBS + have_libz_impl="yes (zlib-ng)" + ], [test "x$have_libz" = "xyes"], [ + have_libz_impl="yes (zlib)" + ], [ + have_libz_impl="no" + ]) ])# DPKG_LIB_Z # DPKG_LIB_LZMA -- Dpkg.Org's dpkg

