summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2024-02-26 09:59:08 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2024-02-26 09:59:08 +0100
commit2acbac8ef9d314b73fbbd68c2e70580988c063a9 (patch)
tree9d134169add19bb6fd752f460c6afaf16ac1310b
parenteece9692d707ccb20356ec06955f8308c4e59ca7 (diff)
New upstream version 4.23upstream/4.23upstream
-rw-r--r--Makefile.in5
-rw-r--r--config.h.in3
-rwxr-xr-xconfigure46
-rw-r--r--configure.ac9
-rw-r--r--doc/changelog.rst21
-rw-r--r--include/libHX/cast.h6
-rw-r--r--include/libHX/defs.h6
-rw-r--r--src/Makefile.am3
-rw-r--r--src/Makefile.in16
-rw-r--r--src/io.c43
-rw-r--r--src/rand.c4
-rw-r--r--src/socket.c6
-rw-r--r--src/string.c2
-rw-r--r--src/tc-socket.c4
14 files changed, 136 insertions, 38 deletions
diff --git a/Makefile.in b/Makefile.in
index e7860e2..6d7c044 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -235,9 +235,9 @@ am__relativize = \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
+DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
-DIST_ARCHIVES = $(distdir).tar.xz
-DIST_TARGETS = dist-xz
+DIST_TARGETS = dist-gzip
# Exists only to be overridden by the user if desired.
AM_DISTCHECK_DVI_TARGET = dvi
distuninstallcheck_listfiles = find . -type f -print
@@ -648,6 +648,7 @@ dist-bzip2: distdir
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__post_remove_distdir)
+
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
diff --git a/config.h.in b/config.h.in
index 112ecb4..bc311a2 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,5 +1,8 @@
/* config.h.in. Generated from configure.ac by autoheader. */
+/* Define to 1 if you have the `copy_file_range' function. */
+#undef HAVE_COPY_FILE_RANGE
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
diff --git a/configure b/configure
index a5cc895..2e8727e 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for libHX 4.19.
+# Generated by GNU Autoconf 2.71 for libHX 4.23.
#
#
# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,
@@ -618,8 +618,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libHX'
PACKAGE_TARNAME='libhx'
-PACKAGE_VERSION='4.19'
-PACKAGE_STRING='libHX 4.19'
+PACKAGE_VERSION='4.23'
+PACKAGE_STRING='libHX 4.23'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -668,6 +668,8 @@ librt_LIBS
libdl_LIBS
HAVE_DLFCN_H_FALSE
HAVE_DLFCN_H_TRUE
+WITH_SUN_LD_FALSE
+WITH_SUN_LD_TRUE
WITH_GNU_LD_FALSE
WITH_GNU_LD_TRUE
pkgconfigdir
@@ -1375,7 +1377,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libHX 4.19 to adapt to many kinds of systems.
+\`configure' configures libHX 4.23 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1446,7 +1448,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libHX 4.19:";;
+ short | recursive ) echo "Configuration of libHX 4.23:";;
esac
cat <<\_ACEOF
@@ -1561,7 +1563,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-libHX configure 4.19
+libHX configure 4.23
generated by GNU Autoconf 2.71
Copyright (C) 2021 Free Software Foundation, Inc.
@@ -2195,7 +2197,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libHX $as_me 4.19, which was
+It was created by libHX $as_me 4.23, which was
generated by GNU Autoconf 2.71. Invocation command line was
$ $0$ac_configure_args_raw
@@ -3684,7 +3686,7 @@ fi
# Define the identity of the package.
PACKAGE='libhx'
- VERSION='4.19'
+ VERSION='4.23'
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -17579,6 +17581,20 @@ else
WITH_GNU_LD_FALSE=
fi
+if test -n "$LD" && $LD -z help >/dev/null 2>/dev/null
+then :
+ with_sun_ld=yes
+else $as_nop
+ with_sun_ld=no
+fi
+ if test "$with_sun_ld" = yes; then
+ WITH_SUN_LD_TRUE=
+ WITH_SUN_LD_FALSE='#'
+else
+ WITH_SUN_LD_TRUE='#'
+ WITH_SUN_LD_FALSE=
+fi
+
LIBS_system="$LIBS"
ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default"
@@ -18151,6 +18167,12 @@ printf "%s\n" "#define HAVE_STRUCT_STAT_ST_OTIME 1" >>confdefs.h
fi
+ac_fn_c_check_func "$LINENO" "copy_file_range" "ac_cv_func_copy_file_range"
+if test "x$ac_cv_func_copy_file_range" = xyes
+then :
+ printf "%s\n" "#define HAVE_COPY_FILE_RANGE 1" >>confdefs.h
+
+fi
ac_fn_c_check_func "$LINENO" "fork" "ac_cv_func_fork"
if test "x$ac_cv_func_fork" = xyes
then :
@@ -18375,6 +18397,10 @@ if test -z "${WITH_GNU_LD_TRUE}" && test -z "${WITH_GNU_LD_FALSE}"; then
as_fn_error $? "conditional \"WITH_GNU_LD\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${WITH_SUN_LD_TRUE}" && test -z "${WITH_SUN_LD_FALSE}"; then
+ as_fn_error $? "conditional \"WITH_SUN_LD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${HAVE_DLFCN_H_TRUE}" && test -z "${HAVE_DLFCN_H_FALSE}"; then
as_fn_error $? "conditional \"HAVE_DLFCN_H\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -18769,7 +18795,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by libHX $as_me 4.19, which was
+This file was extended by libHX $as_me 4.23, which was
generated by GNU Autoconf 2.71. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -18837,7 +18863,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
-libHX config.status 4.19
+libHX config.status 4.23
configured by $0, generated by GNU Autoconf 2.71,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index a41566a..fde64b7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,10 +1,9 @@
-AC_INIT([libHX], [4.19])
+AC_INIT([libHX], [4.23])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_INSTALL
-AM_INIT_AUTOMAKE([-Wall -Wno-override foreign subdir-objects
- tar-pax no-dist-gzip dist-xz])
+AM_INIT_AUTOMAKE([-Wall -Wno-override foreign subdir-objects tar-pax])
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CXX
@@ -62,6 +61,8 @@ AC_SUBST([pkgconfigdir])
CHECK_GCC_FVISIBILITY
AM_CONDITIONAL([WITH_GNU_LD], [test "$with_gnu_ld" = yes])
+AS_IF([test -n "$LD" && $LD -z help >/dev/null 2>/dev/null], [with_sun_ld=yes], [with_sun_ld=no])
+AM_CONDITIONAL([WITH_SUN_LD], [test "$with_sun_ld" = yes])
LIBS_system="$LIBS"
AC_CHECK_HEADERS([dlfcn.h sys/resource.h sys/un.h])
@@ -123,7 +124,7 @@ AC_CHECK_MEMBERS(
#include <sys/time.h>
#include <time.h>
])
-AC_CHECK_FUNCS([fork execv execvp pipe posix_fadvise])
+AC_CHECK_FUNCS([copy_file_range fork execv execvp pipe posix_fadvise])
AC_CHECK_FUNCS([getegid geteuid getpid getppid])
AC_CHECK_FUNCS([initgroups setgid])
diff --git a/doc/changelog.rst b/doc/changelog.rst
index 8903a72..f4bf0f1 100644
--- a/doc/changelog.rst
+++ b/doc/changelog.rst
@@ -1,3 +1,24 @@
+v4.23 (2024-02-15)
+==================
+
+Fixes:
+
+* io: use smaller chunks with sendfile(2) to work around unusual API behavior
+
+Enhancements:
+
+* io: make HX_copy_file() utilize copy_file_range when available
+
+
+v4.21 (2023-12-20)
+==================
+
+Fixes:
+
+* Resolve a compilation error when the signed_cast macro is used without defs.h.
+* Resolve compilation errors in NetBSD and MacOS.
+
+
v4.19 (2023-12-01)
==================
diff --git a/include/libHX/cast.h b/include/libHX/cast.h
index cb2cba5..c8fe0ba 100644
--- a/include/libHX/cast.h
+++ b/include/libHX/cast.h
@@ -1,6 +1,12 @@
#ifndef _LIBHX_CAST_H
#define _LIBHX_CAST_H 1
+#ifndef BUILD_BUG_ON_EXPR
+# define BUILD_BUG_ON_EXPR(condition) (sizeof(char[1 - 2 * !!(condition)]) - 1)
+#endif
+#ifndef BUILD_BUG_ON
+# define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_EXPR(condition))
+#endif
#ifdef __cplusplus
# ifndef const_cast
# define const_cast(T, x) const_cast<T>(x)
diff --git a/include/libHX/defs.h b/include/libHX/defs.h
index 31c818f..ba84b37 100644
--- a/include/libHX/defs.h
+++ b/include/libHX/defs.h
@@ -38,12 +38,6 @@
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)) + __array_size_check(x))
#endif
-#ifndef BUILD_BUG_ON_EXPR
-# define BUILD_BUG_ON_EXPR(condition) (sizeof(char[1 - 2 * !!(condition)]) - 1)
-#endif
-#ifndef BUILD_BUG_ON
-# define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_EXPR(condition))
-#endif
#ifndef DEMOTE_TO_PTR
/*
* An alternative approach is also (p+0), but that does not ensure that
diff --git a/src/Makefile.am b/src/Makefile.am
index 676cd73..11a240e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,6 +13,9 @@ libHX_la_LDFLAGS = -no-undefined -version-info 39:0:7
if WITH_GNU_LD
libHX_la_LDFLAGS += -Wl,--version-script=${srcdir}/libHX.map
endif
+if WITH_SUN_LD
+libHX_la_LDFLAGS += -Wl,-M,${srcdir}/libHX.map
+endif
EXTRA_libHX_la_DEPENDENCIES = libHX.map
if MINGW32
diff --git a/src/Makefile.in b/src/Makefile.in
index 7e1bd81..22766b5 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -91,8 +91,9 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
@WITH_GNU_LD_TRUE@am__append_1 = -Wl,--version-script=${srcdir}/libHX.map
-@MINGW32_TRUE@am__append_2 = ux-file.c ux-mmap.c
-@MINGW32_TRUE@am__append_3 = -lws2_32
+@WITH_SUN_LD_TRUE@am__append_2 = -Wl,-M,${srcdir}/libHX.map
+@MINGW32_TRUE@am__append_3 = ux-file.c ux-mmap.c
+@MINGW32_TRUE@am__append_4 = -lws2_32
check_PROGRAMS = tc-compile$(EXEEXT) tc-cast$(EXEEXT) \
tc-deque$(EXEEXT) tc-dir$(EXEEXT) tc-format$(EXEEXT) \
tc-io$(EXEEXT) tc-list$(EXEEXT) tc-list2$(EXEEXT) \
@@ -104,13 +105,13 @@ check_PROGRAMS = tc-compile$(EXEEXT) tc-cast$(EXEEXT) \
$(am__EXEEXT_1)
TESTS = tc-format$(EXEEXT) tc-option$(EXEEXT) tc-strchr2$(EXEEXT) \
tc-string$(EXEEXT) tc-strquote$(EXEEXT) $(am__EXEEXT_2)
-@HAVE_CXX_TRUE@am__append_4 = tx-compile tx-cast tx-deque tx-dir \
+@HAVE_CXX_TRUE@am__append_5 = tx-compile tx-cast tx-deque tx-dir \
@HAVE_CXX_TRUE@ tx-intdiff tx-list tx-list2 \
@HAVE_CXX_TRUE@ tx-misc tx-netio \
@HAVE_CXX_TRUE@ tx-option tx-proc tx-rand tx-strchr2 tx-string \
@HAVE_CXX_TRUE@ tx-strquote tx-time
-@HAVE_CXX_TRUE@am__append_5 = tx-strchr2 tx-strquote
+@HAVE_CXX_TRUE@am__append_6 = tx-strchr2 tx-strquote
subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/gcc4_visibility.m4 \
@@ -767,10 +768,11 @@ AM_CFLAGS = ${regular_CFLAGS}
AM_CXXFLAGS = ${regular_CXXFLAGS}
lib_LTLIBRARIES = libHX.la
libHX_la_SOURCES = deque.c dl.c format.c io.c map.c mc.c misc.c opt.c \
- proc.c rand.c socket.c string.c time.c $(am__append_2)
+ proc.c rand.c socket.c string.c time.c $(am__append_3)
libHX_la_LIBADD = ${libdl_LIBS} -lm ${libpthread_LIBS} ${librt_LIBS} \
- ${libsocket_LIBS} $(am__append_3)
-libHX_la_LDFLAGS = -no-undefined -version-info 39:0:7 $(am__append_1)
+ ${libsocket_LIBS} $(am__append_4)
+libHX_la_LDFLAGS = -no-undefined -version-info 39:0:7 $(am__append_1) \
+ $(am__append_2)
EXTRA_libHX_la_DEPENDENCIES = libHX.map
EXTRA_DIST = internal.h map_int.h libHX.map uxcompat.h analyze.sh
tc_cast_CFLAGS = ${AM_CFLAGS} -std=gnu99
diff --git a/src/io.c b/src/io.c
index ee48dee..9199d03 100644
--- a/src/io.c
+++ b/src/io.c
@@ -7,6 +7,7 @@
* General Public License as published by the Free Software Foundation;
* either version 2.1 or (at your option) any later version.
*/
+#define _GNU_SOURCE 1
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
@@ -630,15 +631,37 @@ EXPORT_SYMBOL ssize_t HXio_fullwrite(int fd, const void *vbuf, size_t size)
}
#if __linux__
-static ssize_t HX_sendfile_linux(int dst, int src, size_t count)
+#ifdef HAVE_COPY_FILE_RANGE
+static ssize_t HX_cfr_linux(int dst, int src, size_t count)
{
- long pagesize = sysconf(_SC_PAGE_SIZE);
- size_t xfersize;
ssize_t ret, xferd = 0;
+ /*
+ * Use INT(32)_MAX rather than SSIZE_MAX, as there is an issue with
+ * overflow detection pending.
+ * https://lore.kernel.org/linux-man/38nr2286-1o9q-0004-2323-799587773o15@vanv.qr/
+ */
+ size_t xfersize = INT_MAX;
+ if (count > xfersize)
+ count = xfersize;
+ while ((ret = copy_file_range(src, nullptr, dst, nullptr, count, 0)) > 0)
+ xferd += ret;
+ if (xferd > 0)
+ return xferd;
+ if (ret < 0)
+ return -errno;
+ return 0;
+}
+#endif
- if (pagesize < 0)
- pagesize = 4096;
- xfersize = SSIZE_MAX - pagesize;
+static ssize_t HX_sendfile_linux(int dst, int src, size_t count)
+{
+ ssize_t ret, xferd = 0;
+ /*
+ * Use INT(32)_MAX rather than SSIZE_MAX, as there is an issue with
+ * overflow detection pending.
+ * https://lore.kernel.org/linux-man/38nr2286-1o9q-0004-2323-799587773o15@vanv.qr/
+ */
+ size_t xfersize = INT_MAX;
if (count > xfersize)
count = xfersize;
while ((ret = sendfile(dst, src, nullptr, count)) > 0)
@@ -686,7 +709,13 @@ static ssize_t HX_sendfile_rw(int dst, int src, size_t count)
EXPORT_SYMBOL ssize_t HX_sendfile(int dst, int src, size_t count)
{
#if __linux__
- ssize_t ret = HX_sendfile_linux(dst, src, count);
+ ssize_t ret;
+#ifdef HAVE_COPY_FILE_RANGE
+ ret = HX_cfr_linux(dst, src, count);
+ if (ret != -ENOSYS && ret != -EXDEV)
+ return ret;
+#endif
+ ret = HX_sendfile_linux(dst, src, count);
if (ret != -ENOSYS)
return ret;
#endif
diff --git a/src/rand.c b/src/rand.c
index 498d4a5..3247b69 100644
--- a/src/rand.c
+++ b/src/rand.c
@@ -18,6 +18,10 @@
#ifdef __unix__
# include <unistd.h>
#endif
+#ifdef __APPLE__
+# include <sys/types.h>
+# include <unistd.h>
+#endif
#ifdef _WIN32
# include <process.h>
#endif
diff --git a/src/socket.c b/src/socket.c
index 9fdd903..fe813f5 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -41,7 +41,7 @@
#else
# define STUPIDWIN(x) (x)
#endif
-#if defined(__sun) && !defined(SO_PROTOCOL)
+#if defined(__sun) && !defined(SO_PROTOCOL) && defined(SO_PROTOTYPE)
# define SO_PROTOCOL SO_PROTOTYPE
#endif
#ifndef AI_V4MAPPED
@@ -333,18 +333,22 @@ static int try_sk_from_env(int fd, const struct addrinfo *ai, const char *intf)
return -1;
#else
optlen = sizeof(value);
+#ifdef SO_DOMAIN
ret = getsockopt(fd, SOL_SOCKET, SO_DOMAIN, &value, &optlen);
if (ret < 0 || value != ai->ai_family)
return -1;
+#endif
optlen = sizeof(value);
ret = getsockopt(fd, SOL_SOCKET, SO_TYPE, &value, &optlen);
if (ret < 0 || value != ai->ai_socktype)
return -1;
optlen = sizeof(value);
+#ifdef SO_PROTOCOL
ret = getsockopt(fd, SOL_SOCKET, SO_PROTOCOL, &value, &optlen);
if (ret < 0 || value != ai->ai_protocol)
return -1;
#endif
+#endif
struct sockaddr_storage addr;
memset(&addr, 0, sizeof(addr));
optlen = sizeof(addr);
diff --git a/src/string.c b/src/string.c
index 06066ce..e468063 100644
--- a/src/string.c
+++ b/src/string.c
@@ -1036,7 +1036,7 @@ EXPORT_SYMBOL unsigned long long HX_strtoull_unit(const char *s,
* UB. Thus check for range and apply the negation after the
* conversion to ULL.
*/
- if (q > ULLONG_MAX) {
+ if (q >= static_cast(double, ULLONG_MAX)) {
errno = ERANGE;
return ULLONG_MAX;
}
diff --git a/src/tc-socket.c b/src/tc-socket.c
index 3cdeb90..2c140a1 100644
--- a/src/tc-socket.c
+++ b/src/tc-socket.c
@@ -17,6 +17,7 @@
static int t_parse(void)
{
char host[32] = "bogus";
+ uint16_t port = 4321;
if (HX_addrport_split("[::1]", host, sizeof(host), nullptr) != 1 ||
strcmp(host, "::1") != 0)
return 1;
@@ -26,6 +27,9 @@ static int t_parse(void)
if (HX_addrport_split("", host, sizeof(host), nullptr) != 1 ||
strcmp(host, "") != 0)
return 1;
+ if (HX_addrport_split("[]:", host, sizeof(host), &port) != 1 ||
+ strcmp(host, "") != 0 || port != 0)
+ return 1;
return 0;
}