1/* Entry points to finite-math-only compiler runs.
2 Copyright (C) 2011-2018 Free Software Foundation, Inc.
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
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _MATH_H
20# error "Never use <bits/math-finite.h> directly; include <math.h> instead."
21#endif
22
23#define __REDIRFROM(...) __REDIRFROM_X(__VA_ARGS__)
24
25#define __REDIRTO(...) __REDIRTO_X(__VA_ARGS__)
26
27#define __MATH_REDIRCALL_X(from, args, to) \
28 extern _Mdouble_ __REDIRECT_NTH (from, args, to)
29#define __MATH_REDIRCALL(function, reentrant, args) \
30 __MATH_REDIRCALL_X \
31 (__REDIRFROM (function, reentrant), args, \
32 __REDIRTO (function, reentrant))
33#define __MATH_REDIRCALL_2(from, reentrant, args, to) \
34 __MATH_REDIRCALL_X \
35 (__REDIRFROM (from, reentrant), args, \
36 __REDIRTO (to, reentrant))
37
38#define __MATH_REDIRCALL_INTERNAL(function, reentrant, args) \
39 __MATH_REDIRCALL_X \
40 (__REDIRFROM (__CONCAT (__, function), \
41 __CONCAT (reentrant, _finite)), \
42 args, __REDIRTO (function, _r))
43
44
45/* acos. */
46__MATH_REDIRCALL (acos, , (_Mdouble_));
47
48#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
49/* acosh. */
50__MATH_REDIRCALL (acosh, , (_Mdouble_));
51#endif
52
53/* asin. */
54__MATH_REDIRCALL (asin, , (_Mdouble_));
55
56/* atan2. */
57__MATH_REDIRCALL (atan2, , (_Mdouble_, _Mdouble_));
58
59#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
60/* atanh. */
61__MATH_REDIRCALL (atanh, , (_Mdouble_));
62#endif
63
64/* cosh. */
65__MATH_REDIRCALL (cosh, , (_Mdouble_));
66
67/* exp. */
68__MATH_REDIRCALL (exp, , (_Mdouble_));
69
70#if __GLIBC_USE (IEC_60559_FUNCS_EXT)
71/* exp10. */
72__MATH_REDIRCALL (exp10, , (_Mdouble_));
73#endif
74
75#ifdef __USE_ISOC99
76/* exp2. */
77__MATH_REDIRCALL (exp2, , (_Mdouble_));
78#endif
79
80/* fmod. */
81__MATH_REDIRCALL (fmod, , (_Mdouble_, _Mdouble_));
82
83#if defined __USE_XOPEN || defined __USE_ISOC99
84/* hypot. */
85__MATH_REDIRCALL (hypot, , (_Mdouble_, _Mdouble_));
86#endif
87
88#if (__MATH_DECLARING_DOUBLE && (defined __USE_MISC || defined __USE_XOPEN)) \
89 || (!__MATH_DECLARING_DOUBLE && defined __USE_MISC)
90/* j0. */
91__MATH_REDIRCALL (j0, , (_Mdouble_));
92
93/* y0. */
94__MATH_REDIRCALL (y0, , (_Mdouble_));
95
96/* j1. */
97__MATH_REDIRCALL (j1, , (_Mdouble_));
98
99/* y1. */
100__MATH_REDIRCALL (y1, , (_Mdouble_));
101
102/* jn. */
103__MATH_REDIRCALL (jn, , (int, _Mdouble_));
104
105/* yn. */
106__MATH_REDIRCALL (yn, , (int, _Mdouble_));
107#endif
108
109#ifdef __USE_MISC
110/* lgamma_r. */
111__MATH_REDIRCALL (lgamma, _r, (_Mdouble_, int *));
112#endif
113
114/* Redirect __lgammal_r_finite to __lgamma_r_finite when __NO_LONG_DOUBLE_MATH
115 is set and to itself otherwise. It also redirects __lgamma_r_finite and
116 __lgammaf_r_finite to themselves. */
117__MATH_REDIRCALL_INTERNAL (lgamma, _r, (_Mdouble_, int *));
118
119#if ((defined __USE_XOPEN || defined __USE_ISOC99) \
120 && defined __extern_always_inline)
121/* lgamma. */
122__extern_always_inline _Mdouble_
123__NTH (__REDIRFROM (lgamma, ) (_Mdouble_ __d))
124{
125# if defined __USE_MISC || defined __USE_XOPEN
126 return __REDIRTO (lgamma, _r) (__d, &signgam);
127# else
128 int __local_signgam = 0;
129 return __REDIRTO (lgamma, _r) (__d, &__local_signgam);
130# endif
131}
132#endif
133
134#if ((defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)) \
135 && defined __extern_always_inline) && !__MATH_DECLARING_FLOATN
136/* gamma. */
137__extern_always_inline _Mdouble_
138__NTH (__REDIRFROM (gamma, ) (_Mdouble_ __d))
139{
140 return __REDIRTO (lgamma, _r) (__d, &signgam);
141}
142#endif
143
144/* log. */
145__MATH_REDIRCALL (log, , (_Mdouble_));
146
147/* log10. */
148__MATH_REDIRCALL (log10, , (_Mdouble_));
149
150#ifdef __USE_ISOC99
151/* log2. */
152__MATH_REDIRCALL (log2, , (_Mdouble_));
153#endif
154
155/* pow. */
156__MATH_REDIRCALL (pow, , (_Mdouble_, _Mdouble_));
157
158#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
159/* remainder. */
160__MATH_REDIRCALL (remainder, , (_Mdouble_, _Mdouble_));
161#endif
162
163#if ((__MATH_DECLARING_DOUBLE \
164 && (defined __USE_MISC \
165 || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8))) \
166 || (!defined __MATH_DECLARE_LDOUBLE && defined __USE_MISC)) \
167 && !__MATH_DECLARING_FLOATN
168/* scalb. */
169__MATH_REDIRCALL (scalb, , (_Mdouble_, _Mdouble_));
170#endif
171
172/* sinh. */
173__MATH_REDIRCALL (sinh, , (_Mdouble_));
174
175/* sqrt. */
176__MATH_REDIRCALL (sqrt, , (_Mdouble_));
177
178#if defined __USE_ISOC99 && defined __extern_always_inline
179/* tgamma. */
180extern _Mdouble_
181__REDIRFROM (__gamma, _r_finite) (_Mdouble_, int *);
182
183__extern_always_inline _Mdouble_
184__NTH (__REDIRFROM (tgamma, ) (_Mdouble_ __d))
185{
186 int __local_signgam = 0;
187 _Mdouble_ __res = __REDIRTO (gamma, _r) (__d, &__local_signgam);
188 return __local_signgam < 0 ? -__res : __res;
189}
190#endif
191
192#undef __REDIRFROM
193#undef __REDIRTO
194#undef __MATH_REDIRCALL
195#undef __MATH_REDIRCALL_2
196#undef __MATH_REDIRCALL_INTERNAL
197#undef __MATH_REDIRCALL_X
198