summaryrefslogtreecommitdiff
path: root/src/errno/__strerror.h
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-03-04 11:27:01 +0200
committerRich Felker <dalias@aerifal.cx>2020-03-14 21:23:37 -0400
commit8343334d7b9cd4338bdac80e17be079cbc675ec3 (patch)
treef5d9d39d0ae60519f92022e25620e06e26ea9560 /src/errno/__strerror.h
parent2b2c8aafce9d80f9d58652643538f4d58e82b856 (diff)
downloadmusl-8343334d7b9cd4338bdac80e17be079cbc675ec3.tar.gz
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).
Diffstat (limited to 'src/errno/__strerror.h')
-rw-r--r--src/errno/__strerror.h13
1 files changed, 6 insertions, 7 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")