]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/powerpc/bits/floatn.h
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / powerpc / bits / floatn.h
CommitLineData
f819dbea 1/* Macros to control TS 18661-3 glibc features on powerpc.
dff8da6b 2 Copyright (C) 2017-2024 Free Software Foundation, Inc.
f819dbea
PM
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
f819dbea
PM
18
19#ifndef _BITS_FLOATN_H
20#define _BITS_FLOATN_H
21
22#include <features.h>
4e2dff67 23#include <bits/long-double.h>
f819dbea
PM
24
25/* Defined to 1 if the current compiler invocation provides a
26 floating-point type with the IEEE 754 binary128 format, and this glibc
27 includes corresponding *f128 interfaces for it. */
28#if defined _ARCH_PWR8 && defined __LITTLE_ENDIAN__ && (_CALL_ELF == 2) \
4e2dff67 29 && defined __FLOAT128__ && !defined __NO_LONG_DOUBLE_MATH
f819dbea
PM
30# define __HAVE_FLOAT128 1
31#else
32# define __HAVE_FLOAT128 0
33#endif
34
35/* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct
5db7d705
TMQMF
36 from the default float, double and long double types in this glibc, i.e.
37 calls to the binary128 functions go to *f128 symbols instead of *l. */
f819dbea
PM
38#if __HAVE_FLOAT128
39# define __HAVE_DISTINCT_FLOAT128 1
40#else
41# define __HAVE_DISTINCT_FLOAT128 0
42#endif
43
a23aa5b7
JM
44/* Defined to 1 if the current compiler invocation provides a
45 floating-point type with the right format for _Float64x, and this
46 glibc includes corresponding *f64x interfaces for it. */
47#define __HAVE_FLOAT64X __HAVE_FLOAT128
48
49/* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format
50 of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has
51 the format of _Float128, which must be different from that of long
52 double. */
53#define __HAVE_FLOAT64X_LONG_DOUBLE 0
54
015c6dc2
JM
55#ifndef __ASSEMBLER__
56
f819dbea
PM
57/* Defined to concatenate the literal suffix to be used with _Float128
58 types, if __HAVE_FLOAT128 is 1. */
015c6dc2 59# if __HAVE_FLOAT128
3e5760fc 60# if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0))
f819dbea 61/* The literal suffix (f128) exist for powerpc only since GCC 7.0. */
5db7d705
TMQMF
62# if __LDBL_MANT_DIG__ == 113
63# define __f128(x) x##l
64# else
65# define __f128(x) x##q
66# endif
015c6dc2
JM
67# else
68# define __f128(x) x##f128
69# endif
f819dbea 70# endif
f819dbea
PM
71
72/* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */
015c6dc2 73# if __HAVE_FLOAT128
3e5760fc 74# if __LDBL_MANT_DIG__ == 113 && defined __cplusplus && !__GNUC_PREREQ (13, 0)
5db7d705
TMQMF
75typedef long double _Float128;
76# define __CFLOAT128 _Complex long double
3e5760fc 77# elif !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0))
5db7d705
TMQMF
78/* The type _Float128 exist for powerpc only since GCC 7.0. */
79typedef __float128 _Float128;
80/* Add a typedef for older GCC and C++ compilers which don't natively support
f819dbea
PM
81 _Complex _Float128. */
82typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__KC__)));
015c6dc2
JM
83# define __CFLOAT128 __cfloat128
84# else
85# define __CFLOAT128 _Complex _Float128
86# endif
f819dbea 87# endif
f819dbea
PM
88
89/* The remaining of this file provides support for older compilers. */
015c6dc2 90# if __HAVE_FLOAT128
f819dbea 91/* Builtin __builtin_huge_valf128 doesn't exist before GCC 7.0. */
015c6dc2
JM
92# if !__GNUC_PREREQ (7, 0)
93# define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())
94# endif
f819dbea
PM
95
96/* The following builtins (suffixed with 'q') are available in GCC >= 6.2,
97 which is the minimum version required for float128 support on powerpc64le.
98 Since GCC 7.0 the builtins suffixed with f128 are also available, then
99 there is no need to redefined them. */
015c6dc2
JM
100# if !__GNUC_PREREQ (7, 0)
101# define __builtin_copysignf128 __builtin_copysignq
102# define __builtin_fabsf128 __builtin_fabsq
103# define __builtin_inff128 __builtin_infq
104# define __builtin_nanf128 __builtin_nanq
105# define __builtin_nansf128 __builtin_nansq
106# endif
f819dbea 107
8466ee1c
GG
108/* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
109 e.g.: __builtin_signbitf128, before GCC 6. However, there has never
110 been a __builtin_signbitf128 in GCC and the type-generic builtin is
111 only available since GCC 6. */
015c6dc2
JM
112# if !__GNUC_PREREQ (6, 0)
113# define __builtin_signbitf128 __signbitf128
114# endif
115
8466ee1c
GG
116# endif
117
015c6dc2 118#endif /* !__ASSEMBLER__. */
f819dbea 119
797ba44b
JM
120#include <bits/floatn-common.h>
121
f819dbea 122#endif /* _BITS_FLOATN_H */