1/* lroundl() - S390 version.
2 Copyright (C) 2019-2024 Free Software Foundation, Inc.
3
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 License as
8 published by the Free Software Foundation; either version 2.1 of the
9 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#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
21# include <math.h>
22# include <math_private.h>
23# include <libm-alias-ldouble.h>
24
25/* The sizeof (long int) differs between s390x (8byte) and s390 (4byte).
26 Thus we need different instructions as the target size is encoded there.
27 Note: On s390 this instruction is only used if build with -mzarch. */
28# ifdef __s390x__
29# define INSN "cgxbra"
30# else
31# define INSN "cfxbra"
32# endif
33
34long int
35__lroundl (_Float128 x)
36{
37 long int y;
38 /* The z196 zarch "convert to fixed" (cgxbra) instruction is rounding
39 x to the nearest integer with "ties away from 0" rounding mode
40 (M3-field: 1) where inexact exceptions are suppressed (M4-field: 4). */
41 __asm__ (INSN " %0,1,%1,4" : "=d" (y) : "f" (x) : "cc");
42 return y;
43}
44libm_alias_ldouble (__lround, lround)
45
46#else
47# include <sysdeps/ieee754/ldbl-128/s_lroundl.c>
48#endif
49

source code of glibc/sysdeps/s390/fpu/s_lroundl.c