diff options
Diffstat (limited to 'libc/sysdeps/powerpc/nofpu')
25 files changed, 267 insertions, 77 deletions
diff --git a/libc/sysdeps/powerpc/nofpu/Makefile b/libc/sysdeps/powerpc/nofpu/Makefile index b9cbf8023..9de7c4374 100644 --- a/libc/sysdeps/powerpc/nofpu/Makefile +++ b/libc/sysdeps/powerpc/nofpu/Makefile @@ -2,7 +2,8 @@ ifeq ($(subdir),soft-fp) sysdep_routines += $(gcc-single-routines) $(gcc-double-routines) \ - sim-full + sim-full atomic-feholdexcept atomic-feclearexcept \ + atomic-feupdateenv flt-rounds endif ifeq ($(subdir),math) diff --git a/libc/sysdeps/powerpc/nofpu/Versions b/libc/sysdeps/powerpc/nofpu/Versions index 1a29319d5..9f569bd1a 100644 --- a/libc/sysdeps/powerpc/nofpu/Versions +++ b/libc/sysdeps/powerpc/nofpu/Versions @@ -2,9 +2,9 @@ libc { GLIBC_2.3.2 { __sim_exceptions; __sim_disabled_exceptions; __sim_round_mode; __adddf3; __addsf3; __divdf3; __divsf3; __eqdf2; __eqsf2; - __extendsfdf2; __fixdfdi; __fixdfsi; __fixsfdi; __fixsfsi; - __fixunsdfdi; __fixunsdfsi; __fixunssfdi; __fixunssfsi; - __floatdidf; __floatdisf; __floatsidf; __floatsisf; + __extendsfdf2; __fixdfsi; __fixsfsi; + __fixunsdfsi; __fixunssfsi; + __floatsidf; __floatsisf; __gedf2; __gesf2; __ledf2; __lesf2; __muldf3; __mulsf3; __negdf2; __negsf2; __sqrtdf2; __sqrtsf2; __subdf3; __subsf3; __truncdfsf2; @@ -17,4 +17,13 @@ libc { __gtdf2; __gtsf2; __ltdf2; __ltsf2; } + GLIBC_2.19 { + __atomic_feholdexcept; __atomic_feclearexcept; __atomic_feupdateenv; + __flt_rounds; + } + GLIBC_PRIVATE { + __sim_exceptions_thread; + __sim_disabled_exceptions_thread; + __sim_round_mode_thread; + } } diff --git a/libc/sysdeps/powerpc/nofpu/atomic-feclearexcept.c b/libc/sysdeps/powerpc/nofpu/atomic-feclearexcept.c new file mode 100644 index 000000000..780024c78 --- /dev/null +++ b/libc/sysdeps/powerpc/nofpu/atomic-feclearexcept.c @@ -0,0 +1,28 @@ +/* Clear floating-point exceptions for atomic compound assignment. + Copyright (C) 2013-2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include "soft-fp.h" +#include "soft-supp.h" + +void +__atomic_feclearexcept (void) +{ + /* This function postdates the global variables being turned into + compat symbols, so no need to set them. */ + __sim_exceptions_thread = 0; +} diff --git a/libc/sysdeps/powerpc/nofpu/atomic-feholdexcept.c b/libc/sysdeps/powerpc/nofpu/atomic-feholdexcept.c new file mode 100644 index 000000000..aeb00ee7f --- /dev/null +++ b/libc/sysdeps/powerpc/nofpu/atomic-feholdexcept.c @@ -0,0 +1,38 @@ +/* Store current floating-point environment and clear exceptions for + atomic compound assignment. + Copyright (C) 2013-2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include "soft-fp.h" +#include "soft-supp.h" + +void +__atomic_feholdexcept (fenv_t *envp) +{ + fenv_union_t u; + + u.l[0] = __sim_exceptions_thread; + /* The rounding mode is not changed by arithmetic, so no need to + save it. */ + u.l[1] = __sim_disabled_exceptions_thread; + *envp = u.fenv; + + /* This function postdates the global variables being turned into + compat symbols, so no need to set them. */ + __sim_exceptions_thread = 0; + __sim_disabled_exceptions_thread = FE_ALL_EXCEPT; +} diff --git a/libc/sysdeps/powerpc/nofpu/atomic-feupdateenv.c b/libc/sysdeps/powerpc/nofpu/atomic-feupdateenv.c new file mode 100644 index 000000000..700b7cb87 --- /dev/null +++ b/libc/sysdeps/powerpc/nofpu/atomic-feupdateenv.c @@ -0,0 +1,37 @@ +/* Install given floating-point environment and raise exceptions for + atomic compound assignment. + Copyright (C) 2013-2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include "soft-fp.h" +#include "soft-supp.h" +#include <signal.h> + +void +__atomic_feupdateenv (const fenv_t *envp) +{ + fenv_union_t u; + int saved_exceptions = __sim_exceptions_thread; + + /* This function postdates the global variables being turned into + compat symbols, so no need to set them. */ + u.fenv = *envp; + __sim_exceptions_thread |= u.l[0]; + __sim_disabled_exceptions_thread = u.l[1]; + if (saved_exceptions & ~__sim_disabled_exceptions_thread) + raise (SIGFPE); +} diff --git a/libc/sysdeps/powerpc/nofpu/fclrexcpt.c b/libc/sysdeps/powerpc/nofpu/fclrexcpt.c index fabda0ab9..e58552d11 100644 --- a/libc/sysdeps/powerpc/nofpu/fclrexcpt.c +++ b/libc/sysdeps/powerpc/nofpu/fclrexcpt.c @@ -1,5 +1,5 @@ /* Clear floating-point exceptions (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -23,7 +23,8 @@ int __feclearexcept (int x) { - __sim_exceptions &= ~x; + __sim_exceptions_thread &= ~x; + SIM_SET_GLOBAL (__sim_exceptions_global, __sim_exceptions_thread); return 0; } diff --git a/libc/sysdeps/powerpc/nofpu/fedisblxcpt.c b/libc/sysdeps/powerpc/nofpu/fedisblxcpt.c index e06c8f767..4e0f39adf 100644 --- a/libc/sysdeps/powerpc/nofpu/fedisblxcpt.c +++ b/libc/sysdeps/powerpc/nofpu/fedisblxcpt.c @@ -1,5 +1,5 @@ /* Disable exceptions (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -24,9 +24,11 @@ int fedisableexcept (int x) { - int old_exceptions = ~__sim_disabled_exceptions & FE_ALL_EXCEPT; + int old_exceptions = ~__sim_disabled_exceptions_thread & FE_ALL_EXCEPT; - __sim_disabled_exceptions |= x; + __sim_disabled_exceptions_thread |= x; + SIM_SET_GLOBAL (__sim_disabled_exceptions_global, + __sim_disabled_exceptions_thread); return old_exceptions; } diff --git a/libc/sysdeps/powerpc/nofpu/feenablxcpt.c b/libc/sysdeps/powerpc/nofpu/feenablxcpt.c index 93249abf6..bdf075d63 100644 --- a/libc/sysdeps/powerpc/nofpu/feenablxcpt.c +++ b/libc/sysdeps/powerpc/nofpu/feenablxcpt.c @@ -1,5 +1,5 @@ /* Enable exceptions (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -17,16 +17,17 @@ License along with the GNU C Library. If not, see <http://www.gnu.org/licenses/>. */ +#include "soft-supp.h" #include <fenv.h> -extern int __sim_disabled_exceptions; - int feenableexcept (int exceptions) { - int old_exceptions = ~__sim_disabled_exceptions & FE_ALL_EXCEPT; + int old_exceptions = ~__sim_disabled_exceptions_thread & FE_ALL_EXCEPT; - __sim_disabled_exceptions &= ~exceptions; + __sim_disabled_exceptions_thread &= ~exceptions; + SIM_SET_GLOBAL (__sim_disabled_exceptions_global, + __sim_disabled_exceptions_thread); return old_exceptions; } diff --git a/libc/sysdeps/powerpc/nofpu/fegetenv.c b/libc/sysdeps/powerpc/nofpu/fegetenv.c index 51bcef30a..8501a05b6 100644 --- a/libc/sysdeps/powerpc/nofpu/fegetenv.c +++ b/libc/sysdeps/powerpc/nofpu/fegetenv.c @@ -1,5 +1,5 @@ /* Store current floating-point environment (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002, 2010. This file is part of the GNU C Library. @@ -20,18 +20,14 @@ #include "soft-fp.h" #include "soft-supp.h" -extern int __sim_exceptions; -extern int __sim_disabled_exceptions; -extern int __sim_round_mode; - int __fegetenv (fenv_t *envp) { fenv_union_t u; - u.l[0] = __sim_exceptions; - u.l[0] |= __sim_round_mode; - u.l[1] = __sim_disabled_exceptions; + u.l[0] = __sim_exceptions_thread; + u.l[0] |= __sim_round_mode_thread; + u.l[1] = __sim_disabled_exceptions_thread; *envp = u.fenv; diff --git a/libc/sysdeps/powerpc/nofpu/fegetexcept.c b/libc/sysdeps/powerpc/nofpu/fegetexcept.c index ea39a82b7..ab1d087f0 100644 --- a/libc/sysdeps/powerpc/nofpu/fegetexcept.c +++ b/libc/sysdeps/powerpc/nofpu/fegetexcept.c @@ -1,5 +1,5 @@ /* Get floating-point exceptions (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -23,5 +23,5 @@ int fegetexcept (void) { - return (__sim_disabled_exceptions ^ FE_ALL_EXCEPT) & FE_ALL_EXCEPT; + return (__sim_disabled_exceptions_thread ^ FE_ALL_EXCEPT) & FE_ALL_EXCEPT; } diff --git a/libc/sysdeps/powerpc/nofpu/fegetround.c b/libc/sysdeps/powerpc/nofpu/fegetround.c index c232ae379..d746bcfc4 100644 --- a/libc/sysdeps/powerpc/nofpu/fegetround.c +++ b/libc/sysdeps/powerpc/nofpu/fegetround.c @@ -1,5 +1,5 @@ /* Return current rounding mode (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -24,5 +24,6 @@ int fegetround (void) { - return __sim_round_mode; + return __sim_round_mode_thread; } +libm_hidden_def (fegetround) diff --git a/libc/sysdeps/powerpc/nofpu/feholdexcpt.c b/libc/sysdeps/powerpc/nofpu/feholdexcpt.c index ba6a53acc..310b5f429 100644 --- a/libc/sysdeps/powerpc/nofpu/feholdexcpt.c +++ b/libc/sysdeps/powerpc/nofpu/feholdexcpt.c @@ -1,6 +1,6 @@ /* Store current floating-point environment and clear exceptions (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. diff --git a/libc/sysdeps/powerpc/nofpu/fenv_const.c b/libc/sysdeps/powerpc/nofpu/fenv_const.c index 291b1accc..6dc9e6f4f 100644 --- a/libc/sysdeps/powerpc/nofpu/fenv_const.c +++ b/libc/sysdeps/powerpc/nofpu/fenv_const.c @@ -1,5 +1,5 @@ /* Constants for fenv_bits.h (soft float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. diff --git a/libc/sysdeps/powerpc/nofpu/fenv_libc.h b/libc/sysdeps/powerpc/nofpu/fenv_libc.h index 14a2d04a2..dce1524e3 100644 --- a/libc/sysdeps/powerpc/nofpu/fenv_libc.h +++ b/libc/sysdeps/powerpc/nofpu/fenv_libc.h @@ -1,5 +1,5 @@ /* Internal libc stuff for floating point environment routines. - Copyright (C) 2007-2013 Free Software Foundation, Inc. + Copyright (C) 2007-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -25,4 +25,7 @@ #include <fenv.h> +/* ldbl-128ibm code uses __fegetround. */ +#define __fegetround() fegetround () + #endif /* fenv_libc.h */ diff --git a/libc/sysdeps/powerpc/nofpu/fesetenv.c b/libc/sysdeps/powerpc/nofpu/fesetenv.c index 3f35909b6..4ace3d097 100644 --- a/libc/sysdeps/powerpc/nofpu/fesetenv.c +++ b/libc/sysdeps/powerpc/nofpu/fesetenv.c @@ -1,5 +1,5 @@ /* Set floating point environment (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -26,9 +26,13 @@ __fesetenv (const fenv_t *envp) fenv_union_t u; u.fenv = *envp; - __sim_exceptions = u.l[0] & FE_ALL_EXCEPT; - __sim_round_mode = u.l[0] & 0x3; - __sim_disabled_exceptions = u.l[1]; + __sim_exceptions_thread = u.l[0] & FE_ALL_EXCEPT; + SIM_SET_GLOBAL (__sim_exceptions_global, __sim_exceptions_thread); + __sim_round_mode_thread = u.l[0] & 0x3; + SIM_SET_GLOBAL (__sim_round_mode_global, __sim_round_mode_thread); + __sim_disabled_exceptions_thread = u.l[1]; + SIM_SET_GLOBAL (__sim_disabled_exceptions_global, + __sim_disabled_exceptions_thread); return 0; } diff --git a/libc/sysdeps/powerpc/nofpu/fesetround.c b/libc/sysdeps/powerpc/nofpu/fesetround.c index 028c1300c..aae7cc69a 100644 --- a/libc/sysdeps/powerpc/nofpu/fesetround.c +++ b/libc/sysdeps/powerpc/nofpu/fesetround.c @@ -1,5 +1,5 @@ /* Set rounding mode (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -26,7 +26,8 @@ fesetround (int round) if ((unsigned int) round > FE_DOWNWARD) return 1; - __sim_round_mode = round; + __sim_round_mode_thread = round; + SIM_SET_GLOBAL (__sim_round_mode_global, __sim_round_mode_thread); return 0; } diff --git a/libc/sysdeps/powerpc/nofpu/feupdateenv.c b/libc/sysdeps/powerpc/nofpu/feupdateenv.c index 163f67310..000c4d182 100644 --- a/libc/sysdeps/powerpc/nofpu/feupdateenv.c +++ b/libc/sysdeps/powerpc/nofpu/feupdateenv.c @@ -1,6 +1,6 @@ /* Install given floating-point environment and raise exceptions (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -28,14 +28,15 @@ __feupdateenv (const fenv_t *envp) int saved_exceptions; /* Save currently set exceptions. */ - saved_exceptions = __sim_exceptions; + saved_exceptions = __sim_exceptions_thread; /* Set environment. */ fesetenv (envp); /* Raise old exceptions. */ - __sim_exceptions |= saved_exceptions; - if (saved_exceptions & ~__sim_disabled_exceptions) + __sim_exceptions_thread |= saved_exceptions; + SIM_SET_GLOBAL (__sim_exceptions_global, __sim_exceptions_thread); + if (saved_exceptions & ~__sim_disabled_exceptions_thread) raise (SIGFPE); return 0; diff --git a/libc/sysdeps/powerpc/nofpu/fgetexcptflg.c b/libc/sysdeps/powerpc/nofpu/fgetexcptflg.c index 2373fa400..2e03e2634 100644 --- a/libc/sysdeps/powerpc/nofpu/fgetexcptflg.c +++ b/libc/sysdeps/powerpc/nofpu/fgetexcptflg.c @@ -1,5 +1,5 @@ /* Store current representation for exceptions (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -23,7 +23,7 @@ int __fegetexceptflag (fexcept_t *flagp, int excepts) { - *flagp = (fexcept_t) __sim_exceptions & excepts & FE_ALL_EXCEPT; + *flagp = (fexcept_t) __sim_exceptions_thread & excepts & FE_ALL_EXCEPT; return 0; } diff --git a/libc/sysdeps/powerpc/nofpu/flt-rounds.c b/libc/sysdeps/powerpc/nofpu/flt-rounds.c new file mode 100644 index 000000000..5edd6ebca --- /dev/null +++ b/libc/sysdeps/powerpc/nofpu/flt-rounds.c @@ -0,0 +1,38 @@ +/* Return current rounding mode as correct value for FLT_ROUNDS. + Copyright (C) 2013-2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include "soft-fp.h" +#include "soft-supp.h" + +int +__flt_rounds (void) +{ + switch (__sim_round_mode_thread) + { + case FP_RND_ZERO: + return 0; + case FP_RND_NEAREST: + return 1; + case FP_RND_PINF: + return 2; + case FP_RND_MINF: + return 3; + default: + abort (); + } +} diff --git a/libc/sysdeps/powerpc/nofpu/fraiseexcpt.c b/libc/sysdeps/powerpc/nofpu/fraiseexcpt.c index cd142b60b..097502e41 100644 --- a/libc/sysdeps/powerpc/nofpu/fraiseexcpt.c +++ b/libc/sysdeps/powerpc/nofpu/fraiseexcpt.c @@ -1,5 +1,5 @@ /* Raise given exceptions (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -25,8 +25,9 @@ int __feraiseexcept (int x) { - __sim_exceptions |= x; - if (x & ~__sim_disabled_exceptions) + __sim_exceptions_thread |= x; + SIM_SET_GLOBAL (__sim_exceptions_global, __sim_exceptions_thread); + if (x & ~__sim_disabled_exceptions_thread) raise (SIGFPE); return 0; } diff --git a/libc/sysdeps/powerpc/nofpu/fsetexcptflg.c b/libc/sysdeps/powerpc/nofpu/fsetexcptflg.c index 3dc368fdd..b440719fb 100644 --- a/libc/sysdeps/powerpc/nofpu/fsetexcptflg.c +++ b/libc/sysdeps/powerpc/nofpu/fsetexcptflg.c @@ -1,5 +1,5 @@ /* Set floating-point environment exception handling (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -24,7 +24,9 @@ int __fesetexceptflag(const fexcept_t *flagp, int excepts) { /* Ignore exceptions not listed in 'excepts'. */ - __sim_exceptions = (__sim_exceptions & ~excepts) | (*flagp & excepts); + __sim_exceptions_thread + = (__sim_exceptions_thread & ~excepts) | (*flagp & excepts); + SIM_SET_GLOBAL (__sim_exceptions_global, __sim_exceptions_thread); return 0; } diff --git a/libc/sysdeps/powerpc/nofpu/ftestexcept.c b/libc/sysdeps/powerpc/nofpu/ftestexcept.c index f5d01e881..d9f244e76 100644 --- a/libc/sysdeps/powerpc/nofpu/ftestexcept.c +++ b/libc/sysdeps/powerpc/nofpu/ftestexcept.c @@ -1,5 +1,5 @@ /* Test floating-point exceptions (soft-float edition). - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -23,6 +23,6 @@ int fetestexcept (int x) { - return __sim_exceptions & x; + return __sim_exceptions_thread & x; } libm_hidden_def (fetestexcept) diff --git a/libc/sysdeps/powerpc/nofpu/get-rounding-mode.h b/libc/sysdeps/powerpc/nofpu/get-rounding-mode.h index 20eb81030..2199d372b 100644 --- a/libc/sysdeps/powerpc/nofpu/get-rounding-mode.h +++ b/libc/sysdeps/powerpc/nofpu/get-rounding-mode.h @@ -1,6 +1,6 @@ /* Determine floating-point rounding mode within libc. PowerPC soft-float version. - Copyright (C) 2012-2013 Free Software Foundation, Inc. + Copyright (C) 2012-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -29,7 +29,7 @@ static inline int get_rounding_mode (void) { - return __sim_round_mode; + return __sim_round_mode_thread; } #endif /* get-rounding-mode.h */ diff --git a/libc/sysdeps/powerpc/nofpu/sim-full.c b/libc/sysdeps/powerpc/nofpu/sim-full.c index e16703323..59e79c910 100644 --- a/libc/sysdeps/powerpc/nofpu/sim-full.c +++ b/libc/sysdeps/powerpc/nofpu/sim-full.c @@ -1,5 +1,5 @@ /* Software floating-point exception handling emulation. - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -21,26 +21,37 @@ #include "soft-fp.h" #include "soft-supp.h" -/* FIXME: these variables should be thread specific (see bugzilla bug - 15483) and ideally preserved across signal handlers, like hardware - FP status words, but the latter is quite difficult to accomplish in - userland. */ - -/* Global to store sticky exceptions. */ -int __sim_exceptions __attribute__ ((nocommon)); -libc_hidden_data_def (__sim_exceptions); +/* Thread-local to store sticky exceptions. */ +__thread int __sim_exceptions_thread __attribute__ ((nocommon)); +libc_hidden_data_def (__sim_exceptions_thread); /* By default, no exceptions should trap. */ -int __sim_disabled_exceptions = 0xffffffff; -libc_hidden_data_def (__sim_disabled_exceptions); +__thread int __sim_disabled_exceptions_thread = 0xffffffff; +libc_hidden_data_def (__sim_disabled_exceptions_thread); + +__thread int __sim_round_mode_thread __attribute__ ((nocommon)); +libc_hidden_data_def (__sim_round_mode_thread); + +#if SIM_GLOBAL_COMPAT +int __sim_exceptions_global __attribute__ ((nocommon)); +libc_hidden_data_def (__sim_exceptions_global); +SIM_COMPAT_SYMBOL (__sim_exceptions_global, __sim_exceptions); + +int __sim_disabled_exceptions_global = 0xffffffff; +libc_hidden_data_def (__sim_disabled_exceptions_global); +SIM_COMPAT_SYMBOL (__sim_disabled_exceptions_global, + __sim_disabled_exceptions); -int __sim_round_mode __attribute__ ((nocommon)); -libc_hidden_data_def (__sim_round_mode); +int __sim_round_mode_global __attribute__ ((nocommon)); +libc_hidden_data_def (__sim_round_mode_global); +SIM_COMPAT_SYMBOL (__sim_round_mode_global, __sim_round_mode); +#endif void __simulate_exceptions (int x) { - __sim_exceptions |= x; - if (x & ~__sim_disabled_exceptions) + __sim_exceptions_thread |= x; + SIM_SET_GLOBAL (__sim_exceptions_global, __sim_exceptions_thread); + if (x & ~__sim_disabled_exceptions_thread) raise (SIGFPE); } diff --git a/libc/sysdeps/powerpc/nofpu/soft-supp.h b/libc/sysdeps/powerpc/nofpu/soft-supp.h index 18b4550e3..9e59cf077 100644 --- a/libc/sysdeps/powerpc/nofpu/soft-supp.h +++ b/libc/sysdeps/powerpc/nofpu/soft-supp.h @@ -1,5 +1,5 @@ /* Internal support stuff for complete soft float. - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2014 Free Software Foundation, Inc. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002. This file is part of the GNU C Library. @@ -33,16 +33,31 @@ typedef union #endif -/* FIXME: these variables should be thread specific (see bugzilla bug - 15483) and ideally preserved across signal handlers, like hardware - FP status words, but the latter is quite difficult to accomplish in - userland. */ - -extern int __sim_exceptions; -libc_hidden_proto (__sim_exceptions); -extern int __sim_disabled_exceptions; -libc_hidden_proto (__sim_disabled_exceptions); -extern int __sim_round_mode; -libc_hidden_proto (__sim_round_mode); +extern __thread int __sim_exceptions_thread attribute_tls_model_ie; +libc_hidden_tls_proto (__sim_exceptions_thread, tls_model ("initial-exec")); +extern __thread int __sim_disabled_exceptions_thread attribute_tls_model_ie; +libc_hidden_tls_proto (__sim_disabled_exceptions_thread, + tls_model ("initial-exec")); +extern __thread int __sim_round_mode_thread attribute_tls_model_ie; +libc_hidden_tls_proto (__sim_round_mode_thread, tls_model ("initial-exec")); + +/* These variables were formerly global, so there are compat symbols + for global versions as well. */ + +#include <shlib-compat.h> +#define SIM_GLOBAL_COMPAT SHLIB_COMPAT (libc, GLIBC_2_3_2, GLIBC_2_19) +#if SIM_GLOBAL_COMPAT +extern int __sim_exceptions_global; +libc_hidden_proto (__sim_exceptions_global); +extern int __sim_disabled_exceptions_global ; +libc_hidden_proto (__sim_disabled_exceptions_global); +extern int __sim_round_mode_global; +libc_hidden_proto (__sim_round_mode_global); +# define SIM_COMPAT_SYMBOL(GLOBAL_NAME, NAME) \ + compat_symbol (libc, GLOBAL_NAME, NAME, GLIBC_2_3_2) +# define SIM_SET_GLOBAL(GLOBAL_VAR, THREAD_VAR) ((GLOBAL_VAR) = (THREAD_VAR)) +#else +# define SIM_SET_GLOBAL(GLOBAL_VAR, THREAD_VAR) ((void) 0) +#endif extern void __simulate_exceptions (int x) attribute_hidden; |