Debian Codegraph @

libstdc++-v3/acinclude.m4

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