From: Andre Noll Date: Mon, 24 Aug 2015 15:34:28 +0000 (+0200) Subject: Explain the osl_strerror dance. X-Git-Tag: v0.1.3~11 X-Git-Url: http://git.tuebingen.mpg.de/?p=osl.git;a=commitdiff_plain;h=7aa320514ebbb20f6c237627bf0bc8e509321f21;ds=sidebyside Explain the osl_strerror dance. It's not completely obvious what is going on here and *why* we not just go with a simple pointer array for the messages returned by osl_strerror(). This commit explains why pointer arrays are bad in DSOs. --- diff --git a/osl.c b/osl.c index 6666196..e31811b 100644 --- a/osl.c +++ b/osl.c @@ -13,7 +13,14 @@ #include "util.h" #include "osl_core.h" -/* Taken from Drepper: How to write shared libraries, Appendix B. */ +/* + * Taken from Drepper: How to write shared libraries, Appendix B. + * + * The main reason for this rather fancy implementation of strerror() is to + * avoid having an array of pointers. This is desirable because initialized + * pointer variables increase the startup time of the library due to the + * processing of relocations. + */ #include #define MSGSTRFIELD(line) MSGSTRFIELD1(line) #define MSGSTRFIELD1(line) str##line