Debian Codegraph @

libgcobol/libgcobol-fp.h

raw
1 /* Copyright The GNU Toolchain Authors. */
2
3 /* This file is part of the GNU COBOL runtime library (libgcobol).
4
5 libgcobol is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 3 of the License, or (at your option) any later version.
9
10 libgcobol 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
13 GNU General Public License for more details.
14
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
18
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
23
24 /* You must include "config.h" before this file. */
25
26 #if __LDBL_MANT_DIG__ == 113 && __LDBL_MIN_EXP__ == -16381
27 // Use long double, l suffix on calls, l or L suffix in literals
28 # define GCOB_FP128 long double
29 # define GCOB_FP128_LITERAL(lit) (lit ## l)
30 # define FP128_FUNC(funcname) funcname ## l
31 # define FP128_FMT "L"
32 # define strtofp128(nptr, endptr) strtold(nptr, endptr)
33 # define strfromfp128(str, n, format, fp) snprintf(str, n, format, fp)
34 #elif __FLT128_MANT_DIG__ == 113 && __FLT128_MIN_EXP__ == -16381 \
35 && defined(USE_IEC_60559)
36 // Use _Float128, f128 suffix on calls, f128 or F128 suffix on literals
37 # define GCOB_FP128 _Float128
38 # define GCOB_FP128_LITERAL(lit) (lit ## f128)
39 # define FP128_FUNC(funcname) funcname ## f128
40 # define FP128_FMT ""
41 # define strtofp128(nptr, endptr) strtof128(nptr, endptr)
42 # define strfromfp128(str, n, format, fp) strfromf128(str, n, format, fp)
43 #elif __FLT128_MANT_DIG__ == 113 && __FLT128_MIN_EXP__ == -16381
44 // Use __float128, q suffix on calls, q or Q suffix on literals
45 # define GCOB_FP128 __float128
46 # define GCOB_FP128_LITERAL(lit) (lit ## q)
47 # define FP128_FUNC(funcname) funcname ## q
48 # define FP128_FMT "Q"
49 # define strtofp128(nptr, endptr) strtoflt128(nptr, endptr)
50 # define strfromfp128(str, n, format, fp) quadmath_snprintf(str, n, format, fp)
51 #else
52 # error "libgcobol requires 128b floating point"
53 #endif
54
55 #if USE_QUADMATH
56 /* We will assume that unless we found the 128 to/from string and some
57 representative trig functions, we need libquadmath to support those. */
58 # include "quadmath.h"
59 #endif