]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/acinclude.m4
Eenable -Winvalid-memory-order for C++ [PR99612].
[thirdparty/gcc.git] / libstdc++-v3 / acinclude.m4
CommitLineData
92eabea2
PE
1dnl
2dnl GLIBCXX_CONDITIONAL (NAME, SHELL-TEST)
3dnl
4dnl Exactly like AM_CONDITIONAL, but delays evaluation of the test until the
5dnl end of configure. This lets tested variables be reassigned, and the
6dnl conditional will depend on the final state of the variable. For a simple
7dnl example of why this is needed, see GLIBCXX_ENABLE_HOSTED.
8dnl
9m4_define([_m4_divert(glibcxx_diversion)], 8000)dnl
f214923c 10AC_DEFUN([GLIBCXX_CONDITIONAL], [dnl
92eabea2
PE
11 m4_divert_text([glibcxx_diversion],dnl
12 AM_CONDITIONAL([$1],[$2])
13 )dnl
14])dnl
f214923c 15AC_DEFUN([GLIBCXX_EVALUATE_CONDITIONALS], [m4_undivert([glibcxx_diversion])])dnl
92eabea2
PE
16
17
ff66d28f
PE
18dnl
19dnl Check to see what architecture and operating system we are compiling
20dnl for. Also, if architecture- or OS-specific flags are required for
21dnl compilation, pick them up here.
22dnl
f214923c 23AC_DEFUN([GLIBCXX_CHECK_HOST], [
ff66d28f 24 . $glibcxx_srcdir/configure.host
f214923c
BK
25 AC_MSG_NOTICE([CPU config directory is $cpu_include_dir])
26 AC_MSG_NOTICE([OS config directory is $os_include_dir])
ff66d28f
PE
27])
28
ff66d28f
PE
29dnl
30dnl Initialize the rest of the library configury. At this point we have
31dnl variables like $host.
aebb8c22 32dnl
ff66d28f 33dnl Sets:
82ba99d5 34dnl SUBDIRS
ff66d28f
PE
35dnl Substs:
36dnl glibcxx_builddir (absolute path)
37dnl glibcxx_srcdir (absolute path)
5d1c8e77 38dnl toplevel_builddir (absolute path)
ff66d28f
PE
39dnl toplevel_srcdir (absolute path)
40dnl with_cross_host
41dnl with_newlib
42dnl with_target_subdir
43dnl plus
44dnl - the variables in GLIBCXX_CHECK_HOST / configure.host
45dnl - default settings for all AM_CONFITIONAL test variables
46dnl - lots of tools, like CC and CXX
aebb8c22 47dnl
f214923c 48AC_DEFUN([GLIBCXX_CONFIGURE], [
82ba99d5
PE
49 # Keep these sync'd with the list in Makefile.am. The first provides an
50 # expandable list at autoconf time; the second provides an expandable list
51 # (i.e., shell variable) at configure time.
a0e4d7b4 52 m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem doc po testsuite python])
82ba99d5
PE
53 SUBDIRS='glibcxx_SUBDIRS'
54
d2caef2e
PE
55 # These need to be absolute paths, yet at the same time need to
56 # canonicalize only relative paths, because then amd will not unmount
57 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
3d7c150e 58 glibcxx_builddir=`${PWDCMD-pwd}`
d2caef2e 59 case $srcdir in
ff66d28f
PE
60 [\\/$]* | ?:[\\/]*) glibcxx_srcdir=${srcdir} ;;
61 *) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
d2caef2e 62 esac
5d1c8e77 63 toplevel_builddir=${glibcxx_builddir}/..
ff66d28f 64 toplevel_srcdir=${glibcxx_srcdir}/..
3d7c150e
BK
65 AC_SUBST(glibcxx_builddir)
66 AC_SUBST(glibcxx_srcdir)
5d1c8e77 67 AC_SUBST(toplevel_builddir)
ff66d28f 68 AC_SUBST(toplevel_srcdir)
d2caef2e 69
ff66d28f
PE
70 # We use these options to decide which functions to include. They are
71 # set from the top level.
72 AC_ARG_WITH([target-subdir],
73 AC_HELP_STRING([--with-target-subdir=SUBDIR],
b329dd10 74 [configuring in a subdirectory]))
ff66d28f
PE
75
76 AC_ARG_WITH([cross-host],
77 AC_HELP_STRING([--with-cross-host=HOST],
b329dd10 78 [configuring with a cross compiler]))
ff66d28f
PE
79
80 AC_ARG_WITH([newlib],
81 AC_HELP_STRING([--with-newlib],
b329dd10 82 [assume newlib as a system C library]))
ff66d28f 83
ff66d28f
PE
84 # Will set LN_S to either 'ln -s', 'ln', or 'cp -p' (if linking isn't
85 # available). Uncomment the next line to force a particular method.
86 AC_PROG_LN_S
87 #LN_S='cp -p'
88
5780a46b
BK
89 AC_CHECK_TOOL(AS, as)
90 AC_CHECK_TOOL(AR, ar)
46840bcd 91 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
b2dad0e3 92
5780a46b 93 AM_MAINTAINER_MODE
b2dad0e3 94
92eabea2
PE
95 # Set up safe default values for all subsequent AM_CONDITIONAL tests
96 # which are themselves conditionally expanded.
97 ## (Right now, this only matters for enable_wchar_t, but nothing prevents
98 ## other macros from doing the same. This should be automated.) -pme
16da539b 99
176d6eb0
GP
100 # Check for C library flavor since GNU/Linux platforms use different
101 # configuration directories depending on the C library in use.
464aea98
JM
102 AC_EGREP_CPP([_using_uclibc], [
103 #include <stdio.h>
104 #if __UCLIBC__
105 _using_uclibc
106 #endif
107 ], uclibc=yes, uclibc=no)
108
aa6a73b9
MK
109 AC_EGREP_CPP([_using_bionic], [
110 #include <stdio.h>
111 #if __BIONIC__
112 _using_bionic
113 #endif
114 ], bionic=yes, bionic=no)
115
ff66d28f
PE
116 # Find platform-specific directories containing configuration info.
117 # Also possibly modify flags used elsewhere, as needed by the platform.
3d7c150e 118 GLIBCXX_CHECK_HOST
b2dad0e3
BK
119])
120
121
c470c17d 122dnl
52b55e7d
PE
123dnl Tests for newer compiler features, or features that are present in newer
124dnl compiler versions but not older compiler versions still in use, should
125dnl be placed here.
b2dad0e3 126dnl
ff66d28f
PE
127dnl Defines:
128dnl WERROR='-Werror' if requested and possible; g++'s that lack the
129dnl new inlining code or the new system_header pragma will die on -Werror.
130dnl Leave it out by default and use maint-mode to use it.
131dnl SECTION_FLAGS='-ffunction-sections -fdata-sections' if
132dnl compiler supports it and the user has not requested debug mode.
c21b6f87 133dnl
f214923c 134AC_DEFUN([GLIBCXX_CHECK_COMPILER_FEATURES], [
a4e99046 135 # All these tests are for C++; save the language and the compiler flags.
52b55e7d 136 # The CXXFLAGS thing is suspicious, but based on similar bits previously
3d7c150e 137 # found in GLIBCXX_CONFIGURE.
a4e99046
PE
138 AC_LANG_SAVE
139 AC_LANG_CPLUSPLUS
140 ac_test_CXXFLAGS="${CXXFLAGS+set}"
141 ac_save_CXXFLAGS="$CXXFLAGS"
a4e99046 142
c470c17d
BK
143 # Check for -ffunction-sections -fdata-sections
144 AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
85ee35ca
BK
145 CXXFLAGS='-g -Werror -ffunction-sections -fdata-sections'
146 AC_TRY_COMPILE([int foo; void bar() { };],, [ac_fdsections=yes], [ac_fdsections=no])
c470c17d
BK
147 if test "$ac_test_CXXFLAGS" = set; then
148 CXXFLAGS="$ac_save_CXXFLAGS"
149 else
150 # this is the suspicious part
151 CXXFLAGS=''
152 fi
6aa43d99 153 if test x"$ac_fdsections" = x"yes"; then
c470c17d
BK
154 SECTION_FLAGS='-ffunction-sections -fdata-sections'
155 fi
156 AC_MSG_RESULT($ac_fdsections)
157
a4e99046 158 AC_LANG_RESTORE
c470c17d 159 AC_SUBST(SECTION_FLAGS)
b2dad0e3
BK
160])
161
c470c17d
BK
162
163dnl
421173e6
PE
164dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
165dnl the native linker is in use, all variables will be defined to something
166dnl safe (like an empty string).
167dnl
ff66d28f
PE
168dnl Defines:
169dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
a429affe 170dnl OPT_LDFLAGS='-Wl,-O1' and '-z,relro' if possible
ff66d28f
PE
171dnl LD (as a side effect of testing)
172dnl Sets:
173dnl with_gnu_ld
d60a2d4d 174dnl glibcxx_ld_is_gold (set to "no" or "yes")
ff66d28f
PE
175dnl glibcxx_gnu_ld_version (possibly)
176dnl
177dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
178dnl set glibcxx_gnu_ld_version to 12345. Zeros cause problems.
c470c17d 179dnl
f214923c 180AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
421173e6
PE
181 # If we're not using GNU ld, then there's no point in even trying these
182 # tests. Check for that first. We should have already tested for gld
183 # by now (in libtool), but require it now just to be safe...
654421eb
DE
184 test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
185 test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
421173e6 186 AC_REQUIRE([AC_PROG_LD])
ff66d28f 187 AC_REQUIRE([AC_PROG_AWK])
5bd17d39 188
c98b201b
PE
189 # The name set by libtool depends on the version of libtool. Shame on us
190 # for depending on an impl detail, but c'est la vie. Older versions used
191 # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
192 # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
193 # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
194 # set (hence we're using an older libtool), then set it.
195 if test x${with_gnu_ld+set} != xset; then
196 if test x${ac_cv_prog_gnu_ld+set} != xset; then
197 # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
198 with_gnu_ld=no
199 else
200 with_gnu_ld=$ac_cv_prog_gnu_ld
201 fi
202 fi
203
204 # Start by getting the version number. I think the libtool test already
205 # does some of this, but throws away the result.
d60a2d4d 206 glibcxx_ld_is_gold=no
e2c104d8
BK
207 if test x"$with_gnu_ld" = x"yes"; then
208 AC_MSG_CHECKING([for ld version])
209 changequote(,)
d60a2d4d
ILT
210 if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
211 glibcxx_ld_is_gold=yes
212 fi
c82852f7 213 ldver=`$LD --version 2>/dev/null |
c6c2d1bc 214 sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
e2c104d8
BK
215 changequote([,])
216 glibcxx_gnu_ld_version=`echo $ldver | \
b329dd10 217 $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
e2c104d8
BK
218 AC_MSG_RESULT($glibcxx_gnu_ld_version)
219 fi
c98b201b 220
5bd17d39 221 # Set --gc-sections.
d60a2d4d
ILT
222 glibcxx_have_gc_sections=no
223 if test "$glibcxx_ld_is_gold" = "yes"; then
224 if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
225 glibcxx_have_gc_sections=yes
226 fi
227 else
228 glibcxx_gcsections_min_ld=21602
b329dd10 229 if test x"$with_gnu_ld" = x"yes" &&
ac2b2479 230 test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then
d60a2d4d
ILT
231 glibcxx_have_gc_sections=yes
232 fi
233 fi
234 if test "$glibcxx_have_gc_sections" = "yes"; then
ac2b2479
BK
235 # Sufficiently young GNU ld it is! Joy and bunny rabbits!
236 # NB: This flag only works reliably after 2.16.1. Configure tests
237 # for this are difficult, so hard wire a value that should work.
421173e6 238
421173e6
PE
239 ac_test_CFLAGS="${CFLAGS+set}"
240 ac_save_CFLAGS="$CFLAGS"
2a0ab51c 241 CFLAGS='-Wl,--gc-sections'
421173e6
PE
242
243 # Check for -Wl,--gc-sections
244 AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
acb6e9be
BK
245 AC_TRY_LINK([ int one(void) { return 1; }
246 int two(void) { return 2; }
247 ], [ two(); ] , [ac_gcsections=yes], [ac_gcsections=no])
360e8759
L
248 if test "$ac_gcsections" = "yes"; then
249 rm -f conftest.c
250 touch conftest.c
251 if $CC -c conftest.c; then
252 if $LD --gc-sections -o conftest conftest.o 2>&1 | \
253 grep "Warning: gc-sections option ignored" > /dev/null; then
254 ac_gcsections=no
255 fi
256 fi
257 rm -f conftest.c conftest.o conftest
258 fi
acb6e9be
BK
259 if test "$ac_gcsections" = "yes"; then
260 SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
261 fi
262 AC_MSG_RESULT($ac_gcsections)
263
421173e6
PE
264 if test "$ac_test_CFLAGS" = set; then
265 CFLAGS="$ac_save_CFLAGS"
266 else
267 # this is the suspicious part
268 CFLAGS=''
269 fi
5bd17d39 270 fi
a9117427 271
a429affe 272 # Set -z,relro.
952c7b74 273 # Note this is only for shared objects.
a429affe
BK
274 ac_ld_relro=no
275 if test x"$with_gnu_ld" = x"yes"; then
505ea909
JY
276 # cygwin and mingw uses PE, which has no ELF relro support,
277 # multi target ld may confuse configure machinery
278 case "$host" in
279 *-*-cygwin*)
280 ;;
281 *-*-mingw*)
282 ;;
283 *)
284 AC_MSG_CHECKING([for ld that supports -Wl,-z,relro])
285 cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
286 if test -n "$cxx_z_relo"; then
287 OPT_LDFLAGS="-Wl,-z,relro"
288 ac_ld_relro=yes
289 fi
290 AC_MSG_RESULT($ac_ld_relro)
291 esac
a429affe
BK
292 fi
293
5bd17d39 294 # Set linker optimization flags.
6aa43d99 295 if test x"$with_gnu_ld" = x"yes"; then
654421eb 296 OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
421173e6 297 fi
5bd17d39 298
c470c17d 299 AC_SUBST(SECTION_LDFLAGS)
421173e6 300 AC_SUBST(OPT_LDFLAGS)
c470c17d
BK
301])
302
303
b2dad0e3 304dnl
ff66d28f
PE
305dnl Check for headers for, and arguments to, the setrlimit() function.
306dnl Used only in testsuite_hooks.h. Called from GLIBCXX_CONFIGURE_TESTSUITE.
6aa43d99 307dnl
ff66d28f 308dnl Defines:
b329dd10 309dnl _GLIBCXX_RES_LIMITS if we can set artificial resource limits
2ae6e982 310dnl various HAVE_LIMIT_* for individual limit names
6aa43d99 311dnl
f214923c 312AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT_ancilliary], [
e0103440 313 AC_MSG_CHECKING([for RLIMIT_$1])
ff66d28f
PE
314 AC_TRY_COMPILE(
315 [#include <unistd.h>
316 #include <sys/time.h>
317 #include <sys/resource.h>
318 ],
319 [ int f = RLIMIT_$1 ; ],
320 [glibcxx_mresult=1], [glibcxx_mresult=0])
2ae6e982 321 AC_DEFINE_UNQUOTED(HAVE_LIMIT_$1, $glibcxx_mresult,
b329dd10 322 [Only used in build directory testsuite_hooks.h.])
e0103440
GK
323 if test $glibcxx_mresult = 1 ; then res=yes ; else res=no ; fi
324 AC_MSG_RESULT($res)
ff66d28f
PE
325])
326
f214923c 327AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT], [
84de780d
JL
328 AC_LANG_SAVE
329 AC_LANG_CPLUSPLUS
ff66d28f
PE
330 setrlimit_have_headers=yes
331 AC_CHECK_HEADERS(unistd.h sys/time.h sys/resource.h,
b329dd10
BK
332 [],
333 [setrlimit_have_headers=no])
ff66d28f
PE
334 # If don't have the headers, then we can't run the tests now, and we
335 # won't be seeing any of these during testsuite compilation.
336 if test $setrlimit_have_headers = yes; then
337 # Can't do these in a loop, else the resulting syntax is wrong.
338 GLIBCXX_CHECK_SETRLIMIT_ancilliary(DATA)
339 GLIBCXX_CHECK_SETRLIMIT_ancilliary(RSS)
340 GLIBCXX_CHECK_SETRLIMIT_ancilliary(VMEM)
341 GLIBCXX_CHECK_SETRLIMIT_ancilliary(AS)
2ae6e982 342 GLIBCXX_CHECK_SETRLIMIT_ancilliary(FSIZE)
ff66d28f
PE
343
344 # Check for rlimit, setrlimit.
9646a322
JW
345 AC_CACHE_CHECK([for testsuite resource limits support],
346 glibcxx_cv_setrlimit, [
ff66d28f 347 AC_TRY_COMPILE(
b329dd10
BK
348 [#include <unistd.h>
349 #include <sys/time.h>
350 #include <sys/resource.h>
351 ],
352 [struct rlimit r;
353 setrlimit(0, &r);],
354 [glibcxx_cv_setrlimit=yes], [glibcxx_cv_setrlimit=no])
ff66d28f 355 ])
ff66d28f 356
9646a322
JW
357 if test $glibcxx_cv_setrlimit = yes; then
358 AC_DEFINE(_GLIBCXX_RES_LIMITS, 1,
359 [Define if using setrlimit to set resource limits during
360 "make check"])
361 fi
ff66d28f 362 fi
84de780d 363 AC_LANG_RESTORE
6aa43d99
BK
364])
365
366
6aa43d99 367dnl
ff66d28f
PE
368dnl Check whether S_ISREG (Posix) or S_IFREG is available in <sys/stat.h>.
369dnl Define HAVE_S_ISREG / HAVE_S_IFREG appropriately.
6aa43d99 370dnl
f214923c 371AC_DEFUN([GLIBCXX_CHECK_S_ISREG_OR_S_IFREG], [
74745ec5
PC
372
373 AC_LANG_SAVE
374 AC_LANG_CPLUSPLUS
375 ac_save_CXXFLAGS="$CXXFLAGS"
376 CXXFLAGS="$CXXFLAGS -fno-exceptions"
377
e0103440 378 AC_MSG_CHECKING([for S_ISREG or S_IFREG])
ff66d28f 379 AC_CACHE_VAL(glibcxx_cv_S_ISREG, [
74745ec5 380 GCC_TRY_COMPILE_OR_LINK(
ff66d28f
PE
381 [#include <sys/stat.h>],
382 [struct stat buffer;
383 fstat(0, &buffer);
384 S_ISREG(buffer.st_mode);],
385 [glibcxx_cv_S_ISREG=yes],
386 [glibcxx_cv_S_ISREG=no])
387 ])
388 AC_CACHE_VAL(glibcxx_cv_S_IFREG, [
74745ec5 389 GCC_TRY_COMPILE_OR_LINK(
ff66d28f
PE
390 [#include <sys/stat.h>],
391 [struct stat buffer;
392 fstat(0, &buffer);
393 S_IFREG & buffer.st_mode;],
394 [glibcxx_cv_S_IFREG=yes],
395 [glibcxx_cv_S_IFREG=no])
396 ])
e0103440 397 res=no
ff66d28f 398 if test $glibcxx_cv_S_ISREG = yes; then
b329dd10 399 AC_DEFINE(HAVE_S_ISREG, 1,
64e1a55d 400 [Define if S_ISREG is available in <sys/stat.h>.])
e0103440 401 res=S_ISREG
ff66d28f 402 elif test $glibcxx_cv_S_IFREG = yes; then
4651e622 403 AC_DEFINE(HAVE_S_IFREG, 1,
b329dd10 404 [Define if S_IFREG is available in <sys/stat.h>.])
e0103440 405 res=S_IFREG
ff66d28f 406 fi
e0103440 407 AC_MSG_RESULT($res)
74745ec5
PC
408
409 CXXFLAGS="$ac_save_CXXFLAGS"
410 AC_LANG_RESTORE
b2dad0e3
BK
411])
412
413
dcfa0bc8 414dnl
ff66d28f 415dnl Check whether poll is available in <poll.h>, and define HAVE_POLL.
dcfa0bc8 416dnl
f214923c 417AC_DEFUN([GLIBCXX_CHECK_POLL], [
74745ec5
PC
418
419 AC_LANG_SAVE
420 AC_LANG_CPLUSPLUS
421 ac_save_CXXFLAGS="$CXXFLAGS"
422 CXXFLAGS="$CXXFLAGS -fno-exceptions"
423
9646a322 424 AC_CACHE_CHECK([for poll], glibcxx_cv_POLL, [
74745ec5 425 GCC_TRY_COMPILE_OR_LINK(
ff66d28f
PE
426 [#include <poll.h>],
427 [struct pollfd pfd[1];
428 pfd[0].events = POLLIN;
429 poll(pfd, 1, 0);],
430 [glibcxx_cv_POLL=yes],
431 [glibcxx_cv_POLL=no])
432 ])
433 if test $glibcxx_cv_POLL = yes; then
4651e622 434 AC_DEFINE(HAVE_POLL, 1, [Define if poll is available in <poll.h>.])
ff66d28f 435 fi
74745ec5
PC
436
437 CXXFLAGS="$ac_save_CXXFLAGS"
438 AC_LANG_RESTORE
ff66d28f
PE
439])
440
441
442dnl
443dnl Check whether writev is available in <sys/uio.h>, and define HAVE_WRITEV.
444dnl
f214923c 445AC_DEFUN([GLIBCXX_CHECK_WRITEV], [
74745ec5
PC
446
447 AC_LANG_SAVE
448 AC_LANG_CPLUSPLUS
449 ac_save_CXXFLAGS="$CXXFLAGS"
450 CXXFLAGS="$CXXFLAGS -fno-exceptions"
451
9646a322 452 AC_CACHE_CHECK([for writev], glibcxx_cv_WRITEV, [
74745ec5 453 GCC_TRY_COMPILE_OR_LINK(
ff66d28f
PE
454 [#include <sys/uio.h>],
455 [struct iovec iov[2];
456 writev(0, iov, 0);],
457 [glibcxx_cv_WRITEV=yes],
458 [glibcxx_cv_WRITEV=no])
459 ])
460 if test $glibcxx_cv_WRITEV = yes; then
4651e622 461 AC_DEFINE(HAVE_WRITEV, 1, [Define if writev is available in <sys/uio.h>.])
ff66d28f 462 fi
74745ec5
PC
463
464 CXXFLAGS="$ac_save_CXXFLAGS"
465 AC_LANG_RESTORE
ff66d28f
PE
466])
467
468
3d05b345
PC
469dnl
470dnl Check whether LFS support is available.
471dnl
f214923c 472AC_DEFUN([GLIBCXX_CHECK_LFS], [
0c6b814a 473 AC_LANG_SAVE
9d47bc51
PC
474 AC_LANG_CPLUSPLUS
475 ac_save_CXXFLAGS="$CXXFLAGS"
b329dd10 476 CXXFLAGS="$CXXFLAGS -fno-exceptions"
9646a322 477 AC_CACHE_CHECK([for LFS support], glibcxx_cv_LFS, [
74745ec5 478 GCC_TRY_COMPILE_OR_LINK(
0c6b814a
PC
479 [#include <unistd.h>
480 #include <stdio.h>
dd5d134b 481 #include <sys/stat.h>
0c6b814a 482 ],
5c89246d
PC
483 [FILE* fp;
484 fopen64("t", "w");
485 fseeko64(fp, 0, SEEK_CUR);
486 ftello64(fp);
dd5d134b
PC
487 lseek64(1, 0, SEEK_CUR);
488 struct stat64 buf;
489 fstat64(1, &buf);],
3d05b345
PC
490 [glibcxx_cv_LFS=yes],
491 [glibcxx_cv_LFS=no])
492 ])
493 if test $glibcxx_cv_LFS = yes; then
4651e622 494 AC_DEFINE(_GLIBCXX_USE_LFS, 1, [Define if LFS support is available.])
3d05b345 495 fi
9d47bc51
PC
496 CXXFLAGS="$ac_save_CXXFLAGS"
497 AC_LANG_RESTORE
3d05b345
PC
498])
499
500
1165dc50
PC
501dnl
502dnl Check for whether a fully dynamic basic_string implementation should
503dnl be turned on, that does not put empty objects in per-process static
504dnl memory (mostly useful together with shared memory allocators, see PR
505dnl libstdc++/16612 for details).
506dnl
d7a3ef97
JY
507dnl --enable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING to 1
508dnl --disable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING to 0
509dnl otherwise undefined
1165dc50
PC
510dnl + Usage: GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING[(DEFAULT)]
511dnl Where DEFAULT is either `yes' or `no'.
512dnl
513AC_DEFUN([GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING], [
514 GLIBCXX_ENABLE(fully-dynamic-string,$1,,[do not put empty strings in per-process static memory])
515 if test $enable_fully_dynamic_string = yes; then
d7a3ef97
JY
516 enable_fully_dynamic_string_def=1
517 else
518 enable_fully_dynamic_string_def=0
1165dc50 519 fi
d7a3ef97
JY
520 AC_DEFINE_UNQUOTED([_GLIBCXX_FULLY_DYNAMIC_STRING], [${enable_fully_dynamic_string_def}],
521 [Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, undefined for platform defaults])
1165dc50
PC
522])
523
524
ff66d28f
PE
525dnl
526dnl Does any necessary configuration of the testsuite directory. Generates
527dnl the testsuite_hooks.h header.
528dnl
529dnl GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE must be done before this.
530dnl
531dnl Sets:
b329dd10 532dnl enable_abi_check
e3f78d9b
BK
533dnl GLIBCXX_TEST_WCHAR_T
534dnl GLIBCXX_TEST_THREAD
ff66d28f
PE
535dnl Substs:
536dnl baseline_dir
00fc1bf6 537dnl baseline_subdir_switch
ff66d28f 538dnl
f214923c 539AC_DEFUN([GLIBCXX_CONFIGURE_TESTSUITE], [
5a810362
MK
540 # Do checks for resource limit functions.
541 GLIBCXX_CHECK_SETRLIMIT
ff66d28f 542
5a810362 543 if $GLIBCXX_IS_NATIVE ; then
ff66d28f
PE
544 # Look for setenv, so that extended locale tests can be performed.
545 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
0646b059 546 fi
dbc66058 547
0646b059
GK
548 if $GLIBCXX_IS_NATIVE && test $is_hosted = yes &&
549 test $enable_symvers != no; then
550 case "$host" in
551 *-*-cygwin*)
b329dd10 552 enable_abi_check=no ;;
0646b059 553 *)
b329dd10 554 enable_abi_check=yes ;;
0646b059 555 esac
dbc66058
DJ
556 else
557 # Only build this as native, since automake does not understand
558 # CXX_FOR_BUILD.
559 enable_abi_check=no
ff66d28f 560 fi
b329dd10 561
ff66d28f 562 # Export file names for ABI checking.
68c512f6 563 baseline_dir="$glibcxx_srcdir/config/abi/post/${abi_baseline_pair}"
ff66d28f 564 AC_SUBST(baseline_dir)
00fc1bf6
RO
565 baseline_subdir_switch="$abi_baseline_subdir_switch"
566 AC_SUBST(baseline_subdir_switch)
ff66d28f
PE
567])
568
569
b329dd10 570dnl
c1e0e100 571dnl Does any necessary configuration for docbook in the docs directory.
b329dd10
BK
572dnl
573dnl XSLTPROC must be set before this
574dnl
575dnl Sets:
576dnl glibcxx_stylesheets
577dnl Substs:
578dnl XSL_STYLE_DIR
579dnl
580AC_DEFUN([GLIBCXX_CONFIGURE_DOCBOOK], [
581
a4395a84 582glibcxx_docbook_url=http://docbook.sourceforge.net/release/xsl-ns/current/
b329dd10
BK
583
584AC_MSG_CHECKING([for local stylesheet directory])
585glibcxx_local_stylesheets=no
a4395a84
JW
586if test x${XMLCATALOG} = xyes && xsl_style_dir=`xmlcatalog "" $glibcxx_docbook_url 2>/dev/null`
587then
588 XSL_STYLE_DIR=`echo $xsl_style_dir | sed -n 's;^file://;;p'`
589 glibcxx_local_stylesheets=yes
590else
591 for dir in \
592 /usr/share/sgml/docbook/xsl-ns-stylesheets \
593 /usr/share/xml/docbook/stylesheet/docbook-xsl-ns \
594 /usr/share/xml/docbook/stylesheet/nwalsh5/current \
595 /usr/share/xml/docbook/stylesheet/nwalsh/current
596 do
597 if test -d $dir; then
598 glibcxx_local_stylesheets=yes
599 XSL_STYLE_DIR=$dir
600 break
601 fi
602 done
b329dd10
BK
603fi
604AC_MSG_RESULT($glibcxx_local_stylesheets)
605
606if test x"$glibcxx_local_stylesheets" = x"yes"; then
607 AC_SUBST(XSL_STYLE_DIR)
608 AC_MSG_NOTICE($XSL_STYLE_DIR)
a4395a84
JW
609
610 AC_MSG_CHECKING([for docbook stylesheets for documentation creation])
611 glibcxx_stylesheets=no
612 if test x${XMLCATALOG} = xno || xmlcatalog "" $glibcxx_docbook_url/xhtml/docbook.xsl >/dev/null 2>&1; then
613 if test x${XSLTPROC} = xyes && echo '<title/>' | xsltproc --noout --nonet --xinclude $glibcxx_docbook_url/xhtml/docbook.xsl - 2>/dev/null; then
614 glibcxx_stylesheets=yes
615 fi
616 fi
617 AC_MSG_RESULT($glibcxx_stylesheets)
618
b329dd10
BK
619else
620 glibcxx_stylesheets=no
621fi
c1e0e100
BK
622
623# Check for epub3 dependencies.
624AC_MSG_CHECKING([for epub3 stylesheets for documentation creation])
625glibcxx_epub_stylesheets=no
626if test x"$glibcxx_local_stylesheets" = x"yes"; then
e9469833 627 if test -f "$XSL_STYLE_DIR/epub3/chunk.xsl"; then
c1e0e100
BK
628 glibcxx_epub_stylesheets=yes
629 fi
630fi
631AC_MSG_RESULT($glibcxx_epub_stylesheets)
e9469833 632AM_CONDITIONAL(BUILD_EPUB, test x"$glibcxx_epub_stylesheets" = x"yes")
c1e0e100 633
b329dd10
BK
634])
635
636
ff66d28f
PE
637dnl
638dnl Set up *_INCLUDES variables for all sundry Makefile.am's.
639dnl
640dnl Substs:
641dnl GLIBCXX_INCLUDES
642dnl TOPLEVEL_INCLUDES
ff66d28f 643dnl
f214923c 644AC_DEFUN([GLIBCXX_EXPORT_INCLUDES], [
0df3f383
PE
645 # Used for every C++ compile we perform.
646 GLIBCXX_INCLUDES="\
647-I$glibcxx_builddir/include/$host_alias \
648-I$glibcxx_builddir/include \
649-I$glibcxx_srcdir/libsupc++"
ff66d28f 650
0df3f383 651 # For Canadian crosses, pick this up too.
ff66d28f 652 if test $CANADIAN = yes; then
37e0ff11 653 GLIBCXX_INCLUDES="$GLIBCXX_INCLUDES -I\${includedir}"
ff66d28f
PE
654 fi
655
0df3f383 656 # Stuff in the actual top level. Currently only used by libsupc++ to
201cdb74
RO
657 # get unwind* headers from the libgcc dir.
658 #TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/libgcc -I$(toplevel_srcdir)/include'
659 TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/libgcc'
ff66d28f
PE
660
661 # Now, export this to all the little Makefiles....
662 AC_SUBST(GLIBCXX_INCLUDES)
663 AC_SUBST(TOPLEVEL_INCLUDES)
ff66d28f
PE
664])
665
666
667dnl
668dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
669dnl (SECTION_FLAGS is done under CHECK_COMPILER_FEATURES.)
670dnl
671dnl Substs:
672dnl OPTIMIZE_CXXFLAGS
673dnl WARN_FLAGS
674dnl
f214923c 675AC_DEFUN([GLIBCXX_EXPORT_FLAGS], [
ff66d28f
PE
676 # Optimization flags that are probably a good idea for thrill-seekers. Just
677 # uncomment the lines below and make, everything else is ready to go...
62801a96 678 # Alternatively OPTIMIZE_CXXFLAGS can be set in configure.host.
ff66d28f 679 # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
ff66d28f
PE
680 AC_SUBST(OPTIMIZE_CXXFLAGS)
681
c3be340e 682 WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2"
ff66d28f
PE
683 AC_SUBST(WARN_FLAGS)
684])
685
686
687dnl
688dnl All installation directory information is determined here.
689dnl
690dnl Substs:
691dnl gxx_install_dir
692dnl glibcxx_prefixdir
693dnl glibcxx_toolexecdir
694dnl glibcxx_toolexeclibdir
695dnl
696dnl Assumes cross_compiling bits already done, and with_cross_host in
697dnl particular.
698dnl
0f57bf40 699dnl This logic must match gcc/configure.ac's setting of gcc_gxx_include_dir.
505692b0 700dnl config/gxx-include-dir.m4 must be kept consistant with this as well.
f214923c 701AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO], [
ff66d28f
PE
702 glibcxx_toolexecdir=no
703 glibcxx_toolexeclibdir=no
704 glibcxx_prefixdir=$prefix
705
706 AC_MSG_CHECKING([for gxx-include-dir])
707 AC_ARG_WITH([gxx-include-dir],
708 AC_HELP_STRING([--with-gxx-include-dir=DIR],
b329dd10 709 [installation directory for include files]),
ff66d28f
PE
710 [case "$withval" in
711 yes) AC_MSG_ERROR([Missing directory for --with-gxx-include-dir]) ;;
712 no) gxx_include_dir=no ;;
713 *) gxx_include_dir=$withval ;;
714 esac],
715 [gxx_include_dir=no])
716 AC_MSG_RESULT($gxx_include_dir)
717
718 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
719 AC_ARG_ENABLE([version-specific-runtime-libs],
720 AC_HELP_STRING([--enable-version-specific-runtime-libs],
b329dd10 721 [Specify that runtime libraries should be installed in a compiler-specific directory]),
ff66d28f
PE
722 [case "$enableval" in
723 yes) version_specific_libs=yes ;;
724 no) version_specific_libs=no ;;
725 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
726 esac],
727 [version_specific_libs=no])
728 AC_MSG_RESULT($version_specific_libs)
729
e8e66971
MR
730 GCC_WITH_TOOLEXECLIBDIR
731
ff66d28f
PE
732 # Default case for install directory for include files.
733 if test $version_specific_libs = no && test $gxx_include_dir = no; then
0f57bf40 734 gxx_include_dir='include/c++/${gcc_version}'
b329dd10
BK
735 if test -n "$with_cross_host" &&
736 test x"$with_cross_host" != x"no"; then
0f57bf40
MM
737 gxx_include_dir='${prefix}/${target_alias}/'"$gxx_include_dir"
738 else
739 gxx_include_dir='${prefix}/'"$gxx_include_dir"
740 fi
ff66d28f
PE
741 fi
742
743 # Version-specific runtime libs processing.
744 if test $version_specific_libs = yes; then
745 # Need the gcc compiler version to know where to install libraries
746 # and header files if --enable-version-specific-runtime-libs option
0314451d
GK
747 # is selected. FIXME: these variables are misnamed, there are
748 # no executables installed in _toolexecdir or _toolexeclibdir.
ff66d28f 749 if test x"$gxx_include_dir" = x"no"; then
47194af4 750 gxx_include_dir='${libdir}/gcc/${host_alias}/${gcc_version}/include/c++'
ff66d28f 751 fi
0314451d 752 glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
47194af4 753 glibcxx_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
ff66d28f
PE
754 fi
755
756 # Calculate glibcxx_toolexecdir, glibcxx_toolexeclibdir
757 # Install a library built with a cross compiler in tooldir, not libdir.
758 if test x"$glibcxx_toolexecdir" = x"no"; then
759 if test -n "$with_cross_host" &&
760 test x"$with_cross_host" != x"no"; then
fbe057bb 761 glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
e8e66971
MR
762 case ${with_toolexeclibdir} in
763 no)
764 glibcxx_toolexeclibdir='${toolexecdir}/lib'
765 ;;
766 *)
767 glibcxx_toolexeclibdir=${with_toolexeclibdir}
768 ;;
769 esac
ff66d28f 770 else
0314451d 771 glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
fbe057bb 772 glibcxx_toolexeclibdir='${libdir}'
ff66d28f 773 fi
fbe057bb 774 multi_os_directory=`$CXX -print-multi-os-directory`
ff66d28f
PE
775 case $multi_os_directory in
776 .) ;; # Avoid trailing /.
777 *) glibcxx_toolexeclibdir=$glibcxx_toolexeclibdir/$multi_os_directory ;;
778 esac
779 fi
780
781 AC_MSG_CHECKING([for install location])
782 AC_MSG_RESULT($gxx_include_dir)
783
784 AC_SUBST(glibcxx_prefixdir)
785 AC_SUBST(gxx_include_dir)
786 AC_SUBST(glibcxx_toolexecdir)
787 AC_SUBST(glibcxx_toolexeclibdir)
788])
789
790
791dnl
792dnl GLIBCXX_ENABLE
793dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
794dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
795dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
796dnl
88b1a025
JW
797dnl See manual/appendix_porting.html#appendix.porting.build_hacking for
798dnl documentation.
ff66d28f
PE
799dnl
800m4_define([GLIBCXX_ENABLE],[dnl
801m4_define([_g_switch],[--enable-$1])dnl
b453ace3
AS
802m4_define([_g_help],[AC_HELP_STRING([_g_switch$3],[$4 @<:@default=$2@:>@])])dnl
803 AC_ARG_ENABLE([$1],m4_dquote(_g_help),
ff66d28f
PE
804 m4_bmatch([$5],
805 [^permit ],
806 [[
807 case "$enableval" in
808 m4_bpatsubst([$5],[permit ])) ;;
809 *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
b329dd10
BK
810 dnl Idea for future: generate a URL pointing to
811 dnl "onlinedocs/configopts.html#whatever"
ff66d28f
PE
812 esac
813 ]],
814 [^$],
815 [[
816 case "$enableval" in
817 yes|no) ;;
818 *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
819 esac
820 ]],
821 [[$5]]),
822 [enable_]m4_bpatsubst([$1],-,_)[=][$2])
823m4_undefine([_g_switch])dnl
824m4_undefine([_g_help])dnl
825])
826
827
828dnl
829dnl Check for ISO/IEC 9899:1999 "C99" support.
830dnl
831dnl --enable-c99 defines _GLIBCXX_USE_C99
832dnl --disable-c99 leaves _GLIBCXX_USE_C99 undefined
833dnl + Usage: GLIBCXX_ENABLE_C99[(DEFAULT)]
834dnl Where DEFAULT is either `yes' or `no'.
835dnl + If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
836dnl
f214923c 837AC_DEFUN([GLIBCXX_ENABLE_C99], [
ff66d28f
PE
838 GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support])
839
347669a0 840 if test x"$enable_c99" = x"yes"; then
23c64853
JY
841 AC_LANG_SAVE
842 AC_LANG_CPLUSPLUS
843
844 # Use -std=c++98 (instead of -std=gnu++98) because leaving __STRICT_ANSI__
845 # undefined may cause fake C99 facilities, like pre-standard snprintf,
846 # to be spuriously enabled.
847 ac_save_CXXFLAGS="$CXXFLAGS"
848 CXXFLAGS="$CXXFLAGS -std=c++98"
849 ac_save_LIBS="$LIBS"
850 ac_save_gcc_no_link="$gcc_no_link"
851
852 if test x$gcc_no_link != xyes; then
853 # Use -fno-exceptions to that the C driver can link these tests without
854 # hitting undefined references to personality routines.
855 CXXFLAGS="$CXXFLAGS -fno-exceptions"
856 AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [
857 # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
858 gcc_no_link=yes
859 ])
860 fi
347669a0 861
23c64853 862 # Check for the existence of <math.h> functions used if C99 is enabled.
9646a322
JW
863 AC_CACHE_CHECK([for ISO C99 support in <math.h> for C++98],
864 glibcxx_cv_c99_math_cxx98, [
23c64853
JY
865 GCC_TRY_COMPILE_OR_LINK(
866 [#include <math.h>
867 volatile double d1, d2;
868 volatile int i;],
869 [i = fpclassify(d1);
870 i = isfinite(d1);
871 i = isinf(d1);
872 i = isnan(d1);
873 i = isnormal(d1);
874 i = signbit(d1);
875 i = isgreater(d1, d2);
876 i = isgreaterequal(d1, d2);
877 i = isless(d1, d2);
878 i = islessequal(d1, d2);
879 i = islessgreater(d1, d2);
880 i = islessgreater(d1, d2);
881 i = isunordered(d1, d2);
882 ], [glibcxx_cv_c99_math_cxx98=yes], [glibcxx_cv_c99_math_cxx98=no])
883 ])
23c64853
JY
884 if test x"$glibcxx_cv_c99_math_cxx98" = x"yes"; then
885 AC_DEFINE(_GLIBCXX98_USE_C99_MATH, 1,
886 [Define if C99 functions or macros in <math.h> should be imported
887 in <cmath> in namespace std for C++98.])
888 fi
ff66d28f 889
23c64853
JY
890 # Check for the existence of <complex.h> complex math functions.
891 # This is necessary even though libstdc++ uses the builtin versions
892 # of these functions, because if the builtin cannot be used, a reference
893 # to the library function is emitted.
894 AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
895 AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
896 if test x"$ac_has_complex_h" = x"yes"; then
9646a322
JW
897 AC_CACHE_CHECK([for ISO C99 support in <complex.h> for C++98],
898 glibcxx_cv_c99_complex_cxx98, [
23c64853
JY
899 GCC_TRY_COMPILE_OR_LINK(
900 [#include <complex.h>
901 typedef __complex__ float float_type;
902 typedef __complex__ double double_type;
903 typedef __complex__ long double ld_type;
904 volatile float_type tmpf;
905 volatile double_type tmpd;
906 volatile ld_type tmpld;
907 volatile float f;
908 volatile double d;
909 volatile long double ld;],
910 [f = cabsf(tmpf);
911 f = cargf(tmpf);
912 tmpf = ccosf(tmpf);
913 tmpf = ccoshf(tmpf);
914 tmpf = cexpf(tmpf);
915 tmpf = clogf(tmpf);
916 tmpf = csinf(tmpf);
917 tmpf = csinhf(tmpf);
918 tmpf = csqrtf(tmpf);
919 tmpf = ctanf(tmpf);
920 tmpf = ctanhf(tmpf);
921 tmpf = cpowf(tmpf, tmpf);
922 tmpf = cprojf(tmpf);
923 d = cabs(tmpd);
924 d = carg(tmpd);
925 tmpd = ccos(tmpd);
926 tmpd = ccosh(tmpd);
927 tmpd = cexp(tmpd);
928 tmpd = clog(tmpd);
929 tmpd = csin(tmpd);
930 tmpd = csinh(tmpd);
931 tmpd = csqrt(tmpd);
932 tmpd = ctan(tmpd);
933 tmpd = ctanh(tmpd);
934 tmpd = cpow(tmpd, tmpd);
935 tmpd = cproj(tmpd);
936 ld = cabsl(tmpld);
937 ld = cargl(tmpld);
938 tmpld = ccosl(tmpld);
939 tmpld = ccoshl(tmpld);
940 tmpld = cexpl(tmpld);
941 tmpld = clogl(tmpld);
942 tmpld = csinl(tmpld);
943 tmpld = csinhl(tmpld);
944 tmpld = csqrtl(tmpld);
945 tmpld = ctanl(tmpld);
946 tmpld = ctanhl(tmpld);
947 tmpld = cpowl(tmpld, tmpld);
948 tmpld = cprojl(tmpld);
949 ], [glibcxx_cv_c99_complex_cxx98=yes], [glibcxx_cv_c99_complex_cxx98=no])
950 ])
951 fi
23c64853
JY
952 if test x"$glibcxx_cv_c99_complex_cxx98" = x"yes"; then
953 AC_DEFINE(_GLIBCXX98_USE_C99_COMPLEX, 1,
954 [Define if C99 functions in <complex.h> should be used in
955 <complex> for C++98. Using compiler builtins for these functions
956 requires corresponding C99 library functions to be present.])
957 fi
958
959 # Check for the existence in <stdio.h> of vscanf, et. al.
9646a322
JW
960 AC_CACHE_CHECK([for ISO C99 support in <stdio.h> for C++98],
961 glibcxx_cv_c99_stdio_cxx98, [
23c64853
JY
962 GCC_TRY_COMPILE_OR_LINK(
963 [#include <stdio.h>
964 #include <stdarg.h>
965 void foo(char* fmt, ...)
966 {
967 va_list args; va_start(args, fmt);
968 vfscanf(stderr, "%i", args);
969 vscanf("%i", args);
970 vsnprintf(fmt, 0, "%i", args);
971 vsscanf(fmt, "%i", args);
972 snprintf(fmt, 0, "%i");
973 }], [],
974 [glibcxx_cv_c99_stdio_cxx98=yes], [glibcxx_cv_c99_stdio_cxx98=no])
b6f914f6 975 ])
23c64853
JY
976 if test x"$glibcxx_cv_c99_stdio_cxx98" = x"yes"; then
977 AC_DEFINE(_GLIBCXX98_USE_C99_STDIO, 1,
978 [Define if C99 functions or macros in <stdio.h> should be imported
979 in <cstdio> in namespace std for C++98.])
980 fi
b6f914f6 981
3555173f 982 # Check for the existence in <stdlib.h> of lldiv_t, et. al.
9646a322
JW
983 AC_CACHE_CHECK([for ISO C99 support in <stdlib.h> for C++98],
984 glibcxx_cv_c99_stdlib_cxx98, [
3555173f
JW
985 GCC_TRY_COMPILE_OR_LINK(
986 [#include <stdlib.h>
987 volatile float f;
988 volatile long double ld;
989 volatile unsigned long long ll;
990 lldiv_t mydivt;],
991 [char* tmp;
992 f = strtof("gnu", &tmp);
993 ld = strtold("gnu", &tmp);
994 ll = strtoll("gnu", &tmp, 10);
995 ll = strtoull("gnu", &tmp, 10);
996 ll = llabs(10);
997 mydivt = lldiv(10,1);
998 ll = mydivt.quot;
999 ll = mydivt.rem;
1000 ll = atoll("10");
1001 _Exit(0);
1002 ], [glibcxx_cv_c99_stdlib_cxx98=yes], [glibcxx_cv_c99_stdlib_cxx98=no])
1003 ])
3555173f
JW
1004 if test x"$glibcxx_cv_c99_stdlib_cxx98" = x"yes"; then
1005 AC_DEFINE(_GLIBCXX98_USE_C99_STDLIB, 1,
1006 [Define if C99 functions or macros in <stdlib.h> should be imported
1007 in <cstdlib> in namespace std for C++98.])
1008 fi
1009
23c64853
JY
1010 # Check for the existence in <wchar.h> of wcstold, etc.
1011 if test x"$ac_has_wchar_h" = xyes &&
1012 test x"$ac_has_wctype_h" = xyes; then
9646a322
JW
1013 AC_CACHE_CHECK([for ISO C99 support in <wchar.h> for C++98],
1014 glibcxx_cv_c99_wchar_cxx98, [
23c64853
JY
1015 AC_TRY_COMPILE([#include <wchar.h>
1016 namespace test
1017 {
1018 using ::wcstold;
1019 using ::wcstoll;
1020 using ::wcstoull;
1021 }
1022 ], [], [glibcxx_cv_c99_wchar_cxx98=yes], [glibcxx_cv_c99_wchar_cxx98=no])
1023 ])
1024
1025 # Checks for wide character functions that may not be present.
1026 # Injection of these is wrapped with guard macros.
1027 # NB: only put functions here, instead of immediately above, if
1028 # absolutely necessary.
1029 AC_TRY_COMPILE([#include <wchar.h>
1030 namespace test { using ::vfwscanf; }], [],
1031 [AC_DEFINE(HAVE_VFWSCANF, 1, [Defined if vfwscanf exists.])], [])
1032
1033 AC_TRY_COMPILE([#include <wchar.h>
1034 namespace test { using ::vswscanf; }], [],
1035 [AC_DEFINE(HAVE_VSWSCANF, 1, [Defined if vswscanf exists.])], [])
1036
1037 AC_TRY_COMPILE([#include <wchar.h>
1038 namespace test { using ::vwscanf; }], [],
1039 [AC_DEFINE(HAVE_VWSCANF, 1, [Defined if vwscanf exists.])], [])
1040
1041 AC_TRY_COMPILE([#include <wchar.h>
1042 namespace test { using ::wcstof; }], [],
1043 [AC_DEFINE(HAVE_WCSTOF, 1, [Defined if wcstof exists.])], [])
1044
1045 AC_TRY_COMPILE([#include <wctype.h>],
1046 [wint_t t; int i = iswblank(t);],
1047 [AC_DEFINE(HAVE_ISWBLANK, 1, [Defined if iswblank exists.])], [])
1048
23c64853
JY
1049 if test x"$glibcxx_cv_c99_wchar_cxx98" = x"yes"; then
1050 AC_DEFINE(_GLIBCXX98_USE_C99_WCHAR, 1,
1051 [Define if C99 functions or macros in <wchar.h> should be imported
1052 in <cwchar> in namespace std for C++98.])
1053 fi
1054 fi
517da0ce 1055
23c64853
JY
1056 # Option parsed, now set things appropriately.
1057 if test x"$glibcxx_cv_c99_math_cxx98" = x"no" ||
1058 test x"$glibcxx_cv_c99_complex_cxx98" = x"no" ||
1059 test x"$glibcxx_cv_c99_stdio_cxx98" = x"no" ||
1060 test x"$glibcxx_cv_c99_stdlib_cxx98" = x"no" ||
1061 test x"$glibcxx_cv_c99_wchar_cxx98" = x"no"; then
1062 enable_c99=no;
1063 else
1064 AC_DEFINE(_GLIBCXX_USE_C99, 1,
1065 [Define if C99 functions or macros from <wchar.h>, <math.h>,
1066 <complex.h>, <stdio.h>, and <stdlib.h> can be used or exposed.])
1067 fi
52e6723c 1068
23c64853
JY
1069 gcc_no_link="$ac_save_gcc_no_link"
1070 LIBS="$ac_save_LIBS"
1071 CXXFLAGS="$ac_save_CXXFLAGS"
1072 AC_LANG_RESTORE
1073
1074 AC_LANG_SAVE
1075 AC_LANG_CPLUSPLUS
1076
1077 # Use -std=c++11 and test again for C99 library feature in C++11 mode.
1078 # For the reasons given above we use -std=c++11 not -std=gnu++11.
1079 ac_save_CXXFLAGS="$CXXFLAGS"
1080 CXXFLAGS="$CXXFLAGS -std=c++11"
1081 ac_save_LIBS="$LIBS"
1082 ac_save_gcc_no_link="$gcc_no_link"
1083
1084 if test x$gcc_no_link != xyes; then
1085 # Use -fno-exceptions to that the C driver can link these tests without
1086 # hitting undefined references to personality routines.
1087 CXXFLAGS="$CXXFLAGS -fno-exceptions"
1088 AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [
1089 # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
1090 gcc_no_link=yes
1091 ])
1092 fi
ff66d28f 1093
23c64853 1094 # Check for the existence of <math.h> functions used if C99 is enabled.
9646a322
JW
1095 AC_CACHE_CHECK([for ISO C99 support in <math.h> for C++11],
1096 glibcxx_cv_c99_math_cxx11, [
23c64853
JY
1097 GCC_TRY_COMPILE_OR_LINK(
1098 [#include <math.h>
1099 volatile double d1, d2;
1100 volatile int i;],
1101 [i = fpclassify(d1);
1102 i = isfinite(d1);
1103 i = isinf(d1);
1104 i = isnan(d1);
1105 i = isnormal(d1);
1106 i = signbit(d1);
1107 i = isgreater(d1, d2);
1108 i = isgreaterequal(d1, d2);
1109 i = isless(d1, d2);
1110 i = islessequal(d1, d2);
1111 i = islessgreater(d1, d2);
1112 i = islessgreater(d1, d2);
1113 i = isunordered(d1, d2);
1114 ], [glibcxx_cv_c99_math_cxx11=yes], [glibcxx_cv_c99_math_cxx11=no])
1115 ])
23c64853
JY
1116 if test x"$glibcxx_cv_c99_math_cxx11" = x"yes"; then
1117 AC_DEFINE(_GLIBCXX11_USE_C99_MATH, 1,
1118 [Define if C99 functions or macros in <math.h> should be imported
1119 in <cmath> in namespace std for C++11.])
1120 fi
ff66d28f 1121
23c64853
JY
1122 # Check for the existence of <complex.h> complex math functions.
1123 # This is necessary even though libstdc++ uses the builtin versions
1124 # of these functions, because if the builtin cannot be used, a reference
1125 # to the library function is emitted.
1126 AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
1127 AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
1128 if test x"$ac_has_complex_h" = x"yes"; then
9646a322
JW
1129 AC_CACHE_CHECK([for ISO C99 support in <complex.h> for C++11],
1130 glibcxx_cv_c99_complex_cxx11, [
23c64853
JY
1131 GCC_TRY_COMPILE_OR_LINK(
1132 [#include <complex.h>
1133 typedef __complex__ float float_type;
1134 typedef __complex__ double double_type;
1135 typedef __complex__ long double ld_type;
1136 volatile float_type tmpf;
1137 volatile double_type tmpd;
1138 volatile ld_type tmpld;
1139 volatile float f;
1140 volatile double d;
1141 volatile long double ld;],
1142 [f = cabsf(tmpf);
1143 f = cargf(tmpf);
1144 tmpf = ccosf(tmpf);
1145 tmpf = ccoshf(tmpf);
1146 tmpf = cexpf(tmpf);
1147 tmpf = clogf(tmpf);
1148 tmpf = csinf(tmpf);
1149 tmpf = csinhf(tmpf);
1150 tmpf = csqrtf(tmpf);
1151 tmpf = ctanf(tmpf);
1152 tmpf = ctanhf(tmpf);
1153 tmpf = cpowf(tmpf, tmpf);
1154 tmpf = cprojf(tmpf);
1155 d = cabs(tmpd);
1156 d = carg(tmpd);
1157 tmpd = ccos(tmpd);
1158 tmpd = ccosh(tmpd);
1159 tmpd = cexp(tmpd);
1160 tmpd = clog(tmpd);
1161 tmpd = csin(tmpd);
1162 tmpd = csinh(tmpd);
1163 tmpd = csqrt(tmpd);
1164 tmpd = ctan(tmpd);
1165 tmpd = ctanh(tmpd);
1166 tmpd = cpow(tmpd, tmpd);
1167 tmpd = cproj(tmpd);
1168 ld = cabsl(tmpld);
1169 ld = cargl(tmpld);
1170 tmpld = ccosl(tmpld);
1171 tmpld = ccoshl(tmpld);
1172 tmpld = cexpl(tmpld);
1173 tmpld = clogl(tmpld);
1174 tmpld = csinl(tmpld);
1175 tmpld = csinhl(tmpld);
1176 tmpld = csqrtl(tmpld);
1177 tmpld = ctanl(tmpld);
1178 tmpld = ctanhl(tmpld);
1179 tmpld = cpowl(tmpld, tmpld);
1180 tmpld = cprojl(tmpld);
1181 ], [glibcxx_cv_c99_complex_cxx11=yes], [glibcxx_cv_c99_complex_cxx11=no])
1182 ])
1183 fi
23c64853
JY
1184 if test x"$glibcxx_cv_c99_complex_cxx11" = x"yes"; then
1185 AC_DEFINE(_GLIBCXX11_USE_C99_COMPLEX, 1,
1186 [Define if C99 functions in <complex.h> should be used in
1187 <complex> for C++11. Using compiler builtins for these functions
1188 requires corresponding C99 library functions to be present.])
1189 fi
1190
1191 # Check for the existence in <stdio.h> of vscanf, et. al.
9646a322
JW
1192 AC_CACHE_CHECK([for ISO C99 support in <stdio.h> for C++11],
1193 glibcxx_cv_c99_stdio_cxx11, [
23c64853
JY
1194 GCC_TRY_COMPILE_OR_LINK(
1195 [#include <stdio.h>
1196 #include <stdarg.h>
1197 void foo(char* fmt, ...)
1198 {
1199 va_list args; va_start(args, fmt);
1200 vfscanf(stderr, "%i", args);
1201 vscanf("%i", args);
1202 vsnprintf(fmt, 0, "%i", args);
1203 vsscanf(fmt, "%i", args);
1204 snprintf(fmt, 0, "%i");
1205 }], [],
1206 [glibcxx_cv_c99_stdio_cxx11=yes], [glibcxx_cv_c99_stdio_cxx11=no])
1207 ])
23c64853
JY
1208 if test x"$glibcxx_cv_c99_stdio_cxx11" = x"yes"; then
1209 AC_DEFINE(_GLIBCXX11_USE_C99_STDIO, 1,
1210 [Define if C99 functions or macros in <stdio.h> should be imported
1211 in <cstdio> in namespace std for C++11.])
1212 fi
1213
1214 # Check for the existence in <stdlib.h> of lldiv_t, et. al.
9646a322
JW
1215 AC_CACHE_CHECK([for ISO C99 support in <stdlib.h> for C++11],
1216 glibcxx_cv_c99_stdlib_cxx11, [
23c64853
JY
1217 GCC_TRY_COMPILE_OR_LINK(
1218 [#include <stdlib.h>
1219 volatile float f;
1220 volatile long double ld;
1221 volatile unsigned long long ll;
1222 lldiv_t mydivt;],
1223 [char* tmp;
1224 f = strtof("gnu", &tmp);
1225 ld = strtold("gnu", &tmp);
1226 ll = strtoll("gnu", &tmp, 10);
1227 ll = strtoull("gnu", &tmp, 10);
1228 ll = llabs(10);
1229 mydivt = lldiv(10,1);
1230 ll = mydivt.quot;
1231 ll = mydivt.rem;
1232 ll = atoll("10");
1233 _Exit(0);
1234 ], [glibcxx_cv_c99_stdlib_cxx11=yes], [glibcxx_cv_c99_stdlib_cxx11=no])
1235 ])
23c64853
JY
1236 if test x"$glibcxx_cv_c99_stdlib_cxx11" = x"yes"; then
1237 AC_DEFINE(_GLIBCXX11_USE_C99_STDLIB, 1,
1238 [Define if C99 functions or macros in <stdlib.h> should be imported
1239 in <cstdlib> in namespace std for C++11.])
1240 fi
1241
1242 # Check for the existence in <wchar.h> of wcstold, etc.
1243 if test x"$ac_has_wchar_h" = xyes &&
1244 test x"$ac_has_wctype_h" = xyes; then
9646a322
JW
1245 AC_CACHE_CHECK([for ISO C99 support in <wchar.h> for C++11],
1246 glibcxx_cv_c99_wchar_cxx11, [
23c64853
JY
1247 AC_TRY_COMPILE([#include <wchar.h>
1248 namespace test
1249 {
1250 using ::wcstold;
1251 using ::wcstoll;
1252 using ::wcstoull;
1253 }
1254 ], [], [glibcxx_cv_c99_wchar_cxx11=yes], [glibcxx_cv_c99_wchar_cxx11=no])
1255 ])
1256
1257 # Checks for wide character functions that may not be present.
1258 # Injection of these is wrapped with guard macros.
1259 # NB: only put functions here, instead of immediately above, if
1260 # absolutely necessary.
1261 AC_TRY_COMPILE([#include <wchar.h>
1262 namespace test { using ::vfwscanf; }], [],
1263 [AC_DEFINE(HAVE_VFWSCANF, 1, [Defined if vfwscanf exists.])], [])
1264
1265 AC_TRY_COMPILE([#include <wchar.h>
1266 namespace test { using ::vswscanf; }], [],
1267 [AC_DEFINE(HAVE_VSWSCANF, 1, [Defined if vswscanf exists.])], [])
1268
1269 AC_TRY_COMPILE([#include <wchar.h>
1270 namespace test { using ::vwscanf; }], [],
1271 [AC_DEFINE(HAVE_VWSCANF, 1, [Defined if vwscanf exists.])], [])
1272
1273 AC_TRY_COMPILE([#include <wchar.h>
1274 namespace test { using ::wcstof; }], [],
1275 [AC_DEFINE(HAVE_WCSTOF, 1, [Defined if wcstof exists.])], [])
1276
1277 AC_TRY_COMPILE([#include <wctype.h>],
1278 [wint_t t; int i = iswblank(t);],
1279 [AC_DEFINE(HAVE_ISWBLANK, 1, [Defined if iswblank exists.])], [])
1280
23c64853
JY
1281 if test x"$glibcxx_cv_c99_wchar_cxx11" = x"yes"; then
1282 AC_DEFINE(_GLIBCXX11_USE_C99_WCHAR, 1,
1283 [Define if C99 functions or macros in <wchar.h> should be imported
1284 in <cwchar> in namespace std for C++11.])
1285 fi
1286 fi
1287
1288 gcc_no_link="$ac_save_gcc_no_link"
1289 LIBS="$ac_save_LIBS"
1290 CXXFLAGS="$ac_save_CXXFLAGS"
1291 AC_LANG_RESTORE
b329dd10 1292 fi
347669a0
BK
1293
1294 AC_MSG_CHECKING([for fully enabled ISO C99 support])
1295 AC_MSG_RESULT($enable_c99)
dcfa0bc8
PE
1296])
1297
1298
15e38d0d 1299dnl
959d14e1 1300dnl Check for clock_gettime, nanosleep and sched_yield, used in the
9ab48d6e
JW
1301dnl implementation of 20.11.7 [time.clock], and 30.3.2 [thread.thread.this]
1302dnl in the C++11 standard.
15e38d0d 1303dnl
959d14e1
CF
1304dnl --enable-libstdcxx-time
1305dnl --enable-libstdcxx-time=yes
1306dnl checks for the availability of monotonic and realtime clocks,
55ebb0d6 1307dnl nanosleep and sched_yield in libc.
959d14e1 1308dnl --enable-libstdcxx-time=rt
9ab48d6e 1309dnl also searches (and, if needed, links) librt. Note that this is
88b1a025
JW
1310dnl not always desirable because, in glibc 2.16 and earlier, for
1311dnl example, in turn it triggers the linking of libpthread too,
1312dnl which activates locking,
6c3385c1 1313dnl a large overhead for single-thread programs.
959d14e1
CF
1314dnl --enable-libstdcxx-time=no
1315dnl --disable-libstdcxx-time
610870b2
PC
1316dnl disables the checks completely
1317dnl
0d184995
JH
1318dnl N.B. Darwin provides nanosleep but doesn't support the whole POSIX
1319dnl Timers option, so doesn't define _POSIX_TIMERS. Because the test
1320dnl below fails Darwin unconditionally defines _GLIBCXX_USE_NANOSLEEP in
1321dnl os_defines.h and also defines _GLIBCXX_USE_SCHED_YIELD.
1322dnl
959d14e1 1323AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
610870b2 1324
88b1a025 1325 GLIBCXX_ENABLE(libstdcxx-time,auto,[[[=KIND]]],
610870b2
PC
1326 [use KIND for check type],
1327 [permit yes|no|rt])
15e38d0d
CF
1328
1329 AC_LANG_SAVE
1330 AC_LANG_CPLUSPLUS
1331 ac_save_CXXFLAGS="$CXXFLAGS"
1332 CXXFLAGS="$CXXFLAGS -fno-exceptions"
ec6fa56a
PB
1333 ac_save_LIBS="$LIBS"
1334
1ac5e52c
MK
1335 ac_has_clock_monotonic=no
1336 ac_has_clock_realtime=no
88b1a025
JW
1337 ac_has_nanosleep=no
1338 ac_has_sched_yield=no
1339
1340 if test x"$enable_libstdcxx_time" = x"auto"; then
1341
1342 case "${target_os}" in
1343 cygwin*)
1344 ac_has_nanosleep=yes
1345 ;;
1346 darwin*)
1347 ac_has_nanosleep=yes
1348 ac_has_sched_yield=yes
1349 ;;
784daa97
CG
1350 # VxWorks has nanosleep as soon as the kernel is configured with
1351 # INCLUDE_POSIX_TIMERS, which is normally/most-often the case.
1352 vxworks*)
1353 ac_has_nanosleep=yes
1354 ;;
88b1a025 1355 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
759812fd
JW
1356 # Don't use link test for freestanding library, in case gcc_no_link=yes
1357 if test x"$is_hosted" = xyes; then
1358 # Versions of glibc before 2.17 needed -lrt for clock_gettime.
1359 AC_SEARCH_LIBS(clock_gettime, [rt])
1360 if test x"$ac_cv_search_clock_gettime" = x"none required"; then
1361 ac_has_clock_monotonic=yes
1362 ac_has_clock_realtime=yes
1363 fi
88b1a025
JW
1364 fi
1365 ac_has_nanosleep=yes
1366 ac_has_sched_yield=yes
1367 ;;
b76602dc 1368 freebsd*|netbsd*|dragonfly*|rtems*)
88b1a025
JW
1369 ac_has_clock_monotonic=yes
1370 ac_has_clock_realtime=yes
1371 ac_has_nanosleep=yes
1372 ac_has_sched_yield=yes
1373 ;;
1374 openbsd*)
1375 ac_has_clock_monotonic=yes
1376 ac_has_clock_realtime=yes
1377 ac_has_nanosleep=yes
1378 ;;
1379 solaris*)
88b1a025
JW
1380 ac_has_clock_monotonic=yes
1381 ac_has_clock_realtime=yes
1382 ac_has_nanosleep=yes
1383 ac_has_sched_yield=yes
1384 ;;
6508fa9c
CL
1385 uclinux*)
1386 ac_has_nanosleep=yes
1387 ac_has_sched_yield=yes
88b1a025 1388 esac
ec6fa56a 1389
88b1a025 1390 elif test x"$enable_libstdcxx_time" != x"no"; then
ec6fa56a 1391
959d14e1 1392 if test x"$enable_libstdcxx_time" = x"rt"; then
55ebb0d6
RO
1393 AC_SEARCH_LIBS(clock_gettime, [rt])
1394 AC_SEARCH_LIBS(nanosleep, [rt])
610870b2 1395 else
55ebb0d6
RO
1396 AC_CHECK_FUNC(clock_gettime)
1397 AC_CHECK_FUNC(nanosleep)
610870b2
PC
1398 fi
1399
1400 case "$ac_cv_search_clock_gettime" in
1401 -l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime
959d14e1
CF
1402 ;;
1403 esac
1404 case "$ac_cv_search_nanosleep" in
1405 -l*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_nanosleep"
1406 ;;
1407 esac
1408
55ebb0d6 1409 AC_SEARCH_LIBS(sched_yield, [rt])
959d14e1
CF
1410
1411 case "$ac_cv_search_sched_yield" in
959d14e1
CF
1412 -lrt*)
1413 if test x"$enable_libstdcxx_time" = x"rt"; then
b329dd10 1414 GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
88b1a025 1415 ac_has_sched_yield=yes
959d14e1
CF
1416 fi
1417 ;;
1418 *)
88b1a025 1419 ac_has_sched_yield=yes
959d14e1 1420 ;;
610870b2
PC
1421 esac
1422
1423 AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no)
1424
1425 if test x"$ac_has_unistd_h" = x"yes"; then
1426 AC_MSG_CHECKING([for monotonic clock])
1427 AC_TRY_LINK(
b329dd10
BK
1428 [#include <unistd.h>
1429 #include <time.h>
1430 ],
1431 [#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
1432 timespec tp;
1433 #endif
1434 clock_gettime(CLOCK_MONOTONIC, &tp);
1435 ], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no])
1436
1437 AC_MSG_RESULT($ac_has_clock_monotonic)
1438
610870b2
PC
1439 AC_MSG_CHECKING([for realtime clock])
1440 AC_TRY_LINK(
b329dd10
BK
1441 [#include <unistd.h>
1442 #include <time.h>
1443 ],
1444 [#if _POSIX_TIMERS > 0
1445 timespec tp;
1446 #endif
1447 clock_gettime(CLOCK_REALTIME, &tp);
1448 ], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
610870b2
PC
1449
1450 AC_MSG_RESULT($ac_has_clock_realtime)
610870b2 1451
959d14e1
CF
1452 AC_MSG_CHECKING([for nanosleep])
1453 AC_TRY_LINK(
b329dd10
BK
1454 [#include <unistd.h>
1455 #include <time.h>
1456 ],
1457 [#if _POSIX_TIMERS > 0
1458 timespec tp;
1459 #endif
1460 nanosleep(&tp, 0);
1461 ], [ac_has_nanosleep=yes], [ac_has_nanosleep=no])
959d14e1
CF
1462
1463 AC_MSG_RESULT($ac_has_nanosleep)
1464 fi
610870b2
PC
1465 fi
1466
2e8a9734
JJ
1467 if test x"$ac_has_clock_monotonic" != x"yes"; then
1468 case ${target_os} in
6508fa9c 1469 linux* | uclinux*)
2e8a9734
JJ
1470 AC_MSG_CHECKING([for clock_gettime syscall])
1471 AC_TRY_COMPILE(
1472 [#include <unistd.h>
1473 #include <time.h>
1474 #include <sys/syscall.h>
1475 ],
1476 [#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
1477 timespec tp;
1478 #endif
1479 syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &tp);
1480 syscall(SYS_clock_gettime, CLOCK_REALTIME, &tp);
1e3e6c70
JW
1481 ], [ac_has_clock_gettime_syscall=yes], [ac_has_clock_gettime_syscall=no])
1482 AC_MSG_RESULT($ac_has_clock_gettime_syscall)
1483 if test x"$ac_has_clock_gettime_syscall" = x"yes"; then
2e8a9734 1484 AC_DEFINE(_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL, 1,
1e3e6c70 1485 [Defined if clock_gettime syscall has monotonic and realtime clock support. ])
2e8a9734
JJ
1486 ac_has_clock_monotonic=yes
1487 ac_has_clock_realtime=yes
1e3e6c70
JW
1488 AC_MSG_CHECKING([for struct timespec that matches syscall])
1489 AC_TRY_COMPILE(
1490 [#include <time.h>
1491 #include <sys/syscall.h>
1492 ],
1493 [#ifdef SYS_clock_gettime64
1494 #if SYS_clock_gettime64 != SYS_clock_gettime
1495 // We need to use SYS_clock_gettime and libc appears to
1496 // also know about the SYS_clock_gettime64 syscall.
1497 // Check that userspace doesn't use time64 version of timespec.
1498 static_assert(sizeof(timespec::tv_sec) == sizeof(long),
1499 "struct timespec must be compatible with SYS_clock_gettime");
1500 #endif
1501 #endif
1502 ],
1503 [ac_timespec_matches_syscall=yes],
1504 [ac_timespec_matches_syscall=no])
1505 AC_MSG_RESULT($ac_timespec_matches_syscall)
1506 if test x"$ac_timespec_matches_syscall" = no; then
1507 AC_MSG_ERROR([struct timespec is not compatible with SYS_clock_gettime, please report a bug to http://gcc.gnu.org/bugzilla])
1508 fi
2e8a9734
JJ
1509 fi;;
1510 esac
1511 fi
1512
15e38d0d
CF
1513 if test x"$ac_has_clock_monotonic" = x"yes"; then
1514 AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC, 1,
1515 [ Defined if clock_gettime has monotonic clock support. ])
1516 fi
ec6fa56a 1517
15e38d0d
CF
1518 if test x"$ac_has_clock_realtime" = x"yes"; then
1519 AC_DEFINE(_GLIBCXX_USE_CLOCK_REALTIME, 1,
1520 [ Defined if clock_gettime has realtime clock support. ])
1521 fi
ec6fa56a 1522
88b1a025
JW
1523 if test x"$ac_has_sched_yield" = x"yes"; then
1524 AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
1525 [ Defined if sched_yield is available. ])
1526 fi
1527
959d14e1
CF
1528 if test x"$ac_has_nanosleep" = x"yes"; then
1529 AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1,
1530 [ Defined if nanosleep is available. ])
aa66b299
JW
1531 else
1532 AC_MSG_CHECKING([for sleep])
1533 AC_TRY_COMPILE([#include <unistd.h>],
1534 [sleep(1)],
1535 [ac_has_sleep=yes],[ac_has_sleep=no])
1536 if test x"$ac_has_sleep" = x"yes"; then
1537 AC_DEFINE(HAVE_SLEEP,1, [Defined if sleep exists.])
1538 fi
1539 AC_MSG_RESULT($ac_has_sleep)
1540 AC_MSG_CHECKING([for usleep])
1541 AC_TRY_COMPILE([#include <unistd.h>],
1542 [sleep(1);
1543 usleep(100);],
1544 [ac_has_usleep=yes],[ac_has_usleep=no])
1545 if test x"$ac_has_usleep" = x"yes"; then
1546 AC_DEFINE(HAVE_USLEEP,1, [Defined if usleep exists.])
1547 fi
1548 AC_MSG_RESULT($ac_has_usleep)
959d14e1
CF
1549 fi
1550
8ed812cc 1551 if test x"$ac_has_nanosleep$ac_has_sleep" = x"nono"; then
0aa1786d 1552 ac_no_sleep=yes
8ed812cc
JW
1553 AC_MSG_CHECKING([for Sleep])
1554 AC_TRY_COMPILE([#include <windows.h>],
1555 [Sleep(1)],
1556 [ac_has_win32_sleep=yes],[ac_has_win32_sleep=no])
1557 if test x"$ac_has_win32_sleep" = x"yes"; then
1558 AC_DEFINE(HAVE_WIN32_SLEEP,1, [Defined if Sleep exists.])
0aa1786d 1559 ac_no_sleep=no
8ed812cc
JW
1560 fi
1561 AC_MSG_RESULT($ac_has_win32_sleep)
1562 fi
1563
0aa1786d 1564 if test x"$ac_no_sleep" = x"yes"; then
ca1c7065 1565 AC_DEFINE(_GLIBCXX_NO_SLEEP,1, [Defined if no way to sleep is available.])
0aa1786d
JW
1566 fi
1567
ec6fa56a
PB
1568 AC_SUBST(GLIBCXX_LIBS)
1569
15e38d0d 1570 CXXFLAGS="$ac_save_CXXFLAGS"
ec6fa56a 1571 LIBS="$ac_save_LIBS"
15e38d0d
CF
1572 AC_LANG_RESTORE
1573])
1574
1575dnl
9ab48d6e
JW
1576dnl Check for gettimeofday, used in the implementation of 20.11.7
1577dnl [time.clock] in the C++11 standard.
15e38d0d
CF
1578dnl
1579AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
b329dd10 1580
610870b2
PC
1581 AC_MSG_CHECKING([for gettimeofday])
1582
15e38d0d
CF
1583 AC_LANG_SAVE
1584 AC_LANG_CPLUSPLUS
1585 ac_save_CXXFLAGS="$CXXFLAGS"
1586 CXXFLAGS="$CXXFLAGS -fno-exceptions"
b329dd10 1587
15e38d0d
CF
1588 ac_has_gettimeofday=no;
1589 AC_CHECK_HEADERS(sys/time.h, ac_has_sys_time_h=yes, ac_has_sys_time_h=no)
1590 if test x"$ac_has_sys_time_h" = x"yes"; then
1591 AC_MSG_CHECKING([for gettimeofday])
610870b2 1592 GCC_TRY_COMPILE_OR_LINK([#include <sys/time.h>],
15e38d0d
CF
1593 [timeval tv; gettimeofday(&tv, 0);],
1594 [ac_has_gettimeofday=yes], [ac_has_gettimeofday=no])
b329dd10 1595
15e38d0d
CF
1596 AC_MSG_RESULT($ac_has_gettimeofday)
1597 fi
b329dd10 1598
15e38d0d
CF
1599 if test x"$ac_has_gettimeofday" = x"yes"; then
1600 AC_DEFINE(_GLIBCXX_USE_GETTIMEOFDAY, 1,
1601 [ Defined if gettimeofday is available. ])
1602 fi
b329dd10 1603
15e38d0d
CF
1604 CXXFLAGS="$ac_save_CXXFLAGS"
1605 AC_LANG_RESTORE
1606])
1607
bd2bb1ea
PC
1608dnl
1609dnl Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1"
1610dnl facilities in Chapter 8, "C compatibility".
1611dnl
1612AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
1613
1614 AC_LANG_SAVE
1615 AC_LANG_CPLUSPLUS
1616
18f310b7
PC
1617 # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
1618 # undefined and fake C99 facilities may be spuriously enabled.
1619 ac_save_CXXFLAGS="$CXXFLAGS"
1620 CXXFLAGS="$CXXFLAGS -std=c++98"
1621
bd2bb1ea
PC
1622 # Check for the existence of <complex.h> complex math functions used
1623 # by tr1/complex.
1624 AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
1625 ac_c99_complex_tr1=no;
1626 if test x"$ac_has_complex_h" = x"yes"; then
1627 AC_MSG_CHECKING([for ISO C99 support to TR1 in <complex.h>])
1628 AC_TRY_COMPILE([#include <complex.h>],
b329dd10
BK
1629 [typedef __complex__ float float_type; float_type tmpf;
1630 cacosf(tmpf);
1631 casinf(tmpf);
1632 catanf(tmpf);
1633 cacoshf(tmpf);
1634 casinhf(tmpf);
1635 catanhf(tmpf);
bd2bb1ea 1636 typedef __complex__ double double_type; double_type tmpd;
b329dd10
BK
1637 cacos(tmpd);
1638 casin(tmpd);
1639 catan(tmpd);
1640 cacosh(tmpd);
1641 casinh(tmpd);
1642 catanh(tmpd);
bd2bb1ea 1643 typedef __complex__ long double ld_type; ld_type tmpld;
b329dd10
BK
1644 cacosl(tmpld);
1645 casinl(tmpld);
1646 catanl(tmpld);
1647 cacoshl(tmpld);
1648 casinhl(tmpld);
1649 catanhl(tmpld);
bd2bb1ea
PC
1650 ],[ac_c99_complex_tr1=yes], [ac_c99_complex_tr1=no])
1651 fi
1652 AC_MSG_RESULT($ac_c99_complex_tr1)
1653 if test x"$ac_c99_complex_tr1" = x"yes"; then
1654 AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX_TR1, 1,
b329dd10
BK
1655 [Define if C99 functions in <complex.h> should be used in
1656 <tr1/complex>. Using compiler builtins for these functions
bd2bb1ea
PC
1657 requires corresponding C99 library functions to be present.])
1658 fi
1659
1660 # Check for the existence of <ctype.h> functions.
9646a322
JW
1661 AC_CACHE_CHECK([for ISO C99 support to TR1 in <ctype.h>],
1662 glibcxx_cv_c99_ctype_tr1, [
bd2bb1ea 1663 AC_TRY_COMPILE([#include <ctype.h>],
b329dd10
BK
1664 [int ch;
1665 int ret;
1666 ret = isblank(ch);
0f24e8de
PC
1667 ],[glibcxx_cv_c99_ctype_tr1=yes],
1668 [glibcxx_cv_c99_ctype_tr1=no])
bd2bb1ea 1669 ])
6d26724a 1670 if test x"$glibcxx_cv_c99_ctype_tr1" = x"yes"; then
bd2bb1ea 1671 AC_DEFINE(_GLIBCXX_USE_C99_CTYPE_TR1, 1,
b329dd10 1672 [Define if C99 functions in <ctype.h> should be imported in
bd2bb1ea
PC
1673 <tr1/cctype> in namespace std::tr1.])
1674 fi
1675
20921e53
PC
1676 # Check for the existence of <fenv.h> functions.
1677 AC_CHECK_HEADERS(fenv.h, ac_has_fenv_h=yes, ac_has_fenv_h=no)
1678 ac_c99_fenv_tr1=no;
1679 if test x"$ac_has_fenv_h" = x"yes"; then
1680 AC_MSG_CHECKING([for ISO C99 support to TR1 in <fenv.h>])
1681 AC_TRY_COMPILE([#include <fenv.h>],
b329dd10
BK
1682 [int except, mode;
1683 fexcept_t* pflag;
1684 fenv_t* penv;
1685 int ret;
1686 ret = feclearexcept(except);
1687 ret = fegetexceptflag(pflag, except);
1688 ret = feraiseexcept(except);
1689 ret = fesetexceptflag(pflag, except);
1690 ret = fetestexcept(except);
1691 ret = fegetround();
1692 ret = fesetround(mode);
1693 ret = fegetenv(penv);
1694 ret = feholdexcept(penv);
1695 ret = fesetenv(penv);
1696 ret = feupdateenv(penv);
20921e53 1697 ],[ac_c99_fenv_tr1=yes], [ac_c99_fenv_tr1=no])
9646a322 1698 AC_MSG_RESULT($ac_c99_fenv_tr1)
20921e53 1699 fi
20921e53
PC
1700 if test x"$ac_c99_fenv_tr1" = x"yes"; then
1701 AC_DEFINE(_GLIBCXX_USE_C99_FENV_TR1, 1,
b329dd10 1702 [Define if C99 functions in <fenv.h> should be imported in
20921e53
PC
1703 <tr1/cfenv> in namespace std::tr1.])
1704 fi
1705
2a1d6346 1706 # Check for the existence of <stdint.h> types.
9646a322
JW
1707 AC_CACHE_CHECK([for ISO C99 support to TR1 in <stdint.h>],
1708 glibcxx_cv_c99_stdint_tr1, [
5289e808 1709 AC_TRY_COMPILE([#define __STDC_LIMIT_MACROS
b329dd10
BK
1710 #define __STDC_CONSTANT_MACROS
1711 #include <stdint.h>],
1712 [typedef int8_t my_int8_t;
5289e808
PC
1713 my_int8_t i8 = INT8_MIN;
1714 i8 = INT8_MAX;
b329dd10 1715 typedef int16_t my_int16_t;
5289e808
PC
1716 my_int16_t i16 = INT16_MIN;
1717 i16 = INT16_MAX;
b329dd10 1718 typedef int32_t my_int32_t;
5289e808
PC
1719 my_int32_t i32 = INT32_MIN;
1720 i32 = INT32_MAX;
b329dd10 1721 typedef int64_t my_int64_t;
5289e808
PC
1722 my_int64_t i64 = INT64_MIN;
1723 i64 = INT64_MAX;
b329dd10 1724 typedef int_fast8_t my_int_fast8_t;
5289e808
PC
1725 my_int_fast8_t if8 = INT_FAST8_MIN;
1726 if8 = INT_FAST8_MAX;
b329dd10 1727 typedef int_fast16_t my_int_fast16_t;
5289e808
PC
1728 my_int_fast16_t if16 = INT_FAST16_MIN;
1729 if16 = INT_FAST16_MAX;
b329dd10 1730 typedef int_fast32_t my_int_fast32_t;
5289e808
PC
1731 my_int_fast32_t if32 = INT_FAST32_MIN;
1732 if32 = INT_FAST32_MAX;
b329dd10 1733 typedef int_fast64_t my_int_fast64_t;
5289e808
PC
1734 my_int_fast64_t if64 = INT_FAST64_MIN;
1735 if64 = INT_FAST64_MAX;
b329dd10 1736 typedef int_least8_t my_int_least8_t;
5289e808
PC
1737 my_int_least8_t il8 = INT_LEAST8_MIN;
1738 il8 = INT_LEAST8_MAX;
b329dd10 1739 typedef int_least16_t my_int_least16_t;
5289e808
PC
1740 my_int_least16_t il16 = INT_LEAST16_MIN;
1741 il16 = INT_LEAST16_MAX;
b329dd10 1742 typedef int_least32_t my_int_least32_t;
5289e808
PC
1743 my_int_least32_t il32 = INT_LEAST32_MIN;
1744 il32 = INT_LEAST32_MAX;
b329dd10 1745 typedef int_least64_t my_int_least64_t;
5289e808
PC
1746 my_int_least64_t il64 = INT_LEAST64_MIN;
1747 il64 = INT_LEAST64_MAX;
2a1d6346 1748 typedef intmax_t my_intmax_t;
5289e808
PC
1749 my_intmax_t im = INTMAX_MAX;
1750 im = INTMAX_MIN;
2a1d6346 1751 typedef intptr_t my_intptr_t;
5289e808
PC
1752 my_intptr_t ip = INTPTR_MAX;
1753 ip = INTPTR_MIN;
b329dd10 1754 typedef uint8_t my_uint8_t;
5289e808
PC
1755 my_uint8_t ui8 = UINT8_MAX;
1756 ui8 = UINT8_MAX;
b329dd10 1757 typedef uint16_t my_uint16_t;
5289e808
PC
1758 my_uint16_t ui16 = UINT16_MAX;
1759 ui16 = UINT16_MAX;
b329dd10 1760 typedef uint32_t my_uint32_t;
5289e808
PC
1761 my_uint32_t ui32 = UINT32_MAX;
1762 ui32 = UINT32_MAX;
b329dd10 1763 typedef uint64_t my_uint64_t;
5289e808
PC
1764 my_uint64_t ui64 = UINT64_MAX;
1765 ui64 = UINT64_MAX;
b329dd10 1766 typedef uint_fast8_t my_uint_fast8_t;
5289e808
PC
1767 my_uint_fast8_t uif8 = UINT_FAST8_MAX;
1768 uif8 = UINT_FAST8_MAX;
b329dd10 1769 typedef uint_fast16_t my_uint_fast16_t;
5289e808
PC
1770 my_uint_fast16_t uif16 = UINT_FAST16_MAX;
1771 uif16 = UINT_FAST16_MAX;
b329dd10 1772 typedef uint_fast32_t my_uint_fast32_t;
5289e808
PC
1773 my_uint_fast32_t uif32 = UINT_FAST32_MAX;
1774 uif32 = UINT_FAST32_MAX;
b329dd10 1775 typedef uint_fast64_t my_uint_fast64_t;
5289e808
PC
1776 my_uint_fast64_t uif64 = UINT_FAST64_MAX;
1777 uif64 = UINT_FAST64_MAX;
b329dd10 1778 typedef uint_least8_t my_uint_least8_t;
5289e808
PC
1779 my_uint_least8_t uil8 = UINT_LEAST8_MAX;
1780 uil8 = UINT_LEAST8_MAX;
b329dd10 1781 typedef uint_least16_t my_uint_least16_t;
5289e808
PC
1782 my_uint_least16_t uil16 = UINT_LEAST16_MAX;
1783 uil16 = UINT_LEAST16_MAX;
b329dd10 1784 typedef uint_least32_t my_uint_least32_t;
5289e808
PC
1785 my_uint_least32_t uil32 = UINT_LEAST32_MAX;
1786 uil32 = UINT_LEAST32_MAX;
b329dd10 1787 typedef uint_least64_t my_uint_least64_t;
5289e808
PC
1788 my_uint_least64_t uil64 = UINT_LEAST64_MAX;
1789 uil64 = UINT_LEAST64_MAX;
2a1d6346 1790 typedef uintmax_t my_uintmax_t;
5289e808
PC
1791 my_uintmax_t uim = UINTMAX_MAX;
1792 uim = UINTMAX_MAX;
2a1d6346 1793 typedef uintptr_t my_uintptr_t;
5289e808
PC
1794 my_uintptr_t uip = UINTPTR_MAX;
1795 uip = UINTPTR_MAX;
0f24e8de
PC
1796 ],[glibcxx_cv_c99_stdint_tr1=yes],
1797 [glibcxx_cv_c99_stdint_tr1=no])
2a1d6346 1798 ])
6d26724a 1799 if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
2a1d6346 1800 AC_DEFINE(_GLIBCXX_USE_C99_STDINT_TR1, 1,
b329dd10 1801 [Define if C99 types in <stdint.h> should be imported in
2a1d6346
PC
1802 <tr1/cstdint> in namespace std::tr1.])
1803 fi
1804
4f0de5dd 1805 # Check for the existence of <math.h> functions.
9646a322
JW
1806 AC_CACHE_CHECK([for ISO C99 support to TR1 in <math.h>],
1807 glibcxx_cv_c99_math_tr1, [
4f0de5dd 1808 AC_TRY_COMPILE([#include <math.h>],
b329dd10
BK
1809 [typedef double_t my_double_t;
1810 typedef float_t my_float_t;
1811 acosh(0.0);
1812 acoshf(0.0f);
1813 acoshl(0.0l);
1814 asinh(0.0);
1815 asinhf(0.0f);
1816 asinhl(0.0l);
1817 atanh(0.0);
1818 atanhf(0.0f);
1819 atanhl(0.0l);
1820 cbrt(0.0);
1821 cbrtf(0.0f);
1822 cbrtl(0.0l);
1823 copysign(0.0, 0.0);
1824 copysignf(0.0f, 0.0f);
1825 copysignl(0.0l, 0.0l);
1826 erf(0.0);
1827 erff(0.0f);
1828 erfl(0.0l);
1829 erfc(0.0);
1830 erfcf(0.0f);
1831 erfcl(0.0l);
1832 exp2(0.0);
1833 exp2f(0.0f);
1834 exp2l(0.0l);
1835 expm1(0.0);
1836 expm1f(0.0f);
1837 expm1l(0.0l);
1838 fdim(0.0, 0.0);
1839 fdimf(0.0f, 0.0f);
1840 fdiml(0.0l, 0.0l);
1841 fma(0.0, 0.0, 0.0);
1842 fmaf(0.0f, 0.0f, 0.0f);
1843 fmal(0.0l, 0.0l, 0.0l);
1844 fmax(0.0, 0.0);
1845 fmaxf(0.0f, 0.0f);
1846 fmaxl(0.0l, 0.0l);
1847 fmin(0.0, 0.0);
1848 fminf(0.0f, 0.0f);
1849 fminl(0.0l, 0.0l);
1850 hypot(0.0, 0.0);
1851 hypotf(0.0f, 0.0f);
1852 hypotl(0.0l, 0.0l);
1853 ilogb(0.0);
1854 ilogbf(0.0f);
1855 ilogbl(0.0l);
1856 lgamma(0.0);
1857 lgammaf(0.0f);
1858 lgammal(0.0l);
a7765de8 1859 #ifndef __APPLE__ /* see below */
b329dd10
BK
1860 llrint(0.0);
1861 llrintf(0.0f);
1862 llrintl(0.0l);
1863 llround(0.0);
1864 llroundf(0.0f);
1865 llroundl(0.0l);
a7765de8 1866 #endif
b329dd10
BK
1867 log1p(0.0);
1868 log1pf(0.0f);
1869 log1pl(0.0l);
1870 log2(0.0);
1871 log2f(0.0f);
1872 log2l(0.0l);
1873 logb(0.0);
1874 logbf(0.0f);
1875 logbl(0.0l);
1876 lrint(0.0);
1877 lrintf(0.0f);
1878 lrintl(0.0l);
1879 lround(0.0);
1880 lroundf(0.0f);
1881 lroundl(0.0l);
1882 nan(0);
1883 nanf(0);
1884 nanl(0);
1885 nearbyint(0.0);
1886 nearbyintf(0.0f);
1887 nearbyintl(0.0l);
1888 nextafter(0.0, 0.0);
1889 nextafterf(0.0f, 0.0f);
1890 nextafterl(0.0l, 0.0l);
1891 nexttoward(0.0, 0.0);
1892 nexttowardf(0.0f, 0.0f);
1893 nexttowardl(0.0l, 0.0l);
1894 remainder(0.0, 0.0);
1895 remainderf(0.0f, 0.0f);
1896 remainderl(0.0l, 0.0l);
1897 remquo(0.0, 0.0, 0);
1898 remquof(0.0f, 0.0f, 0);
1899 remquol(0.0l, 0.0l, 0);
1900 rint(0.0);
1901 rintf(0.0f);
1902 rintl(0.0l);
1903 round(0.0);
1904 roundf(0.0f);
1905 roundl(0.0l);
1906 scalbln(0.0, 0l);
1907 scalblnf(0.0f, 0l);
1908 scalblnl(0.0l, 0l);
1909 scalbn(0.0, 0);
1910 scalbnf(0.0f, 0);
1911 scalbnl(0.0l, 0);
1912 tgamma(0.0);
1913 tgammaf(0.0f);
1914 tgammal(0.0l);
1915 trunc(0.0);
1916 truncf(0.0f);
1917 truncl(0.0l);
6d26724a 1918 ],[glibcxx_cv_c99_math_tr1=yes], [glibcxx_cv_c99_math_tr1=no])
4f0de5dd 1919 ])
6d26724a 1920 if test x"$glibcxx_cv_c99_math_tr1" = x"yes"; then
4f0de5dd 1921 AC_DEFINE(_GLIBCXX_USE_C99_MATH_TR1, 1,
b329dd10
BK
1922 [Define if C99 functions or macros in <math.h> should be imported
1923 in <tr1/cmath> in namespace std::tr1.])
a7765de8
JW
1924
1925 case "${target_os}" in
1926 darwin*)
9646a322
JW
1927 AC_CACHE_CHECK([for ISO C99 rounding functions in <math.h>],
1928 glibcxx_cv_c99_math_llround, [
a7765de8
JW
1929 AC_TRY_COMPILE([#include <math.h>],
1930 [llrint(0.0);
1931 llrintf(0.0f);
1932 llrintl(0.0l);
1933 llround(0.0);
1934 llroundf(0.0f);
1935 llroundl(0.0l);
1936 ],
1937 [glibcxx_cv_c99_math_llround=yes],
1938 [glibcxx_cv_c99_math_llround=no])
1939 ])
a7765de8
JW
1940 ;;
1941 esac
1942 if test x"$glibcxx_cv_c99_math_llround" = x"no"; then
1943 AC_DEFINE(_GLIBCXX_NO_C99_ROUNDING_FUNCS, 1,
1944 [Define if C99 llrint and llround functions are missing from <math.h>.])
1945 fi
4f0de5dd
PC
1946 fi
1947
03bf3bc1 1948 # Check for the existence of <inttypes.h> functions (NB: doesn't make
a834e097 1949 # sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
03bf3bc1 1950 ac_c99_inttypes_tr1=no;
6d26724a 1951 if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
03bf3bc1
PC
1952 AC_MSG_CHECKING([for ISO C99 support to TR1 in <inttypes.h>])
1953 AC_TRY_COMPILE([#include <inttypes.h>],
b329dd10
BK
1954 [intmax_t i, numer, denom, base;
1955 const char* s;
1956 char** endptr;
1957 intmax_t ret = imaxabs(i);
1958 imaxdiv_t dret = imaxdiv(numer, denom);
1959 ret = strtoimax(s, endptr, base);
1960 uintmax_t uret = strtoumax(s, endptr, base);
1961 ],[ac_c99_inttypes_tr1=yes], [ac_c99_inttypes_tr1=no])
9646a322 1962 AC_MSG_RESULT($ac_c99_inttypes_tr1)
03bf3bc1 1963 fi
52a64bd3
PC
1964 if test x"$ac_c99_inttypes_tr1" = x"yes"; then
1965 AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_TR1, 1,
b329dd10
BK
1966 [Define if C99 functions in <inttypes.h> should be imported in
1967 <tr1/cinttypes> in namespace std::tr1.])
52a64bd3
PC
1968 fi
1969
bb93f35d 1970 # Check for the existence of wchar_t <inttypes.h> functions (NB: doesn't
a834e097
PC
1971 # make sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
1972 ac_c99_inttypes_wchar_t_tr1=no;
1973 if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
1974 AC_MSG_CHECKING([for wchar_t ISO C99 support to TR1 in <inttypes.h>])
1975 AC_TRY_COMPILE([#include <inttypes.h>],
b329dd10 1976 [intmax_t base;
a834e097 1977 const wchar_t* s;
b329dd10
BK
1978 wchar_t** endptr;
1979 intmax_t ret = wcstoimax(s, endptr, base);
1980 uintmax_t uret = wcstoumax(s, endptr, base);
1981 ],[ac_c99_inttypes_wchar_t_tr1=yes],
a834e097 1982 [ac_c99_inttypes_wchar_t_tr1=no])
9646a322 1983 AC_MSG_RESULT($ac_c99_inttypes_wchar_t_tr1)
a834e097 1984 fi
a834e097
PC
1985 if test x"$ac_c99_inttypes_wchar_t_tr1" = x"yes"; then
1986 AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1, 1,
b329dd10 1987 [Define if wchar_t C99 functions in <inttypes.h> should be
a834e097
PC
1988 imported in <tr1/cinttypes> in namespace std::tr1.])
1989 fi
1990
b329dd10 1991 # Check for the existence of the <stdbool.h> header.
1e41a98c
PC
1992 AC_CHECK_HEADERS(stdbool.h)
1993
e0f0ee74
JW
1994 # Check for the existence of the <stdalign.h> header.
1995 AC_CHECK_HEADERS(stdalign.h)
1996
18f310b7 1997 CXXFLAGS="$ac_save_CXXFLAGS"
bd2bb1ea
PC
1998 AC_LANG_RESTORE
1999])
2000
20b5f0b3
ESR
2001dnl
2002dnl Check for uchar.h and usability.
2003dnl
2004AC_DEFUN([GLIBCXX_CHECK_UCHAR_H], [
2005
2006 # Test uchar.h.
2007 AC_CHECK_HEADERS(uchar.h, ac_has_uchar_h=yes, ac_has_uchar_h=no)
2008
2009 AC_LANG_SAVE
2010 AC_LANG_CPLUSPLUS
2011 ac_save_CXXFLAGS="$CXXFLAGS"
2012 CXXFLAGS="$CXXFLAGS -std=c++11"
2013
2014 if test x"$ac_has_uchar_h" = x"yes"; then
2015 AC_MSG_CHECKING([for ISO C11 support for <uchar.h>])
2016 AC_TRY_COMPILE([#include <uchar.h>
2017 #ifdef __STDC_UTF_16__
2018 long i = __STDC_UTF_16__;
2019 #endif
2020 #ifdef __STDC_UTF_32__
2021 long j = __STDC_UTF_32__;
2022 #endif
2023 namespace test
2024 {
2025 using ::c16rtomb;
2026 using ::c32rtomb;
2027 using ::mbrtoc16;
2028 using ::mbrtoc32;
2029 }
2030 ],
2031 [], [ac_c11_uchar_cxx11=yes], [ac_c11_uchar_cxx11=no])
9646a322 2032 AC_MSG_RESULT($ac_c11_uchar_cxx11)
20b5f0b3
ESR
2033 else
2034 ac_c11_uchar_cxx11=no
2035 fi
20b5f0b3
ESR
2036 if test x"$ac_c11_uchar_cxx11" = x"yes"; then
2037 AC_DEFINE(_GLIBCXX_USE_C11_UCHAR_CXX11, 1,
2038 [Define if C11 functions in <uchar.h> should be imported into
2039 namespace std in <cuchar>.])
2040 fi
2041
2042 CXXFLAGS="$ac_save_CXXFLAGS"
2043 AC_LANG_RESTORE
2044])
2045
2046
d8bc9819 2047dnl
5ae2c32a
JW
2048dnl Check whether "/dev/random" and "/dev/urandom" are available for
2049dnl class std::random_device from C++ 2011 [rand.device], and
d8bc9819
PC
2050dnl random_device of "TR1" (Chapter 5.1, "Random number generation").
2051dnl
5ae2c32a 2052AC_DEFUN([GLIBCXX_CHECK_DEV_RANDOM], [
d8bc9819 2053
9646a322
JW
2054 AC_CACHE_CHECK([for "/dev/random" and "/dev/urandom" for std::random_device],
2055 glibcxx_cv_dev_random, [
9ce0a22e 2056 if test -r /dev/random && test -r /dev/urandom; then
5ae2c32a
JW
2057 ## For MSys environment the test above is detected as false-positive
2058 ## on mingw-targets. So disable it explicitly for them.
cf2f3b1b 2059 case ${target_os} in
5ae2c32a
JW
2060 *mingw*) glibcxx_cv_dev_random=no ;;
2061 *) glibcxx_cv_dev_random=yes ;;
cf2f3b1b 2062 esac
9ce0a22e 2063 else
5ae2c32a 2064 glibcxx_cv_dev_random=no;
9ce0a22e 2065 fi
d8bc9819 2066 ])
9ce0a22e 2067
5ae2c32a
JW
2068 if test x"$glibcxx_cv_dev_random" = x"yes"; then
2069 AC_DEFINE(_GLIBCXX_USE_DEV_RANDOM, 1,
2070 [Define if /dev/random and /dev/urandom are available for
2071 std::random_device.])
d8bc9819 2072 AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1, 1,
b329dd10 2073 [Define if /dev/random and /dev/urandom are available for
d8bc9819
PC
2074 the random_device of TR1 (Chapter 5.1).])
2075 fi
2076
2077])
bd2bb1ea 2078
1814157e 2079dnl
ddc9c40d
PC
2080dnl Compute the EOF, SEEK_CUR, and SEEK_END integer constants.
2081dnl
2082AC_DEFUN([GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS], [
2083
9b04fa91 2084 AC_CACHE_CHECK([for the value of EOF], glibcxx_cv_stdio_eof, [
ddc9c40d 2085 AC_COMPUTE_INT([glibcxx_cv_stdio_eof], [[EOF]],
b329dd10
BK
2086 [#include <stdio.h>],
2087 [AC_MSG_ERROR([computing EOF failed])])
ddc9c40d 2088 ])
ddc9c40d 2089 AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_EOF, $glibcxx_cv_stdio_eof,
b329dd10 2090 [Define to the value of the EOF integer constant.])
ddc9c40d 2091
9b04fa91 2092 AC_CACHE_CHECK([for the value of SEEK_CUR], glibcxx_cv_stdio_seek_cur, [
ddc9c40d 2093 AC_COMPUTE_INT([glibcxx_cv_stdio_seek_cur], [[SEEK_CUR]],
b329dd10
BK
2094 [#include <stdio.h>],
2095 [AC_MSG_ERROR([computing SEEK_CUR failed])])
ddc9c40d 2096 ])
ddc9c40d 2097 AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_SEEK_CUR, $glibcxx_cv_stdio_seek_cur,
b329dd10 2098 [Define to the value of the SEEK_CUR integer constant.])
ddc9c40d 2099
9b04fa91 2100 AC_CACHE_CHECK([for the value of SEEK_END], glibcxx_cv_stdio_seek_end, [
ddc9c40d 2101 AC_COMPUTE_INT([glibcxx_cv_stdio_seek_end], [[SEEK_END]],
b329dd10
BK
2102 [#include <stdio.h>],
2103 [AC_MSG_ERROR([computing SEEK_END failed])])
ddc9c40d 2104 ])
ddc9c40d 2105 AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_SEEK_END, $glibcxx_cv_stdio_seek_end,
b329dd10 2106 [Define to the value of the SEEK_END integer constant.])
1814157e
PC
2107])
2108
1b6ce36f
BK
2109dnl
2110dnl Check whether required C++ overloads are present in <stdio.h>.
2111dnl
2112AC_DEFUN([GLIBCXX_CHECK_STDIO_PROTO], [
2113
2114 AC_LANG_SAVE
2115 AC_LANG_CPLUSPLUS
36105dbd
JW
2116 # Use C++11 because a conforming <stdio.h> won't define gets for C++14,
2117 # and we don't need a declaration for C++14 anyway.
2118 ac_save_CXXFLAGS="$CXXFLAGS"
2119 CXXFLAGS="$CXXFLAGS -std=gnu++11"
1b6ce36f 2120
9646a322 2121 AC_CACHE_CHECK([for gets declaration], glibcxx_cv_gets, [
1b6ce36f
BK
2122 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
2123 [#include <stdio.h>
7607ff49 2124 namespace test
1b6ce36f
BK
2125 {
2126 using ::gets;
2127 }
2128 ])],
2129 [glibcxx_cv_gets=yes],
2130 [glibcxx_cv_gets=no]
2131 )])
2132
2133 if test $glibcxx_cv_gets = yes; then
36105dbd 2134 AC_DEFINE(HAVE_GETS, 1, [Define if gets is available in <stdio.h> before C++14.])
1b6ce36f 2135 fi
1b6ce36f 2136
36105dbd 2137 CXXFLAGS="$ac_save_CXXFLAGS"
1b6ce36f
BK
2138 AC_LANG_RESTORE
2139])
2140
ef3a7506 2141dnl
3115f94f
RO
2142dnl Check whether required C++11 overloads for floating point and integral
2143dnl types are present in <math.h>.
ef3a7506
RO
2144dnl
2145AC_DEFUN([GLIBCXX_CHECK_MATH11_PROTO], [
2146
2147 AC_LANG_SAVE
2148 AC_LANG_CPLUSPLUS
2149 ac_save_CXXFLAGS="$CXXFLAGS"
2150 CXXFLAGS="$CXXFLAGS -std=c++11"
2151
2152 case "$host" in
2153 *-*-solaris2.*)
3115f94f
RO
2154 # Solaris 12 Build 86, Solaris 11.3 SRU 3.6, and Solaris 10 Patch
2155 # 11996[67]-02 introduced the C++11 <math.h> floating point overloads.
9646a322
JW
2156 AC_CACHE_CHECK([for C++11 <math.h> floating point overloads],
2157 glibcxx_cv_math11_fp_overload, [
ef3a7506
RO
2158 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
2159 [#include <math.h>
2160 #undef isfinite
2161 namespace std {
2162 inline bool isfinite(float __x)
2163 { return __builtin_isfinite(__x); }
2164 }
2165 ])],
3115f94f
RO
2166 [glibcxx_cv_math11_fp_overload=no],
2167 [glibcxx_cv_math11_fp_overload=yes]
ef3a7506
RO
2168 )])
2169
2170 # autoheader cannot handle indented templates.
3115f94f
RO
2171 AH_VERBATIM([__CORRECT_ISO_CPP11_MATH_H_PROTO_FP],
2172 [/* Define if all C++11 floating point overloads are available in <math.h>. */
ef3a7506 2173#if __cplusplus >= 201103L
3115f94f 2174#undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
ef3a7506
RO
2175#endif])
2176
3115f94f
RO
2177 if test $glibcxx_cv_math11_fp_overload = yes; then
2178 AC_DEFINE(__CORRECT_ISO_CPP11_MATH_H_PROTO_FP)
ef3a7506 2179 fi
3115f94f
RO
2180
2181 # Solaris 12 Build 90, Solaris 11.3 SRU 5.6, and Solaris 10 Patch
2182 # 11996[67]-02 introduced the C++11 <math.h> integral type overloads.
9646a322
JW
2183 AC_CACHE_CHECK([for C++11 <math.h> integral type overloads],
2184 glibcxx_cv_math11_int_overload, [
3115f94f
RO
2185 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
2186 [#include <math.h>
2187 namespace std {
2188 template<typename _Tp>
2189 struct __is_integer;
2190 template<>
2191 struct __is_integer<int>
2192 {
2193 enum { __value = 1 };
2194 };
2195 }
2196 namespace __gnu_cxx {
2197 template<bool, typename>
2198 struct __enable_if;
2199 template<typename _Tp>
2200 struct __enable_if<true, _Tp>
2201 { typedef _Tp __type; };
2202 }
2203 namespace std {
2204 template<typename _Tp>
2205 constexpr typename __gnu_cxx::__enable_if
2206 <__is_integer<_Tp>::__value, double>::__type
2207 log2(_Tp __x)
2208 { return __builtin_log2(__x); }
2209 }
2210 int
2211 main (void)
2212 {
2213 int i = 1000;
2214 return std::log2(i);
2215 }
2216 ])],
2217 [glibcxx_cv_math11_int_overload=no],
2218 [glibcxx_cv_math11_int_overload=yes]
2219 )])
2220
2221 # autoheader cannot handle indented templates.
2222 AH_VERBATIM([__CORRECT_ISO_CPP11_MATH_H_PROTO_INT],
2223 [/* Define if all C++11 integral type overloads are available in <math.h>. */
2224#if __cplusplus >= 201103L
2225#undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2226#endif])
2227
2228 if test $glibcxx_cv_math11_int_overload = yes; then
2229 AC_DEFINE(__CORRECT_ISO_CPP11_MATH_H_PROTO_INT)
2230 fi
ef3a7506 2231 ;;
cc07da33 2232 *)
39a1d8c8
JW
2233 # If <math.h> defines the obsolete isinf(double) and isnan(double)
2234 # functions (instead of or as well as the C99 generic macros) then we
2235 # can't define std::isinf(double) and std::isnan(double) in <cmath>
2236 # and must use the ones from <math.h> instead.
9646a322
JW
2237 AC_CACHE_CHECK([for obsolete isinf function in <math.h>],
2238 glibcxx_cv_obsolete_isinf, [
39a1d8c8 2239 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
cc07da33
JW
2240 [#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
2241 #include <math.h>
39a1d8c8 2242 #undef isinf
39a1d8c8
JW
2243 namespace std {
2244 using ::isinf;
2158532f
JW
2245 bool isinf(float);
2246 bool isinf(long double);
69b0daeb
JDA
2247 }
2248 using std::isinf;
2249 bool b = isinf(0.0);
2250 ])],
2251 [glibcxx_cv_obsolete_isinf=yes],
2252 [glibcxx_cv_obsolete_isinf=no]
2253 )])
69b0daeb
JDA
2254 if test $glibcxx_cv_obsolete_isinf = yes; then
2255 AC_DEFINE(HAVE_OBSOLETE_ISINF, 1,
2256 [Define if <math.h> defines obsolete isinf function.])
2257 fi
2258
9646a322
JW
2259 AC_CACHE_CHECK([for obsolete isnan function in <math.h>],
2260 glibcxx_cv_obsolete_isnan, [
69b0daeb 2261 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
74106ead
GL
2262 [#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
2263 #include <math.h>
69b0daeb
JDA
2264 #undef isnan
2265 namespace std {
39a1d8c8
JW
2266 using ::isnan;
2267 bool isnan(float);
2268 bool isnan(long double);
2269 }
39a1d8c8 2270 using std::isnan;
69b0daeb 2271 bool b = isnan(0.0);
39a1d8c8 2272 ])],
69b0daeb
JDA
2273 [glibcxx_cv_obsolete_isnan=yes],
2274 [glibcxx_cv_obsolete_isnan=no]
39a1d8c8 2275 )])
69b0daeb
JDA
2276 if test $glibcxx_cv_obsolete_isnan = yes; then
2277 AC_DEFINE(HAVE_OBSOLETE_ISNAN, 1,
2278 [Define if <math.h> defines obsolete isnan function.])
39a1d8c8 2279 fi
39a1d8c8 2280 ;;
ef3a7506
RO
2281 esac
2282
2283 CXXFLAGS="$ac_save_CXXFLAGS"
2284 AC_LANG_RESTORE
2285])
2286
0214010c 2287dnl
ff66d28f
PE
2288dnl Check for what type of C headers to use.
2289dnl
2290dnl --enable-cheaders= [does stuff].
2291dnl --disable-cheaders [does not do anything, really].
2292dnl + Usage: GLIBCXX_ENABLE_CHEADERS[(DEFAULT)]
55484a0f
JW
2293dnl Where DEFAULT is either 'c' or 'c_global' or 'c_std'.
2294dnl
2295dnl To use the obsolete 'c_std' headers use --enable-cheaders-obsolete as
2296dnl well as --enable-cheaders=c_std, otherwise configure will fail.
ff66d28f 2297dnl
f214923c 2298AC_DEFUN([GLIBCXX_ENABLE_CHEADERS], [
55484a0f
JW
2299 GLIBCXX_ENABLE(cheaders-obsolete,no,,
2300 [allow use of obsolete "C" headers for g++])
b453ace3 2301 GLIBCXX_ENABLE(cheaders,$1,[[[=KIND]]],
55484a0f 2302 [construct "C" headers for g++], [permit c|c_global|c_std])
ff66d28f 2303 AC_MSG_NOTICE("C" header strategy set to $enable_cheaders)
55484a0f
JW
2304 if test $enable_cheaders = c_std ; then
2305 AC_MSG_WARN([the --enable-cheaders=c_std configuration is obsolete, c_global should be used instead])
2306 AC_MSG_WARN([if you are unable to use c_global please report a bug or inform libstdc++@gcc.gnu.org])
2307 if test $enable_cheaders_obsolete != yes ; then
2308 AC_MSG_ERROR(use --enable-cheaders-obsolete to use c_std "C" headers)
2309 fi
2310 fi
ff66d28f
PE
2311
2312 C_INCLUDE_DIR='${glibcxx_srcdir}/include/'$enable_cheaders
2313
af13a7a6
BK
2314 # Allow overrides to configure.host here.
2315 if test $enable_cheaders = c_global; then
2316 c_compatibility=yes
2317 fi
2318
ff66d28f 2319 AC_SUBST(C_INCLUDE_DIR)
92eabea2
PE
2320 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C, test $enable_cheaders = c)
2321 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_STD, test $enable_cheaders = c_std)
af13a7a6 2322 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_GLOBAL, test $enable_cheaders = c_global)
92eabea2 2323 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_COMPATIBILITY, test $c_compatibility = yes)
ff66d28f
PE
2324])
2325
2326
0214010c 2327dnl
ff66d28f
PE
2328dnl Check for which locale library to use. The choice is mapped to
2329dnl a subdirectory of config/locale.
37bc6ca2 2330dnl
ff66d28f 2331dnl Default is generic.
0214010c 2332dnl
f214923c 2333AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
b453ace3 2334 GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]],
ff66d28f 2335 [use MODEL for target locale package],
aeb4926a 2336 [permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto])
0258dc3a
BK
2337
2338 # Deal with gettext issues. Default to not using it (=no) until we detect
2339 # support for it later. Let the user turn it off via --e/d, but let that
2340 # default to on for easier handling.
2341 USE_NLS=no
2342 AC_ARG_ENABLE(nls,
2343 AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]),
2344 [],
2345 [enable_nls=yes])
b329dd10 2346
aeb4926a 2347 # Either a known package, or "auto"
ff66d28f
PE
2348 if test $enable_clocale = no || test $enable_clocale = yes; then
2349 enable_clocale=auto
2350 fi
0214010c
BK
2351 enable_clocale_flag=$enable_clocale
2352
0258dc3a 2353 # Probe for locale model to use if none specified.
ff66d28f
PE
2354 # Default to "generic".
2355 if test $enable_clocale_flag = auto; then
7d3998a4
PE
2356 case ${target_os} in
2357 linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
b329dd10
BK
2358 enable_clocale_flag=gnu
2359 ;;
301d1d00 2360 darwin*)
b329dd10 2361 enable_clocale_flag=darwin
f9686024 2362 ;;
523ca640
CG
2363 vxworks*)
2364 enable_clocale_flag=vxworks
2365 ;;
301d1d00 2366 dragonfly* | freebsd*)
dbed5a9b
JM
2367 enable_clocale_flag=dragonfly
2368 ;;
1f726ff8
MK
2369 openbsd*)
2370 enable_clocale_flag=newlib
2371 ;;
56deb74c 2372 *)
aeb4926a
YZ
2373 if test x"$with_newlib" = x"yes"; then
2374 enable_clocale_flag=newlib
2375 else
2376 enable_clocale_flag=generic
2377 fi
b329dd10 2378 ;;
56deb74c
BK
2379 esac
2380 fi
2381
0258dc3a
BK
2382 # Sanity check model, and test for special functionality.
2383 if test $enable_clocale_flag = gnu; then
2384 AC_EGREP_CPP([_GLIBCXX_ok], [
2385 #include <features.h>
22b36782 2386 #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(__UCLIBC__)
0258dc3a
BK
2387 _GLIBCXX_ok
2388 #endif
2389 ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
2390
0258dc3a 2391 # Set it to scream when it hurts.
b329dd10 2392 ac_save_CFLAGS="$CFLAGS"
0258dc3a
BK
2393 CFLAGS="-Wimplicit-function-declaration -Werror"
2394
2395 # Use strxfrm_l if available.
2396 AC_TRY_COMPILE([#define _GNU_SOURCE 1
2397 #include <string.h>
2398 #include <locale.h>],
b329dd10
BK
2399 [char s[128]; __locale_t loc; strxfrm_l(s, "C", 5, loc);],
2400 AC_DEFINE(HAVE_STRXFRM_L, 1,
2401 [Define if strxfrm_l is available in <string.h>.]),)
2402
0258dc3a
BK
2403 # Use strerror_l if available.
2404 AC_TRY_COMPILE([#define _GNU_SOURCE 1
2405 #include <string.h>
2406 #include <locale.h>],
b329dd10
BK
2407 [__locale_t loc; strerror_l(5, loc);],
2408 AC_DEFINE(HAVE_STRERROR_L, 1,
2409 [Define if strerror_l is available in <string.h>.]),)
0258dc3a
BK
2410
2411 CFLAGS="$ac_save_CFLAGS"
2412 fi
2413
2414 # Perhaps use strerror_r if available, and strerror_l isn't.
b329dd10 2415 ac_save_CFLAGS="$CFLAGS"
0258dc3a
BK
2416 CFLAGS="-Wimplicit-function-declaration -Werror"
2417 AC_TRY_COMPILE([#define _GNU_SOURCE 1
2418 #include <string.h>
2419 #include <locale.h>],
b329dd10
BK
2420 [char s[128]; strerror_r(5, s, 128);],
2421 AC_DEFINE(HAVE_STRERROR_R, 1,
2422 [Define if strerror_r is available in <string.h>.]),)
0258dc3a 2423 CFLAGS="$ac_save_CFLAGS"
501e321e 2424
ff66d28f 2425 # Set configure bits for specified locale package
0258dc3a 2426 AC_MSG_CHECKING([for C locale to use])
ff66d28f
PE
2427 case ${enable_clocale_flag} in
2428 generic)
33590f13
BK
2429 AC_MSG_RESULT(generic)
2430
1fa4bed7
BK
2431 CLOCALE_H=config/locale/generic/c_locale.h
2432 CLOCALE_CC=config/locale/generic/c_locale.cc
38cca750 2433 CCODECVT_CC=config/locale/generic/codecvt_members.cc
1fa4bed7
BK
2434 CCOLLATE_CC=config/locale/generic/collate_members.cc
2435 CCTYPE_CC=config/locale/generic/ctype_members.cc
2436 CMESSAGES_H=config/locale/generic/messages_members.h
2437 CMESSAGES_CC=config/locale/generic/messages_members.cc
2438 CMONEY_CC=config/locale/generic/monetary_members.cc
2439 CNUMERIC_CC=config/locale/generic/numeric_members.cc
1c26d8fd 2440 CTIME_H=config/locale/generic/time_members.h
1fa4bed7 2441 CTIME_CC=config/locale/generic/time_members.cc
89671b70 2442 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
33590f13 2443 ;;
f9686024 2444 darwin)
301d1d00 2445 AC_MSG_RESULT(darwin)
f9686024
GK
2446
2447 CLOCALE_H=config/locale/generic/c_locale.h
2448 CLOCALE_CC=config/locale/generic/c_locale.cc
f9686024
GK
2449 CCODECVT_CC=config/locale/generic/codecvt_members.cc
2450 CCOLLATE_CC=config/locale/generic/collate_members.cc
2451 CCTYPE_CC=config/locale/darwin/ctype_members.cc
2452 CMESSAGES_H=config/locale/generic/messages_members.h
2453 CMESSAGES_CC=config/locale/generic/messages_members.cc
2454 CMONEY_CC=config/locale/generic/monetary_members.cc
2455 CNUMERIC_CC=config/locale/generic/numeric_members.cc
2456 CTIME_H=config/locale/generic/time_members.h
2457 CTIME_CC=config/locale/generic/time_members.cc
2458 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
2459 ;;
523ca640
CG
2460 vxworks)
2461 AC_MSG_RESULT(vxworks)
b329dd10 2462
523ca640
CG
2463 CLOCALE_H=config/locale/generic/c_locale.h
2464 CLOCALE_CC=config/locale/generic/c_locale.cc
2465 CCODECVT_CC=config/locale/generic/codecvt_members.cc
2466 CCOLLATE_CC=config/locale/generic/collate_members.cc
2467 CCTYPE_CC=config/locale/vxworks/ctype_members.cc
2468 CMESSAGES_H=config/locale/generic/messages_members.h
2469 CMESSAGES_CC=config/locale/generic/messages_members.cc
2470 CMONEY_CC=config/locale/generic/monetary_members.cc
2471 CNUMERIC_CC=config/locale/generic/numeric_members.cc
2472 CTIME_H=config/locale/generic/time_members.h
2473 CTIME_CC=config/locale/generic/time_members.cc
2474 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
2475 ;;
dbed5a9b 2476 dragonfly)
301d1d00 2477 AC_MSG_RESULT(dragonfly or freebsd)
dbed5a9b 2478
a98e4e62 2479 CLOCALE_H=config/locale/dragonfly/c_locale.h
dbed5a9b 2480 CLOCALE_CC=config/locale/dragonfly/c_locale.cc
a98e4e62
JM
2481 CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc
2482 CCOLLATE_CC=config/locale/dragonfly/collate_members.cc
dbed5a9b
JM
2483 CCTYPE_CC=config/locale/dragonfly/ctype_members.cc
2484 CMESSAGES_H=config/locale/generic/messages_members.h
2485 CMESSAGES_CC=config/locale/generic/messages_members.cc
a98e4e62
JM
2486 CMONEY_CC=config/locale/dragonfly/monetary_members.cc
2487 CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc
2488 CTIME_H=config/locale/dragonfly/time_members.h
2489 CTIME_CC=config/locale/dragonfly/time_members.cc
dbed5a9b
JM
2490 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
2491 ;;
2492
ff66d28f 2493 gnu)
0214010c 2494 AC_MSG_RESULT(gnu)
33590f13
BK
2495
2496 # Declare intention to use gettext, and add support for specific
2497 # languages.
248a9163 2498 # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
33590f13 2499 ALL_LINGUAS="de fr"
501e321e 2500
248a9163 2501 # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
501e321e
BK
2502 AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
2503 if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
b329dd10 2504 USE_NLS=yes
501e321e 2505 fi
33590f13
BK
2506 # Export the build objects.
2507 for ling in $ALL_LINGUAS; do \
b329dd10
BK
2508 glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
2509 glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
33590f13 2510 done
3d7c150e
BK
2511 AC_SUBST(glibcxx_MOFILES)
2512 AC_SUBST(glibcxx_POFILES)
33590f13 2513
1fa4bed7
BK
2514 CLOCALE_H=config/locale/gnu/c_locale.h
2515 CLOCALE_CC=config/locale/gnu/c_locale.cc
38cca750 2516 CCODECVT_CC=config/locale/gnu/codecvt_members.cc
1fa4bed7
BK
2517 CCOLLATE_CC=config/locale/gnu/collate_members.cc
2518 CCTYPE_CC=config/locale/gnu/ctype_members.cc
2519 CMESSAGES_H=config/locale/gnu/messages_members.h
2520 CMESSAGES_CC=config/locale/gnu/messages_members.cc
2521 CMONEY_CC=config/locale/gnu/monetary_members.cc
2522 CNUMERIC_CC=config/locale/gnu/numeric_members.cc
1c26d8fd 2523 CTIME_H=config/locale/gnu/time_members.h
1fa4bed7 2524 CTIME_CC=config/locale/gnu/time_members.cc
89671b70 2525 CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h
0214010c 2526 ;;
ff66d28f 2527 ieee_1003.1-2001)
7f78b6ca 2528 AC_MSG_RESULT(IEEE 1003.1)
33590f13 2529
1fa4bed7
BK
2530 CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
2531 CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
38cca750 2532 CCODECVT_CC=config/locale/generic/codecvt_members.cc
1fa4bed7
BK
2533 CCOLLATE_CC=config/locale/generic/collate_members.cc
2534 CCTYPE_CC=config/locale/generic/ctype_members.cc
2535 CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
2536 CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
2537 CMONEY_CC=config/locale/generic/monetary_members.cc
2538 CNUMERIC_CC=config/locale/generic/numeric_members.cc
1c26d8fd 2539 CTIME_H=config/locale/generic/time_members.h
1fa4bed7 2540 CTIME_CC=config/locale/generic/time_members.cc
89671b70 2541 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
0214010c 2542 ;;
aeb4926a
YZ
2543 newlib)
2544 AC_MSG_RESULT(newlib)
2545
2546 CLOCALE_H=config/locale/generic/c_locale.h
2547 CLOCALE_CC=config/locale/generic/c_locale.cc
2548 CCODECVT_CC=config/locale/generic/codecvt_members.cc
2549 CCOLLATE_CC=config/locale/generic/collate_members.cc
2550 CCTYPE_CC=config/locale/newlib/ctype_members.cc
2551 CMESSAGES_H=config/locale/generic/messages_members.h
2552 CMESSAGES_CC=config/locale/generic/messages_members.cc
2553 CMONEY_CC=config/locale/generic/monetary_members.cc
2554 CNUMERIC_CC=config/locale/generic/numeric_members.cc
2555 CTIME_H=config/locale/generic/time_members.h
2556 CTIME_CC=config/locale/generic/time_members.cc
2557 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
2558 ;;
0214010c
BK
2559 esac
2560
33590f13
BK
2561 # This is where the testsuite looks for locale catalogs, using the
2562 # -DLOCALEDIR define during testsuite compilation.
3d7c150e
BK
2563 glibcxx_localedir=${glibcxx_builddir}/po/share/locale
2564 AC_SUBST(glibcxx_localedir)
33590f13 2565
7f78b6ca
PE
2566 # A standalone libintl (e.g., GNU libintl) may be in use.
2567 if test $USE_NLS = yes; then
c67528fe
PE
2568 AC_CHECK_HEADERS([libintl.h], [], USE_NLS=no)
2569 AC_SEARCH_LIBS(gettext, intl, [], USE_NLS=no)
2570 fi
2571 if test $USE_NLS = yes; then
b329dd10
BK
2572 AC_DEFINE(_GLIBCXX_USE_NLS, 1,
2573 [Define if NLS translations are to be used.])
7f78b6ca
PE
2574 fi
2575
4e10943d 2576 AC_SUBST(USE_NLS)
4a9d5109 2577 AC_SUBST(CLOCALE_H)
33590f13 2578 AC_SUBST(CMESSAGES_H)
6aa43d99
BK
2579 AC_SUBST(CCODECVT_CC)
2580 AC_SUBST(CCOLLATE_CC)
2581 AC_SUBST(CCTYPE_CC)
2582 AC_SUBST(CMESSAGES_CC)
2583 AC_SUBST(CMONEY_CC)
2584 AC_SUBST(CNUMERIC_CC)
1c26d8fd 2585 AC_SUBST(CTIME_H)
6aa43d99
BK
2586 AC_SUBST(CTIME_CC)
2587 AC_SUBST(CLOCALE_CC)
2588 AC_SUBST(CLOCALE_INTERNAL_H)
0214010c
BK
2589])
2590
2591
8b0d6051
BK
2592dnl
2593dnl Check for which std::allocator base class to use. The choice is
2594dnl mapped from a subdirectory of include/ext.
2595dnl
2596dnl Default is new.
2597dnl
2598AC_DEFUN([GLIBCXX_ENABLE_ALLOCATOR], [
347669a0 2599 AC_MSG_CHECKING([for std::allocator base class])
b453ace3 2600 GLIBCXX_ENABLE(libstdcxx-allocator,auto,[[[=KIND]]],
8b0d6051 2601 [use KIND for target std::allocator base],
e2e98f52 2602 [permit new|malloc|yes|no|auto])
7d3998a4 2603
8b0d6051
BK
2604 # If they didn't use this option switch, or if they specified --enable
2605 # with no specific model, we'll have to look for one. If they
2606 # specified --disable (???), do likewise.
7d3998a4
PE
2607 if test $enable_libstdcxx_allocator = no ||
2608 test $enable_libstdcxx_allocator = yes;
2609 then
8b0d6051
BK
2610 enable_libstdcxx_allocator=auto
2611 fi
2612
780028b6
BK
2613 # Either a known package, or "auto". Auto implies the default choice
2614 # for a particular platform.
8b0d6051
BK
2615 enable_libstdcxx_allocator_flag=$enable_libstdcxx_allocator
2616
2617 # Probe for host-specific support if no specific model is specified.
2618 # Default to "new".
2619 if test $enable_libstdcxx_allocator_flag = auto; then
2620 case ${target_os} in
780028b6 2621 linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
b329dd10
BK
2622 enable_libstdcxx_allocator_flag=new
2623 ;;
8b0d6051 2624 *)
b329dd10
BK
2625 enable_libstdcxx_allocator_flag=new
2626 ;;
8b0d6051
BK
2627 esac
2628 fi
2629 AC_MSG_RESULT($enable_libstdcxx_allocator_flag)
b329dd10 2630
8b0d6051
BK
2631
2632 # Set configure bits for specified locale package
2633 case ${enable_libstdcxx_allocator_flag} in
8b0d6051
BK
2634 malloc)
2635 ALLOCATOR_H=config/allocator/malloc_allocator_base.h
2636 ALLOCATOR_NAME=__gnu_cxx::malloc_allocator
2637 ;;
8b0d6051
BK
2638 new)
2639 ALLOCATOR_H=config/allocator/new_allocator_base.h
2640 ALLOCATOR_NAME=__gnu_cxx::new_allocator
2641 ;;
2642 esac
2643
a04d5fc9
TR
2644 GLIBCXX_CONDITIONAL(ENABLE_ALLOCATOR_NEW,
2645 test $enable_libstdcxx_allocator_flag = new)
8b0d6051
BK
2646 AC_SUBST(ALLOCATOR_H)
2647 AC_SUBST(ALLOCATOR_NAME)
2648])
2649
2650
b2dad0e3 2651dnl
ff66d28f
PE
2652dnl Check for whether the Boost-derived checks should be turned on.
2653dnl
2654dnl --enable-concept-checks turns them on.
2655dnl --disable-concept-checks leaves them off.
2656dnl + Usage: GLIBCXX_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
2657dnl Where DEFAULT is either `yes' or `no'.
2658dnl
f214923c 2659AC_DEFUN([GLIBCXX_ENABLE_CONCEPT_CHECKS], [
ff66d28f
PE
2660 GLIBCXX_ENABLE(concept-checks,$1,,[use Boost-derived template checks])
2661 if test $enable_concept_checks = yes; then
4651e622 2662 AC_DEFINE(_GLIBCXX_CONCEPT_CHECKS, 1,
b329dd10 2663 [Define to use concept checking code from the boost libraries.])
ff66d28f
PE
2664 fi
2665])
2666
ed4f96af
BK
2667dnl
2668dnl Use extern templates.
2669dnl
2670dnl --enable-extern-template defines _GLIBCXX_EXTERN_TEMPLATE to 1
2671dnl --disable-extern-template defines _GLIBCXX_EXTERN_TEMPLATE to 0
2672
2673dnl + Usage: GLIBCXX_ENABLE_TEMPLATE[(DEFAULT)]
2674dnl Where DEFAULT is `yes' or `no'.
2675dnl
2676AC_DEFUN([GLIBCXX_ENABLE_EXTERN_TEMPLATE], [
2677
2678 GLIBCXX_ENABLE(extern-template,$1,,[enable extern template])
2679
2680 AC_MSG_CHECKING([for extern template support])
2681 AC_MSG_RESULT([$enable_extern_template])
2682
2683 GLIBCXX_CONDITIONAL(ENABLE_EXTERN_TEMPLATE, test $enable_extern_template = yes)
2684])
2685
2077db1b
CT
2686dnl
2687dnl Use vtable verification.
2688dnl
2689dnl --enable-vtable-verify defines _GLIBCXX_VTABLE_VERIFY to 1
2690dnl --disable-vtable-verify defines _GLIBCXX_VTABLE_VERIFY to 0
2691
2692dnl + Usage: GLIBCXX_ENABLE_VTABLE_VERIFY[(DEFAULT)]
2693dnl Where DEFAULT is `yes' or `no'.
2694dnl
2695AC_DEFUN([GLIBCXX_ENABLE_VTABLE_VERIFY], [
2696
2697 GLIBCXX_ENABLE(vtable-verify,$1,,[enable vtable verify])
2698
2699 AC_MSG_CHECKING([for vtable verify support])
2700 AC_MSG_RESULT([$enable_vtable_verify])
2701
536616b7 2702 vtv_cygmin=no
2077db1b 2703 if test $enable_vtable_verify = yes; then
f7f049fa
CT
2704 case ${target_os} in
2705 cygwin*|mingw32*)
2706 VTV_CXXFLAGS="-fvtable-verify=std -Wl,-lvtv,-u_vtable_map_vars_start,-u_vtable_map_vars_end"
441fb2cd 2707 VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,--rpath -Wl,${toplevel_builddir}/libvtv/.libs"
536616b7 2708 vtv_cygmin=yes
f7f049fa 2709 ;;
441fb2cd
CT
2710 darwin*)
2711 VTV_CXXFLAGS="-fvtable-verify=std -Wl,-u,_vtable_map_vars_start -Wl,-u,_vtable_map_vars_end"
2712 VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,-rpath,${toplevel_builddir}/libvtv/.libs"
2713 ;;
e5ef217c
RO
2714 solaris2*)
2715 VTV_CXXFLAGS="-fvtable-verify=std -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end"
2716 VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,-R -Wl,${toplevel_builddir}/libvtv/.libs"
2717 ;;
f7f049fa
CT
2718 *)
2719 VTV_CXXFLAGS="-fvtable-verify=std -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end"
441fb2cd 2720 VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,--rpath -Wl,${toplevel_builddir}/libvtv/.libs"
f7f049fa
CT
2721 ;;
2722 esac
2077db1b 2723 VTV_PCH_CXXFLAGS="-fvtable-verify=std"
2077db1b 2724 else
7607ff49 2725 VTV_CXXFLAGS=
2077db1b 2726 VTV_PCH_CXXFLAGS=
7607ff49 2727 VTV_CXXLINKFLAGS=
2077db1b
CT
2728 fi
2729
2730 AC_SUBST(VTV_CXXFLAGS)
2731 AC_SUBST(VTV_PCH_CXXFLAGS)
2732 AC_SUBST(VTV_CXXLINKFLAGS)
536616b7 2733 AM_CONDITIONAL(VTV_CYGMIN, test x$vtv_cygmin = xyes)
2077db1b
CT
2734 GLIBCXX_CONDITIONAL(ENABLE_VTABLE_VERIFY, test $enable_vtable_verify = yes)
2735])
2736
c2ba9709
JS
2737dnl
2738dnl Check for parallel mode pre-requisites, including OpenMP support.
2739dnl
2740dnl + Usage: GLIBCXX_ENABLE_PARALLEL
2741dnl
2742AC_DEFUN([GLIBCXX_ENABLE_PARALLEL], [
2743
2744 enable_parallel=no;
6995087d 2745
0aec205c
BK
2746 # See if configured libgomp/omp.h exists. (libgomp may be in
2747 # noconfigdirs but not explicitly disabled.)
aae29963 2748 if echo " ${TARGET_CONFIGDIRS} " | grep " libgomp " > /dev/null 2>&1 ; then
0aec205c
BK
2749 enable_parallel=yes;
2750 else
aae29963 2751 AC_MSG_NOTICE([target-libgomp not built])
c2ba9709
JS
2752 fi
2753
2754 AC_MSG_CHECKING([for parallel mode support])
2755 AC_MSG_RESULT([$enable_parallel])
c2ba9709
JS
2756])
2757
ff66d28f 2758
b2dad0e3 2759dnl
75aee072 2760dnl Check for which I/O library to use: stdio and POSIX, or pure stdio.
37bc6ca2 2761dnl
75aee072 2762dnl Default is stdio_posix.
b2dad0e3 2763dnl
f214923c 2764AC_DEFUN([GLIBCXX_ENABLE_CSTDIO], [
ff66d28f 2765 AC_MSG_CHECKING([for underlying I/O to use])
b453ace3 2766 GLIBCXX_ENABLE(cstdio,stdio,[[[=PACKAGE]]],
75aee072 2767 [use target-specific I/O package], [permit stdio|stdio_posix|stdio_pure])
ff66d28f 2768
75aee072
KP
2769 # The only available I/O model is based on stdio, via basic_file_stdio.
2770 # The default "stdio" is actually "stdio + POSIX" because it uses fdopen(3)
2771 # to get a file descriptor and then uses read(3) and write(3) with it.
2772 # The "stdio_pure" model doesn't use fdopen and only uses FILE* for I/O.
ff66d28f 2773 case ${enable_cstdio} in
75aee072 2774 stdio*)
33590f13
BK
2775 CSTDIO_H=config/io/c_io_stdio.h
2776 BASIC_FILE_H=config/io/basic_file_stdio.h
2777 BASIC_FILE_CC=config/io/basic_file_stdio.cc
9717c75c 2778 AC_MSG_RESULT(stdio)
75aee072
KP
2779
2780 if test "x$enable_cstdio" = "xstdio_pure" ; then
2781 AC_DEFINE(_GLIBCXX_USE_STDIO_PURE, 1,
2782 [Define to restrict std::__basic_file<> to stdio APIs.])
2783 fi
dd75251f 2784 ;;
b2dad0e3 2785 esac
cc5112c9 2786
4a9d5109
SW
2787 AC_SUBST(CSTDIO_H)
2788 AC_SUBST(BASIC_FILE_H)
6aa43d99 2789 AC_SUBST(BASIC_FILE_CC)
b2dad0e3
BK
2790])
2791
2792
9e57d5ca 2793dnl
ff66d28f 2794dnl Check for "unusual" flags to pass to the compiler while building.
9e57d5ca 2795dnl
ff66d28f
PE
2796dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
2797dnl experimental flags such as -fpch, -fIMI, -Dfloat=char, etc.
2798dnl --disable-cxx-flags passes nothing.
2799dnl + See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
2800dnl http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
2801dnl http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
2802dnl + Usage: GLIBCXX_ENABLE_CXX_FLAGS(default flags)
2803dnl If "default flags" is an empty string, the effect is the same
2804dnl as --disable or --enable=no.
44f0760e 2805dnl
f214923c 2806AC_DEFUN([GLIBCXX_ENABLE_CXX_FLAGS], [dnl
ff66d28f
PE
2807 AC_MSG_CHECKING([for extra compiler flags for building])
2808 GLIBCXX_ENABLE(cxx-flags,$1,[=FLAGS],
2809 [pass compiler FLAGS when building library],
2810 [case "x$enable_cxx_flags" in
2811 xno | x) enable_cxx_flags= ;;
2812 x-*) ;;
2813 *) AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
2814 esac])
2815
2816 # Run through flags (either default or command-line) and set anything
2817 # extra (e.g., #defines) that must accompany particular g++ options.
2818 if test -n "$enable_cxx_flags"; then
2819 for f in $enable_cxx_flags; do
2820 case "$f" in
b329dd10
BK
2821 -fhonor-std) ;;
2822 -*) ;;
2823 *) # and we're trying to pass /what/ exactly?
2824 AC_MSG_ERROR([compiler flags start with a -]) ;;
ff66d28f
PE
2825 esac
2826 done
44f0760e
BK
2827 fi
2828
ff66d28f
PE
2829 EXTRA_CXX_FLAGS="$enable_cxx_flags"
2830 AC_MSG_RESULT($EXTRA_CXX_FLAGS)
2831 AC_SUBST(EXTRA_CXX_FLAGS)
9e57d5ca
BK
2832])
2833
ff66d28f 2834
ff66d28f
PE
2835dnl
2836dnl Check to see if debugging libraries are to be built.
2837dnl
2838dnl --enable-libstdcxx-debug
2839dnl builds a separate set of debugging libraries in addition to the
2840dnl normal (shared, static) libstdc++ binaries.
2841dnl
2842dnl --disable-libstdcxx-debug
2843dnl builds only one (non-debug) version of libstdc++.
2844dnl
2845dnl --enable-libstdcxx-debug-flags=FLAGS
2846dnl iff --enable-debug == yes, then use FLAGS to build the debug library.
2847dnl
2848dnl + Usage: GLIBCXX_ENABLE_DEBUG[(DEFAULT)]
2849dnl Where DEFAULT is either `yes' or `no'.
2850dnl
f214923c 2851AC_DEFUN([GLIBCXX_ENABLE_DEBUG], [
ff66d28f 2852 AC_MSG_CHECKING([for additional debug build])
86f73527 2853 skip_debug_build=
ff66d28f 2854 GLIBCXX_ENABLE(libstdcxx-debug,$1,,[build extra debug library])
86f73527
JW
2855 if test x$enable_libstdcxx_debug = xyes; then
2856 if test -f $toplevel_builddir/../stage_final \
2857 && test -f $toplevel_builddir/../stage_current; then
2858 stage_final=`cat $toplevel_builddir/../stage_final`
2859 stage_current=`cat $toplevel_builddir/../stage_current`
2860 if test x$stage_current != x$stage_final ; then
2861 skip_debug_build=" (skipped for bootstrap stage $stage_current)"
2862 enable_libstdcxx_debug=no
2863 fi
2864 fi
2865 fi
2866 AC_MSG_RESULT($enable_libstdcxx_debug$skip_debug_build)
92eabea2 2867 GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_DEBUG, test $enable_libstdcxx_debug = yes)
b2dad0e3
BK
2868])
2869
2870
52a11cbf 2871dnl
ff66d28f 2872dnl Check for explicit debug flags.
52a11cbf 2873dnl
ff66d28f
PE
2874dnl --enable-libstdcxx-debug-flags='-O1'
2875dnl is a general method for passing flags to be used when
38cccb0b 2876dnl building debug libraries with --enable-libstdcxx-debug.
52a11cbf 2877dnl
ff66d28f
PE
2878dnl --disable-libstdcxx-debug-flags does nothing.
2879dnl + Usage: GLIBCXX_ENABLE_DEBUG_FLAGS(default flags)
2880dnl If "default flags" is an empty string, the effect is the same
2881dnl as --disable or --enable=no.
2882dnl
f214923c 2883AC_DEFUN([GLIBCXX_ENABLE_DEBUG_FLAGS], [
ff66d28f
PE
2884 GLIBCXX_ENABLE(libstdcxx-debug-flags,[$1],[=FLAGS],
2885 [pass compiler FLAGS when building debug library],
2886 [case "x$enable_libstdcxx_debug_flags" in
2887 xno | x) enable_libstdcxx_debug_flags= ;;
2888 x-*) ;;
2889 *) AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
2890 esac])
2891
2892 # Option parsed, now set things appropriately
2893 DEBUG_FLAGS="$enable_libstdcxx_debug_flags"
2894 AC_SUBST(DEBUG_FLAGS)
2895
2896 AC_MSG_NOTICE([Debug build flags set to $DEBUG_FLAGS])
52a11cbf
RH
2897])
2898
2899
92eabea2
PE
2900dnl
2901dnl Check if the user only wants a freestanding library implementation.
2902dnl
2903dnl --disable-hosted-libstdcxx will turn off most of the library build,
2904dnl installing only the headers required by [17.4.1.3] and the language
2905dnl support library. More than that will be built (to keep the Makefiles
2906dnl conveniently clean), but not installed.
2907dnl
2908dnl Sets:
2909dnl is_hosted (yes/no)
2910dnl
3660e02f
PE
2911dnl Defines:
2912dnl _GLIBCXX_HOSTED (always defined, either to 1 or 0)
2913dnl
f214923c 2914AC_DEFUN([GLIBCXX_ENABLE_HOSTED], [
92eabea2
PE
2915 AC_ARG_ENABLE([hosted-libstdcxx],
2916 AC_HELP_STRING([--disable-hosted-libstdcxx],
b329dd10 2917 [only build freestanding C++ runtime support]),,
4c24b21a 2918 [case "$host" in
b329dd10 2919 arm*-*-symbianelf*)
4c24b21a
MM
2920 enable_hosted_libstdcxx=no
2921 ;;
b329dd10 2922 *)
4c24b21a
MM
2923 enable_hosted_libstdcxx=yes
2924 ;;
2925 esac])
92eabea2
PE
2926 if test "$enable_hosted_libstdcxx" = no; then
2927 AC_MSG_NOTICE([Only freestanding libraries will be built])
2928 is_hosted=no
3660e02f 2929 hosted_define=0
92eabea2
PE
2930 enable_abi_check=no
2931 enable_libstdcxx_pch=no
2932 else
2933 is_hosted=yes
3660e02f 2934 hosted_define=1
92eabea2
PE
2935 fi
2936 GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes)
3660e02f
PE
2937 AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define,
2938 [Define to 1 if a full hosted library is built, or 0 if freestanding.])
92eabea2
PE
2939])
2940
2941
5a86d36f
SH
2942dnl
2943dnl Check if the user wants a non-verbose library implementation.
2944dnl
2945dnl --disable-libstdcxx-verbose will turn off descriptive messages to
2946dnl standard error on termination.
2947dnl
2948dnl Defines:
2949dnl _GLIBCXX_VERBOSE (always defined, either to 1 or 0)
2950dnl
2951AC_DEFUN([GLIBCXX_ENABLE_VERBOSE], [
2952 AC_ARG_ENABLE([libstdcxx-verbose],
2953 AC_HELP_STRING([--disable-libstdcxx-verbose],
2954 [disable termination messages to standard error]),,
2955 [enable_libstdcxx_verbose=yes])
2956 if test x"$enable_libstdcxx_verbose" = xyes; then
2957 verbose_define=1
2958 else
2959 AC_MSG_NOTICE([verbose termination messages are disabled])
2960 verbose_define=0
2961 fi
2962 AC_DEFINE_UNQUOTED(_GLIBCXX_VERBOSE, $verbose_define,
2963 [Define to 1 if a verbose library is built, or 0 otherwise.])
2964])
2965
2966
6c3a9f72 2967dnl
347669a0 2968dnl Check for template specializations for the 'long long' type.
22248545
PE
2969dnl The result determines only whether 'long long' I/O is enabled; things
2970dnl like numeric_limits<> specializations are always available.
6c3a9f72 2971dnl
3d7c150e
BK
2972dnl --enable-long-long defines _GLIBCXX_USE_LONG_LONG
2973dnl --disable-long-long leaves _GLIBCXX_USE_LONG_LONG undefined
2974dnl + Usage: GLIBCXX_ENABLE_LONG_LONG[(DEFAULT)]
ff66d28f 2975dnl Where DEFAULT is either `yes' or `no'.
6c3a9f72 2976dnl
f214923c 2977AC_DEFUN([GLIBCXX_ENABLE_LONG_LONG], [
347669a0 2978 GLIBCXX_ENABLE(long-long,$1,,[enable template specializations for 'long long'])
ff66d28f 2979 if test $enable_long_long = yes; then
b329dd10
BK
2980 AC_DEFINE(_GLIBCXX_USE_LONG_LONG, 1,
2981 [Define if code specialized for long long should be used.])
6c3a9f72 2982 fi
347669a0
BK
2983 AC_MSG_CHECKING([for enabled long long specializations])
2984 AC_MSG_RESULT([$enable_long_long])
2985])
2986
2987
4cdc8761
BK
2988dnl
2989dnl Check for decimal floating point.
2990dnl See:
2991dnl http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html#Decimal-Float
2992dnl
2993dnl This checks to see if the host supports decimal floating point types.
2994dnl
2995dnl Defines:
2996dnl _GLIBCXX_USE_DECIMAL_FLOAT
2997dnl
2998AC_DEFUN([GLIBCXX_ENABLE_DECIMAL_FLOAT], [
2999
3000 # Fake what AC_TRY_COMPILE does, without linking as this is
3001 # unnecessary for this test.
3002
3003 cat > conftest.$ac_ext << EOF
3004[#]line __oline__ "configure"
3005int main()
3006{
3007 _Decimal32 d1;
3008 _Decimal64 d2;
3009 _Decimal128 d3;
3010 return 0;
3011}
3012EOF
3013
3014 AC_MSG_CHECKING([for ISO/IEC TR 24733 ])
3015 if AC_TRY_EVAL(ac_compile); then
3016 AC_DEFINE(_GLIBCXX_USE_DECIMAL_FLOAT, 1,
3017 [Define if ISO/IEC TR 24733 decimal floating point types are supported on this host.])
3018 enable_dfp=yes
3019 else
3020 enable_dfp=no
3021 fi
3022 AC_MSG_RESULT($enable_dfp)
3023 rm -f conftest*
3024])
3025
6d585f01 3026dnl
ad0a3be4 3027dnl Check for GNU 128-bit floating point type.
6d585f01 3028dnl
ad0a3be4 3029dnl Note: also checks that the type isn't a standard types.
6d585f01
PC
3030dnl
3031dnl Defines:
f421e442 3032dnl ENABLE_FLOAT128
6d585f01 3033dnl
ad0a3be4 3034AC_DEFUN([GLIBCXX_ENABLE_FLOAT128], [
6d585f01
PC
3035
3036 AC_LANG_SAVE
3037 AC_LANG_CPLUSPLUS
3038
3039 # Fake what AC_TRY_COMPILE does, without linking as this is
3040 # unnecessary for this test.
3041
ad0a3be4 3042 cat > conftest.$ac_ext << EOF
6d585f01
PC
3043[#]line __oline__ "configure"
3044template<typename T1, typename T2>
3045 struct same
3046 { typedef T2 type; };
3047
3048template<typename T>
3049 struct same<T, T>;
3050
3051int main()
3052{
2a5d011c 3053 typename same<double, __float128>::type f1;
6d585f01
PC
3054 typename same<long double, __float128>::type f2;
3055}
3056EOF
3057
3058 AC_MSG_CHECKING([for __float128])
3059 if AC_TRY_EVAL(ac_compile); then
6d585f01
PC
3060 enable_float128=yes
3061 else
3062 enable_float128=no
3063 fi
3064 AC_MSG_RESULT($enable_float128)
f421e442 3065 GLIBCXX_CONDITIONAL(ENABLE_FLOAT128, test $enable_float128 = yes)
6d585f01
PC
3066 rm -f conftest*
3067
3068 AC_LANG_RESTORE
3069])
3070
347669a0
BK
3071dnl
3072dnl Check for template specializations for the 'wchar_t' type.
3073dnl
3074dnl --enable-wchar_t defines _GLIBCXX_USE_WCHAR_T
3075dnl --disable-wchar_t leaves _GLIBCXX_USE_WCHAR_T undefined
3076dnl + Usage: GLIBCXX_ENABLE_WCHAR_T[(DEFAULT)]
3077dnl Where DEFAULT is either `yes' or `no'.
3078dnl
8a9b2875 3079dnl Necessary support must also be present.
347669a0
BK
3080dnl
3081AC_DEFUN([GLIBCXX_ENABLE_WCHAR_T], [
3082 GLIBCXX_ENABLE(wchar_t,$1,,[enable template specializations for 'wchar_t'])
8a9b2875
PC
3083
3084 # Test wchar.h for mbstate_t, which is needed for char_traits and fpos.
3085 AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
3086 AC_MSG_CHECKING([for mbstate_t])
3087 AC_TRY_COMPILE([#include <wchar.h>],
3088 [mbstate_t teststate;],
3089 have_mbstate_t=yes, have_mbstate_t=no)
3090 AC_MSG_RESULT($have_mbstate_t)
3091 if test x"$have_mbstate_t" = xyes; then
3092 AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.])
3093 fi
3094
d814595c
PC
3095 # Test it always, for use in GLIBCXX_ENABLE_C99, together with
3096 # ac_has_wchar_h.
3097 AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
b329dd10 3098
8a9b2875
PC
3099 if test x"$enable_wchar_t" = x"yes"; then
3100
3101 AC_LANG_SAVE
3102 AC_LANG_CPLUSPLUS
b329dd10 3103
8a9b2875
PC
3104 if test x"$ac_has_wchar_h" = xyes &&
3105 test x"$ac_has_wctype_h" = xyes; then
3106 AC_TRY_COMPILE([#include <wchar.h>
b329dd10
BK
3107 #include <stddef.h>
3108 wint_t i;
8a9b2875
PC
3109 long l = WEOF;
3110 long j = WCHAR_MIN;
3111 long k = WCHAR_MAX;
b329dd10
BK
3112 namespace test
3113 {
8a9b2875
PC
3114 using ::btowc;
3115 using ::fgetwc;
3116 using ::fgetws;
3117 using ::fputwc;
3118 using ::fputws;
3119 using ::fwide;
b329dd10 3120 using ::fwprintf;
8a9b2875
PC
3121 using ::fwscanf;
3122 using ::getwc;
3123 using ::getwchar;
b329dd10
BK
3124 using ::mbrlen;
3125 using ::mbrtowc;
3126 using ::mbsinit;
3127 using ::mbsrtowcs;
8a9b2875
PC
3128 using ::putwc;
3129 using ::putwchar;
b329dd10
BK
3130 using ::swprintf;
3131 using ::swscanf;
8a9b2875 3132 using ::ungetwc;
b329dd10
BK
3133 using ::vfwprintf;
3134 using ::vswprintf;
3135 using ::vwprintf;
3136 using ::wcrtomb;
3137 using ::wcscat;
3138 using ::wcschr;
3139 using ::wcscmp;
3140 using ::wcscoll;
3141 using ::wcscpy;
3142 using ::wcscspn;
3143 using ::wcsftime;
8a9b2875 3144 using ::wcslen;
b329dd10
BK
3145 using ::wcsncat;
3146 using ::wcsncmp;
3147 using ::wcsncpy;
8a9b2875 3148 using ::wcspbrk;
b329dd10
BK
3149 using ::wcsrchr;
3150 using ::wcsrtombs;
3151 using ::wcsspn;
8a9b2875 3152 using ::wcsstr;
b329dd10
BK
3153 using ::wcstod;
3154 using ::wcstok;
8a9b2875 3155 using ::wcstol;
b329dd10
BK
3156 using ::wcstoul;
3157 using ::wcsxfrm;
3158 using ::wctob;
8a9b2875
PC
3159 using ::wmemchr;
3160 using ::wmemcmp;
3161 using ::wmemcpy;
3162 using ::wmemmove;
3163 using ::wmemset;
b329dd10
BK
3164 using ::wprintf;
3165 using ::wscanf;
8a9b2875
PC
3166 }
3167 ],[],[], [enable_wchar_t=no])
3168 else
3169 enable_wchar_t=no
3170 fi
3171
3172 AC_LANG_RESTORE
3173 fi
3174
3175 if test x"$enable_wchar_t" = x"yes"; then
4651e622 3176 AC_DEFINE(_GLIBCXX_USE_WCHAR_T, 1,
b329dd10 3177 [Define if code specialized for wchar_t should be used.])
347669a0 3178 fi
8a9b2875 3179
347669a0
BK
3180 AC_MSG_CHECKING([for enabled wchar_t specializations])
3181 AC_MSG_RESULT([$enable_wchar_t])
6c3a9f72
BK
3182])
3183
3184
99246c90 3185dnl
ff66d28f 3186dnl Check to see if building and using a C++ precompiled header can be done.
72ed2836 3187dnl
ff66d28f
PE
3188dnl --enable-libstdcxx-pch=yes
3189dnl default, this shows intent to use stdc++.h.gch If it looks like it
3190dnl may work, after some light-hearted attempts to puzzle out compiler
3191dnl support, flip bits on in include/Makefile.am
43ba4a58 3192dnl
ff66d28f
PE
3193dnl --disable-libstdcxx-pch
3194dnl turns off attempts to use or build stdc++.h.gch.
fe413112 3195dnl
ff66d28f
PE
3196dnl Substs:
3197dnl glibcxx_PCHFLAGS
fe413112 3198dnl
f214923c 3199AC_DEFUN([GLIBCXX_ENABLE_PCH], [
ff66d28f 3200 GLIBCXX_ENABLE(libstdcxx-pch,$1,,[build pre-compiled libstdc++ headers])
ff66d28f
PE
3201 if test $enable_libstdcxx_pch = yes; then
3202 AC_CACHE_CHECK([for compiler with PCH support],
3203 [glibcxx_cv_prog_CXX_pch],
3204 [ac_save_CXXFLAGS="$CXXFLAGS"
3205 CXXFLAGS="$CXXFLAGS -Werror -Winvalid-pch -Wno-deprecated"
3206 AC_LANG_SAVE
3207 AC_LANG_CPLUSPLUS
3208 echo '#include <math.h>' > conftest.h
3209 if $CXX $CXXFLAGS $CPPFLAGS -x c++-header conftest.h \
b329dd10
BK
3210 -o conftest.h.gch 1>&5 2>&1 &&
3211 echo '#error "pch failed"' > conftest.h &&
3212 echo '#include "conftest.h"' > conftest.cc &&
ff66d28f
PE
3213 $CXX -c $CXXFLAGS $CPPFLAGS conftest.cc 1>&5 2>&1 ;
3214 then
b329dd10 3215 glibcxx_cv_prog_CXX_pch=yes
ff66d28f 3216 else
b329dd10 3217 glibcxx_cv_prog_CXX_pch=no
ff66d28f
PE
3218 fi
3219 rm -f conftest*
3220 CXXFLAGS=$ac_save_CXXFLAGS
3221 AC_LANG_RESTORE
3222 ])
3223 enable_libstdcxx_pch=$glibcxx_cv_prog_CXX_pch
c4c064e7 3224 fi
747d0967 3225
797308b2
BK
3226 AC_MSG_CHECKING([for enabled PCH])
3227 AC_MSG_RESULT([$enable_libstdcxx_pch])
3228
92eabea2 3229 GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_PCH, test $enable_libstdcxx_pch = yes)
ff66d28f 3230 if test $enable_libstdcxx_pch = yes; then
c2ba9709 3231 glibcxx_PCHFLAGS="-include bits/stdc++.h"
c4c064e7 3232 else
ff66d28f 3233 glibcxx_PCHFLAGS=""
bbacb998 3234 fi
ff66d28f 3235 AC_SUBST(glibcxx_PCHFLAGS)
bbacb998
PC
3236])
3237
7cda84dc 3238
701a3eee
BK
3239dnl
3240dnl Check for atomic builtins.
3241dnl See:
75cee7c6 3242dnl http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
701a3eee
BK
3243dnl
3244dnl This checks to see if the host supports the compiler-generated
b329dd10 3245dnl builtins for atomic operations for various integral sizes. Note, this
35648b45
BK
3246dnl is intended to be an all-or-nothing switch, so all the atomic operations
3247dnl that are used should be checked.
701a3eee
BK
3248dnl
3249dnl Note:
2cd9cdcc 3250dnl libgomp and libgfortran use a link test, see CHECK_SYNC_FETCH_AND_ADD.
701a3eee 3251dnl
701a3eee 3252AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
701a3eee
BK
3253 AC_LANG_SAVE
3254 AC_LANG_CPLUSPLUS
35648b45 3255 old_CXXFLAGS="$CXXFLAGS"
2cd9cdcc
PC
3256
3257 # Do link tests if possible, instead asm tests, limited to some platforms
3258 # see discussion in PR target/40134, PR libstdc++/40133 and the thread
3259 # starting at http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00322.html
3260 atomic_builtins_link_tests=no
3261 if test x$gcc_no_link != xyes; then
3262 # Can do link tests. Limit to some tested platforms
3263 case "$host" in
3264 *-*-linux* | *-*-uclinux* | *-*-kfreebsd*-gnu | *-*-gnu*)
3265 atomic_builtins_link_tests=yes
b329dd10 3266 ;;
2cd9cdcc
PC
3267 esac
3268 fi
3269
3270 if test x$atomic_builtins_link_tests = xyes; then
3271
3272 # Do link tests.
3273
3274 CXXFLAGS="$CXXFLAGS -fno-exceptions"
3275
9646a322
JW
3276 AC_CACHE_CHECK([for atomic builtins for bool],
3277 glibcxx_cv_atomic_bool, [
2cd9cdcc
PC
3278 AC_TRY_LINK(
3279 [ ],
3280 [typedef bool atomic_type;
3281 atomic_type c1;
3282 atomic_type c2;
75cee7c6 3283 atomic_type c3(0);
d2aee115 3284 // N.B. __atomic_fetch_add is not supported for bool.
75cee7c6 3285 __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
2a5d011c 3286 __ATOMIC_RELAXED);
75cee7c6
BK
3287 __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
3288 __atomic_load_n(&c1, __ATOMIC_RELAXED);
3289 ],
2cd9cdcc
PC
3290 [glibcxx_cv_atomic_bool=yes],
3291 [glibcxx_cv_atomic_bool=no])
b329dd10 3292 ])
2cd9cdcc 3293
9646a322
JW
3294 AC_CACHE_CHECK([for atomic builtins for short],
3295 glibcxx_cv_atomic_short, [
2cd9cdcc
PC
3296 AC_TRY_LINK(
3297 [ ],
3298 [typedef short atomic_type;
3299 atomic_type c1;
3300 atomic_type c2;
75cee7c6
BK
3301 atomic_type c3(0);
3302 __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
3303 __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
2a5d011c 3304 __ATOMIC_RELAXED);
75cee7c6
BK
3305 __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
3306 __atomic_load_n(&c1, __ATOMIC_RELAXED);
3307 ],
2cd9cdcc
PC
3308 [glibcxx_cv_atomic_short=yes],
3309 [glibcxx_cv_atomic_short=no])
b329dd10 3310 ])
2cd9cdcc 3311
9646a322
JW
3312 AC_CACHE_CHECK([for atomic builtins for int],
3313 glibcxx_cv_atomic_int, [
2cd9cdcc
PC
3314 AC_TRY_LINK(
3315 [ ],
3316 [typedef int atomic_type;
3317 atomic_type c1;
3318 atomic_type c2;
75cee7c6
BK
3319 atomic_type c3(0);
3320 __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
3321 __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
2a5d011c 3322 __ATOMIC_RELAXED);
75cee7c6
BK
3323 __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
3324 __atomic_load_n(&c1, __ATOMIC_RELAXED);
3325 ],
2cd9cdcc
PC
3326 [glibcxx_cv_atomic_int=yes],
3327 [glibcxx_cv_atomic_int=no])
b329dd10 3328 ])
2cd9cdcc 3329
9646a322
JW
3330 AC_CACHE_CHECK([for atomic builtins for long long],
3331 glibcxx_cv_atomic_long_long, [
2cd9cdcc
PC
3332 AC_TRY_LINK(
3333 [ ],
3334 [typedef long long atomic_type;
3335 atomic_type c1;
3336 atomic_type c2;
75cee7c6
BK
3337 atomic_type c3(0);
3338 __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
3339 __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
2a5d011c 3340 __ATOMIC_RELAXED);
75cee7c6
BK
3341 __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
3342 __atomic_load_n(&c1, __ATOMIC_RELAXED);
3343 ],
2cd9cdcc
PC
3344 [glibcxx_cv_atomic_long_long=yes],
3345 [glibcxx_cv_atomic_long_long=no])
b329dd10 3346 ])
2cd9cdcc
PC
3347
3348 else
3349
3350 # Do asm tests.
3351
35648b45
BK
3352 # Compile unoptimized.
3353 CXXFLAGS='-O0 -S'
3354
2cd9cdcc 3355 # Fake what AC_TRY_COMPILE does.
701a3eee 3356
701a3eee
BK
3357 cat > conftest.$ac_ext << EOF
3358[#]line __oline__ "configure"
3359int main()
50ce8d3d
BK
3360{
3361 typedef bool atomic_type;
3362 atomic_type c1;
3363 atomic_type c2;
75cee7c6 3364 atomic_type c3(0);
d2aee115 3365 // N.B. __atomic_fetch_add is not supported for bool.
75cee7c6 3366 __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
2a5d011c 3367 __ATOMIC_RELAXED);
75cee7c6
BK
3368 __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
3369 __atomic_load_n(&c1, __ATOMIC_RELAXED);
2a5d011c 3370
50ce8d3d
BK
3371 return 0;
3372}
3373EOF
3374
3375 AC_MSG_CHECKING([for atomic builtins for bool])
3376 if AC_TRY_EVAL(ac_compile); then
904bfee8 3377 if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
b329dd10 3378 glibcxx_cv_atomic_bool=no
50ce8d3d 3379 else
b329dd10 3380 glibcxx_cv_atomic_bool=yes
50ce8d3d
BK
3381 fi
3382 fi
2cd9cdcc 3383 AC_MSG_RESULT($glibcxx_cv_atomic_bool)
50ce8d3d
BK
3384 rm -f conftest*
3385
3386 cat > conftest.$ac_ext << EOF
3387[#]line __oline__ "configure"
3388int main()
3389{
3390 typedef short atomic_type;
3391 atomic_type c1;
3392 atomic_type c2;
75cee7c6
BK
3393 atomic_type c3(0);
3394 __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
3395 __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
2a5d011c 3396 __ATOMIC_RELAXED);
75cee7c6
BK
3397 __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
3398 __atomic_load_n(&c1, __ATOMIC_RELAXED);
3399
50ce8d3d
BK
3400 return 0;
3401}
3402EOF
3403
3404 AC_MSG_CHECKING([for atomic builtins for short])
3405 if AC_TRY_EVAL(ac_compile); then
904bfee8 3406 if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
b329dd10 3407 glibcxx_cv_atomic_short=no
50ce8d3d 3408 else
b329dd10 3409 glibcxx_cv_atomic_short=yes
50ce8d3d
BK
3410 fi
3411 fi
2cd9cdcc 3412 AC_MSG_RESULT($glibcxx_cv_atomic_short)
50ce8d3d
BK
3413 rm -f conftest*
3414
3415 cat > conftest.$ac_ext << EOF
3416[#]line __oline__ "configure"
3417int main()
701a3eee 3418{
b329dd10 3419 // NB: _Atomic_word not necessarily int.
701a3eee
BK
3420 typedef int atomic_type;
3421 atomic_type c1;
3422 atomic_type c2;
75cee7c6
BK
3423 atomic_type c3(0);
3424 __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
3425 __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
2a5d011c 3426 __ATOMIC_RELAXED);
75cee7c6
BK
3427 __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
3428 __atomic_load_n(&c1, __ATOMIC_RELAXED);
3429
35648b45
BK
3430 return 0;
3431}
3432EOF
3433
3434 AC_MSG_CHECKING([for atomic builtins for int])
3435 if AC_TRY_EVAL(ac_compile); then
904bfee8 3436 if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
b329dd10 3437 glibcxx_cv_atomic_int=no
35648b45 3438 else
b329dd10 3439 glibcxx_cv_atomic_int=yes
35648b45
BK
3440 fi
3441 fi
2cd9cdcc 3442 AC_MSG_RESULT($glibcxx_cv_atomic_int)
35648b45
BK
3443 rm -f conftest*
3444
3445 cat > conftest.$ac_ext << EOF
3446[#]line __oline__ "configure"
3447int main()
3448{
50ce8d3d 3449 typedef long long atomic_type;
35648b45
BK
3450 atomic_type c1;
3451 atomic_type c2;
75cee7c6
BK
3452 atomic_type c3(0);
3453 __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
3454 __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
2a5d011c 3455 __ATOMIC_RELAXED);
75cee7c6
BK
3456 __atomic_test_and_set(&c1, __ATOMIC_RELAXED);
3457 __atomic_load_n(&c1, __ATOMIC_RELAXED);
3458
35648b45 3459 return 0;
701a3eee
BK
3460}
3461EOF
35648b45 3462
50ce8d3d 3463 AC_MSG_CHECKING([for atomic builtins for long long])
701a3eee 3464 if AC_TRY_EVAL(ac_compile); then
904bfee8 3465 if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
b329dd10 3466 glibcxx_cv_atomic_long_long=no
701a3eee 3467 else
b329dd10 3468 glibcxx_cv_atomic_long_long=yes
701a3eee
BK
3469 fi
3470 fi
2cd9cdcc 3471 AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
701a3eee
BK
3472 rm -f conftest*
3473
2cd9cdcc 3474 fi
50ce8d3d 3475
35648b45
BK
3476 CXXFLAGS="$old_CXXFLAGS"
3477 AC_LANG_RESTORE
3478
320c7be3
SH
3479 # Set atomicity_dir to builtins if all but the long long test above passes,
3480 # or if the builtins were already chosen (e.g. by configure.host).
3481 if { test "$glibcxx_cv_atomic_bool" = yes \
3d076231 3482 && test "$glibcxx_cv_atomic_short" = yes \
320c7be3
SH
3483 && test "$glibcxx_cv_atomic_int" = yes; } \
3484 || test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then
a152e96f
BK
3485 AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS, 1,
3486 [Define if the compiler supports C++11 atomics.])
35648b45
BK
3487 atomicity_dir=cpu/generic/atomicity_builtins
3488 fi
3489
3490 # If still generic, set to mutex.
701a3eee 3491 if test $atomicity_dir = "cpu/generic" ; then
35648b45 3492 atomicity_dir=cpu/generic/atomicity_mutex
6995087d 3493 AC_MSG_WARN([No native atomic operations are provided for this platform.])
dd88bc97 3494 if test "x$target_thread_file" = xsingle; then
b329dd10
BK
3495 AC_MSG_WARN([They cannot be faked when thread support is disabled.])
3496 AC_MSG_WARN([Thread-safety of certain classes is not guaranteed.])
6995087d 3497 else
b329dd10
BK
3498 AC_MSG_WARN([They will be faked using a mutex.])
3499 AC_MSG_WARN([Performance of certain classes will degrade as a result.])
6995087d 3500 fi
701a3eee 3501 fi
35648b45 3502
701a3eee
BK
3503])
3504
da29d2a3
JW
3505dnl
3506dnl Set default lock policy for synchronizing shared_ptr reference counting.
3507dnl
3508dnl --with-libstdcxx-lock-policy=auto
3509dnl Use atomic operations for shared_ptr reference counting only if
3510dnl the default target supports atomic compare-and-swap.
3511dnl --with-libstdcxx-lock-policy=atomic
3512dnl Use atomic operations for shared_ptr reference counting.
3513dnl --with-libstdcxx-lock-policy=mutex
3514dnl Use a mutex to synchronize shared_ptr reference counting.
3515dnl
3516dnl This controls the value of __gnu_cxx::__default_lock_policy, which
3517dnl determines how shared_ptr reference counts are synchronized.
3518dnl The option "atomic" means that atomic operations should be used,
3519dnl "mutex" means that a mutex will be used. The default option, "auto",
3520dnl will check if the target supports the compiler-generated builtins
3521dnl for atomic compare-and-swap operations for 2-byte and 4-byte integers,
3522dnl and will use "atomic" if supported, "mutex" otherwise.
3523dnl This option is ignored if the thread model used by GCC is "single",
3524dnl as no synchronization is used at all in that case.
3525dnl This option affects the library ABI (except in the "single" thread model).
3526dnl
3527dnl Defines _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY to 1 if atomics should be used.
3528dnl
3529AC_DEFUN([GLIBCXX_ENABLE_LOCK_POLICY], [
3530
3531 AC_ARG_WITH([libstdcxx-lock-policy],
3532 AC_HELP_STRING([--with-libstdcxx-lock-policy={atomic,mutex,auto}],
3533 [synchronization policy for shared_ptr reference counting [default=auto]]),
3534 [libstdcxx_atomic_lock_policy=$withval],
3535 [libstdcxx_atomic_lock_policy=auto])
3536
3537 case "$libstdcxx_atomic_lock_policy" in
3538 atomic|mutex|auto) ;;
3539 *) AC_MSG_ERROR([Invalid argument for --with-libstdcxx-lock-policy]) ;;
3540 esac
3541 AC_MSG_CHECKING([for lock policy for shared_ptr reference counts])
3542
3543 if test x"$libstdcxx_atomic_lock_policy" = x"auto"; then
3544 AC_LANG_SAVE
3545 AC_LANG_CPLUSPLUS
3546 ac_save_CXXFLAGS="$CXXFLAGS"
3547
3548 dnl Why do we care about 2-byte CAS on targets with 4-byte _Atomic_word?!
3549 AC_TRY_COMPILE([
3550 #if ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
3551 # error "No 2-byte compare-and-swap"
3552 #elif ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
3553 # error "No 4-byte compare-and-swap"
3554 #endif
3555 ],,
3556 [libstdcxx_atomic_lock_policy=atomic],
3557 [libstdcxx_atomic_lock_policy=mutex])
3558 AC_LANG_RESTORE
3559 CXXFLAGS="$ac_save_CXXFLAGS"
3560 fi
3561
3562 if test x"$libstdcxx_atomic_lock_policy" = x"atomic"; then
3563 AC_MSG_RESULT(atomic)
3564 AC_DEFINE(HAVE_ATOMIC_LOCK_POLICY,1,
3565 [Defined if shared_ptr reference counting should use atomic operations.])
3566 else
3567 AC_MSG_RESULT(mutex)
3568 fi
3569
3570])
701a3eee 3571
98e615b4
BK
3572dnl
3573dnl Allow visibility attributes to be used on namespaces, objects, etc.
3574dnl
dbe17524
PC
3575dnl --enable-libstdcxx-visibility enables attempt to use visibility attributes.
3576dnl --disable-libstdcxx-visibility turns off all use of visibility attributes.
3577dnl + Usage: GLIBCXX_ENABLE_LIBSTDCXX_VISIBILITY[(DEFAULT)]
98e615b4
BK
3578dnl Where DEFAULT is 'yes'.
3579dnl
dbe17524
PC
3580AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_VISIBILITY], [
3581GLIBCXX_ENABLE(libstdcxx-visibility,$1,,[enables visibility safe usage])
98e615b4 3582
dbe17524 3583if test x$enable_libstdcxx_visibility = xyes ; then
98e615b4
BK
3584 dnl all hail libgfortran
3585 dnl Check whether the target supports hidden visibility.
3586 AC_CACHE_CHECK([whether the target supports hidden visibility],
6d26724a 3587 glibcxx_cv_have_attribute_visibility, [
98e615b4
BK
3588 save_CFLAGS="$CFLAGS"
3589 CFLAGS="$CFLAGS -Werror"
3590 AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
6d26724a
RW
3591 [], glibcxx_cv_have_attribute_visibility=yes,
3592 glibcxx_cv_have_attribute_visibility=no)
98e615b4 3593 CFLAGS="$save_CFLAGS"])
6d26724a 3594 if test $glibcxx_cv_have_attribute_visibility = no; then
dbe17524 3595 enable_libstdcxx_visibility=no
98e615b4
BK
3596 fi
3597fi
3598
dbe17524
PC
3599GLIBCXX_CONDITIONAL(ENABLE_VISIBILITY, test $enable_libstdcxx_visibility = yes)
3600AC_MSG_NOTICE([visibility supported: $enable_libstdcxx_visibility])
98e615b4
BK
3601])
3602
3603
530539d9
PE
3604dnl
3605dnl Add version tags to symbols in shared library (or not), additionally
3606dnl marking other symbols as private/local (or not).
3607dnl
2799d972
BK
3608dnl Sets libtool_VERSION, and determines shared library SONAME.
3609dnl
3610dnl This depends on GLIBCXX CHECK_LINKER_FEATURES, but without it assumes no.
3611dnl
c98b201b
PE
3612dnl --enable-symvers=style adds a version script to the linker call when
3613dnl creating the shared library. The choice of version script is
3614dnl controlled by 'style'.
530539d9 3615dnl --disable-symvers does not.
2799d972 3616dnl
3d7c150e 3617dnl + Usage: GLIBCXX_ENABLE_SYMVERS[(DEFAULT)]
ff66d28f
PE
3618dnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to
3619dnl choose a default style based on linker characteristics. Passing
3620dnl 'no' disables versioning.
3621dnl
f214923c 3622AC_DEFUN([GLIBCXX_ENABLE_SYMVERS], [
ff66d28f 3623
b453ace3 3624GLIBCXX_ENABLE(symvers,$1,[[[=STYLE]]],
ff66d28f 3625 [enables symbol versioning of the shared library],
c18dc5cc 3626 [permit yes|no|gnu|gnu-versioned-namespace|darwin|darwin-export|sun])
c98b201b 3627
3d7c150e 3628# If we never went through the GLIBCXX_CHECK_LINKER_FEATURES macro, then we
37bc6ca2 3629# don't know enough about $LD to do tricks...
ff66d28f 3630AC_REQUIRE([GLIBCXX_CHECK_LINKER_FEATURES])
c18dc5cc
RO
3631# Sun style symbol versions needs GNU c++filt for make_sunver.pl to work
3632# with extern "C++" in version scripts.
3633AC_REQUIRE([GCC_PROG_GNU_CXXFILT])
a9fdd472
GK
3634
3635# Turn a 'yes' into a suitable default.
3636if test x$enable_symvers = xyes ; then
4bd726d0 3637 if test $enable_shared = no || test "x$LD" = x || test x$gcc_no_link = xyes; then
a9fdd472 3638 enable_symvers=no
a9fdd472 3639 else
fb5c309d 3640 if test $with_gnu_ld = yes ; then
d89f0ad6 3641 case ${target_os} in
b329dd10
BK
3642 hpux*)
3643 enable_symvers=no ;;
3644 *)
3645 enable_symvers=gnu ;;
d89f0ad6 3646 esac
fb5c309d
BK
3647 else
3648 case ${target_os} in
b329dd10 3649 darwin*)
fb5c309d 3650 enable_symvers=darwin ;;
c18dc5cc
RO
3651 # Sun symbol versioning exists since Solaris 2.5.
3652 solaris2.[[5-9]]* | solaris2.1[[0-9]]*)
3653 # make_sunver.pl needs GNU c++filt to support extern "C++" in
3654 # version scripts, so disable symbol versioning if none can be
3655 # found.
3656 if test -z "$ac_cv_path_CXXFILT"; then
3657 AC_MSG_WARN([=== You have requested Sun symbol versioning, but])
3658 AC_MSG_WARN([=== no GNU c++filt could be found.])
3659 AC_MSG_WARN([=== Symbol versioning will be disabled.])
3660 enable_symvers=no
3661 else
3662 enable_symvers=sun
3663 fi
3664 ;;
b329dd10
BK
3665 *)
3666 enable_symvers=no ;;
fb5c309d
BK
3667 esac
3668 fi
a9fdd472 3669 fi
530539d9 3670fi
c98b201b 3671
fb5c309d
BK
3672# Check to see if 'darwin' or 'darwin-export' can win.
3673if test x$enable_symvers = xdarwin-export ; then
3674 enable_symvers=darwin
3675fi
3676
c18dc5cc
RO
3677# Check if 'sun' was requested on non-Solaris 2 platforms.
3678if test x$enable_symvers = xsun ; then
3679 case ${target_os} in
3680 solaris2*)
3681 # All fine.
3682 ;;
3683 *)
3684 # Unlikely to work.
3685 AC_MSG_WARN([=== You have requested Sun symbol versioning, but])
3686 AC_MSG_WARN([=== you are not targetting Solaris 2.])
3687 AC_MSG_WARN([=== Symbol versioning will be disabled.])
3688 enable_symvers=no
3689 ;;
3690 esac
3691fi
3692
f47bddec 3693# Check to see if 'gnu' can win.
b329dd10
BK
3694if test $enable_symvers = gnu ||
3695 test $enable_symvers = gnu-versioned-namespace ||
c18dc5cc 3696 test $enable_symvers = sun; then
f47bddec 3697 # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
2c839a4e
PE
3698 AC_MSG_CHECKING([for shared libgcc])
3699 ac_save_CFLAGS="$CFLAGS"
3700 CFLAGS=' -lgcc_s'
ff66d28f 3701 AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes, glibcxx_shared_libgcc=no)
2c839a4e 3702 CFLAGS="$ac_save_CFLAGS"
d5325238
JJ
3703 if test $glibcxx_shared_libgcc = no; then
3704 cat > conftest.c <<EOF
3705int main (void) { return 0; }
3706EOF
3707changequote(,)dnl
3708 glibcxx_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
3709 -shared -shared-libgcc -o conftest.so \
3710 conftest.c -v 2>&1 >/dev/null \
3711 | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
3712changequote([,])dnl
3713 rm -f conftest.c conftest.so
3714 if test x${glibcxx_libgcc_s_suffix+set} = xset; then
3715 CFLAGS=" -lgcc_s$glibcxx_libgcc_s_suffix"
3716 AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes)
3717 CFLAGS="$ac_save_CFLAGS"
3718 fi
3719 fi
3d7c150e 3720 AC_MSG_RESULT($glibcxx_shared_libgcc)
a9fdd472 3721
a9fdd472
GK
3722 # For GNU ld, we need at least this version. The format is described in
3723 # GLIBCXX_CHECK_LINKER_FEATURES above.
3724 glibcxx_min_gnu_ld_version=21400
c98b201b 3725
f47bddec
GK
3726 # If no shared libgcc, can't win.
3727 if test $glibcxx_shared_libgcc != yes; then
3728 AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
3729 AC_MSG_WARN([=== you are not building a shared libgcc_s.])
3730 AC_MSG_WARN([=== Symbol versioning will be disabled.])
3731 enable_symvers=no
c18dc5cc
RO
3732 elif test $with_gnu_ld != yes && test $enable_symvers = sun; then
3733 : All interesting versions of Sun ld support sun style symbol versioning.
f47bddec 3734 elif test $with_gnu_ld != yes ; then
ab3bc736 3735 # just fail for now
a9fdd472
GK
3736 AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
3737 AC_MSG_WARN([=== you are not using the GNU linker.])
3738 AC_MSG_WARN([=== Symbol versioning will be disabled.])
3739 enable_symvers=no
d60a2d4d
ILT
3740 elif test $glibcxx_ld_is_gold = yes ; then
3741 : All versions of gold support symbol versioning.
a9fdd472
GK
3742 elif test $glibcxx_gnu_ld_version -lt $glibcxx_min_gnu_ld_version ; then
3743 # The right tools, the right setup, but too old. Fallbacks?
3744 AC_MSG_WARN(=== Linker version $glibcxx_gnu_ld_version is too old for)
3745 AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
3746 AC_MSG_WARN(=== You would need to upgrade your binutils to version)
3747 AC_MSG_WARN(=== $glibcxx_min_gnu_ld_version or later and rebuild GCC.)
58579a27 3748 AC_MSG_WARN([=== Symbol versioning will be disabled.])
ab3bc736
BK
3749 enable_symvers=no
3750 fi
3751fi
3752
2799d972 3753# For libtool versioning info, format is CURRENT:REVISION:AGE
a54ce886 3754libtool_VERSION=6:30:0
2799d972
BK
3755
3756# Everything parsed; figure out what files and settings to use.
c98b201b 3757case $enable_symvers in
ab3bc736 3758 no)
fb5c309d 3759 SYMVER_FILE=config/abi/pre/none.ver
ff66d28f 3760 ;;
c98b201b 3761 gnu)
fb5c309d 3762 SYMVER_FILE=config/abi/pre/gnu.ver
b329dd10
BK
3763 AC_DEFINE(_GLIBCXX_SYMVER_GNU, 1,
3764 [Define to use GNU versioning in the shared library.])
a9fdd472 3765 ;;
3cbc7af0 3766 gnu-versioned-namespace)
87c7063d 3767 libtool_VERSION=8:0:0
3cbc7af0 3768 SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
b329dd10
BK
3769 AC_DEFINE(_GLIBCXX_SYMVER_GNU_NAMESPACE, 1,
3770 [Define to use GNU namespace versioning in the shared library.])
3cbc7af0 3771 ;;
fb5c309d
BK
3772 darwin)
3773 SYMVER_FILE=config/abi/pre/gnu.ver
b329dd10
BK
3774 AC_DEFINE(_GLIBCXX_SYMVER_DARWIN, 1,
3775 [Define to use darwin versioning in the shared library.])
ff66d28f 3776 ;;
c18dc5cc
RO
3777 sun)
3778 SYMVER_FILE=config/abi/pre/gnu.ver
b329dd10
BK
3779 AC_DEFINE(_GLIBCXX_SYMVER_SUN, 1,
3780 [Define to use Sun versioning in the shared library.])
c18dc5cc 3781 ;;
c98b201b
PE
3782esac
3783
fb5c309d
BK
3784if test x$enable_symvers != xno ; then
3785 AC_DEFINE(_GLIBCXX_SYMVER, 1,
3786 [Define to use symbol versioning in the shared library.])
3787fi
3788
1f93f687
JJ
3789AC_CACHE_CHECK([whether the target supports .symver directive],
3790 glibcxx_cv_have_as_symver_directive, [
3791 AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");],
3792 [], glibcxx_cv_have_as_symver_directive=yes,
3793 glibcxx_cv_have_as_symver_directive=no)])
3794if test $glibcxx_cv_have_as_symver_directive = yes; then
3795 AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1,
3796 [Define to 1 if the target assembler supports .symver directive.])
3797fi
3798
fb5c309d
BK
3799AC_SUBST(SYMVER_FILE)
3800AC_SUBST(port_specific_symbol_files)
3801GLIBCXX_CONDITIONAL(ENABLE_SYMVERS, test $enable_symvers != no)
3802GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU, test $enable_symvers = gnu)
3cbc7af0 3803GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU_NAMESPACE, test $enable_symvers = gnu-versioned-namespace)
fb5c309d 3804GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_DARWIN, test $enable_symvers = darwin)
c18dc5cc 3805GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_SUN, test $enable_symvers = sun)
fb5c309d
BK
3806AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
3807
c18dc5cc
RO
3808if test $enable_symvers != no ; then
3809 case ${target_os} in
3810 # The Solaris 2 runtime linker doesn't support the GNU extension of
3811 # binding the same symbol to different versions
3812 solaris2*)
cc2de92d 3813 ;;
c18dc5cc
RO
3814 # Other platforms with GNU symbol versioning (GNU/Linux, more?) do.
3815 *)
8198d541 3816 AC_DEFINE(HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT, 1,
b329dd10 3817 [Define to 1 if the target runtime linker supports binding the same symbol to different versions.])
cc2de92d 3818 ;;
c18dc5cc
RO
3819 esac
3820fi
c18dc5cc 3821
fb5c309d 3822# Now, set up compatibility support, if any.
bb2b2a24
BK
3823# In addition, need this to deal with std::size_t mangling in
3824# src/compatibility.cc. In a perfect world, could use
3825# typeid(std::size_t).name()[0] to do direct substitution.
3826AC_MSG_CHECKING([for size_t as unsigned int])
3827ac_save_CFLAGS="$CFLAGS"
3828CFLAGS="-Werror"
b329dd10
BK
3829AC_TRY_COMPILE(, [__SIZE_TYPE__* stp; unsigned int* uip; stp = uip;],
3830 [glibcxx_size_t_is_i=yes], [glibcxx_size_t_is_i=no])
bb2b2a24
BK
3831CFLAGS=$ac_save_CFLAGS
3832if test "$glibcxx_size_t_is_i" = yes; then
3833 AC_DEFINE(_GLIBCXX_SIZE_T_IS_UINT, 1, [Define if size_t is unsigned int.])
3834fi
3835AC_MSG_RESULT([$glibcxx_size_t_is_i])
3836
3837AC_MSG_CHECKING([for ptrdiff_t as int])
3838ac_save_CFLAGS="$CFLAGS"
3839CFLAGS="-Werror"
b329dd10
BK
3840AC_TRY_COMPILE(, [__PTRDIFF_TYPE__* ptp; int* ip; ptp = ip;],
3841 [glibcxx_ptrdiff_t_is_i=yes], [glibcxx_ptrdiff_t_is_i=no])
bb2b2a24
BK
3842CFLAGS=$ac_save_CFLAGS
3843if test "$glibcxx_ptrdiff_t_is_i" = yes; then
3844 AC_DEFINE(_GLIBCXX_PTRDIFF_T_IS_INT, 1, [Define if ptrdiff_t is int.])
3845fi
3846AC_MSG_RESULT([$glibcxx_ptrdiff_t_is_i])
ff66d28f
PE
3847])
3848
3849
3850dnl
3851dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
3852dnl We must stage the required headers so that they will be installed
3853dnl with the library (unlike libgcc, the STL implementation is provided
3854dnl solely within headers). Since we must not inject random user-space
3855dnl macro names into user-provided C++ code, we first stage into <file>-in
3856dnl and process to <file> with an output command. The reason for a two-
3857dnl stage process here is to correctly handle $srcdir!=$objdir without
3858dnl having to write complex code (the sed commands to clean the macro
3859dnl namespace are complex and fragile enough as it is). We must also
3860dnl add a relative path so that -I- is supported properly.
3861dnl
1183dc2c
PC
3862dnl Substs:
3863dnl thread_header
3864dnl
f214923c 3865AC_DEFUN([GLIBCXX_ENABLE_THREADS], [
ff66d28f 3866 AC_MSG_CHECKING([for thread model used by GCC])
fbe057bb 3867 target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
ff66d28f 3868 AC_MSG_RESULT([$target_thread_file])
1183dc2c 3869 GCC_AC_THREAD_HEADER([$target_thread_file])
ff66d28f
PE
3870])
3871
3872
b8c41c8e
CF
3873dnl
3874dnl Check if gthread implementation defines the types and functions
3875dnl required by the c++0x thread library. Conforming gthread
3876dnl implementations can define __GTHREADS_CXX0X to enable use with c++0x.
3877dnl
bae868fb
RO
3878dnl GLIBCXX_ENABLE_SYMVERS must be done before this.
3879dnl
b8c41c8e 3880AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
bae868fb
RO
3881 GLIBCXX_ENABLE(libstdcxx-threads,auto,,[enable C++11 threads support])
3882
7607ff49 3883 if test x$enable_libstdcxx_threads = xauto ||
bae868fb
RO
3884 test x$enable_libstdcxx_threads = xyes; then
3885
b8c41c8e
CF
3886 AC_LANG_SAVE
3887 AC_LANG_CPLUSPLUS
3888
3889 ac_save_CXXFLAGS="$CXXFLAGS"
5d1c8e77
RO
3890 CXXFLAGS="$CXXFLAGS -fno-exceptions \
3891 -I${toplevel_srcdir}/libgcc -I${toplevel_builddir}/libgcc"
b8c41c8e 3892
3b2eeb43
JW
3893 target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
3894 case $target_thread_file in
3895 posix)
3896 CXXFLAGS="$CXXFLAGS -DSUPPORTS_WEAK -DGTHREAD_USE_WEAK -D_PTHREADS"
3897 esac
3898
3899 AC_MSG_CHECKING([whether it can be safely assumed that mutex_timedlock is available])
6545e33e
PC
3900
3901 AC_TRY_COMPILE([#include <unistd.h>],
3902 [
3b2eeb43
JW
3903 // In case of POSIX threads check _POSIX_TIMEOUTS.
3904 #if (defined(_PTHREADS) \
2a5d011c 3905 && (!defined(_POSIX_TIMEOUTS) || _POSIX_TIMEOUTS <= 0))
6545e33e
PC
3906 #error
3907 #endif
3908 ], [ac_gthread_use_mutex_timedlock=1], [ac_gthread_use_mutex_timedlock=0])
3909
3910 AC_DEFINE_UNQUOTED(_GTHREAD_USE_MUTEX_TIMEDLOCK, $ac_gthread_use_mutex_timedlock,
2a5d011c 3911 [Define to 1 if mutex_timedlock is available.])
6545e33e
PC
3912
3913 if test $ac_gthread_use_mutex_timedlock = 1 ; then res_mutex_timedlock=yes ;
3914 else res_mutex_timedlock=no ; fi
3915 AC_MSG_RESULT([$res_mutex_timedlock])
3916
b8c41c8e
CF
3917 AC_MSG_CHECKING([for gthreads library])
3918
3b2eeb43 3919 AC_TRY_COMPILE([#include "gthr.h"],
b8c41c8e 3920 [
a1c5742d
PC
3921 #ifndef __GTHREADS_CXX0X
3922 #error
3923 #endif
d9f069ab 3924 ], [ac_has_gthreads=yes], [ac_has_gthreads=no])
bae868fb
RO
3925 else
3926 ac_has_gthreads=no
3927 fi
b8c41c8e
CF
3928
3929 AC_MSG_RESULT([$ac_has_gthreads])
3930
3931 if test x"$ac_has_gthreads" = x"yes"; then
3932 AC_DEFINE(_GLIBCXX_HAS_GTHREADS, 1,
b329dd10 3933 [Define if gthreads library is available.])
5e0216f1
JW
3934
3935 # Also check for pthread_rwlock_t for std::shared_timed_mutex in C++14
7607ff49
JL
3936 # but only do so if we're using pthread in the gthread library.
3937 # On VxWorks for example, pthread_rwlock_t is defined in sys/types.h
3938 # but the pthread library is not there by default and the gthread library
3939 # does not use it.
3940 AC_TRY_COMPILE([#include "gthr.h"],
3941 [
3942 #if (!defined(_PTHREADS))
3943 #error
3944 #endif
3945 ], [ac_gthread_use_pthreads=yes], [ac_gthread_use_pthreads=no])
3946 if test x"$ac_gthread_use_pthreads" = x"yes"; then
3947 AC_CHECK_TYPE([pthread_rwlock_t],
3948 [AC_DEFINE([_GLIBCXX_USE_PTHREAD_RWLOCK_T], 1,
3949 [Define if POSIX read/write locks are available in <gthr.h>.])],
3950 [],
3951 [#include "gthr.h"])
3952 fi
b8c41c8e
CF
3953 fi
3954
92b47a32
JW
3955 AC_CHECK_HEADER(semaphore.h, [
3956 AC_MSG_CHECKING([for POSIX Semaphores and sem_timedwait])
3957 AC_TRY_COMPILE([
3958 #include <unistd.h>
3959 #include <semaphore.h>
3960 #include <limits.h>
3961 ],
3962 [
3963 #if !defined _POSIX_TIMEOUTS || _POSIX_TIMEOUTS <= 0
3964 # error "POSIX Timeouts option not supported"
3965 #elif !defined _POSIX_SEMAPHORES || _POSIX_SEMAPHORES <= 0
3966 # error "POSIX Semaphores option not supported"
3967 #else
3968 #if defined SEM_VALUE_MAX
3969 constexpr int sem_value_max = SEM_VALUE_MAX;
3970 #elif defined _POSIX_SEM_VALUE_MAX
3971 constexpr int sem_value_max = _POSIX_SEM_VALUE_MAX;
3972 #else
3973 # error "SEM_VALUE_MAX not available"
3974 #endif
3975 sem_t sem;
3976 sem_init(&sem, 0, sem_value_max);
3977 struct timespec ts = { 0 };
3978 sem_timedwait(&sem, &ts);
3979 #endif
3980 ],
3981 [ac_have_posix_semaphore=yes],
3982 [ac_have_posix_semaphore=no])],
3983 [ac_have_posix_semaphore=no])
3984
3985 if test $ac_have_posix_semaphore = yes ; then
2d4c3af9 3986 AC_DEFINE(HAVE_POSIX_SEMAPHORE,
92b47a32
JW
3987 1,
3988 [Define to 1 if POSIX Semaphores with sem_timedwait are available in <semaphore.h>.])
3989 fi
3990 AC_MSG_RESULT([$ac_have_posix_semaphore])
3991
b8c41c8e
CF
3992 CXXFLAGS="$ac_save_CXXFLAGS"
3993 AC_LANG_RESTORE
3994])
3995
3996
ff66d28f
PE
3997# Check whether LC_MESSAGES is available in <locale.h>.
3998# Ulrich Drepper <drepper@cygnus.com>, 1995.
3999#
4000# This file file be copied and used freely without restrictions. It can
4001# be used in projects which are not available under the GNU Public License
4002# but which still want to provide support for the GNU gettext functionality.
4003# Please note that the actual code is *not* freely available.
f214923c 4004AC_DEFUN([AC_LC_MESSAGES], [
ff66d28f
PE
4005 AC_CHECK_HEADER(locale.h, [
4006 AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
99bf8d16 4007 [AC_TRY_COMPILE([#include <locale.h>], [return LC_MESSAGES],
ff66d28f
PE
4008 ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
4009 if test $ac_cv_val_LC_MESSAGES = yes; then
b329dd10
BK
4010 AC_DEFINE(HAVE_LC_MESSAGES, 1,
4011 [Define if LC_MESSAGES is available in <locale.h>.])
ff66d28f
PE
4012 fi
4013 ])
4014])
4015
3ca6351d
UD
4016dnl
4017dnl Check whether rdrand is supported in the assembler.
4018AC_DEFUN([GLIBCXX_CHECK_X86_RDRAND], [
9646a322
JW
4019 AC_CACHE_CHECK([for rdrand support in assembler],
4020 ac_cv_x86_rdrand, [
3ca6351d
UD
4021 ac_cv_x86_rdrand=no
4022 case "$target" in
4023 i?86-*-* | \
4024 x86_64-*-*)
4025 AC_TRY_COMPILE(, [asm("rdrand %eax");],
4026 [ac_cv_x86_rdrand=yes], [ac_cv_x86_rdrand=no])
4027 esac
4028 ])
4029 if test $ac_cv_x86_rdrand = yes; then
4030 AC_DEFINE(_GLIBCXX_X86_RDRAND, 1,
4031 [ Defined if as can handle rdrand. ])
4032 fi
3ca6351d
UD
4033])
4034
b0c0d878
JW
4035dnl
4036dnl Check whether rdseed is supported in the assembler.
4037AC_DEFUN([GLIBCXX_CHECK_X86_RDSEED], [
9646a322
JW
4038 AC_CACHE_CHECK([for rdseed support in assembler],
4039 ac_cv_x86_rdseed, [
b0c0d878
JW
4040 ac_cv_x86_rdseed=no
4041 case "$target" in
4042 i?86-*-* | \
4043 x86_64-*-*)
4044 AC_TRY_COMPILE(, [asm("rdseed %eax");],
4045 [ac_cv_x86_rdseed=yes], [ac_cv_x86_rdseed=no])
4046 esac
4047 ])
4048 if test $ac_cv_x86_rdseed = yes; then
4049 AC_DEFINE(_GLIBCXX_X86_RDSEED, 1,
4050 [ Defined if as can handle rdseed. ])
4051 fi
b0c0d878
JW
4052])
4053
43653c33
JW
4054dnl
4055dnl Check whether get_nprocs is available in <sys/sysinfo.h>, and define _GLIBCXX_USE_GET_NPROCS.
4056dnl
4057AC_DEFUN([GLIBCXX_CHECK_GET_NPROCS], [
4058
4059 AC_LANG_SAVE
4060 AC_LANG_CPLUSPLUS
4061 ac_save_CXXFLAGS="$CXXFLAGS"
4062 CXXFLAGS="$CXXFLAGS -fno-exceptions"
4063
9646a322
JW
4064 AC_CACHE_CHECK([for get_nprocs],
4065 glibcxx_cv_GET_NPROCS, [
43653c33
JW
4066 GCC_TRY_COMPILE_OR_LINK(
4067 [#include <sys/sysinfo.h>],
4068 [int n = get_nprocs();],
4069 [glibcxx_cv_GET_NPROCS=yes],
4070 [glibcxx_cv_GET_NPROCS=no])
4071 ])
4072 if test $glibcxx_cv_GET_NPROCS = yes; then
4073 AC_DEFINE(_GLIBCXX_USE_GET_NPROCS, 1, [Define if get_nprocs is available in <sys/sysinfo.h>.])
4074 fi
43653c33
JW
4075
4076 CXXFLAGS="$ac_save_CXXFLAGS"
4077 AC_LANG_RESTORE
4078])
4079
4080dnl
4081dnl Check whether sysconf(_SC_NPROCESSORS_ONLN) is available in <unistd.h>, and define _GLIBCXX_USE_SC_NPROCESSORS_ONLN.
4082dnl
4083AC_DEFUN([GLIBCXX_CHECK_SC_NPROCESSORS_ONLN], [
4084
4085 AC_LANG_SAVE
4086 AC_LANG_CPLUSPLUS
4087 ac_save_CXXFLAGS="$CXXFLAGS"
4088 CXXFLAGS="$CXXFLAGS -fno-exceptions"
4089
9646a322
JW
4090 AC_CACHE_CHECK([for _SC_NPROCESSORS_ONLN],
4091 glibcxx_cv_SC_NPROCESSORS_ONLN, [
43653c33
JW
4092 GCC_TRY_COMPILE_OR_LINK(
4093 [#include <unistd.h>],
4094 [int n = sysconf(_SC_NPROCESSORS_ONLN);],
4095 [glibcxx_cv_SC_NPROCESSORS_ONLN=yes],
4096 [glibcxx_cv_SC_NPROCESSORS_ONLN=no])
4097 ])
4098 if test $glibcxx_cv_SC_NPROCESSORS_ONLN = yes; then
4099 AC_DEFINE(_GLIBCXX_USE_SC_NPROCESSORS_ONLN, 1, [Define if _SC_NPROCESSORS_ONLN is available in <unistd.h>.])
4100 fi
43653c33
JW
4101
4102 CXXFLAGS="$ac_save_CXXFLAGS"
4103 AC_LANG_RESTORE
4104])
4105
5ee360d0
JW
4106dnl
4107dnl Check whether sysconf(_SC_NPROC_ONLN) is available in <unistd.h>, and define _GLIBCXX_USE_SC_NPROC_ONLN.
4108dnl
4109AC_DEFUN([GLIBCXX_CHECK_SC_NPROC_ONLN], [
4110
4111 AC_LANG_SAVE
4112 AC_LANG_CPLUSPLUS
4113 ac_save_CXXFLAGS="$CXXFLAGS"
4114 CXXFLAGS="$CXXFLAGS -fno-exceptions"
4115
9646a322
JW
4116 AC_CACHE_CHECK([for _SC_NPROC_ONLN],
4117 glibcxx_cv_SC_NPROC_ONLN, [
5ee360d0
JW
4118 GCC_TRY_COMPILE_OR_LINK(
4119 [#include <unistd.h>],
4120 [int n = sysconf(_SC_NPROC_ONLN);],
4121 [glibcxx_cv_SC_NPROC_ONLN=yes],
4122 [glibcxx_cv_SC_NPROC_ONLN=no])
4123 ])
4124 if test $glibcxx_cv_SC_NPROC_ONLN = yes; then
4125 AC_DEFINE(_GLIBCXX_USE_SC_NPROC_ONLN, 1, [Define if _SC_NPROC_ONLN is available in <unistd.h>.])
4126 fi
5ee360d0
JW
4127
4128 CXXFLAGS="$ac_save_CXXFLAGS"
4129 AC_LANG_RESTORE
4130])
4131
4132dnl
4133dnl Check whether pthread_num_processors_np is available in <pthread.h>, and define _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP.
4134dnl
4135AC_DEFUN([GLIBCXX_CHECK_PTHREADS_NUM_PROCESSORS_NP], [
4136
4137 AC_LANG_SAVE
4138 AC_LANG_CPLUSPLUS
4139 ac_save_CXXFLAGS="$CXXFLAGS"
4140 CXXFLAGS="$CXXFLAGS -fno-exceptions"
4141
9646a322
JW
4142 AC_CACHE_CHECK([for pthreads_num_processors_np],
4143 glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP, [
5ee360d0
JW
4144 GCC_TRY_COMPILE_OR_LINK(
4145 [#include <pthread.h>],
4146 [int n = pthread_num_processors_np();],
4147 [glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP=yes],
4148 [glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP=no])
4149 ])
4150 if test $glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP = yes; then
4151 AC_DEFINE(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP, 1, [Define if pthreads_num_processors_np is available in <pthread.h>.])
4152 fi
5ee360d0
JW
4153
4154 CXXFLAGS="$ac_save_CXXFLAGS"
4155 AC_LANG_RESTORE
4156])
4157
ad4d1d21
MC
4158dnl
4159dnl Check whether pthread_cond_clockwait is available in <pthread.h> for std::condition_variable to use,
4160dnl and define _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT.
4161dnl
4162AC_DEFUN([GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT], [
4163
4164 AC_LANG_SAVE
4165 AC_LANG_CPLUSPLUS
4166 ac_save_CXXFLAGS="$CXXFLAGS"
4167 CXXFLAGS="$CXXFLAGS -fno-exceptions"
4168 ac_save_LIBS="$LIBS"
4169 LIBS="$LIBS -lpthread"
4170
9646a322
JW
4171 AC_CACHE_CHECK([for pthread_cond_clockwait],
4172 glibcxx_cv_PTHREAD_COND_CLOCKWAIT, [
ad4d1d21
MC
4173 GCC_TRY_COMPILE_OR_LINK(
4174 [#include <pthread.h>],
4175 [pthread_mutex_t mutex; pthread_cond_t cond; struct timespec ts; int n = pthread_cond_clockwait(&cond, &mutex, 0, &ts);],
4176 [glibcxx_cv_PTHREAD_COND_CLOCKWAIT=yes],
4177 [glibcxx_cv_PTHREAD_COND_CLOCKWAIT=no])
4178 ])
4179 if test $glibcxx_cv_PTHREAD_COND_CLOCKWAIT = yes; then
4180 AC_DEFINE(_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT, 1, [Define if pthread_cond_clockwait is available in <pthread.h>.])
4181 fi
ad4d1d21
MC
4182
4183 CXXFLAGS="$ac_save_CXXFLAGS"
4184 LIBS="$ac_save_LIBS"
4185 AC_LANG_RESTORE
4186])
4187
3b2fb543
MC
4188dnl
4189dnl Check whether pthread_mutex_clocklock is available in <pthread.h> for std::timed_mutex to use,
4190dnl and define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK.
4191dnl
4192AC_DEFUN([GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK], [
4193
4194 AC_LANG_SAVE
4195 AC_LANG_CPLUSPLUS
4196 ac_save_CXXFLAGS="$CXXFLAGS"
4197 CXXFLAGS="$CXXFLAGS -fno-exceptions"
4198 ac_save_LIBS="$LIBS"
4199 LIBS="$LIBS -lpthread"
4200
9646a322
JW
4201 AC_CACHE_CHECK([for pthread_mutex_clocklock],
4202 glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK, [
3b2fb543
MC
4203 GCC_TRY_COMPILE_OR_LINK(
4204 [#include <pthread.h>],
4205 [pthread_mutex_t mutex; struct timespec ts; int n = pthread_mutex_clocklock(&mutex, CLOCK_REALTIME, &ts);],
4206 [glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK=yes],
4207 [glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK=no])
4208 ])
4209 if test $glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK = yes; then
4210 AC_DEFINE(_GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK, 1, [Define if pthread_mutex_clocklock is available in <pthread.h>.])
4211 fi
3b2fb543
MC
4212
4213 CXXFLAGS="$ac_save_CXXFLAGS"
4214 LIBS="$ac_save_LIBS"
4215 AC_LANG_RESTORE
4216])
4217
ab40695a
MC
4218dnl
4219dnl Check whether pthread_mutex_clocklock is available in <pthread.h> for std::timed_mutex to use,
4220dnl and define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK.
4221dnl
4222AC_DEFUN([GLIBCXX_CHECK_PTHREAD_RWLOCK_CLOCKLOCK], [
4223
4224 AC_LANG_SAVE
4225 AC_LANG_CPLUSPLUS
4226 ac_save_CXXFLAGS="$CXXFLAGS"
4227 CXXFLAGS="$CXXFLAGS -fno-exceptions"
4228 ac_save_LIBS="$LIBS"
4229 LIBS="$LIBS -lpthread"
4230
9646a322
JW
4231 AC_CACHE_CHECK([for pthread_rwlock_clockrdlock, pthread_wlock_clockwrlock],
4232 glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK, [
ab40695a
MC
4233 GCC_TRY_COMPILE_OR_LINK(
4234 [#include <pthread.h>],
4235 [pthread_rwlock_t rwl; struct timespec ts;]
4236 [int n = pthread_rwlock_clockrdlock(&rwl, CLOCK_REALTIME, &ts);]
4237 [int m = pthread_rwlock_clockwrlock(&rwl, CLOCK_REALTIME, &ts);],
4238 [glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK=yes],
4239 [glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK=no])
4240 ])
4241 if test $glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK = yes; then
4242 AC_DEFINE(_GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK, 1, [Define if pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock are available in <pthread.h>.])
4243 fi
ab40695a
MC
4244
4245 CXXFLAGS="$ac_save_CXXFLAGS"
4246 LIBS="$ac_save_LIBS"
4247 AC_LANG_RESTORE
4248])
4249
5ee360d0
JW
4250dnl
4251dnl Check whether sysctl is available in <pthread.h>, and define _GLIBCXX_USE_SYSCTL_HW_NCPU.
4252dnl
4253AC_DEFUN([GLIBCXX_CHECK_SYSCTL_HW_NCPU], [
4254
4255 AC_LANG_SAVE
4256 AC_LANG_CPLUSPLUS
4257 ac_save_CXXFLAGS="$CXXFLAGS"
4258 CXXFLAGS="$CXXFLAGS -fno-exceptions"
4259
9646a322
JW
4260 AC_CACHE_CHECK([for hw.ncpu sysctl],
4261 glibcxx_cv_SYSCTL_HW_NCPU, [
5ee360d0
JW
4262 GCC_TRY_COMPILE_OR_LINK(
4263 [
4264 #include <stddef.h>
4265 #include <sys/sysctl.h>
4266 ],
4267 [
4268 int count;
4269 size_t size = sizeof(count);
4270 int mib[] = { CTL_HW, HW_NCPU };
4271 sysctl(mib, 2, &count, &size, NULL, 0);
4272 ],
4273 [glibcxx_cv_SYSCTL_HW_NCPU=yes],
4274 [glibcxx_cv_SYSCTL_HW_NCPU=no])
4275 ])
4276 if test $glibcxx_cv_SYSCTL_HW_NCPU = yes; then
4277 AC_DEFINE(_GLIBCXX_USE_SYSCTL_HW_NCPU, 1, [Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>.])
4278 fi
5ee360d0
JW
4279
4280 CXXFLAGS="$ac_save_CXXFLAGS"
4281 AC_LANG_RESTORE
4282])
43653c33 4283
2a5d011c
BK
4284dnl
4285dnl Check to see if python pretty printing can be activated.
4286dnl
4287dnl --with-python-dir=dir
4288dnl installs directory into $prefix/dir
4289AC_DEFUN([GLIBCXX_ENABLE_PYTHON], [
4290
4291AC_MSG_CHECKING([for custom python install directory])
4292AC_ARG_WITH([python-dir],
4293 AS_HELP_STRING([--with-python-dir],
4294 [the location to install Python modules. This path is relative starting from the prefix.]),
4295 [with_python_dir=$withval], [with_python_dir="no"])
4296AC_MSG_RESULT(${with_python_dir})
4297
4298# Needed for installing Python modules during make install.
4299python_mod_dir="${with_python_dir}"
4300AC_SUBST(python_mod_dir)
4301GLIBCXX_CONDITIONAL(ENABLE_PYTHONDIR, test $python_mod_dir != no)
4302])
4303
b124c5c4
BK
4304dnl
4305dnl Check to see if -Werror is disabled.
4306dnl
4307dnl --enable-werror/--disable-werror
4308AC_DEFUN([GLIBCXX_ENABLE_WERROR], [
4309 AC_MSG_CHECKING([for -Werror])
4310 GLIBCXX_ENABLE(werror,$1,,[turns on -Werror])
4311 AC_MSG_RESULT($enable_werror)
4312 GLIBCXX_CONDITIONAL(ENABLE_WERROR, test $enable_werror = yes)
4313])
4314
7370b9df
BRF
4315dnl
4316dnl Check whether obsolescent tmpnam is available in <stdio.h>,
4317dnl and define _GLIBCXX_USE_TMPNAM.
4318dnl
4319AC_DEFUN([GLIBCXX_CHECK_TMPNAM], [dnl
4320dnl
4321 AC_LANG_SAVE
4322 AC_LANG_CPLUSPLUS
4323 ac_save_CXXFLAGS="$CXXFLAGS"
4324 CXXFLAGS="$CXXFLAGS -fno-exceptions"
4325dnl
9646a322 4326 AC_CACHE_CHECK([for tmpnam], glibcxx_cv_TMPNAM, [dnl
7370b9df
BRF
4327 GCC_TRY_COMPILE_OR_LINK(
4328 [#include <stdio.h>],
4329 [char *tmp = tmpnam(NULL);],
4330 [glibcxx_cv_TMPNAM=yes],
4331 [glibcxx_cv_TMPNAM=no])
4332 ])
4333 if test $glibcxx_cv_TMPNAM = yes; then
4334 AC_DEFINE(_GLIBCXX_USE_TMPNAM, 1, [Define if obsolescent tmpnam is available in <stdio.h>.])
4335 fi
7370b9df
BRF
4336dnl
4337 CXXFLAGS="$ac_save_CXXFLAGS"
4338 AC_LANG_RESTORE
4339])
2a5d011c 4340
d74e340d
TT
4341dnl
4342dnl Check to see if sys/sdt.h exists and that it is suitable for use.
4343dnl Some versions of sdt.h were not compatible with C++11.
4344dnl
4345AC_DEFUN([GLIBCXX_CHECK_SDT_H], [
d74e340d
TT
4346 # Note that this test has to be run with the C language.
4347 # Otherwise, sdt.h will try to include some headers from
4348 # libstdc++ itself.
4349 AC_LANG_SAVE
4350 AC_LANG_C
9646a322
JW
4351 AC_CACHE_CHECK([for suitable sys/sdt.h],
4352 glibcxx_cv_sys_sdt_h, [
d74e340d
TT
4353 # Because we have to run the test in C, we use grep rather
4354 # than the compiler to check for the bug. The bug is that
4355 # were strings without trailing whitespace, causing g++
4356 # to look for operator"". The pattern searches for the fixed
4357 # output.
4358 AC_EGREP_CPP([ \",\" ], [
4359 #include <sys/sdt.h>
4360 int f() { STAP_PROBE(hi, bob); }
4361 ], [glibcxx_cv_sys_sdt_h=yes], [glibcxx_cv_sys_sdt_h=no])
4362 ])
4363 AC_LANG_RESTORE
4364 if test $glibcxx_cv_sys_sdt_h = yes; then
4365 AC_DEFINE(HAVE_SYS_SDT_H, 1,
4366 [Define to 1 if you have a suitable <sys/sdt.h> header file])
4367 fi
d74e340d
TT
4368])
4369
375f837b 4370dnl
34a2b755
JW
4371dnl Control whether the library should define symbols for old and new ABIs.
4372dnl This affects definitions of strings, stringstreams and locale facets.
375f837b 4373dnl
34a2b755 4374dnl --disable-libstdcxx-dual-abi will use old ABI for all types.
375f837b
JW
4375dnl
4376dnl Defines:
34a2b755 4377dnl _GLIBCXX_USE_DUAL_ABI (always defined, either to 1 or 0)
375f837b 4378dnl
34a2b755
JW
4379AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI], [
4380 GLIBCXX_ENABLE(libstdcxx-dual-abi,$1,,[support two versions of std::string])
8dcf3d3c
JW
4381 if test x$enable_symvers = xgnu-versioned-namespace; then
4382 # gnu-versioned-namespace is incompatible with the dual ABI.
4383 enable_libstdcxx_dual_abi="no"
4384 fi
34a2b755
JW
4385 if test x"$enable_libstdcxx_dual_abi" != xyes; then
4386 AC_MSG_NOTICE([dual ABI is disabled])
10d712eb 4387 default_libstdcxx_abi="gcc4-compatible"
375f837b 4388 fi
34a2b755 4389 GLIBCXX_CONDITIONAL(ENABLE_DUAL_ABI, test $enable_libstdcxx_dual_abi = yes)
375f837b
JW
4390])
4391
34a2b755
JW
4392dnl
4393dnl Check to see which ABI should be enabled by default.
4394dnl
10d712eb 4395dnl --with-default-libstdcxx-abi={gcc4-compatible,new}
34a2b755
JW
4396dnl
4397dnl Defines:
4398dnl _GLIBCXX_USE_CXX11_ABI (always defined, either to 1 or 0)
4399dnl
4400AC_DEFUN([GLIBCXX_DEFAULT_ABI], [
4401 if test x$enable_libstdcxx_dual_abi = xyes; then
4402 AC_MSG_CHECKING([for default std::string ABI to use])
4403 AC_ARG_WITH([default-libstdcxx-abi],
4404 AS_HELP_STRING([--with-default-libstdcxx-abi],
4405 [set the std::string ABI to use by default]),
4406 [case "$withval" in
10d712eb
JW
4407 gcc4-compatible) default_libstdcxx_abi="gcc4-compatible" ;;
4408 new|cxx11) default_libstdcxx_abi="new" ;;
4409 c++*|gnu++*) AC_MSG_ERROR([Supported arguments for --with-default-libstdcxx-abi have changed, use "new" or "gcc4-compatible"]) ;;
4410 *) AC_MSG_ERROR([Invalid argument for --with-default-libstdcxx-abi]) ;;
4411 esac
4412 ],
4413 [default_libstdcxx_abi="new"])
34a2b755
JW
4414 AC_MSG_RESULT(${default_libstdcxx_abi})
4415 fi
10d712eb 4416 if test $default_libstdcxx_abi = "new"; then
34a2b755
JW
4417 glibcxx_cxx11_abi=1
4418 glibcxx_cxx98_abi=0
4419 else
4420 glibcxx_cxx11_abi=0
4421 glibcxx_cxx98_abi=1
4422 fi
4423 AC_SUBST(glibcxx_cxx98_abi)
4424 GLIBCXX_CONDITIONAL(ENABLE_CXX11_ABI, test $glibcxx_cxx11_abi = 1)
4425])
4426
0ca7ba9a
JW
4427dnl
4428dnl Check to see whether to build libstdc++fs.a
4429dnl
4430dnl --enable-libstdcxx-filesystem-ts
4431dnl
4432AC_DEFUN([GLIBCXX_ENABLE_FILESYSTEM_TS], [
4433 GLIBCXX_ENABLE(libstdcxx-filesystem-ts,auto,,
4434 [turns on ISO/IEC TS 18822 support],
4435 [permit yes|no|auto])
4436
4437 AC_MSG_CHECKING([whether to build Filesystem TS support])
bf53e6a9
JW
4438 if test x"$ac_cv_header_dirent_h" != x"yes"; then
4439 enable_libstdcxx_filesystem_ts=no
4440 fi
0ca7ba9a
JW
4441 if test x"$enable_libstdcxx_filesystem_ts" = x"auto"; then
4442 case "${target_os}" in
4443 freebsd*|netbsd*|openbsd*|dragonfly*|darwin*)
4444 enable_libstdcxx_filesystem_ts=yes
4445 ;;
6508fa9c 4446 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu | uclinux*)
0ca7ba9a
JW
4447 enable_libstdcxx_filesystem_ts=yes
4448 ;;
b76602dc
SH
4449 rtems*)
4450 enable_libstdcxx_filesystem_ts=yes
4451 ;;
0ca7ba9a 4452 solaris*)
32ff3768 4453 enable_libstdcxx_filesystem_ts=yes
0ca7ba9a 4454 ;;
f0cfae9f
JW
4455 mingw*)
4456 enable_libstdcxx_filesystem_ts=yes
4457 ;;
0ca7ba9a
JW
4458 *)
4459 enable_libstdcxx_filesystem_ts=no
4460 ;;
4461 esac
4462 fi
4463 AC_MSG_RESULT($enable_libstdcxx_filesystem_ts)
4464 GLIBCXX_CONDITIONAL(ENABLE_FILESYSTEM_TS, test $enable_libstdcxx_filesystem_ts = yes)
4465])
4466
4467dnl
90f7636b
JW
4468dnl Check whether the library calls required by the C++17 Filesystem library
4469dnl and the Filesystem TS are present.
7314856c
JW
4470dnl Defines:
4471dnl HAVE_STRUCT_DIRENT_D_TYPE
4472dnl _GLIBCXX_USE_REALPATH
4473dnl _GLIBCXX_USE_UTIMENSAT
4474dnl _GLIBCXX_USE_ST_MTIM
4475dnl _GLIBCXX_USE_FCHMOD
4476dnl _GLIBCXX_USE_FCHMODAT
4477dnl _GLIBCXX_USE_SENDFILE
4478dnl HAVE_LINK
4479dnl HAVE_READLINK
4480dnl HAVE_SYMLINK
0ca7ba9a
JW
4481dnl
4482AC_DEFUN([GLIBCXX_CHECK_FILESYSTEM_DEPS], [dnl
4483dnl
90f7636b
JW
4484 AC_LANG_SAVE
4485 AC_LANG_CPLUSPLUS
4486 ac_save_CXXFLAGS="$CXXFLAGS"
4487 CXXFLAGS="$CXXFLAGS -fno-exceptions"
0b9fc9fe 4488dnl
9646a322 4489 AC_CACHE_CHECK([for struct dirent.d_type], glibcxx_cv_dirent_d_type, [dnl
90f7636b
JW
4490 GCC_TRY_COMPILE_OR_LINK(
4491 [#include <dirent.h>],
4492 [
4493 struct dirent d;
4494 if (sizeof d.d_type) return 0;
4495 ],
4496 [glibcxx_cv_dirent_d_type=yes],
4497 [glibcxx_cv_dirent_d_type=no])
4498 ])
4499 if test $glibcxx_cv_dirent_d_type = yes; then
4500 AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE, 1, [Define to 1 if `d_type' is a member of `struct dirent'.])
4501 fi
0ca7ba9a 4502dnl
9646a322 4503 AC_CACHE_CHECK([for realpath], glibcxx_cv_realpath, [dnl
90f7636b
JW
4504 GCC_TRY_COMPILE_OR_LINK(
4505 [
4506 #include <limits.h>
4507 #include <stdlib.h>
4508 #include <unistd.h>
4509 ],
4510 [
4511 #if _XOPEN_VERSION < 500
4512 #error
4513 #elif _XOPEN_VERSION >= 700 || defined(PATH_MAX)
4514 char *tmp = realpath((const char*)NULL, (char*)NULL);
4515 #else
4516 #error
4517 #endif
4518 ],
4519 [glibcxx_cv_realpath=yes],
4520 [glibcxx_cv_realpath=no])
4521 ])
4522 if test $glibcxx_cv_realpath = yes; then
4523 AC_DEFINE(_GLIBCXX_USE_REALPATH, 1, [Define if usable realpath is available in <stdlib.h>.])
4524 fi
0ca7ba9a 4525dnl
9646a322 4526 AC_CACHE_CHECK([for utimensat], glibcxx_cv_utimensat, [dnl
90f7636b
JW
4527 GCC_TRY_COMPILE_OR_LINK(
4528 [
4529 #include <fcntl.h>
4530 #include <sys/stat.h>
4531 ],
4532 [
4533 struct timespec ts[2] = { { 0, UTIME_OMIT }, { 1, 1 } };
4534 int i = utimensat(AT_FDCWD, "path", ts, 0);
4535 ],
4536 [glibcxx_cv_utimensat=yes],
4537 [glibcxx_cv_utimensat=no])
4538 ])
4539 if test $glibcxx_cv_utimensat = yes; then
4540 AC_DEFINE(_GLIBCXX_USE_UTIMENSAT, 1, [Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and AT_FDCWD in <fcntl.h>.])
4541 fi
de4db54f 4542dnl
9646a322 4543 AC_CACHE_CHECK([for utime], glibcxx_cv_utime, [dnl
90f7636b
JW
4544 GCC_TRY_COMPILE_OR_LINK(
4545 [
4546 #include <utime.h>
4547 ],
4548 [
4549 struct utimbuf t = { 1, 1 };
4550 int i = utime("path", &t);
4551 ],
4552 [glibcxx_cv_utime=yes],
4553 [glibcxx_cv_utime=no])
4554 ])
4555 if test $glibcxx_cv_utime = yes; then
4556 AC_DEFINE(_GLIBCXX_USE_UTIME, 1, [Define if utime is available in <utime.h>.])
4557 fi
de4db54f 4558dnl
9646a322 4559 AC_CACHE_CHECK([for lstat], glibcxx_cv_lstat, [dnl
90f7636b
JW
4560 GCC_TRY_COMPILE_OR_LINK(
4561 [ #include <sys/stat.h> ],
4562 [
4563 struct stat st;
4564 int i = lstat("path", &st);
4565 ],
4566 [glibcxx_cv_lstat=yes],
4567 [glibcxx_cv_lstat=no])
4568 ])
4569 if test $glibcxx_cv_lstat = yes; then
4570 AC_DEFINE(_GLIBCXX_USE_LSTAT, 1, [Define if lstat is available in <sys/stat.h>.])
4571 fi
0ca7ba9a 4572dnl
9646a322
JW
4573 AC_CACHE_CHECK([for struct stat.st_mtim.tv_nsec],
4574 glibcxx_cv_st_mtim, [dnl
90f7636b
JW
4575 GCC_TRY_COMPILE_OR_LINK(
4576 [ #include <sys/stat.h> ],
4577 [
4578 struct stat st;
4579 return st.st_mtim.tv_nsec;
4580 ],
4581 [glibcxx_cv_st_mtim=yes],
4582 [glibcxx_cv_st_mtim=no])
4583 ])
4584 if test $glibcxx_cv_st_mtim = yes; then
4585 AC_DEFINE(_GLIBCXX_USE_ST_MTIM, 1, [Define if struct stat has timespec members.])
4586 fi
a0c4531c 4587dnl
9646a322
JW
4588 AC_CACHE_CHECK([for fchmod],
4589 glibcxx_cv_fchmod, [dnl
90f7636b
JW
4590 GCC_TRY_COMPILE_OR_LINK(
4591 [#include <sys/stat.h>],
4592 [fchmod(1, S_IWUSR);],
4593 [glibcxx_cv_fchmod=yes],
4594 [glibcxx_cv_fchmod=no])
4595 ])
4596 if test $glibcxx_cv_fchmod = yes; then
4597 AC_DEFINE(_GLIBCXX_USE_FCHMOD, 1, [Define if fchmod is available in <sys/stat.h>.])
4598 fi
bf53e6a9 4599dnl
9646a322
JW
4600 AC_CACHE_CHECK([for fchmodat],
4601 glibcxx_cv_fchmodat, [dnl
90f7636b
JW
4602 GCC_TRY_COMPILE_OR_LINK(
4603 [
4604 #include <fcntl.h>
4605 #include <sys/stat.h>
4606 ],
4607 [fchmodat(AT_FDCWD, "", 0, AT_SYMLINK_NOFOLLOW);],
4608 [glibcxx_cv_fchmodat=yes],
4609 [glibcxx_cv_fchmodat=no])
4610 ])
4611 if test $glibcxx_cv_fchmodat = yes; then
4612 AC_DEFINE(_GLIBCXX_USE_FCHMODAT, 1, [Define if fchmodat is available in <sys/stat.h>.])
4613 fi
a0c4531c 4614dnl
9646a322
JW
4615 AC_CACHE_CHECK([for sendfile that can copy files],
4616 glibcxx_cv_sendfile, [dnl
90f7636b
JW
4617 case "${target_os}" in
4618 gnu* | linux* | solaris* | uclinux*)
4619 GCC_TRY_COMPILE_OR_LINK(
4620 [#include <sys/sendfile.h>],
4621 [sendfile(1, 2, (off_t*)0, sizeof 1);],
4622 [glibcxx_cv_sendfile=yes],
4623 [glibcxx_cv_sendfile=no])
4624 ;;
4625 *)
4626 glibcxx_cv_sendfile=no
4627 ;;
4628 esac
4629 ])
4630 if test $glibcxx_cv_sendfile = yes; then
4631 AC_DEFINE(_GLIBCXX_USE_SENDFILE, 1, [Define if sendfile is available in <sys/sendfile.h>.])
4632 fi
0ca7ba9a 4633dnl
9646a322
JW
4634 AC_CACHE_CHECK([for link],
4635 glibcxx_cv_link, [dnl
90f7636b
JW
4636 GCC_TRY_COMPILE_OR_LINK(
4637 [#include <unistd.h>],
4638 [link("", "");],
4639 [glibcxx_cv_link=yes],
4640 [glibcxx_cv_link=no])
4641 ])
4642 if test $glibcxx_cv_link = yes; then
4643 AC_DEFINE(HAVE_LINK, 1, [Define if link is available in <unistd.h>.])
4644 fi
7314856c 4645dnl
9646a322
JW
4646 AC_CACHE_CHECK([for readlink],
4647 glibcxx_cv_readlink, [dnl
90f7636b
JW
4648 GCC_TRY_COMPILE_OR_LINK(
4649 [#include <unistd.h>],
4650 [char buf[32]; readlink("", buf, sizeof(buf));],
4651 [glibcxx_cv_readlink=yes],
4652 [glibcxx_cv_readlink=no])
4653 ])
4654 if test $glibcxx_cv_readlink = yes; then
4655 AC_DEFINE(HAVE_READLINK, 1, [Define if readlink is available in <unistd.h>.])
4656 fi
cf4b581f 4657dnl
9646a322
JW
4658 AC_CACHE_CHECK([for symlink],
4659 glibcxx_cv_symlink, [dnl
90f7636b
JW
4660 GCC_TRY_COMPILE_OR_LINK(
4661 [#include <unistd.h>],
4662 [symlink("", "");],
4663 [glibcxx_cv_symlink=yes],
4664 [glibcxx_cv_symlink=no])
4665 ])
4666 if test $glibcxx_cv_symlink = yes; then
4667 AC_DEFINE(HAVE_SYMLINK, 1, [Define if symlink is available in <unistd.h>.])
4668 fi
7314856c 4669dnl
9646a322
JW
4670 AC_CACHE_CHECK([for truncate],
4671 glibcxx_cv_truncate, [dnl
90f7636b
JW
4672 GCC_TRY_COMPILE_OR_LINK(
4673 [#include <unistd.h>],
4674 [truncate("", 99);],
4675 [glibcxx_cv_truncate=yes],
4676 [glibcxx_cv_truncate=no])
4677 ])
4678 if test $glibcxx_cv_truncate = yes; then
4679 AC_DEFINE(HAVE_TRUNCATE, 1, [Define if truncate is available in <unistd.h>.])
7314856c 4680 fi
90f7636b
JW
4681dnl
4682 CXXFLAGS="$ac_save_CXXFLAGS"
4683 AC_LANG_RESTORE
0ca7ba9a 4684])
34a2b755 4685
a04d5fc9
TR
4686dnl
4687dnl Check how size_t is mangled. Copied from libitm.
4688dnl
4689AC_DEFUN([GLIBCXX_CHECK_SIZE_T_MANGLING], [
4690 AC_CACHE_CHECK([how size_t is mangled],
4691 glibcxx_cv_size_t_mangling, [
4692 AC_TRY_COMPILE([], [extern __SIZE_TYPE__ x; extern unsigned long x;],
4693 [glibcxx_cv_size_t_mangling=m], [
4694 AC_TRY_COMPILE([], [extern __SIZE_TYPE__ x; extern unsigned int x;],
4695 [glibcxx_cv_size_t_mangling=j], [
4696 AC_TRY_COMPILE([],
4697 [extern __SIZE_TYPE__ x; extern unsigned long long x;],
4698 [glibcxx_cv_size_t_mangling=y], [
4699 AC_TRY_COMPILE([],
4700 [extern __SIZE_TYPE__ x; extern unsigned short x;],
f14d2c52
JS
4701 [glibcxx_cv_size_t_mangling=t], [
4702 AC_TRY_COMPILE([],
4703 [extern __SIZE_TYPE__ x; extern __int20 unsigned x;],
4704 [glibcxx_cv_size_t_mangling=u6uint20],
4705 [glibcxx_cv_size_t_mangling=x])
4706 ])
a04d5fc9
TR
4707 ])
4708 ])
4709 ])
4710 ])
4711 if test $glibcxx_cv_size_t_mangling = x; then
4712 AC_MSG_ERROR([Unknown underlying type for size_t])
4713 fi
4714 AC_DEFINE_UNQUOTED(_GLIBCXX_MANGLE_SIZE_T, [$glibcxx_cv_size_t_mangling],
4715 [Define to the letter to which size_t is mangled.])
4716])
4717
ed3cb497
PN
4718dnl
4719dnl Determine whether std::exception_ptr symbols should be exported with
4720dnl the symbol versions from GCC 4.6.0 or GCC 7.1.0, depending on which
4721dnl release first added support for std::exception_ptr. Originally it was
4722dnl only supported for targets with always-lock-free atomics for int, but
4723dnl since GCC 7.1 it is supported for all targets.
4724dnl
4725AC_DEFUN([GLIBCXX_CHECK_EXCEPTION_PTR_SYMVER], [
4726 if test $enable_symvers != no; then
4727 AC_MSG_CHECKING([for first version to support std::exception_ptr])
4728 case ${target} in
4729 aarch64-*-* | alpha-*-* | hppa*-*-* | i?86-*-* | x86_64-*-* | \
4730 m68k-*-* | powerpc*-*-* | s390*-*-* | *-*-solaris* )
4731 ac_exception_ptr_since_gcc46=yes
4732 ;;
4733 *)
4734 # If the value of this macro changes then we will need to hardcode
4735 # yes/no here for additional targets based on the original value.
4736 AC_TRY_COMPILE([], [
4737 #if __GCC_ATOMIC_INT_LOCK_FREE <= 1
4738 # error atomic int not always lock free
4739 #endif
4740 ],
4741 [ac_exception_ptr_since_gcc46=yes],
4742 [ac_exception_ptr_since_gcc46=no])
4743 ;;
4744 esac
4745 if test x"$ac_exception_ptr_since_gcc46" = x"yes" ; then
4746 AC_DEFINE(HAVE_EXCEPTION_PTR_SINCE_GCC46, 1,
4747 [Define to 1 if GCC 4.6 supported std::exception_ptr for the target])
4748 AC_MSG_RESULT([4.6.0])
4749 else
4750 AC_MSG_RESULT([7.1.0])
4751 fi
4752 fi
4753])
4754
3439657b
JW
4755dnl
4756dnl Check whether getentropy is present in <unistd.h>.
4757dnl
4758AC_DEFUN([GLIBCXX_CHECK_GETENTROPY], [
4759
4760 AC_LANG_SAVE
4761 AC_LANG_CPLUSPLUS
9646a322 4762 AC_CACHE_CHECK([for getentropy], glibcxx_cv_getentropy, [
60f761c7 4763 GCC_TRY_COMPILE_OR_LINK(
3439657b
JW
4764 [#include <unistd.h>],
4765 [unsigned i;
4766 ::getentropy(&i, sizeof(i));],
4767 [glibcxx_cv_getentropy=yes], [glibcxx_cv_getentropy=no])
4768 ])
4769
4770 if test $glibcxx_cv_getentropy = yes; then
4771 AC_DEFINE(HAVE_GETENTROPY, 1, [Define if getentropy is available in <unistd.h>.])
4772 fi
3439657b
JW
4773 AC_LANG_RESTORE
4774])
4775
4776dnl
4777dnl Check whether arc4random is present in <stdlib.h>.
4778dnl
4779AC_DEFUN([GLIBCXX_CHECK_ARC4RANDOM], [
4780
4781 AC_LANG_SAVE
4782 AC_LANG_CPLUSPLUS
9646a322 4783 AC_CACHE_CHECK([for arc4random], glibcxx_cv_arc4random, [
60f761c7 4784 GCC_TRY_COMPILE_OR_LINK(
3439657b
JW
4785 [#include <stdlib.h>],
4786 [unsigned i = ::arc4random();],
4787 [glibcxx_cv_arc4random=yes], [glibcxx_cv_arc4random=no])
4788 ])
4789
4790 if test $glibcxx_cv_arc4random = yes; then
4791 AC_DEFINE(HAVE_ARC4RANDOM, 1, [Define if arc4random is available in <stdlib.h>.])
4792 fi
3439657b
JW
4793 AC_LANG_RESTORE
4794])
4795
4796
cddfb1c7 4797# Macros from the top-level gcc directory.
c18dc5cc 4798m4_include([../config/gc++filt.m4])
cddfb1c7 4799m4_include([../config/tls.m4])
1183dc2c 4800m4_include([../config/gthr.m4])
36101de9 4801m4_include([../config/cet.m4])