]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/linkage.m4
[to-be-committed] [RISC-V] Some basic patterns for zbkb code generation
[thirdparty/gcc.git] / libstdc++-v3 / linkage.m4
1 dnl
2 dnl This file contains macros for testing linkage.
3 dnl
4
5 dnl
6 dnl Check to see if the (math function) argument passed is
7 dnl declared when using the c++ compiler
8 dnl ASSUMES argument is a math function with ONE parameter
9 dnl
10 dnl GLIBCXX_CHECK_MATH_DECL_1
11 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_1], [
12 AC_MSG_CHECKING([for $1 declaration])
13 if test x${glibcxx_cv_func_$1_use+set} != xset; then
14 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
15 AC_LANG_SAVE
16 AC_LANG_CPLUSPLUS
17 AC_TRY_COMPILE([#include <math.h>
18 #ifdef HAVE_IEEEFP_H
19 #include <ieeefp.h>
20 #endif
21 ],
22 [ $1(0);],
23 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
24 AC_LANG_RESTORE
25 ])
26 fi
27 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
28 ])
29
30
31 dnl
32 dnl Check to see if the (math function) argument passed is
33 dnl 1) declared when using the c++ compiler
34 dnl 2) has "C" linkage
35 dnl
36 dnl Define HAVE_CARGF etc if "cargf" is declared and links
37 dnl
38 dnl argument 1 is name of function to check
39 dnl
40 dnl ASSUMES argument is a math function with ONE parameter
41 dnl
42 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1
43 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1], [
44 GLIBCXX_CHECK_MATH_DECL_1($1)
45 if test x$glibcxx_cv_func_$1_use = x"yes"; then
46 AC_CHECK_FUNCS($1)
47 fi
48 ])
49
50
51 dnl
52 dnl Like GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
53 dnl of functions at once. It's an all-or-nothing check -- either
54 dnl HAVE_XYZ is defined for each of the functions, or for none of them.
55 dnl Doing it this way saves significant configure time.
56 AC_DEFUN([GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1], [
57 define([funclist],patsubst($3,\(\w+\)\(\W*\),\1 ))dnl
58 AC_MSG_CHECKING([for $1 functions])
59 AC_CACHE_VAL(glibcxx_cv_func_$2_use, [
60 AC_LANG_SAVE
61 AC_LANG_CPLUSPLUS
62 AC_TRY_COMPILE([#include <math.h>],
63 patsubst(funclist,[\w+],[\& (0);]),
64 [glibcxx_cv_func_$2_use=yes],
65 [glibcxx_cv_func_$2_use=no])
66 AC_LANG_RESTORE])
67 AC_MSG_RESULT($glibcxx_cv_func_$2_use)
68 if test x$glibcxx_cv_func_$2_use = x"yes"; then
69 AC_CHECK_FUNCS(funclist)
70 fi
71 undefine([funclist])
72 ])
73
74 dnl
75 dnl Check to see if the (math function) argument passed is
76 dnl declared when using the c++ compiler
77 dnl ASSUMES argument is a math function with TWO parameters
78 dnl
79 dnl GLIBCXX_CHECK_MATH_DECL_2
80 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_2], [
81 AC_MSG_CHECKING([for $1 declaration])
82 if test x${glibcxx_cv_func_$1_use+set} != xset; then
83 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
84 AC_LANG_SAVE
85 AC_LANG_CPLUSPLUS
86 AC_TRY_COMPILE([#include <math.h>],
87 [ $1(0, 0);],
88 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
89 AC_LANG_RESTORE
90 ])
91 fi
92 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
93 ])
94
95 dnl
96 dnl Check to see if the (math function) argument passed is
97 dnl 1) declared when using the c++ compiler
98 dnl 2) has "C" linkage
99 dnl
100 dnl Define HAVE_CARGF etc if "cargf" is declared and links
101 dnl
102 dnl argument 1 is name of function to check
103 dnl
104 dnl ASSUMES argument is a math function with TWO parameters
105 dnl
106 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2
107 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2], [
108 GLIBCXX_CHECK_MATH_DECL_2($1)
109 if test x$glibcxx_cv_func_$1_use = x"yes"; then
110 AC_CHECK_FUNCS($1)
111 fi
112 ])
113
114
115 dnl
116 dnl Check to see if the (math function) argument passed is
117 dnl declared when using the c++ compiler
118 dnl ASSUMES argument is a math function with THREE parameters
119 dnl
120 dnl GLIBCXX_CHECK_MATH_DECL_3
121 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_3], [
122 AC_MSG_CHECKING([for $1 declaration])
123 if test x${glibcxx_cv_func_$1_use+set} != xset; then
124 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
125 AC_LANG_SAVE
126 AC_LANG_CPLUSPLUS
127 AC_TRY_COMPILE([#include <math.h>],
128 [ $1(0, 0, 0);],
129 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
130 AC_LANG_RESTORE
131 ])
132 fi
133 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
134 ])
135
136 dnl
137 dnl Check to see if the (math function) argument passed is
138 dnl 1) declared when using the c++ compiler
139 dnl 2) has "C" linkage
140 dnl
141 dnl Define HAVE_CARGF etc if "cargf" is declared and links
142 dnl
143 dnl argument 1 is name of function to check
144 dnl
145 dnl ASSUMES argument is a math function with THREE parameters
146 dnl
147 dnl GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3
148 AC_DEFUN([GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3], [
149 GLIBCXX_CHECK_MATH_DECL_3($1)
150 if test x$glibcxx_cv_func_$1_use = x"yes"; then
151 AC_CHECK_FUNCS($1)
152 fi
153 ])
154
155
156 dnl
157 dnl Check to see if the (stdlib function) argument passed is
158 dnl 1) declared when using the c++ compiler
159 dnl 2) has "C" linkage
160 dnl
161 dnl argument 1 is name of function to check
162 dnl
163 dnl ASSUMES argument is a stdlib function without parameters
164 dnl
165 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0
166 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_0], [
167 AC_MSG_CHECKING([for $1 declaration])
168 if test x${glibcxx_cv_func_$1_use+set} != xset; then
169 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
170 AC_LANG_SAVE
171 AC_LANG_CPLUSPLUS
172 AC_TRY_COMPILE([#include <stdlib.h>],
173 [ $1();],
174 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
175 AC_LANG_RESTORE
176 ])
177 fi
178 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
179 if test x$glibcxx_cv_func_$1_use = x"yes"; then
180 AC_CHECK_FUNCS($1)
181 fi
182 ])
183
184
185 dnl
186 dnl Check to see if the (stdlib function) argument passed is
187 dnl 1) declared when using the c++ compiler
188 dnl 2) has "C" linkage
189 dnl
190 dnl argument 1 is name of function to check
191 dnl
192 dnl ASSUMES argument is a stdlib function with ONE parameter
193 dnl
194 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1
195 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1], [
196 AC_MSG_CHECKING([for $1 declaration])
197 if test x${glibcxx_cv_func_$1_use+set} != xset; then
198 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
199 AC_LANG_SAVE
200 AC_LANG_CPLUSPLUS
201 AC_TRY_COMPILE([#include <stdlib.h>],
202 [ $1(0);],
203 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
204 AC_LANG_RESTORE
205 ])
206 fi
207 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
208 if test x$glibcxx_cv_func_$1_use = x"yes"; then
209 AC_CHECK_FUNCS($1)
210 fi
211 ])
212
213
214 dnl
215 dnl Check to see if the (stdlib function) argument passed is
216 dnl 1) declared when using the c++ compiler
217 dnl 2) has "C" linkage
218 dnl
219 dnl argument 1 is name of function to check
220 dnl
221 dnl ASSUMES argument is a stdlib function with TWO parameters
222 dnl
223 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2
224 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2], [
225 AC_MSG_CHECKING([for $1 declaration])
226 if test x${glibcxx_cv_func_$1_use+set} != xset; then
227 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
228 AC_LANG_SAVE
229 AC_LANG_CPLUSPLUS
230 AC_TRY_COMPILE([#include <stdlib.h>],
231 [ $1(0, 0);],
232 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
233 AC_LANG_RESTORE
234 ])
235 fi
236 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
237 if test x$glibcxx_cv_func_$1_use = x"yes"; then
238 AC_CHECK_FUNCS($1)
239 fi
240 ])
241
242
243 dnl
244 dnl Check to see if the (stdlib function) argument passed is
245 dnl 1) declared when using the c++ compiler
246 dnl 2) has "C" linkage
247 dnl
248 dnl argument 1 is name of function to check
249 dnl
250 dnl ASSUMES argument is a stdlib function with THREE parameters
251 dnl
252 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3
253 AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3], [
254 AC_MSG_CHECKING([for $1 declaration])
255 if test x${glibcxx_cv_func_$1_use+set} != xset; then
256 AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
257 AC_LANG_SAVE
258 AC_LANG_CPLUSPLUS
259 AC_TRY_COMPILE([#include <stdlib.h>],
260 [ $1(0, 0, 0);],
261 [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
262 AC_LANG_RESTORE
263 ])
264 fi
265 AC_MSG_RESULT($glibcxx_cv_func_$1_use)
266 if test x$glibcxx_cv_func_$1_use = x"yes"; then
267 AC_CHECK_FUNCS($1)
268 fi
269 ])
270
271 dnl
272 dnl Check to see what the underlying c library is like
273 dnl These checks need to do two things:
274 dnl 1) make sure the name is declared when using the c++ compiler
275 dnl 2) make sure the name has "C" linkage
276 dnl This might seem like overkill but experience has shown that it's not...
277 dnl
278 dnl Define HAVE_STRTOLD if "strtold" is declared and links
279 dnl Define HAVE_STRTOF if "strtof" is declared and links
280 dnl
281 dnl GLIBCXX_CHECK_STDLIB_SUPPORT
282 AC_DEFUN([GLIBCXX_CHECK_STDLIB_SUPPORT], [
283 ac_test_CXXFLAGS="${CXXFLAGS+set}"
284 ac_save_CXXFLAGS="$CXXFLAGS"
285 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
286
287 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1(at_quick_exit)
288 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1(quick_exit)
289 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
290 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
291
292 CXXFLAGS="$ac_save_CXXFLAGS"
293 ])
294
295 dnl
296 dnl Check to see what the underlying c library or math library is like.
297 dnl These checks need to do two things:
298 dnl 1) make sure the name is declared when using the c++ compiler
299 dnl 2) make sure the name has "C" linkage
300 dnl This might seem like overkill but experience has shown that it's not...
301 dnl
302 dnl Define HAVE_CARGF etc if "cargf" is found.
303 dnl
304 dnl GLIBCXX_CHECK_MATH_SUPPORT
305 AC_DEFUN([GLIBCXX_CHECK_MATH_SUPPORT], [
306 ac_test_CXXFLAGS="${CXXFLAGS+set}"
307 ac_save_CXXFLAGS="$CXXFLAGS"
308 CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
309
310 dnl Check libm
311 AC_CHECK_LIB(m, sin, libm="-lm")
312 ac_save_LIBS="$LIBS"
313 LIBS="$LIBS $libm"
314
315 dnl Check to see if certain C math functions exist.
316 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
317 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
318 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
319 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
320 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
321 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
322 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
323
324 dnl Check to see if basic C math functions have float versions.
325 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
326 float_trig,
327 acosf asinf atanf \
328 cosf sinf tanf \
329 coshf sinhf tanhf)
330 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
331 float_round,
332 ceilf floorf)
333 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
334 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
335 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
336 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
337 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
338 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
339 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
340 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
341 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
342 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
343 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
344 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
345 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modf)
346 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
347 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
348 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
349 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
350
351 dnl Check to see if basic C math functions have long double versions.
352 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
353 long_double_trig,
354 acosl asinl atanl \
355 cosl sinl tanl \
356 coshl sinhl tanhl)
357 GLIBCXX_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
358 long_double_round,
359 ceill floorl)
360 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
361 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
362 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
363 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
364 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
365 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
366 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
367 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
368 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
369 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
370 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
371 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
372 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
373 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
374 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
375 GLIBCXX_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
376
377 LIBS="$ac_save_LIBS"
378 CXXFLAGS="$ac_save_CXXFLAGS"
379 ])