Provide a replacement for frexpl() if the system has it but it doesn't work.
[gnulib.git] / lib / math_.h
1 /* A GNU-like <math.h>.
2
3    Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
10    This program 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    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #ifndef _GL_MATH_H
20 #define _GL_MATH_H
21
22 #include @ABSOLUTE_MATH_H@
23
24
25 /* The definition of GL_LINK_WARNING is copied here.  */
26
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32
33 /* Write x as
34      x = mantissa * 2^exp
35    where
36      If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
37      If x is zero: mantissa = x, exp = 0.
38      If x is infinite or NaN: mantissa = x, exp unspecified.
39    Store exp and return mantissa.  */
40 #if @GNULIB_FREXP@
41 # if @REPLACE_FREXP@
42 #  define frexp rpl_frexp
43 extern double frexp (double x, int *exp);
44 # endif
45 #elif defined GNULIB_POSIXCHECK
46 # undef frexp
47 # define frexp(x,e) \
48     (GL_LINK_WARNING ("frexp is unportable - " \
49                       "use gnulib module frexp for portability"), \
50      frexp (x, e))
51 #endif
52
53
54 #if @GNULIB_MATHL@ || !@HAVE_DECL_ACOSL@
55 extern long double acosl (long double x);
56 #endif
57 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
58 # undef acosl
59 # define acosl(x) \
60     (GL_LINK_WARNING ("acosl is unportable - " \
61                       "use gnulib module mathl for portability"), \
62      acosl (x))
63 #endif
64
65 #if @GNULIB_MATHL@ || !@HAVE_DECL_ASINL@
66 extern long double asinl (long double x);
67 #endif
68 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
69 # undef asinl
70 # define asinl(x) \
71     (GL_LINK_WARNING ("asinl is unportable - " \
72                       "use gnulib module mathl for portability"), \
73      asinl (x))
74 #endif
75
76 #if @GNULIB_MATHL@ || !@HAVE_DECL_ATANL@
77 extern long double atanl (long double x);
78 #endif
79 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
80 # undef atanl
81 # define atanl(x) \
82     (GL_LINK_WARNING ("atanl is unportable - " \
83                       "use gnulib module mathl for portability"), \
84      atanl (x))
85 #endif
86
87 #if @GNULIB_MATHL@ || !@HAVE_DECL_CEILL@
88 extern long double ceill (long double x);
89 #endif
90 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
91 # undef ceill
92 # define ceill(x) \
93     (GL_LINK_WARNING ("ceill is unportable - " \
94                       "use gnulib module mathl for portability"), \
95      ceill (x))
96 #endif
97
98 #if @GNULIB_MATHL@ || !@HAVE_DECL_COSL@
99 extern long double cosl (long double x);
100 #endif
101 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
102 # undef cosl
103 # define cosl(x) \
104     (GL_LINK_WARNING ("cosl is unportable - " \
105                       "use gnulib module mathl for portability"), \
106      cosl (x))
107 #endif
108
109 #if @GNULIB_MATHL@ || !@HAVE_DECL_EXPL@
110 extern long double expl (long double x);
111 #endif
112 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
113 # undef expl
114 # define expl(x) \
115     (GL_LINK_WARNING ("expl is unportable - " \
116                       "use gnulib module mathl for portability"), \
117      expl (x))
118 #endif
119
120 #if @GNULIB_MATHL@ || !@HAVE_DECL_FLOORL@
121 extern long double floorl (long double x);
122 #endif
123 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
124 # undef floorl
125 # define floorl(x) \
126     (GL_LINK_WARNING ("floorl is unportable - " \
127                       "use gnulib module mathl for portability"), \
128      floorl (x))
129 #endif
130
131 /* Write x as
132      x = mantissa * 2^exp
133    where
134      If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
135      If x is zero: mantissa = x, exp = 0.
136      If x is infinite or NaN: mantissa = x, exp unspecified.
137    Store exp and return mantissa.  */
138 #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@
139 # define frexpl rpl_frexpl
140 #endif
141 #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@
142 extern long double frexpl (long double x, int *exp);
143 #endif
144 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
145 # undef frexpl
146 # define frexpl(x,e) \
147     (GL_LINK_WARNING ("frexpl is unportable - " \
148                       "use gnulib module frexpl for portability"), \
149      frexpl (x, e))
150 #endif
151
152 #if @GNULIB_MATHL@ || !@HAVE_DECL_LDEXPL@
153 extern long double ldexpl (long double x, int exp);
154 #endif
155 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
156 # undef ldexpl
157 # define ldexpl(x,e) \
158     (GL_LINK_WARNING ("ldexpl is unportable - " \
159                       "use gnulib module mathl for portability"), \
160      ldexpl (x, e))
161 #endif
162
163 #if @GNULIB_MATHL@ || !@HAVE_DECL_LOGL@
164 extern long double logl (long double x);
165 #endif
166 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
167 # undef logl
168 # define logl(x) \
169     (GL_LINK_WARNING ("logl is unportable - " \
170                       "use gnulib module mathl for portability"), \
171      logl (x))
172 #endif
173
174 #if @GNULIB_MATHL@ || !@HAVE_DECL_SINL@
175 extern long double sinl (long double x);
176 #endif
177 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
178 # undef sinl
179 # define sinl(x) \
180     (GL_LINK_WARNING ("sinl is unportable - " \
181                       "use gnulib module mathl for portability"), \
182      sinl (x))
183 #endif
184
185 #if @GNULIB_MATHL@ || !@HAVE_DECL_SQRTL@
186 extern long double sqrtl (long double x);
187 #endif
188 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
189 # undef sqrtl
190 # define sqrtl(x) \
191     (GL_LINK_WARNING ("sqrtl is unportable - " \
192                       "use gnulib module mathl for portability"), \
193      sqrtl (x))
194 #endif
195
196 #if @GNULIB_MATHL@ || !@HAVE_DECL_TANL@
197 extern long double tanl (long double x);
198 #endif
199 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
200 # undef tanl
201 # define tanl(x) \
202     (GL_LINK_WARNING ("tanl is unportable - " \
203                       "use gnulib module mathl for portability"), \
204      tanl (x))
205 #endif
206
207
208 #ifdef __cplusplus
209 }
210 #endif
211
212 #endif