stdlib: Fix stdbit.h with -Wconversion for clang
[glibc.git] / sysdeps / alpha / sfp-machine.h
blob2d40ecfebe871ed5fbf92a2592963fda1d0dd72e
1 /* Machine-dependent software floating-point definitions.
2 Alpha userland IEEE 128-bit version.
3 Copyright (C) 2004-2024 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
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
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
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.
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/>. */
20 #include <fenv_libc.h>
22 #define _FP_W_TYPE_SIZE 64
23 #define _FP_W_TYPE unsigned long
24 #define _FP_WS_TYPE signed long
25 #define _FP_I_TYPE long
27 #define _FP_MUL_MEAT_S(R,X,Y) \
28 _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y)
29 #define _FP_MUL_MEAT_D(R,X,Y) \
30 _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
31 #define _FP_MUL_MEAT_Q(R,X,Y) \
32 _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
34 #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm)
35 #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
36 #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
38 #define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
39 #define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1)
40 #define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1
41 #define _FP_NANSIGN_S 0
42 #define _FP_NANSIGN_D 0
43 #define _FP_NANSIGN_Q 0
45 #define _FP_KEEPNANFRACP 1
46 #define _FP_QNANNEGATEDP 0
48 /* Alpha Architecture Handbook, 4.7.10.4 sez that we should prefer any
49 type of NaN in Fb, then Fa. */
50 #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
51 do { \
52 R##_s = Y##_s; \
53 _FP_FRAC_COPY_##wc(R,X); \
54 R##_c = FP_CLS_NAN; \
55 } while (0)
57 /* Rounding mode settings. */
58 #define FP_RND_NEAREST FE_TONEAREST
59 #define FP_RND_ZERO FE_TOWARDZERO
60 #define FP_RND_PINF FE_UPWARD
61 #define FP_RND_MINF FE_DOWNWARD
63 /* Obtain the current rounding mode. It's given as an argument to
64 all the Ots functions, with 4 meaning "dynamic". */
65 #define FP_ROUNDMODE _round
67 /* Exception flags. */
68 #define FP_EX_INVALID FE_INVALID
69 #define FP_EX_OVERFLOW FE_OVERFLOW
70 #define FP_EX_UNDERFLOW FE_UNDERFLOW
71 #define FP_EX_DIVZERO FE_DIVBYZERO
72 #define FP_EX_INEXACT FE_INEXACT
74 #define _FP_TININESS_AFTER_ROUNDING 1
76 #define FP_INIT_ROUNDMODE \
77 do { \
78 if (__builtin_expect (_round == 4, 0)) \
79 { \
80 unsigned long t; \
81 __asm__ __volatile__("excb; mf_fpcr %0" : "=f"(t)); \
82 _round = (t >> FPCR_ROUND_SHIFT) & 3; \
83 } \
84 } while (0)
86 /* We copy the libm function into libc for soft-fp. */
87 extern int __feraiseexcept (int __excepts) attribute_hidden;
89 #define FP_HANDLE_EXCEPTIONS \
90 do { \
91 if (__builtin_expect (_fex, 0)) \
92 __feraiseexcept (_fex); \
93 } while (0)
95 #define FP_TRAPPING_EXCEPTIONS \
96 ((__ieee_get_fp_control () & SWCR_ENABLE_MASK) << SWCR_ENABLE_SHIFT)