From 58f46c794a3dc049ae8c53dab76d83ea23408479 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 10 Apr 2001 21:46:48 +0000 Subject: Update. 2001-04-10 Martin Schwidefsky * sysdeps/unix/sysv/linux/s390/s390-32/getcontext.S: Fix return value of getcontext. * sysdeps/unix/sysv/linux/s390/s390-64/getcontext.S: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/setcontext.S: Fix return value of setcontext. * sysdeps/unix/sysv/linux/s390/s390-64/setcontext.S: Likewise. * sysdeps/unix/sysv/linux/s390/swapcontext.c: Skip setcontext call by changing the saved context. --- sysdeps/unix/sysv/linux/s390/s390-32/getcontext.S | 10 +++++----- sysdeps/unix/sysv/linux/s390/s390-32/setcontext.S | 3 +-- sysdeps/unix/sysv/linux/s390/s390-64/getcontext.S | 10 +++++----- sysdeps/unix/sysv/linux/s390/s390-64/setcontext.S | 3 +-- sysdeps/unix/sysv/linux/s390/swapcontext.c | 10 ++++++++-- 5 files changed, 20 insertions(+), 16 deletions(-) (limited to 'sysdeps/unix') diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/getcontext.S b/sysdeps/unix/sysv/linux/s390/s390-32/getcontext.S index e64cc8588c..b3cae1c7fe 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/getcontext.S +++ b/sysdeps/unix/sysv/linux/s390/s390-32/getcontext.S @@ -25,9 +25,7 @@ /* __getcontext (const ucontext_t *ucp) Saves the machine context in UCP such that when it is activated, - it appears as if __getcontext() returned again. The only difference - is that on a first return, %r2 contains 1 and on a subsequent - return, it contains 0. + it appears as if __getcontext() returned again. This implementation is intended to be used for *synchronous* context switches only. Therefore, it does not have to save anything @@ -61,11 +59,13 @@ ENTRY(__getcontext) std %f14,SC_FPRS+112(%r5) std %f15,SC_FPRS+120(%r5) + /* Set __getcontext return value to 0. */ + slr %r2,%r2 + /* Store general purpose registers. */ stm %r0,%r15,SC_GPRS(%r5) - /* Return 0. */ - slr %r2,%r2 + /* Return. */ br %r14 END(__getcontext) diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/setcontext.S b/sysdeps/unix/sysv/linux/s390/s390-32/setcontext.S index 40adc8574a..2bed31847a 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/setcontext.S +++ b/sysdeps/unix/sysv/linux/s390/s390-32/setcontext.S @@ -62,8 +62,7 @@ ENTRY(__setcontext) /* Load general purpose registers. */ lm %r0,%r15,SC_GPRS(%r5) - /* Return 1. */ - la %r2,1 + /* Return. */ br %r14 END(__setcontext) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/getcontext.S b/sysdeps/unix/sysv/linux/s390/s390-64/getcontext.S index 2fc21e2b60..9eba838edf 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/getcontext.S +++ b/sysdeps/unix/sysv/linux/s390/s390-64/getcontext.S @@ -25,9 +25,7 @@ /* __getcontext (const ucontext_t *ucp) Saves the machine context in UCP such that when it is activated, - it appears as if __getcontext() returned again. The only difference - is that on a first return, %r2 contains 1 and on a subsequent - return, it contains 0. + it appears as if __getcontext() returned again. This implementation is intended to be used for *synchronous* context switches only. Therefore, it does not have to save anything @@ -61,11 +59,13 @@ ENTRY(__getcontext) std %f14,SC_FPRS+112(%r5) std %f15,SC_FPRS+120(%r5) + /* Set __getcontext return value to 0. */ + slr %r2,%r2 + /* Store general purpose registers. */ stmg %r0,%r15,SC_GPRS(%r5) - /* Return 0. */ - slgr %r2,%r2 + /* Return. */ br %r14 END(__getcontext) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/setcontext.S b/sysdeps/unix/sysv/linux/s390/s390-64/setcontext.S index b3a9fea405..a652ad3173 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/setcontext.S +++ b/sysdeps/unix/sysv/linux/s390/s390-64/setcontext.S @@ -62,8 +62,7 @@ ENTRY(__setcontext) /* Load general purpose registers. */ lmg %r0,%r15,SC_GPRS(%r5) - /* Return 1. */ - la %r2,1 + /* Return. */ br %r14 END(__setcontext) diff --git a/sysdeps/unix/sysv/linux/s390/swapcontext.c b/sysdeps/unix/sysv/linux/s390/swapcontext.c index 9f1be058db..2b34b63ce4 100644 --- a/sysdeps/unix/sysv/linux/s390/swapcontext.c +++ b/sysdeps/unix/sysv/linux/s390/swapcontext.c @@ -25,8 +25,14 @@ extern int __setcontext (__const ucontext_t *__ucp) __THROW; int __swapcontext (ucontext_t *oucp, const ucontext_t *ucp) { - if (__getcontext (oucp) == 0) - __setcontext (ucp); + /* Save the current machine context to oucp. */ + __getcontext (oucp); + /* Modify oucp to skip the __setcontext call on reactivation. */ + oucp->uc_mcontext.gregs[14] = &&fake_return; + /* Restore the machine context in ucp. */ + __setcontext (ucp); + +fake_return: return 0; } -- cgit 1.4.1