aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-03-21 13:39:06 +0200
committerTimo Teräs <timo.teras@iki.fi>2020-03-21 13:39:48 +0200
commit6dbdfd21b06bdc380a9ce9b363033ebc88db46a7 (patch)
tree6b5161637bc6a2819a53b868f6791a64fdec57dd
parenta519575528ead8cc8179fddc330f765ffafede6d (diff)
downloadaports-6dbdfd21b06bdc380a9ce9b363033ebc88db46a7.tar.bz2
aports-6dbdfd21b06bdc380a9ce9b363033ebc88db46a7.tar.xz
main/musl: cherry-pick strerror speedup from musl git master
It's moderately important as it improves startup time for openssl library.
-rw-r--r--main/musl/APKBUILD4
-rw-r--r--main/musl/improve-strerror-speed.patch101
2 files changed, 104 insertions, 1 deletions
diff --git a/main/musl/APKBUILD b/main/musl/APKBUILD
index 4c7621ae73..c957e00219 100644
--- a/main/musl/APKBUILD
+++ b/main/musl/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=1.1.24
-pkgrel=2
+pkgrel=3
pkgdesc="the musl c library (libc) implementation"
url="https://musl.libc.org/"
arch="all"
@@ -26,6 +26,7 @@ source="https://musl.libc.org/releases/musl-$pkgver.tar.gz
fix-incorrect-results-for-catanf-and-catanl-with-som.patch
fix-return-value-of-ungetc-when-argument-is-outside-.patch
fix-errno-for-posix_openpt-with-no-free-ptys-availab.patch
+ improve-strerror-speed.patch
ldconfig
__stack_chk_fail_local.c
@@ -175,6 +176,7 @@ sha512sums="8987f1e194ea616f34f4f21fe9def28fb7f81d7060e38619206c6349f79db3bbb76b
41934951bbc16f155d40824abf30d818b4c124f668f74f5a13674b5251650bb9d9bf9fde0b75462bb2a4b80dc00871ba122960fa027998e71970d533df1cb987 fix-incorrect-results-for-catanf-and-catanl-with-som.patch
81bddb171fc2171a7aa86e74bf674e3a99508d27416dfc1cfcf2824f17b33ee7dda7c5968a8a69a542fdd6eecded5b8e3973e81079d9a061aa80142d08fc1a90 fix-return-value-of-ungetc-when-argument-is-outside-.patch
144b4525483cbc97f0414955b7e5ce42c9ff69580e5be714b56330da30b0687911bd6019aef3c8611bd0a5bd7671d690b66b4920ae47cf3442a1c982ed000e22 fix-errno-for-posix_openpt-with-no-free-ptys-availab.patch
+4875efd7249613f696b4c470fb0aedf9968f1260cf35ef640666897d9ef2f3032588ac4c37659928ed45c1c010848ec2b19414ba5406f3bd7d745288b8b105d4 improve-strerror-speed.patch
8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f ldconfig
062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b __stack_chk_fail_local.c
0d80f37b34a35e3d14b012257c50862dfeb9d2c81139ea2dfa101d981d093b009b9fa450ba27a708ac59377a48626971dfc58e20a3799084a65777a0c32cbc7d getconf.c
diff --git a/main/musl/improve-strerror-speed.patch b/main/musl/improve-strerror-speed.patch
new file mode 100644
index 0000000000..013b6b80e0
--- /dev/null
+++ b/main/musl/improve-strerror-speed.patch
@@ -0,0 +1,101 @@
+From 8343334d7b9cd4338bdac80e17be079cbc675ec3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
+Date: Wed, 4 Mar 2020 11:27:01 +0200
+Subject: [PATCH] improve strerror speed
+
+change the current O(n) lookup to O(1) based on the machinery
+described in "How To Write Shared Libraries" (Appendix B).
+---
+ src/errno/__strerror.h | 13 ++++++-------
+ src/errno/strerror.c | 41 ++++++++++++++++++++++++++---------------
+ 2 files changed, 32 insertions(+), 22 deletions(-)
+
+diff --git a/src/errno/__strerror.h b/src/errno/__strerror.h
+index 2f04d400..2d992da5 100644
+--- a/src/errno/__strerror.h
++++ b/src/errno/__strerror.h
+@@ -1,8 +1,9 @@
+-/* This file is sorted such that 'errors' which represent exceptional
+- * conditions under which a correct program may fail come first, followed
+- * by messages that indicate an incorrect program or system failure. The
+- * macro E() along with double-inclusion is used to ensure that ordering
+- * of the strings remains synchronized. */
++/* The first entry is a catch-all for codes not enumerated here.
++ * This file is included multiple times to declare and define a structure
++ * with these messages, and then to define a lookup table translating
++ * error codes to offsets of corresponding fields in the structure. */
++
++E(0, "No error information")
+
+ E(EILSEQ, "Illegal byte sequence")
+ E(EDOM, "Domain error")
+@@ -101,5 +102,3 @@ E(EDQUOT, "Quota exceeded")
+ E(ENOMEDIUM, "No medium found")
+ E(EMEDIUMTYPE, "Wrong medium type")
+ E(EMULTIHOP, "Multihop attempted")
+-
+-E(0, "No error information")
+diff --git a/src/errno/strerror.c b/src/errno/strerror.c
+index e3ed771a..7f926432 100644
+--- a/src/errno/strerror.c
++++ b/src/errno/strerror.c
+@@ -1,30 +1,41 @@
+ #include <errno.h>
++#include <stddef.h>
+ #include <string.h>
+ #include "locale_impl.h"
+
+-#define E(a,b) ((unsigned char)a),
+-static const unsigned char errid[] = {
++/* mips has one error code outside of the 8-bit range due to a
++ * historical typo, so we just remap it. */
++#if EDQUOT==1133
++#define EDQUOT_ORIG 1133
++#undef EDQUOT
++#define EDQUOT 109
++#endif
++
++static const struct errmsgstr_t {
++#define E(n, s) char str##n[sizeof(s)];
++#include "__strerror.h"
++#undef E
++} errmsgstr = {
++#define E(n, s) s,
+ #include "__strerror.h"
++#undef E
+ };
+
+-#undef E
+-#define E(a,b) b "\0"
+-static const char errmsg[] =
++static const unsigned short errmsgidx[] = {
++#define E(n, s) [n] = offsetof(struct errmsgstr_t, str##n),
+ #include "__strerror.h"
+-;
++#undef E
++};
+
+ char *__strerror_l(int e, locale_t loc)
+ {
+ const char *s;
+- int i;
+- /* mips has one error code outside of the 8-bit range due to a
+- * historical typo, so we just remap it. */
+- if (EDQUOT==1133) {
+- if (e==109) e=-1;
+- else if (e==EDQUOT) e=109;
+- }
+- for (i=0; errid[i] && errid[i] != e; i++);
+- for (s=errmsg; i; s++, i--) for (; *s; s++);
++#ifdef EDQUOT_ORIG
++ if (e==EDQUOT) e=0;
++ else if (e==EDQUOT_ORIG) e=EDQUOT;
++#endif
++ if (e >= sizeof errmsgidx / sizeof *errmsgidx) e = 0;
++ s = (char *)&errmsgstr + errmsgidx[e];
+ return (char *)LCTRANS(s, LC_MESSAGES, loc);
+ }
+
+--
+2.25.1
+