]> git.tuebingen.mpg.de Git - osl.git/commitdiff
Explain the osl_strerror dance.
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 24 Aug 2015 15:34:28 +0000 (17:34 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 13 Oct 2015 13:53:46 +0000 (15:53 +0200)
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.

osl.c

diff --git a/osl.c b/osl.c
index 66661969e3720193d7f7af4c5295ee02d8db13d5..e31811b9c57eb0d897aee1c92c41b72cb35a97cc 100644 (file)
--- a/osl.c
+++ b/osl.c
 #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 <stddef.h>
 #define MSGSTRFIELD(line) MSGSTRFIELD1(line)
 #define MSGSTRFIELD1(line) str##line