(root)/
glibc-2.38/
sysdeps/
powerpc/
fpu/
feupdateenv.c
       1  /* Install given floating-point environment and raise exceptions.
       2     Copyright (C) 1997-2023 Free Software Foundation, Inc.
       3     This file is part of the GNU C Library.
       4  
       5     The GNU C Library is free software; you can redistribute it and/or
       6     modify it under the terms of the GNU Lesser General Public
       7     License as published by the Free Software Foundation; either
       8     version 2.1 of the License, or (at your option) any later version.
       9  
      10     The GNU C Library is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13     Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public
      16     License along with the GNU C Library; if not, see
      17     <https://www.gnu.org/licenses/>.  */
      18  
      19  #include <fenv_libc.h>
      20  #include <fpu_control.h>
      21  
      22  int
      23  __feupdateenv (const fenv_t *envp)
      24  {
      25    fenv_union_t old, new;
      26  
      27    /* Save the currently set exceptions.  */
      28    new.fenv = *envp;
      29    old.fenv = fegetenv_register ();
      30  
      31    /* Restore rounding mode and exception enable from *envp and merge
      32       exceptions.  Leave fraction rounded/inexact and FP result/CC bits
      33       unchanged.  */
      34    new.l = (old.l & 0xffffffff1fffff00LL) | (new.l & 0x1ff80fff);
      35  
      36    __TEST_AND_EXIT_NON_STOP (old.l, new.l);
      37    __TEST_AND_ENTER_NON_STOP (old.l, new.l);
      38  
      39    /* Atomically enable and raise (if appropriate) exceptions set in `new'. */
      40    fesetenv_register (new.fenv);
      41  
      42    /* Success.  */
      43    return 0;
      44  }
      45  
      46  #include <shlib-compat.h>
      47  #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
      48  strong_alias (__feupdateenv, __old_feupdateenv)
      49  compat_symbol (libm, __old_feupdateenv, feupdateenv, GLIBC_2_1);
      50  #endif
      51  
      52  libm_hidden_def (__feupdateenv)
      53  libm_hidden_ver (__feupdateenv, feupdateenv)
      54  versioned_symbol (libm, __feupdateenv, feupdateenv, GLIBC_2_2);