1 /* Stub for defining degree-valued trigonometric functions in libgfortran.
2 Copyright (C) 2020 Free Software Foundation, Inc.
3 Contributed by Steven G. Kargl <kargl@gcc.gnu.org>
4 and Fritz Reese <foreese@gcc.gnu.org>
6 This file is part of the GNU Fortran runtime library (libgfortran).
8 Libgfortran is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public
10 License as published by the Free Software Foundation; either
11 version 3 of the License, or (at your option) any later version.
13 Libgfortran is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
28 This replaces all GMP/MPFR functions used by trigd.inc with native versions.
29 The precision is defined by FTYPE defined before including this file.
30 The module which includes this file must define the following:
32 FTYPE -- floating point type
33 SIND, COSD, TAND -- names of the functions to define
34 SUFFIX(x) -- add a literal suffix for floating point constants (f, ...)
36 COSD_SMALL [optional] -- for x <= COSD_SMALL, COSD(x) = 1 if set
37 TINY [optional] -- subtract from 1 under the above condition if set
38 SIND_SMALL [optional] -- for x <= SIND_SMALL, SIND(x) = D2R(x) if set
39 COSD30 -- literal value of COSD(30) to the precision of FTYPE
40 PIO180H -- upper bits of pi/180 for FMA
41 PIO180L -- lower bits of pi/180 for FMA
46 #define GFC_RND_MODE 0
48 #define RETURN(x) return (x)
50 #define ISFINITE(x) isfinite(x)
51 #define mpfr_init(x) do { } while (0)
52 #define mpfr_init_set_ui(x, v, rnd) (x = (v))
53 #define mpfr_clear(x) do { } while (0)
54 #define mpfr_swap(x, y) do { FTYPE z = y; y = x; x = z; } while (0)
55 #define mpfr_copysign(rop, op1, op2, rnd) rop = SUFFIX(copysign)((op1), (op2))
56 #define mpfr_fmod(rop, x, d, rnd) (rop = SUFFIX(fmod)((x), (d)))
57 #define mpfr_abs(rop, op, rnd) (rop = SUFFIX(fabs)(op))
58 #define mpfr_cmp_ld(x, y) ((x) - (y))
59 #define mpfr_cmp_ui(x, n) ((x) - (n))
60 #define mpfr_zero_p(x) ((x) == 0)
61 #define mpfr_set(rop, x, rnd) (rop = (x))
62 #define mpfr_set_zero(rop, s) (rop = SUFFIX(copysign)(0, (s)))
63 #define mpfr_set_inf(rop, s) (rop = ((s)*-2 + 1) * INFINITY)
64 #define mpfr_set_ui(rop, n, rnd) (rop = (n))
65 #define mpfr_set_si(rop, n, rnd) (rop = (n))
66 #define mpfr_set_ld(rop, x, rnd) (rop = (x))
67 #define mpfr_set_si_2exp(rop, op, exp, rnd) (rop = (0x1.p##exp))
68 #define mpfr_get_z(rop, x, rnd) ((rop = (int)(x)), (rop - (x)))
69 #define mpfr_mul(rop, op1, op2, rnd) (rop = ((op1) * (op2)))
70 #define mpfr_sub_d(rop, op1, op2, rnd) (rop = ((op1) - (op2)))
71 #define mpfr_sub_ui(rop, op1, op2, rnd) (rop = ((op1) - (op2)))
72 #define mpfr_sub(rop, op1, op2, rnd) (rop = ((op1) - (op2)))
73 #define mpfr_ui_sub(rop, op1, op2, rnd) (rop = ((op1) - (op2)))
74 #define mpfr_neg(rop, op, rnd) (rop = -(op))
75 #define mpfr_sin(rop, x, rnd) (rop = SUFFIX(sin)(x))
76 #define mpfr_cos(rop, x, rnd) (rop = SUFFIX(cos)(x))
77 #define mpfr_tan(rop, x, rnd) (rop = SUFFIX(tan)(x))
79 #define mpz_init(n) do { } while (0)
80 #define mpz_clear(x) do { } while (0)
81 #define mpz_cmp_ui(x, y) ((x) - (y))
82 #define mpz_divisible_ui_p(n, d) ((n) % (d) == 0)
84 #define FMA(x,y,z) SUFFIX(fma)((x), (y), (z))
85 #define D2R(x) (x = FMA((x), PIO180H, (x) * PIO180L))
87 #define SET_COSD30(x) (x = COSD30)
90 extern FTYPE SIND (FTYPE);
93 extern FTYPE COSD (FTYPE);
96 extern FTYPE TAND (FTYPE);
110 #undef mpfr_init_set_ui
124 #undef mpfr_set_si_2exp
139 #undef mpz_divisible_ui_p