Blame sysdeps/s390/fpu/s_lround.c

Packit Service aef062
/* lround() - S390 version.
Packit Service aef062
   Copyright (C) 2019 Free Software Foundation, Inc.
Packit Service aef062
Packit Service aef062
   This file is part of the GNU C Library.
Packit Service aef062
Packit Service aef062
   The GNU C Library is free software; you can redistribute it and/or
Packit Service aef062
   modify it under the terms of the GNU Lesser General Public License as
Packit Service aef062
   published by the Free Software Foundation; either version 2.1 of the
Packit Service aef062
   License, or (at your option) any later version.
Packit Service aef062
Packit Service aef062
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service aef062
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service aef062
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service aef062
   Lesser General Public License for more details.
Packit Service aef062
Packit Service aef062
   You should have received a copy of the GNU Lesser General Public
Packit Service aef062
   License along with the GNU C Library; if not, see
Packit Service aef062
   <https://www.gnu.org/licenses/>.  */
Packit Service aef062
Packit Service aef062
#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
Packit Service aef062
# include <math.h>
Packit Service aef062
# include <libm-alias-double.h>
Packit Service aef062
Packit Service aef062
/* The sizeof (long int) differs between s390x (8byte) and s390 (4byte).
Packit Service aef062
   Thus we need different instructions as the target size is encoded there.
Packit Service aef062
   Note: On s390 this instruction is only used if build with -mzarch.  */
Packit Service aef062
# ifdef __s390x__
Packit Service aef062
#  define INSN "cgdbra"
Packit Service aef062
# else
Packit Service aef062
#  define INSN "cfdbra"
Packit Service aef062
# endif
Packit Service aef062
Packit Service aef062
long int
Packit Service aef062
__lround (double x)
Packit Service aef062
{
Packit Service aef062
  long int y;
Packit Service aef062
  /* The z196 zarch "convert to fixed" (cgdbra) instruction is rounding
Packit Service aef062
     x to the nearest integer with "ties away from 0" rounding mode
Packit Service aef062
     (M3-field: 1) where inexact exceptions are suppressed (M4-field: 4).  */
Packit Service aef062
  __asm__ (INSN " %0,1,%1,4" : "=d" (y) : "f" (x) : "cc");
Packit Service aef062
  return y;
Packit Service aef062
}
Packit Service aef062
libm_alias_double (__lround, lround)
Packit Service aef062
Packit Service aef062
#else
Packit Service aef062
# include <sysdeps/ieee754/dbl-64/s_lround.c>
Packit Service aef062
#endif