|
Packit Service |
4852b2 |
/* llrint() - S390 version.
|
|
Packit Service |
4852b2 |
Copyright (C) 2019 Free Software Foundation, Inc.
|
|
Packit Service |
4852b2 |
|
|
Packit Service |
4852b2 |
This file is part of the GNU C Library.
|
|
Packit Service |
4852b2 |
|
|
Packit Service |
4852b2 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
4852b2 |
modify it under the terms of the GNU Lesser General Public License as
|
|
Packit Service |
4852b2 |
published by the Free Software Foundation; either version 2.1 of the
|
|
Packit Service |
4852b2 |
License, or (at your option) any later version.
|
|
Packit Service |
4852b2 |
|
|
Packit Service |
4852b2 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
4852b2 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4852b2 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4852b2 |
Lesser General Public License for more details.
|
|
Packit Service |
4852b2 |
|
|
Packit Service |
4852b2 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
4852b2 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
4852b2 |
<https://www.gnu.org/licenses/>. */
|
|
Packit Service |
4852b2 |
|
|
Packit Service |
4852b2 |
#if defined __s390x__ && defined HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
|
|
Packit Service |
4852b2 |
/* We only support s390x as on s390 a long long int refers to a register pair
|
|
Packit Service |
4852b2 |
of two 4byte registers instead of a 8byte register which is produced by the
|
|
Packit Service |
4852b2 |
instruction.
|
|
Packit Service |
4852b2 |
Note: On s390 this instruction would only be used if build with -mzarch. */
|
|
Packit Service |
4852b2 |
# include <math.h>
|
|
Packit Service |
4852b2 |
# include <libm-alias-double.h>
|
|
Packit Service |
4852b2 |
|
|
Packit Service |
4852b2 |
long long int
|
|
Packit Service |
4852b2 |
__llrint (double x)
|
|
Packit Service |
4852b2 |
{
|
|
Packit Service |
4852b2 |
long long int y;
|
|
Packit Service |
4852b2 |
/* The z196 zarch "convert to fixed" (cgdbra) instruction is rounding
|
|
Packit Service |
4852b2 |
according to current rounding mode (M3-field: 0).
|
|
Packit Service |
4852b2 |
First convert x with suppressed inexact exception and check if the
|
|
Packit Service |
4852b2 |
resulting value is beyond the target limits (indicated by cc=3;
|
|
Packit Service |
4852b2 |
Note: a nan is also indicated by cc=3).
|
|
Packit Service |
4852b2 |
If the resulting value is within the target limits, redo
|
|
Packit Service |
4852b2 |
without suppressing the inexact exception. */
|
|
Packit Service |
4852b2 |
__asm__ ("cgdbra %0,0,%1,4 \n\t"
|
|
Packit Service |
4852b2 |
"jo 1f \n\t"
|
|
Packit Service |
4852b2 |
"cgdbra %0,0,%1,0 \n\t"
|
|
Packit Service |
4852b2 |
"1:"
|
|
Packit Service |
4852b2 |
: "=&d" (y) : "f" (x) : "cc");
|
|
Packit Service |
4852b2 |
return y;
|
|
Packit Service |
4852b2 |
}
|
|
Packit Service |
4852b2 |
libm_alias_double (__llrint, llrint)
|
|
Packit Service |
4852b2 |
|
|
Packit Service |
4852b2 |
#else
|
|
Packit Service |
4852b2 |
# include <sysdeps/ieee754/dbl-64/s_llrint.c>
|
|
Packit Service |
4852b2 |
#endif
|