aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2022-04-08 08:26:57 +0300
committerTimo Teräs <timo.teras@iki.fi>2022-04-08 08:38:28 +0300
commitee13d43a53938d8a04ba787b9423f3270a3c14a7 (patch)
treea911d6429db4a8332effc779837e7a5f5b2122b8
parent80766eca41e09407351c0de81e33fbeb90a201b5 (diff)
downloadaports-ee13d43a53938d8a04ba787b9423f3270a3c14a7.tar.gz
aports-ee13d43a53938d8a04ba787b9423f3270a3c14a7.tar.bz2
aports-ee13d43a53938d8a04ba787b9423f3270a3c14a7.tar.xz
main/musl: upgrade to 1.2.3
-rw-r--r--main/musl/0001-fix-TZ-parsing-logic-for-identifying-POSIX-form-stri.patch57
-rw-r--r--main/musl/0001-riscv64-define-ELF_NFPREG.patch24
-rw-r--r--main/musl/APKBUILD34
-rw-r--r--main/musl/eh-frame.patch140
-rw-r--r--main/musl/qsort_r.patch213
-rw-r--r--main/musl/syscall-cp-epoll.patch16
6 files changed, 10 insertions, 474 deletions
diff --git a/main/musl/0001-fix-TZ-parsing-logic-for-identifying-POSIX-form-stri.patch b/main/musl/0001-fix-TZ-parsing-logic-for-identifying-POSIX-form-stri.patch
deleted file mode 100644
index 50c62ac74d..0000000000
--- a/main/musl/0001-fix-TZ-parsing-logic-for-identifying-POSIX-form-stri.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From 937822abb6ac48880939be3c60e6b57bddf62cf6 Mon Sep 17 00:00:00 2001
-From: Rich Felker <dalias@aerifal.cx>
-Date: Wed, 23 Jun 2021 17:22:47 -0400
-Subject: [PATCH] fix TZ parsing logic for identifying POSIX-form strings
-
-previously, the contents of the TZ variable were considered a
-candidate for a file/path name only if they began with a colon or
-contained a slash before any comma. the latter was very sloppy logic
-to avoid treating any valid POSIX TZ string as a file name, but it
-also triggered on values that are not valid POSIX TZ strings,
-including 3-letter timezone names without any offset.
-
-instead, only treat the TZ variable as POSIX form if it begins with a
-nonzero standard time name followed by +, -, or a digit.
-
-also, special case GMT and UTC to always be treated as POSIX form
-(with implicit zero offset) so that a stray file by the same name
-cannot break software that depends on setting TZ=GMT or TZ=UTC.
----
- src/time/__tz.c | 14 +++++++++++++-
- 1 file changed, 13 insertions(+), 1 deletion(-)
-
-diff --git a/src/time/__tz.c b/src/time/__tz.c
-index 09a6317e..3e2fcdcb 100644
---- a/src/time/__tz.c
-+++ b/src/time/__tz.c
-@@ -4,6 +4,7 @@
- #include <stdlib.h>
- #include <string.h>
- #include <sys/mman.h>
-+#include <ctype.h>
- #include "libc.h"
- #include "lock.h"
- #include "fork_impl.h"
-@@ -154,10 +155,21 @@ static void do_tzset()
- }
- if (old_tz) memcpy(old_tz, s, i+1);
-
-+ int posix_form = 0;
-+ if (*s != ':') {
-+ p = s;
-+ char dummy_name[TZNAME_MAX+1];
-+ getname(dummy_name, &p);
-+ if (p!=s && (*p == '+' || *p == '-' || isdigit(*p)
-+ || !strcmp(dummy_name, "UTC")
-+ || !strcmp(dummy_name, "GMT")))
-+ posix_form = 1;
-+ }
-+
- /* Non-suid can use an absolute tzfile pathname or a relative
- * pathame beginning with "."; in secure mode, only the
- * standard path will be searched. */
-- if (*s == ':' || ((p=strchr(s, '/')) && !memchr(s, ',', p-s))) {
-+ if (!posix_form) {
- if (*s == ':') s++;
- if (*s == '/' || *s == '.') {
- if (!libc.secure || !strcmp(s, "/etc/localtime"))
diff --git a/main/musl/0001-riscv64-define-ELF_NFPREG.patch b/main/musl/0001-riscv64-define-ELF_NFPREG.patch
deleted file mode 100644
index b2f0a0f338..0000000000
--- a/main/musl/0001-riscv64-define-ELF_NFPREG.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-From e5d2823631bbfebacf48e1a34ed28f28d7cb2570 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Mon, 11 Jan 2021 09:40:33 -0800
-Subject: [PATCH] riscv64: define ELF_NFPREG
-
-ELF_NFPREG is used by some userspace applications like gdb
----
- arch/riscv64/bits/user.h | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/arch/riscv64/bits/user.h b/arch/riscv64/bits/user.h
-index 2da743ea..0d37de0b 100644
---- a/arch/riscv64/bits/user.h
-+++ b/arch/riscv64/bits/user.h
-@@ -1,5 +1,6 @@
- #include <signal.h>
-
- #define ELF_NGREG 32
-+#define ELF_NFPREG 33
- typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
- typedef union __riscv_mc_fp_state elf_fpregset_t;
---
-2.30.1
-
diff --git a/main/musl/APKBUILD b/main/musl/APKBUILD
index 67b2eca109..8c3d71ec27 100644
--- a/main/musl/APKBUILD
+++ b/main/musl/APKBUILD
@@ -1,8 +1,8 @@
# Contributor: Ariadne Conill <ariadne@dereferenced.org>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
-pkgver=1.2.2
-pkgrel=7
+pkgver=1.2.3
+pkgrel=0
pkgdesc="the musl c library (libc) implementation"
url="https://musl.libc.org/"
arch="all"
@@ -19,14 +19,9 @@ nocc) pkgname="musl-dev"; subpackages="";;
nolibc) ;;
*) subpackages="$subpackages $pkgname-utils";;
esac
-commit="v1.2.2"
-source="musl-$commit.tar.gz::https://git.musl-libc.org/cgit/musl/snapshot/$commit.tar.gz
- 0001-riscv64-define-ELF_NFPREG.patch
- 0001-fix-TZ-parsing-logic-for-identifying-POSIX-form-stri.patch
+_commit="v1.2.3"
+source="musl-$_commit.tar.gz::https://git.musl-libc.org/cgit/musl/snapshot/$_commit.tar.gz
handle-aux-at_base.patch
- syscall-cp-epoll.patch
- eh-frame.patch
- qsort_r.patch
ldconfig
__stack_chk_fail_local.c
@@ -43,11 +38,9 @@ source="musl-$commit.tar.gz::https://git.musl-libc.org/cgit/musl/snapshot/$commi
# 1.1.15-r4:
# - CVE-2016-8859
-builddir="$srcdir"/$commit
+builddir="$srcdir"/$_commit
build() {
- cd "$builddir"
-
[ "$BOOTSTRAP" = "nocc" ] && return 0
# provide minimal libssp_nonshared.a so we don't need libssp from gcc
@@ -63,7 +56,7 @@ build() {
fi
# note: not autotools
- LDFLAGS="$LDFLAGS -Wl,-soname,libc.musl-${CARCH}.so.1" \
+ LDFLAGS="$LDFLAGS -Wl,-soname,libc.musl-$CARCH.so.1" \
./configure \
--build=$CBUILD \
--host=$CHOST \
@@ -78,8 +71,6 @@ build() {
}
package() {
- cd "$builddir"
-
case "$CARCH" in
aarch64*) ARCH="aarch64" ;;
arm*) ARCH="arm" ;;
@@ -103,7 +94,7 @@ package() {
# make LDSO the be the real file, and libc the symlink
local LDSO=$(make -f Makefile --eval "$(echo -e 'print-ldso:\n\t@echo $$(basename $(LDSO_PATHNAME))')" print-ldso)
mv -f "$pkgdir"/usr/lib/libc.so "$pkgdir"/lib/"$LDSO"
- ln -sf "$LDSO" "$pkgdir"/lib/libc.musl-${CARCH}.so.1
+ ln -sf "$LDSO" "$pkgdir"/lib/libc.musl-$CARCH.so.1
ln -sf ../../lib/"$LDSO" "$pkgdir"/usr/lib/libc.so
mkdir -p "$pkgdir"/usr/bin
@@ -165,21 +156,16 @@ compat() {
x86_64) _ld="lib64/ld-linux-x86-64.so.2";;
esac
mkdir -p "$subpkgdir/${_ld%/*}"
- ln -sf "/lib/libc.musl-${CARCH}.so.1" "$subpkgdir/$_ld"
+ ln -sf "/lib/libc.musl-$CARCH.so.1" "$subpkgdir/$_ld"
for i in libc.so.6 libcrypt.so.1 libm.so.6 libpthread.so.0 librt.so.1 libutil.so.1; do
- ln -sf "/lib/libc.musl-${CARCH}.so.1" "$subpkgdir/lib/$i"
+ ln -sf "/lib/libc.musl-$CARCH.so.1" "$subpkgdir/lib/$i"
done
}
sha512sums="
-7240550ab45cb6b410d65013c92f1f1de0f274322e7ba10e3cf9ce0464a1a833337c2fde39d2fc8c25af1d60599a5bb0ec0d9fb3723c098df3a72e82251bb3eb musl-v1.2.2.tar.gz
-f036317426d54efb4df41c08664c8513d3991408b20f4c74220c8b0324d2e96a97094851ea225e363dd593828c2280e77422b0f4b924dbd106df45504723a00e 0001-riscv64-define-ELF_NFPREG.patch
-6493dd1f3c4413442ed8122a4a2727d491294753fb3c925b6053f8cd593069f9d8374e91576f2fa2133fa9ecae7c093b3b128feb9a916d85715d2780cb60dba4 0001-fix-TZ-parsing-logic-for-identifying-POSIX-form-stri.patch
+9a1b8f9208d99582ac00e3c46c829aa1fad3b7f09aa7d6822f02f25542453d3d977c69519ad01430b8dd624ac9dc70f47d611e36aefd7fef31ea47a7679e3111 musl-v1.2.3.tar.gz
a76f79b801497ad994746cf82bb6eaf86f9e1ae646e6819fbae8532a7f4eee53a96ac1d4e789ec8f66aea2a68027b0597f7a579b3369e01258da8accfce41370 handle-aux-at_base.patch
-d256ba7857c98d39b86aa73674eda5d45ab8134dde3fac2bc48ebb6ba9a824c20c43f2cdc6af54d2a45c162d1e4ec6517c36400992bba10496bcc51b374cbcd0 syscall-cp-epoll.patch
-72177ca2cfa74033778064dbd241a333cae842000513ede57a467b68fb5bced91a15674c29acb140ef4e6b596c03f40caece867833581fb2bd7716047d150f8e eh-frame.patch
-307ad7619cff93a86d4de432db56c37d77303203cc0dddf1b0daa60d5c39453a73c387d8965ac3def37e2a92618d2a1cfd3d825866c9cf19cf2f1c46604cf947 qsort_r.patch
8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f ldconfig
062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b __stack_chk_fail_local.c
0d80f37b34a35e3d14b012257c50862dfeb9d2c81139ea2dfa101d981d093b009b9fa450ba27a708ac59377a48626971dfc58e20a3799084a65777a0c32cbc7d getconf.c
diff --git a/main/musl/eh-frame.patch b/main/musl/eh-frame.patch
deleted file mode 100644
index af7ba3e9f3..0000000000
--- a/main/musl/eh-frame.patch
+++ /dev/null
@@ -1,140 +0,0 @@
-From b2d24e3cc6015aa6a4b01b1fdbad1e68b6fccb96 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
-Date: Fri, 9 Jul 2021 10:57:20 +0300
-Subject: add configure option to enable .eh_frame generation
-
-Add --enable-eh-frame to enable .eh_frame generation. This adds
-about 80kB to ELF size on x86_64.
-
-This is useful to run continuous profilers, gdb, valgrind and other
-debugging utilities to generate backtrace information without having
-to install the full musl-dbg package.
-
-As side effect, this might seem to make exception handling work
-through C-library fuctions when they are calling a callback (e.g. qsort),
-but this continues to be UB and is not supported. This actually is the
-case on ARM where .ARM.exidx is used for unwind info which is present
-always on the musl DSO.
-
----
- Makefile | 4 ++--
- configure | 30 ++++++++++++++++++++++--------
- tools/add-cfi.i386.awk | 2 +-
- tools/add-cfi.x86_64.awk | 2 +-
- 4 files changed, 26 insertions(+), 12 deletions(-)
-
-diff --git a/Makefile b/Makefile
-index e8cc4436..2b501c25 100644
---- a/Makefile
-+++ b/Makefile
-@@ -134,8 +134,8 @@ $(LOBJS) $(LDSO_OBJS): CFLAGS_ALL += -fPIC
- CC_CMD = $(CC) $(CFLAGS_ALL) -c -o $@ $<
-
- # Choose invocation of assembler to be used
--ifeq ($(ADD_CFI),yes)
-- AS_CMD = LC_ALL=C awk -f $(srcdir)/tools/add-cfi.common.awk -f $(srcdir)/tools/add-cfi.$(ARCH).awk $< | $(CC) $(CFLAGS_ALL) -x assembler -c -o $@ -
-+ifneq ($(ADD_CFI),no)
-+ AS_CMD = LC_ALL=C awk -v CFI_SECTIONS="$(ADD_CFI)" -f $(srcdir)/tools/add-cfi.common.awk -f $(srcdir)/tools/add-cfi.$(ARCH).awk $< | $(CC) $(CFLAGS_ALL) -x assembler -c -o $@ -
- else
- AS_CMD = $(CC_CMD)
- endif
-diff --git a/configure b/configure
-index a5231a0e..eea16e6c 100755
---- a/configure
-+++ b/configure
-@@ -30,6 +30,7 @@ System types:
- Optional features:
- --enable-optimize=... optimize listed components for speed over size [auto]
- --enable-debug build with debugging information [disabled]
-+ --enable-eh-frame keep .eh_frame on main binary [disabled]
- --disable-warnings build with recommended warnings flags [enabled]
- --enable-wrapper=... build given musl toolchain wrapper [auto]
- --disable-shared inhibit building shared library [enabled]
-@@ -142,6 +143,7 @@ static=yes
- wrapper=auto
- gcc_wrapper=no
- clang_wrapper=no
-+eh_frame=no
- malloc_dir=mallocng
-
- for arg ; do
-@@ -172,6 +174,8 @@ case "$arg" in
- --disable-wrapper|--enable-wrapper=no) wrapper=no ;;
- --enable-gcc-wrapper|--enable-gcc-wrapper=yes) wrapper=yes ; gcc_wrapper=yes ;;
- --disable-gcc-wrapper|--enable-gcc-wrapper=no) wrapper=no ;;
-+--enable-eh-frame|--enable-eh-frame=yes) eh_frame=yes ;;
-+--disable-eh-frame|--enable-eh-frame=no) eh_frame=no ;;
- --with-malloc=*) malloc_dir=${arg#*=} ;;
- --enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
- --host=*|--target=*) target=${arg#*=} ;;
-@@ -407,14 +411,22 @@ test "$debug" = yes && CFLAGS_AUTO=-g
- # enabled, our assembler supports the needed directives, and the
- # preprocessing script has been written for our architecture.
- #
--printf "checking whether we should preprocess assembly to add debugging information... "
--if fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS" &&
-- test -f "tools/add-cfi.$ARCH.awk" &&
-+printf "checking whether we should preprocess assembly to add unwind information... "
-+
-+ADD_CFI="no"
-+if test -f "tools/add-cfi.$ARCH.awk" &&
- printf ".file 1 \"srcfile.s\"\n.line 1\n.cfi_startproc\n.cfi_endproc" | $CC -g -x assembler -c -o /dev/null 2>/dev/null -
- then
-- ADD_CFI=yes
--else
-- ADD_CFI=no
-+ if test "$eh_frame" = "yes" && fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS"
-+ then
-+ ADD_CFI=".eh_frame, .debug_frame"
-+ elif test "$eh_frame" = "yes"
-+ then
-+ ADD_CFI=".eh_frame"
-+ elif fnmatch '-g*|*\ -g*' "$CFLAGS_AUTO $CFLAGS"
-+ then
-+ ADD_CFI=".debug_frame"
-+ fi
- fi
- printf "%s\n" "$ADD_CFI"
-
-@@ -478,8 +490,10 @@ fi
- # unstrippable. These options force them back to debug sections (and
- # cause them not to get generated at all if debugging is off).
- #
--tryflag CFLAGS_AUTO -fno-unwind-tables
--tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables
-+if test "$eh_frame" = "no"; then
-+ tryflag CFLAGS_AUTO -fno-unwind-tables
-+ tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables
-+fi
-
- #
- # Attempt to put each function and each data object in its own
-diff --git a/tools/add-cfi.i386.awk b/tools/add-cfi.i386.awk
-index d05037de..f758acec 100644
---- a/tools/add-cfi.i386.awk
-+++ b/tools/add-cfi.i386.awk
-@@ -9,7 +9,7 @@
-
- BEGIN {
- # don't put CFI data in the .eh_frame ELF section (which we don't keep)
-- print ".cfi_sections .debug_frame"
-+ print ".cfi_sections " CFI_SECTIONS
-
- # only emit CFI directives inside a function
- in_function = 0
-diff --git a/tools/add-cfi.x86_64.awk b/tools/add-cfi.x86_64.awk
-index 7e1513d6..4a2ae029 100644
---- a/tools/add-cfi.x86_64.awk
-+++ b/tools/add-cfi.x86_64.awk
-@@ -2,7 +2,7 @@
-
- BEGIN {
- # don't put CFI data in the .eh_frame ELF section (which we don't keep)
-- print ".cfi_sections .debug_frame"
-+ print ".cfi_sections " CFI_SECTIONS
-
- # only emit CFI directives inside a function
- in_function = 0
---
-2.32.0
-
diff --git a/main/musl/qsort_r.patch b/main/musl/qsort_r.patch
deleted file mode 100644
index 4ea6366c31..0000000000
--- a/main/musl/qsort_r.patch
+++ /dev/null
@@ -1,213 +0,0 @@
-Date: Tue, 9 Mar 2021 18:02:13 -0300
-From: Érico Nogueira <ericonr@...root.org>
-To: musl@...ts.openwall.com
-Cc: Érico Nogueira <ericonr@...root.org>
-Subject: [PATCH v3] add qsort_r and make qsort a wrapper around it
-
-we make qsort a wrapper by providing a wrapper_cmp function that uses
-the extra argument as a function pointer. should be optimized to a tail
-call on most architectures, as long as it's built with
--fomit-frame-pointer, so the performance impact should be minimal.
-
-to keep the git history clean, for now qsort_r is implemented in qsort.c
-and qsort is implemented in qsort_nr.c. qsort.c also received a few
-trivial cleanups, including replacing (*cmp)() calls with cmp().
-qsort_nr.c contains only wrapper_cmp and qsort as a qsort_r wrapper
-itself.
----
-
-Following suggestions from IRC, as few changes as possible to the files,
-a final clean up commit after this one would involve some git mv's (I
-won't make a patch for it). Added weak_alias to force qsort to use
-libc's qsort_r.
-
-If this can't be accepted due to the overhead on some archs (ppc, mips,
-arm in some situations?), maybe we could revisit v2 of the patch?
-
- include/stdlib.h | 1 +
- src/include/stdlib.h | 1 +
- src/stdlib/qsort.c | 37 ++++++++++++++++++++-----------------
- src/stdlib/qsort_nr.c | 14 ++++++++++++++
- 4 files changed, 36 insertions(+), 17 deletions(-)
- create mode 100644 src/stdlib/qsort_nr.c
-
-diff --git a/include/stdlib.h b/include/stdlib.h
-index b54a051f..0c0ced5f 100644
---- a/include/stdlib.h
-+++ b/include/stdlib.h
-@@ -158,6 +158,7 @@ struct __locale_struct;
- float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *);
- double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *);
- long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *);
-+void qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
- #endif
-
- #if defined(_LARGEFILE64_SOURCE) || defined(_BSD_SOURCE)
-diff --git a/src/include/stdlib.h b/src/include/stdlib.h
-index e9da2015..812b04de 100644
---- a/src/include/stdlib.h
-+++ b/src/include/stdlib.h
-@@ -8,6 +8,7 @@ hidden void __env_rm_add(char *, char *);
- hidden int __mkostemps(char *, int, int);
- hidden int __ptsname_r(int, char *, size_t);
- hidden char *__randname(char *);
-+hidden void __qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
-
- hidden void *__libc_malloc(size_t);
- hidden void *__libc_malloc_impl(size_t);
-diff --git a/src/stdlib/qsort.c b/src/stdlib/qsort.c
-index da58fd31..20e40dda 100644
---- a/src/stdlib/qsort.c
-+++ b/src/stdlib/qsort.c
-@@ -24,6 +24,7 @@
- /* Smoothsort, an adaptive variant of Heapsort. Memory usage: O(1).
- Run time: Worst case O(n log n), close to O(n) in the mostly-sorted case. */
-
-+#define _BSD_SOURCE
- #include <stdint.h>
- #include <stdlib.h>
- #include <string.h>
-@@ -31,7 +32,7 @@
- #include "atomic.h"
- #define ntz(x) a_ctz_l((x))
-
--typedef int (*cmpfun)(const void *, const void *);
-+typedef int (*cmpfun)(const void *, const void *, void *);
-
- static inline int pntz(size_t p[2]) {
- int r = ntz(p[0] - 1);
-@@ -88,7 +89,7 @@ static inline void shr(size_t p[2], int n)
- p[1] >>= n;
- }
-
--static void sift(unsigned char *head, size_t width, cmpfun cmp, int pshift, size_t lp[])
-+static void sift(unsigned char *head, size_t width, cmpfun cmp, void *arg, int pshift, size_t lp[])
- {
- unsigned char *rt, *lf;
- unsigned char *ar[14 * sizeof(size_t) + 1];
-@@ -99,10 +100,10 @@ static void sift(unsigned char *head, size_t width, cmpfun cmp, int pshift, size
- rt = head - width;
- lf = head - width - lp[pshift - 2];
-
-- if((*cmp)(ar[0], lf) >= 0 && (*cmp)(ar[0], rt) >= 0) {
-+ if(cmp(ar[0], lf, arg) >= 0 && cmp(ar[0], rt, arg) >= 0) {
- break;
- }
-- if((*cmp)(lf, rt) >= 0) {
-+ if(cmp(lf, rt, arg) >= 0) {
- ar[i++] = lf;
- head = lf;
- pshift -= 1;
-@@ -115,7 +116,7 @@ static void sift(unsigned char *head, size_t width, cmpfun cmp, int pshift, size
- cycle(width, ar, i);
- }
-
--static void trinkle(unsigned char *head, size_t width, cmpfun cmp, size_t pp[2], int pshift, int trusty, size_t lp[])
-+static void trinkle(unsigned char *head, size_t width, cmpfun cmp, void *arg, size_t pp[2], int pshift, int trusty, size_t lp[])
- {
- unsigned char *stepson,
- *rt, *lf;
-@@ -130,13 +131,13 @@ static void trinkle(unsigned char *head, size_t width, cmpfun cmp, size_t pp[2],
- ar[0] = head;
- while(p[0] != 1 || p[1] != 0) {
- stepson = head - lp[pshift];
-- if((*cmp)(stepson, ar[0]) <= 0) {
-+ if(cmp(stepson, ar[0], arg) <= 0) {
- break;
- }
- if(!trusty && pshift > 1) {
- rt = head - width;
- lf = head - width - lp[pshift - 2];
-- if((*cmp)(rt, stepson) >= 0 || (*cmp)(lf, stepson) >= 0) {
-+ if(cmp(rt, stepson, arg) >= 0 || cmp(lf, stepson, arg) >= 0) {
- break;
- }
- }
-@@ -150,11 +151,11 @@ static void trinkle(unsigned char *head, size_t width, cmpfun cmp, size_t pp[2],
- }
- if(!trusty) {
- cycle(width, ar, i);
-- sift(head, width, cmp, pshift, lp);
-+ sift(head, width, cmp, arg, pshift, lp);
- }
- }
-
--void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
-+void __qsort_r(void *base, size_t nel, size_t width, cmpfun cmp, void *arg)
- {
- size_t lp[12*sizeof(size_t)];
- size_t i, size = width * nel;
-@@ -173,16 +174,16 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
-
- while(head < high) {
- if((p[0] & 3) == 3) {
-- sift(head, width, cmp, pshift, lp);
-+ sift(head, width, cmp, arg, pshift, lp);
- shr(p, 2);
- pshift += 2;
- } else {
- if(lp[pshift - 1] >= high - head) {
-- trinkle(head, width, cmp, p, pshift, 0, lp);
-+ trinkle(head, width, cmp, arg, p, pshift, 0, lp);
- } else {
-- sift(head, width, cmp, pshift, lp);
-+ sift(head, width, cmp, arg, pshift, lp);
- }
--
-+
- if(pshift == 1) {
- shl(p, 1);
- pshift = 0;
-@@ -191,12 +192,12 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
- pshift = 1;
- }
- }
--
-+
- p[0] |= 1;
- head += width;
- }
-
-- trinkle(head, width, cmp, p, pshift, 0, lp);
-+ trinkle(head, width, cmp, arg, p, pshift, 0, lp);
-
- while(pshift != 1 || p[0] != 1 || p[1] != 0) {
- if(pshift <= 1) {
-@@ -208,11 +209,13 @@ void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
- pshift -= 2;
- p[0] ^= 7;
- shr(p, 1);
-- trinkle(head - lp[pshift] - width, width, cmp, p, pshift + 1, 1, lp);
-+ trinkle(head - lp[pshift] - width, width, cmp, arg, p, pshift + 1, 1, lp);
- shl(p, 1);
- p[0] |= 1;
-- trinkle(head - width, width, cmp, p, pshift, 1, lp);
-+ trinkle(head - width, width, cmp, arg, p, pshift, 1, lp);
- }
- head -= width;
- }
- }
-+
-+weak_alias(__qsort_r, qsort_r);
-diff --git a/src/stdlib/qsort_nr.c b/src/stdlib/qsort_nr.c
-new file mode 100644
-index 00000000..fe408fb1
---- /dev/null
-+++ b/src/stdlib/qsort_nr.c
-@@ -0,0 +1,14 @@
-+#define _BSD_SOURCE
-+#include <stdlib.h>
-+
-+typedef int (*cmpfun)(const void *, const void *);
-+
-+static int wrapper_cmp(const void *v1, const void *v2, void *cmp)
-+{
-+ return ((cmpfun)cmp)(v1, v2);
-+}
-+
-+void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
-+{
-+ __qsort_r(base, nel, width, wrapper_cmp, cmp);
-+}
---
-2.30.2
diff --git a/main/musl/syscall-cp-epoll.patch b/main/musl/syscall-cp-epoll.patch
deleted file mode 100644
index 338620a373..0000000000
--- a/main/musl/syscall-cp-epoll.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-diff --git a/src/linux/epoll.c b/src/linux/epoll.c
-index deff5b10..93baa814 100644
---- a/src/linux/epoll.c
-+++ b/src/linux/epoll.c
-@@ -24,9 +24,9 @@ int epoll_ctl(int fd, int op, int fd2, struct epoll_event *ev)
-
- int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs)
- {
-- int r = __syscall(SYS_epoll_pwait, fd, ev, cnt, to, sigs, _NSIG/8);
-+ int r = __syscall_cp(SYS_epoll_pwait, fd, ev, cnt, to, sigs, _NSIG/8);
- #ifdef SYS_epoll_wait
-- if (r==-ENOSYS && !sigs) r = __syscall(SYS_epoll_wait, fd, ev, cnt, to);
-+ if (r==-ENOSYS && !sigs) r = __syscall_cp(SYS_epoll_wait, fd, ev, cnt, to);
- #endif
- return __syscall_ret(r);
- }