summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2013-08-26 21:38:10 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2013-08-26 21:38:10 +0000
commite9f4bf1da1af81716733684468d927489693c23c (patch)
treecefe9ea0aad52683d7075fedab912e36a9e15471 /lib
parentd3f9c59d503b5b2c53f52910f4a5969042fa5fa9 (diff)
Use %r27 as the thread control block pointer, allowing for __get_tcb() calls
in libpthread to be optimized away. While there, follow DG/UX's example of using more than one register for thread purposes (after all, the ABI reserves four of them), and also use %r26 to store a pointer to the current thread's errno. Since it is not possible to initialize %r26 at thread creation without intrusive and potentially race-prone changes, have __tfork() reset %r26 to zero, and libpthread's __cerror lazy initialize it. As soon as %r26 is nonzero, it will be used instead of calling __errno(). This means that binaries linked against HEAD libpthread need to run on HEAD kernels, and we are belatedly jumping on the 64-bit time_t bump (since there are no 64-bit time_t m88k snapshots yet). Joint work with guenther@; "Your love of asm is sick and wrong, and yet beautiful." and ok guenther@
Diffstat (limited to 'lib')
-rw-r--r--lib/librthread/arch/m88k/cerror.S24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/librthread/arch/m88k/cerror.S b/lib/librthread/arch/m88k/cerror.S
index fecea2caa09..d31dc807c50 100644
--- a/lib/librthread/arch/m88k/cerror.S
+++ b/lib/librthread/arch/m88k/cerror.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: cerror.S,v 1.4 2013/01/27 09:56:05 miod Exp $ */
+/* $OpenBSD: cerror.S,v 1.5 2013/08/26 21:38:08 miod Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -37,7 +37,16 @@
.globl _C_LABEL(__errno)
+/*
+ * long long __cerror(register_t errcode)
+ * stores `errcode' into the current thread's errno variable, and returns
+ * -1LL.
+ */
+
ASENTRY(__cerror)
+ /* if %r26 has been initialized, don't bother setting up a frame */
+ bcnd ne0, %r26, has_r26
+
subu %r31,%r31,16
st %r25,%r0,%r31
st %r1,%r31,4
@@ -48,13 +57,16 @@ ASENTRY(__cerror)
bsr.n _C_LABEL(__errno)
#endif
or %r25,%r0,%r2
- st %r25,%r0,%r2
-
- subu %r2,%r0,1
- or %r3, %r0, %r2
+ or %r26,%r0,%r2 /* save errno ptr */
+ or %r2,%r0,%r25 /* and restore errno value */
ld %r1,%r31,4
ld %r25,%r0,%r31
+ addu %r31,%r31,16
+
+has_r26:
+ st %r2,%r0,%r26
+ subu %r2,%r0,1
jmp.n %r1
- addu %r31,%r31,16
+ or %r3, %r0, %r2
END(__cerror)