From 956f8acd6cf6ce33193a679c7f34c1f71db5c94a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 17 Jan 2002 00:50:24 +0000 Subject: [PATCH] Update. 2002-01-16 Martin Schwidefsky * sysdeps/s390/s390-32/pt-machine.h (MEMORY_BARRIER): Define. (CURRENT_STACK_FRAME): Remove duplicate definition. * sysdeps/s390/s390-64/pt-machine.h: Likewise. --- linuxthreads/ChangeLog | 6 ++ linuxthreads/sysdeps/s390/s390-32/pt-machine.h | 11 +-- linuxthreads/sysdeps/s390/s390-64/pt-machine.h | 11 +-- sysdeps/s390/fpu/libm-test-ulps | 103 ++++++-------------- sysdeps/unix/sysv/linux/s390/s390-32/swapcontext.S | 108 +++++++++++++++++++++ sysdeps/unix/sysv/linux/s390/s390-64/swapcontext.S | 108 +++++++++++++++++++++ sysdeps/unix/sysv/linux/s390/swapcontext.c | 39 -------- 7 files changed, 262 insertions(+), 124 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/swapcontext.S create mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/swapcontext.S delete mode 100644 sysdeps/unix/sysv/linux/s390/swapcontext.c diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index aa115ee..a8a98e8 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,9 @@ +2002-01-16 Martin Schwidefsky + + * sysdeps/s390/s390-32/pt-machine.h (MEMORY_BARRIER): Define. + (CURRENT_STACK_FRAME): Remove duplicate definition. + * sysdeps/s390/s390-64/pt-machine.h: Likewise. + 2002-01-14 Martin Schwidefsky * Makefile (CFLAGS-tst-cancel.c): Add -fno-inline-functions to prevent diff --git a/linuxthreads/sysdeps/s390/s390-32/pt-machine.h b/linuxthreads/sysdeps/s390/s390-32/pt-machine.h index 3afc9d5..f84ccdf 100644 --- a/linuxthreads/sysdeps/s390/s390-32/pt-machine.h +++ b/linuxthreads/sysdeps/s390/s390-32/pt-machine.h @@ -23,6 +23,11 @@ # define PT_EI extern inline #endif +/* For multiprocessor systems, we want to ensure all memory accesses + are completed before we reset a lock. On other systems, we still + need to make sure that the compiler has flushed everything to memory. */ +#define MEMORY_BARRIER() __asm__ __volatile__ ("bcr 15,0" : : : "memory") + /* Spinlock implementation; required. */ PT_EI long int testandset (int *spinlock) @@ -94,9 +99,3 @@ __compare_and_swap(long int *p, long int oldval, long int newval) return retval == 0; } - - -/* Get some notion of the current stack. Need not be exactly the top - of the stack, just something somewhere in the current frame. */ -#define CURRENT_STACK_FRAME stack_pointer -register char * stack_pointer __asm__ ("%r15"); diff --git a/linuxthreads/sysdeps/s390/s390-64/pt-machine.h b/linuxthreads/sysdeps/s390/s390-64/pt-machine.h index f205c12..8b12335 100644 --- a/linuxthreads/sysdeps/s390/s390-64/pt-machine.h +++ b/linuxthreads/sysdeps/s390/s390-64/pt-machine.h @@ -23,6 +23,11 @@ # define PT_EI extern inline #endif +/* For multiprocessor systems, we want to ensure all memory accesses + are completed before we reset a lock. On other systems, we still + need to make sure that the compiler has flushed everything to memory. */ +#define MEMORY_BARRIER() __asm__ __volatile__ ("bcr 15,0" : : : "memory") + /* Spinlock implementation; required. */ PT_EI long int testandset (int *spinlock) @@ -99,9 +104,3 @@ __compare_and_swap(long int *p, long int oldval, long int newval) return retval == 0; } - - -/* Get some notion of the current stack. Need not be exactly the top - of the stack, just something somewhere in the current frame. */ -#define CURRENT_STACK_FRAME stack_pointer -register char * stack_pointer __asm__ ("%r15"); diff --git a/sysdeps/s390/fpu/libm-test-ulps b/sysdeps/s390/fpu/libm-test-ulps index 675ceeb..cf6a174 100644 --- a/sysdeps/s390/fpu/libm-test-ulps +++ b/sysdeps/s390/fpu/libm-test-ulps @@ -1,28 +1,15 @@ # Begin of automatic generation # asin -Test "asin (-0.5) == -pi/6": -float: 2 -ifloat: 2 -Test "asin (0.5) == pi/6": -float: 2 -ifloat: 2 -Test "asin (0.7) == 0.7753974966107530637": -double: 1 -float: 2 -idouble: 1 -ifloat: 2 Test "asin (0.7) == 0.77539749661075306374035335271498708": double: 1 -float: 2 idouble: 1 -ifloat: 2 # atan2 -Test "atan2 (0.7, -1.0) == 2.530866689200584621918884506789267": +Test "atan2 (-0.7, -1.0) == -2.530866689200584621918884506789267": float: 3 ifloat: 3 -Test "atan2 (-0.7, -1.0) == -2.530866689200584621918884506789267": +Test "atan2 (0.7, -1.0) == 2.530866689200584621918884506789267": float: 3 ifloat: 3 Test "atan2 (1.4, -0.93) == 2.1571487668237843754887415992772736": @@ -136,9 +123,7 @@ Test "Real part of: catanh (0.7 + 1.2 i) == 0.2600749516525135959200648705635915 float: 1 ifloat: 1 Test "Imaginary part of: catanh (0.7 + 1.2 i) == 0.2600749516525135959200648705635915 + 0.97024030779509898497385130162655963 i": -double: 1 float: 6 -idouble: 1 ifloat: 6 # cbrt @@ -180,14 +165,6 @@ idouble: 1 Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i": float: 1 ifloat: 1 -Test "Real part of: cexp (0.7 + 1.2 i) == 0.7296989091503236012 + 1.8768962328348102821 i": -double: 1 -float: 1 -idouble: 1 -ifloat: 1 -Test "Imaginary part of: cexp (0.7 + 1.2 i) == 0.7296989091503236012 + 1.8768962328348102821 i": -float: 1 -ifloat: 1 Test "Real part of: cexp (0.7 + 1.2 i) == 0.72969890915032360123451688642930727 + 1.8768962328348102821139467908203072 i": double: 1 float: 1 @@ -199,9 +176,7 @@ ifloat: 1 # clog Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i": -double: 1 float: 3 -idouble: 1 ifloat: 3 # clog10 @@ -262,11 +237,6 @@ float: 1 ifloat: 1 # cos -Test "cos (0.7) == 0.7648421872844884262": -double: 1 -float: 1 -idouble: 1 -ifloat: 1 Test "cos (0.7) == 0.76484218728448842625585999019186495": double: 1 float: 1 @@ -274,19 +244,19 @@ idouble: 1 ifloat: 1 Test "cos (M_PI_6l * 2.0) == 0.5": double: 1 -float: 0.5 +float: 1 idouble: 1 -ifloat: 0.5 +ifloat: 1 Test "cos (M_PI_6l * 4.0) == -0.5": double: 2 float: 1 idouble: 2 ifloat: 1 Test "cos (pi/2) == 0": -double: 0.2758 -float: 0.3667 -idouble: 0.2758 -ifloat: 0.3667 +double: 1 +float: 1 +idouble: 1 +ifloat: 1 # cpow Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i": @@ -298,9 +268,9 @@ Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i": float: 2 ifloat: 2 Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i": -double: 1.1031 +double: 2 float: 2 -idouble: 1.1031 +idouble: 2 ifloat: 2 # csin @@ -392,9 +362,6 @@ double: 2 float: 1 idouble: 2 ifloat: 1 -Test "exp10 (0.7) == 5.0118723362727228500": -float: 1 -ifloat: 1 Test "exp10 (0.7) == 5.0118723362727228500155418688494574": float: 1 ifloat: 1 @@ -461,6 +428,11 @@ float: 1 ifloat: 1 # j0 +Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 Test "j0 (10.0) == -0.24593576445134833520": double: 2 float: 1 @@ -469,6 +441,11 @@ ifloat: 1 Test "j0 (2.0) == 0.22389077914123566805": float: 2 ifloat: 2 +Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 Test "j0 (8.0) == 0.17165080713755390609": float: 1 ifloat: 1 @@ -589,37 +566,24 @@ double: 1 float: 1 idouble: 1 ifloat: 1 -Test "sincos (0.7, &sin_res, &cos_res) puts 0.76484218728448842626 in cos_res": +Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res": double: 1 float: 1 idouble: 1 ifloat: 1 -Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res": -double: 1 -float: 0.5 -idouble: 1 -ifloat: 0.5 Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res": double: 1 float: 1 idouble: 1 ifloat: 1 -Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.866025403784438646764 in sin_res": +Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res": double: 1 float: 1 idouble: 1 ifloat: 1 -Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res": -double: 0.2758 -float: 0.3667 -idouble: 0.2758 -ifloat: 0.3667 Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res": float: 1 ifloat: 1 -Test "sincos (pi/6, &sin_res, &cos_res) puts 0.866025403784438646764 in cos_res": -float: 1 -ifloat: 1 # sinh Test "sinh (0.7) == 0.75858370183953350346": @@ -630,17 +594,16 @@ ifloat: 1 # tan Test "tan (pi/4) == 1": -double: 0.5 -idouble: 0.5 +double: 1 +idouble: 1 # tanh -Test "tanh (0.7) == 0.60436777711716349631": +Test "tanh (-0.7) == -0.60436777711716349631": double: 1 float: 1 idouble: 1 ifloat: 1 - -Test "tanh (-0.7) == -0.60436777711716349631": +Test "tanh (0.7) == 0.60436777711716349631": double: 1 float: 1 idouble: 1 @@ -805,9 +768,7 @@ idouble: 1 # Maximal error of functions: Function: "asin": double: 1 -float: 2 idouble: 1 -ifloat: 2 Function: "atan2": float: 4 @@ -884,9 +845,7 @@ idouble: 4 ifloat: 1 Function: Imaginary part of "catanh": -double: 1 float: 6 -idouble: 1 ifloat: 6 Function: "cbrt": @@ -926,9 +885,7 @@ float: 1 ifloat: 1 Function: Imaginary part of "clog": -double: 1 float: 3 -idouble: 1 ifloat: 3 Function: Real part of "clog10": @@ -956,9 +913,9 @@ idouble: 1 ifloat: 4 Function: Imaginary part of "cpow": -double: 1.1031 +double: 2 float: 2 -idouble: 1.1031 +idouble: 2 ifloat: 2 Function: Imaginary part of "csin": @@ -1098,8 +1055,8 @@ idouble: 1 ifloat: 1 Function: "tan": -double: 0.5 -idouble: 0.5 +double: 1 +idouble: 1 Function: "tanh": double: 1 diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/swapcontext.S b/sysdeps/unix/sysv/linux/s390/s390-32/swapcontext.S new file mode 100644 index 0000000..d9abb62 --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/s390-32/swapcontext.S @@ -0,0 +1,108 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "ucontext_i.h" + +/* __swapcontext (ucontext_t *oucp, const ucontext_t *ucp) + + Saves the machine context in oucp such that when it is activated, + it appears as if __swapcontextt() returned again, restores the + machine context in ucp and thereby resumes execution in that + context. + + This implementation is intended to be used for *synchronous* context + switches only. Therefore, it does not have to save anything + other than the PRESERVED state. */ + +ENTRY(__swapcontext) + lr %r1,%r2 + lr %r5,%r3 + + /* sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask). */ + la %r2,SIG_BLOCK + slr %r3,%r3 + la %r4,SC_MASK(%r1) + svc SYS_ify(rt_sigprocmask) + + /* Store fpu context. */ + stfpc SC_FPC(%r1) + std %f0,SC_FPRS(%r1) + std %f1,SC_FPRS+8(%r1) + std %f2,SC_FPRS+16(%r1) + std %f3,SC_FPRS+24(%r1) + std %f4,SC_FPRS+32(%r1) + std %f5,SC_FPRS+40(%r1) + std %f6,SC_FPRS+48(%r1) + std %f7,SC_FPRS+56(%r1) + std %f8,SC_FPRS+64(%r1) + std %f9,SC_FPRS+72(%r1) + std %f10,SC_FPRS+80(%r1) + std %f11,SC_FPRS+88(%r1) + std %f12,SC_FPRS+96(%r1) + std %f13,SC_FPRS+104(%r1) + std %f14,SC_FPRS+112(%r1) + std %f15,SC_FPRS+120(%r1) + + /* Set __swapcontext return value to 0. */ + slr %r2,%r2 + + /* Store access registers. */ + stam %a0,%a15,SC_ACRS(%r1) + + /* Store general purpose registers. */ + stm %r0,%r15,SC_GPRS(%r1) + + /* sigprocmask (SIG_SETMASK, &sc->sc_mask, NULL). */ + la %r2,SIG_BLOCK + la %r3,SC_MASK(%r5) + slr %r4,%r4 + svc SYS_ify(rt_sigprocmask) + + /* Load fpu context. */ + lfpc SC_FPC(%r5) + ld %f0,SC_FPRS(%r5) + ld %f1,SC_FPRS+8(%r5) + ld %f2,SC_FPRS+16(%r5) + ld %f3,SC_FPRS+24(%r5) + ld %f4,SC_FPRS+32(%r5) + ld %f5,SC_FPRS+40(%r5) + ld %f6,SC_FPRS+48(%r5) + ld %f7,SC_FPRS+56(%r5) + ld %f8,SC_FPRS+64(%r5) + ld %f9,SC_FPRS+72(%r5) + ld %f10,SC_FPRS+80(%r5) + ld %f11,SC_FPRS+88(%r5) + ld %f12,SC_FPRS+96(%r5) + ld %f13,SC_FPRS+104(%r5) + ld %f14,SC_FPRS+112(%r5) + ld %f15,SC_FPRS+120(%r5) + + /* Don't touch %a0, used for thread purposes. */ + lam %a1,%a15,SC_ACRS+4(%r5) + + /* Load general purpose registers. */ + lm %r0,%r15,SC_GPRS(%r5) + + /* Return. */ + br %r14 +END(__swapcontext) +weak_alias(__swapcontext, swapcontext) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/swapcontext.S b/sysdeps/unix/sysv/linux/s390/s390-64/swapcontext.S new file mode 100644 index 0000000..55a9aa1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/s390-64/swapcontext.S @@ -0,0 +1,108 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#include "ucontext_i.h" + +/* __swapcontext (ucontext_t *oucp, const ucontext_t *ucp) + + Saves the machine context in oucp such that when it is activated, + it appears as if __swapcontextt() returned again, restores the + machine context in ucp and thereby resumes execution in that + context. + + This implementation is intended to be used for *synchronous* context + switches only. Therefore, it does not have to save anything + other than the PRESERVED state. */ + +ENTRY(__swapcontext) + lr %r1,%r2 + lr %r5,%r3 + + /* sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask). */ + la %r2,SIG_BLOCK + slr %r3,%r3 + la %r4,SC_MASK(%r1) + svc SYS_ify(rt_sigprocmask) + + /* Store fpu context. */ + stfpc SC_FPC(%r1) + std %f0,SC_FPRS(%r1) + std %f1,SC_FPRS+8(%r1) + std %f2,SC_FPRS+16(%r1) + std %f3,SC_FPRS+24(%r1) + std %f4,SC_FPRS+32(%r1) + std %f5,SC_FPRS+40(%r1) + std %f6,SC_FPRS+48(%r1) + std %f7,SC_FPRS+56(%r1) + std %f8,SC_FPRS+64(%r1) + std %f9,SC_FPRS+72(%r1) + std %f10,SC_FPRS+80(%r1) + std %f11,SC_FPRS+88(%r1) + std %f12,SC_FPRS+96(%r1) + std %f13,SC_FPRS+104(%r1) + std %f14,SC_FPRS+112(%r1) + std %f15,SC_FPRS+120(%r1) + + /* Set __swapcontext return value to 0. */ + slr %r2,%r2 + + /* Store access registers. */ + stam %a0,%a15,SC_ACRS(%r1) + + /* Store general purpose registers. */ + stmg %r0,%r15,SC_GPRS(%r1) + + /* sigprocmask (SIG_SETMASK, &sc->sc_mask, NULL). */ + la %r2,SIG_BLOCK + la %r3,SC_MASK(%r5) + slgr %r4,%r4 + svc SYS_ify(rt_sigprocmask) + + /* Load fpu context. */ + lfpc SC_FPC(%r5) + ld %f0,SC_FPRS(%r5) + ld %f1,SC_FPRS+8(%r5) + ld %f2,SC_FPRS+16(%r5) + ld %f3,SC_FPRS+24(%r5) + ld %f4,SC_FPRS+32(%r5) + ld %f5,SC_FPRS+40(%r5) + ld %f6,SC_FPRS+48(%r5) + ld %f7,SC_FPRS+56(%r5) + ld %f8,SC_FPRS+64(%r5) + ld %f9,SC_FPRS+72(%r5) + ld %f10,SC_FPRS+80(%r5) + ld %f11,SC_FPRS+88(%r5) + ld %f12,SC_FPRS+96(%r5) + ld %f13,SC_FPRS+104(%r5) + ld %f14,SC_FPRS+112(%r5) + ld %f15,SC_FPRS+120(%r5) + + /* Don't touch %a0 and %a1, used for thread purposes. */ + lam %a2,%a15,SC_ACRS+8(%r5) + + /* Load general purpose registers. */ + lmg %r0,%r15,SC_GPRS(%r5) + + /* Return. */ + br %r14 +END(__swapcontext) +weak_alias(__swapcontext, swapcontext) diff --git a/sysdeps/unix/sysv/linux/s390/swapcontext.c b/sysdeps/unix/sysv/linux/s390/swapcontext.c deleted file mode 100644 index 0c8d4c0..0000000 --- a/sysdeps/unix/sysv/linux/s390/swapcontext.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -extern int __getcontext (ucontext_t *__ucp) __THROW; -extern int __setcontext (__const ucontext_t *__ucp) __THROW; - -int -__swapcontext (ucontext_t *oucp, const ucontext_t *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; -} - -weak_alias (__swapcontext, swapcontext) -- 2.7.4