1 /* GCC Quad-Precision Math Library
2 Copyright (C) 2010 Free Software Foundation, Inc.
3 Written by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
5 This file is part of the libiberty library.
6 Libiberty is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 Libiberty 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 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with libiberty; see the file COPYING.LIB. If
18 not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19 Boston, MA 02110-1301, USA. */
21 #ifndef QUADMATH_IMP_H
22 #define QUADMATH_IMP_H
29 // Prototypes for internal functions
30 extern int32_t __quadmath_rem_pio2q (__float128
, __float128
*);
31 extern void __quadmath_kernel_sincosq (__float128
, __float128
, __float128
*,
33 extern __float128
__quadmath_kernel_sinq (__float128
, __float128
, int);
34 extern __float128
__quadmath_kernel_cosq (__float128
, __float128
);
38 // Frankly, if you have __float128, you have 64-bit integers, right?
44 // If we don't have macros to know endianess, assume little endian
45 #if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
46 # define __LITTLE_ENDIAN__ 1
50 // Main union type we use to manipulate the floating-point type
60 uint64_t mant_high
:48;
65 uint64_t mant_high
:48;
103 unsigned exponent
:15;
104 unsigned quiet_nan
:1;
105 uint64_t mant_high
:47;
106 uint64_t mant_low
:64;
108 #if __LITTLE_ENDIAN__
109 uint64_t mant_low
:64;
110 uint64_t mant_high
:47;
111 unsigned quiet_nan
:1;
112 unsigned exponent
:15;
120 /* Get two 64 bit ints from a long double. */
121 #define GET_FLT128_WORDS64(ix0,ix1,d) \
123 ieee854_float128 u; \
125 (ix0) = u.words64.high; \
126 (ix1) = u.words64.low; \
129 /* Set a long double from two 64 bit ints. */
130 #define SET_FLT128_WORDS64(d,ix0,ix1) \
132 ieee854_float128 u; \
133 u.words64.high = (ix0); \
134 u.words64.low = (ix1); \
138 /* Get the more significant 64 bits of a long double mantissa. */
139 #define GET_FLT128_MSW64(v,d) \
141 ieee854_float128 u; \
143 (v) = u.words64.high; \
146 /* Set the more significant 64 bits of a long double mantissa from an int. */
147 #define SET_FLT128_MSW64(d,v) \
149 ieee854_float128 u; \
151 u.words64.high = (v); \
155 /* Get the least significant 64 bits of a long double mantissa. */
156 #define GET_FLT128_LSW64(v,d) \
158 ieee854_float128 u; \
160 (v) = u.words64.low; \
164 #define IEEE854_FLOAT128_BIAS 0x3fff