|
Packit Service |
82fcde |
/* Private floating point rounding and exceptions handling. PowerPC version.
|
|
Packit Service |
82fcde |
Copyright (C) 2013-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library. If not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifndef FENV_PRIVATE_H
|
|
Packit Service |
82fcde |
#define FENV_PRIVATE_H 1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <fenv.h>
|
|
Packit Service |
82fcde |
#include <fenv_libc.h>
|
|
Packit Service |
82fcde |
#include <fpu_control.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static __always_inline void
|
|
Packit Service |
c954e2 |
libc_feholdexcept_setround_ppc (fenv_t *envp, int r)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
fenv_union_t old, new;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
old.fenv = *envp = fegetenv_register ();
|
|
Packit Service |
82fcde |
|
|
Packit Service |
c954e2 |
__TEST_AND_ENTER_NON_STOP (old.l, 0ULL);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
c954e2 |
/* Clear everything and set the rounding mode. */
|
|
Packit Service |
c954e2 |
new.l = r;
|
|
Packit Service |
82fcde |
fesetenv_register (new.fenv);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static __always_inline unsigned long long
|
|
Packit Service |
82fcde |
__libc_femergeenv_ppc (const fenv_t *envp, unsigned long long old_mask,
|
|
Packit Service |
82fcde |
unsigned long long new_mask)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
fenv_union_t old, new;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
new.fenv = *envp;
|
|
Packit Service |
82fcde |
old.fenv = fegetenv_register ();
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Merge bits while masking unwanted bits from new and old env. */
|
|
Packit Service |
82fcde |
new.l = (old.l & old_mask) | (new.l & new_mask);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
c954e2 |
__TEST_AND_EXIT_NON_STOP (old.l, new.l);
|
|
Packit Service |
c954e2 |
__TEST_AND_ENTER_NON_STOP (old.l, new.l);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
c43741 |
/* If requesting to keep status, replace control, and merge exceptions,
|
|
Packit Service |
c43741 |
and exceptions haven't changed, we can just set new control instead
|
|
Packit Service |
c43741 |
of the whole FPSCR. */
|
|
Packit Service |
c43741 |
if ((old_mask & (FPSCR_CONTROL_MASK|FPSCR_STATUS_MASK|FPSCR_EXCEPTIONS_MASK))
|
|
Packit Service |
c43741 |
== (FPSCR_STATUS_MASK|FPSCR_EXCEPTIONS_MASK) &&
|
|
Packit Service |
c43741 |
(new_mask & (FPSCR_CONTROL_MASK|FPSCR_STATUS_MASK|FPSCR_EXCEPTIONS_MASK))
|
|
Packit Service |
c43741 |
== (FPSCR_CONTROL_MASK|FPSCR_EXCEPTIONS_MASK) &&
|
|
Packit Service |
c43741 |
(old.l & FPSCR_EXCEPTIONS_MASK) == (new.l & FPSCR_EXCEPTIONS_MASK))
|
|
Packit Service |
c43741 |
{
|
|
Packit Service |
c43741 |
fesetenv_mode (new.fenv);
|
|
Packit Service |
c43741 |
}
|
|
Packit Service |
c43741 |
else
|
|
Packit Service |
c43741 |
/* Atomically enable and raise (if appropriate) exceptions set in `new'. */
|
|
Packit Service |
c43741 |
fesetenv_register (new.fenv);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return old.l;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static __always_inline void
|
|
Packit Service |
82fcde |
libc_fesetenv_ppc (const fenv_t *envp)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* Replace the entire environment. */
|
|
Packit Service |
82fcde |
__libc_femergeenv_ppc (envp, 0LL, -1LL);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static __always_inline void
|
|
Packit Service |
82fcde |
libc_feresetround_ppc (fenv_t *envp)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
db3c67 |
fenv_union_t new = { .fenv = *envp };
|
|
Packit Service |
e4aee5 |
fegetenv_and_set_rn (new.l & FPSCR_RN_MASK);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static __always_inline int
|
|
Packit Service |
82fcde |
libc_feupdateenv_test_ppc (fenv_t *envp, int ex)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
c954e2 |
return __libc_femergeenv_ppc (envp, ~FPSCR_CONTROL_MASK,
|
|
Packit Service |
c954e2 |
~FPSCR_STATUS_MASK) & ex;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static __always_inline void
|
|
Packit Service |
82fcde |
libc_feupdateenv_ppc (fenv_t *e)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
libc_feupdateenv_test_ppc (e, 0);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define libc_feholdexceptf libc_feholdexcept_ppc
|
|
Packit Service |
82fcde |
#define libc_feholdexcept libc_feholdexcept_ppc
|
|
Packit Service |
82fcde |
#define libc_feholdexcept_setroundf libc_feholdexcept_setround_ppc
|
|
Packit Service |
82fcde |
#define libc_feholdexcept_setround libc_feholdexcept_setround_ppc
|
|
Packit Service |
82fcde |
#define libc_fetestexceptf libc_fetestexcept_ppc
|
|
Packit Service |
82fcde |
#define libc_fetestexcept libc_fetestexcept_ppc
|
|
Packit Service |
82fcde |
#define libc_fesetroundf libc_fesetround_ppc
|
|
Packit Service |
82fcde |
#define libc_fesetround libc_fesetround_ppc
|
|
Packit Service |
82fcde |
#define libc_fesetenvf libc_fesetenv_ppc
|
|
Packit Service |
82fcde |
#define libc_fesetenv libc_fesetenv_ppc
|
|
Packit Service |
82fcde |
#define libc_feupdateenv_testf libc_feupdateenv_test_ppc
|
|
Packit Service |
82fcde |
#define libc_feupdateenv_test libc_feupdateenv_test_ppc
|
|
Packit Service |
82fcde |
#define libc_feupdateenvf libc_feupdateenv_ppc
|
|
Packit Service |
82fcde |
#define libc_feupdateenv libc_feupdateenv_ppc
|
|
Packit Service |
82fcde |
#define libc_feholdsetroundf libc_feholdsetround_ppc
|
|
Packit Service |
82fcde |
#define libc_feholdsetround libc_feholdsetround_ppc
|
|
Packit Service |
82fcde |
#define libc_feresetroundf libc_feresetround_ppc
|
|
Packit Service |
82fcde |
#define libc_feresetround libc_feresetround_ppc
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* We have support for rounding mode context. */
|
|
Packit Service |
82fcde |
#define HAVE_RM_CTX 1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static __always_inline void
|
|
Packit Service |
82fcde |
libc_feholdsetround_ppc_ctx (struct rm_ctx *ctx, int r)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
e4aee5 |
fenv_union_t old;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
e4aee5 |
ctx->env = old.fenv = fegetenv_and_set_rn (r);
|
|
Packit Service |
e4aee5 |
ctx->updated_status = (r != (old.l & FPSCR_RN_MASK));
|
|
Packit Service |
db3c67 |
}
|
|
Packit Service |
db3c67 |
|
|
Packit Service |
db3c67 |
static __always_inline void
|
|
Packit Service |
db3c67 |
libc_feholdsetround_noex_ppc_ctx (struct rm_ctx *ctx, int r)
|
|
Packit Service |
db3c67 |
{
|
|
Packit Service |
db3c67 |
fenv_union_t old, new;
|
|
Packit Service |
db3c67 |
|
|
Packit Service |
82fcde |
old.fenv = fegetenv_register ();
|
|
Packit Service |
82fcde |
|
|
Packit Service |
db3c67 |
new.l = (old.l & ~(FPSCR_ENABLES_MASK|FPSCR_RN_MASK)) | r;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ctx->env = old.fenv;
|
|
Packit Service |
82fcde |
if (__glibc_unlikely (new.l != old.l))
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
c954e2 |
__TEST_AND_ENTER_NON_STOP (old.l, 0ULL);
|
|
Packit Service |
82fcde |
fesetenv_register (new.fenv);
|
|
Packit Service |
82fcde |
ctx->updated_status = true;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
else
|
|
Packit Service |
82fcde |
ctx->updated_status = false;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static __always_inline void
|
|
Packit Service |
82fcde |
libc_fesetenv_ppc_ctx (struct rm_ctx *ctx)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
libc_fesetenv_ppc (&ctx->env);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static __always_inline void
|
|
Packit Service |
82fcde |
libc_feupdateenv_ppc_ctx (struct rm_ctx *ctx)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
if (__glibc_unlikely (ctx->updated_status))
|
|
Packit Service |
82fcde |
libc_feresetround_ppc (&ctx->env);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static __always_inline void
|
|
Packit Service |
82fcde |
libc_feresetround_ppc_ctx (struct rm_ctx *ctx)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
if (__glibc_unlikely (ctx->updated_status))
|
|
Packit Service |
82fcde |
libc_feresetround_ppc (&ctx->env);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define libc_fesetenv_ctx libc_fesetenv_ppc_ctx
|
|
Packit Service |
82fcde |
#define libc_fesetenvf_ctx libc_fesetenv_ppc_ctx
|
|
Packit Service |
82fcde |
#define libc_fesetenvl_ctx libc_fesetenv_ppc_ctx
|
|
Packit Service |
82fcde |
#define libc_feholdsetround_ctx libc_feholdsetround_ppc_ctx
|
|
Packit Service |
82fcde |
#define libc_feholdsetroundf_ctx libc_feholdsetround_ppc_ctx
|
|
Packit Service |
82fcde |
#define libc_feholdsetroundl_ctx libc_feholdsetround_ppc_ctx
|
|
Packit Service |
db3c67 |
#define libc_feholdsetround_noex_ctx libc_feholdsetround_noex_ppc_ctx
|
|
Packit Service |
db3c67 |
#define libc_feholdsetround_noexf_ctx libc_feholdsetround_noex_ppc_ctx
|
|
Packit Service |
db3c67 |
#define libc_feholdsetround_noexl_ctx libc_feholdsetround_noex_ppc_ctx
|
|
Packit Service |
82fcde |
#define libc_feresetround_ctx libc_feresetround_ppc_ctx
|
|
Packit Service |
82fcde |
#define libc_feresetroundf_ctx libc_feresetround_ppc_ctx
|
|
Packit Service |
82fcde |
#define libc_feresetroundl_ctx libc_feresetround_ppc_ctx
|
|
Packit Service |
82fcde |
#define libc_feupdateenv_ctx libc_feupdateenv_ppc_ctx
|
|
Packit Service |
82fcde |
#define libc_feupdateenvf_ctx libc_feupdateenv_ppc_ctx
|
|
Packit Service |
82fcde |
#define libc_feupdateenvl_ctx libc_feupdateenv_ppc_ctx
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#endif
|