(root)/
glibc-2.38/
sysdeps/
ieee754/
soft-fp/
s_ffma.c
       1  /* Fused multiply-add of double values, narrowing the result to float,
       2     using soft-fp.
       3     Copyright (C) 2021-2023 Free Software Foundation, Inc.
       4     This file is part of the GNU C Library.
       5  
       6     The GNU C Library is free software; you can redistribute it and/or
       7     modify it under the terms of the GNU Lesser General Public
       8     License as published by the Free Software Foundation; either
       9     version 2.1 of the License, or (at your option) any later version.
      10  
      11     The GNU C Library is distributed in the hope that it will be useful,
      12     but WITHOUT ANY WARRANTY; without even the implied warranty of
      13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14     Lesser General Public License for more details.
      15  
      16     You should have received a copy of the GNU Lesser General Public
      17     License along with the GNU C Library; if not, see
      18     <https://www.gnu.org/licenses/>.  */
      19  
      20  #define f32fmaf64 __hide_f32fmaf64
      21  #define f32fmaf32x __hide_f32fmaf32x
      22  #define ffmal __hide_ffmal
      23  #include <math.h>
      24  #undef f32fmaf64
      25  #undef f32fmaf32x
      26  #undef ffmal
      27  
      28  #include <math-narrow.h>
      29  #include <libc-diag.h>
      30  
      31  /* R_e is not set in cases where it is not used in packing, but the
      32     compiler does not see that it is set in all cases where it is
      33     used, resulting in warnings that it may be used uninitialized.
      34     The location of the warning differs in different versions of GCC,
      35     it may be where R is defined using a macro or it may be where the
      36     macro is defined.  */
      37  DIAG_PUSH_NEEDS_COMMENT;
      38  DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wmaybe-uninitialized");
      39  
      40  #include <soft-fp.h>
      41  #include <single.h>
      42  #include <double.h>
      43  
      44  float
      45  __ffma (double x, double y, double z)
      46  {
      47    FP_DECL_EX;
      48    FP_DECL_D (X);
      49    FP_DECL_D (Y);
      50    FP_DECL_D (Z);
      51    FP_DECL_D (R);
      52    FP_DECL_S (RN);
      53    float ret;
      54  
      55    FP_INIT_ROUNDMODE;
      56    FP_UNPACK_D (X, x);
      57    FP_UNPACK_D (Y, y);
      58    FP_UNPACK_D (Z, z);
      59    FP_FMA_D (R, X, Y, Z);
      60  #if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
      61    FP_TRUNC_COOKED (S, D, 1, 2, RN, R);
      62  #else
      63    FP_TRUNC_COOKED (S, D, 1, 1, RN, R);
      64  #endif
      65    FP_PACK_S (ret, RN);
      66    FP_HANDLE_EXCEPTIONS;
      67    CHECK_NARROW_FMA (ret, x, y, z);
      68    return ret;
      69  }
      70  DIAG_POP_NEEDS_COMMENT;
      71  
      72  libm_alias_float_double (fma)