Blame sysdeps/s390/fpu/s_lroundl.c

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