Blame sysdeps/s390/fpu/s_lrintl.c

Packit Service cd9092
/* lrintl() - S390 version.
Packit Service cd9092
   Copyright (C) 2019 Free Software Foundation, Inc.
Packit Service cd9092
Packit Service cd9092
   This file is part of the GNU C Library.
Packit Service cd9092
Packit Service cd9092
   The GNU C Library is free software; you can redistribute it and/or
Packit Service cd9092
   modify it under the terms of the GNU Lesser General Public License as
Packit Service cd9092
   published by the Free Software Foundation; either version 2.1 of the
Packit Service cd9092
   License, or (at your option) any later version.
Packit Service cd9092
Packit Service cd9092
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service cd9092
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service cd9092
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service cd9092
   Lesser General Public License for more details.
Packit Service cd9092
Packit Service cd9092
   You should have received a copy of the GNU Lesser General Public
Packit Service cd9092
   License along with the GNU C Library; if not, see
Packit Service cd9092
   <https://www.gnu.org/licenses/>.  */
Packit Service cd9092
Packit Service cd9092
#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
Packit Service cd9092
# include <math.h>
Packit Service cd9092
# include <math_private.h>
Packit Service cd9092
# include <libm-alias-ldouble.h>
Packit Service cd9092
Packit Service cd9092
/* The sizeof (long int) differs between s390x (8byte) and s390 (4byte).
Packit Service cd9092
   Thus we need different instructions as the target size is encoded there.
Packit Service cd9092
   Note: On s390 this instruction is only used if build with -mzarch.  */
Packit Service cd9092
# ifdef __s390x__
Packit Service cd9092
#  define INSN "cgxbra"
Packit Service cd9092
# else
Packit Service cd9092
#  define INSN "cfxbra"
Packit Service cd9092
# endif
Packit Service cd9092
Packit Service cd9092
long int
Packit Service cd9092
__lrintl (_Float128 x)
Packit Service cd9092
{
Packit Service cd9092
  long int y;
Packit Service cd9092
  /* The z196 zarch "convert to fixed" (cgxbra) instruction is rounding
Packit Service cd9092
     according to current rounding mode (M3-field: 0).
Packit Service cd9092
     First convert x with suppressed inexact exception and check if the
Packit Service cd9092
     resulting value is beyond the target limits (indicated by cc=3;
Packit Service cd9092
     Note: a nan is also indicated by cc=3).
Packit Service cd9092
     If the resulting value is within the target limits, redo
Packit Service cd9092
     without suppressing the inexact exception.  */
Packit Service cd9092
  __asm__ (INSN " %0,0,%1,4 \n\t"
Packit Service cd9092
	   "jo 1f \n\t"
Packit Service cd9092
	   INSN " %0,0,%1,0 \n\t"
Packit Service cd9092
	   "1:"
Packit Service cd9092
	   : "=&d" (y) : "f" (x) : "cc");
Packit Service cd9092
  return y;
Packit Service cd9092
}
Packit Service cd9092
libm_alias_ldouble (__lrint, lrint)
Packit Service cd9092
Packit Service cd9092
#else
Packit Service cd9092
# include <sysdeps/ieee754/ldbl-128/s_lrintl.c>
Packit Service cd9092
#endif