add hidden version of &errno accessor function
authorRich Felker <dalias@aerifal.cx>
Sat, 15 Sep 2018 03:08:53 +0000 (23:08 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 15 Sep 2018 03:08:53 +0000 (23:08 -0400)
this significantly improves codegen in functions that need to access
errno but otherwise have no need for a GOT pointer.

we could probably improve it much more by including an inline version
of the &errno accessor function, but that depends on having the
definitions of struct __pthread and __pthread_self(), which at present
would expose a lot more than is appropriate. moving them to a small
tls.h later might make this more reasonable.

src/errno/__errno_location.c
src/include/errno.h [new file with mode: 0644]

index ad9f92415a555cad7ca77cccf9e6facc5989a483..7f9d6027a276a0b5574362f0e9aa547fed213523 100644 (file)
@@ -5,3 +5,5 @@ int *__errno_location(void)
 {
        return &__pthread_self()->errno_val;
 }
+
+weak_alias(__errno_location, ___errno_location);
diff --git a/src/include/errno.h b/src/include/errno.h
new file mode 100644 (file)
index 0000000..54a38ff
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef ERRNO_H
+#define ERRNO_H
+
+#include "../../include/errno.h"
+
+hidden int *___errno_location(void);
+
+#undef errno
+#define errno (*___errno_location())
+
+#endif