14fee23f9Smrgdnl 24fee23f9Smrgdnl GLIBCXX_CONDITIONAL (NAME, SHELL-TEST) 34fee23f9Smrgdnl 44fee23f9Smrgdnl Exactly like AM_CONDITIONAL, but delays evaluation of the test until the 54fee23f9Smrgdnl end of configure. This lets tested variables be reassigned, and the 64fee23f9Smrgdnl conditional will depend on the final state of the variable. For a simple 74fee23f9Smrgdnl example of why this is needed, see GLIBCXX_ENABLE_HOSTED. 84fee23f9Smrgdnl 94fee23f9Smrgm4_define([_m4_divert(glibcxx_diversion)], 8000)dnl 104fee23f9SmrgAC_DEFUN([GLIBCXX_CONDITIONAL], [dnl 114fee23f9Smrg m4_divert_text([glibcxx_diversion],dnl 124fee23f9Smrg AM_CONDITIONAL([$1],[$2]) 134fee23f9Smrg )dnl 144fee23f9Smrg])dnl 154fee23f9SmrgAC_DEFUN([GLIBCXX_EVALUATE_CONDITIONALS], [m4_undivert([glibcxx_diversion])])dnl 164fee23f9Smrg 174fee23f9Smrg 184fee23f9Smrgdnl 194fee23f9Smrgdnl Check to see what architecture and operating system we are compiling 204fee23f9Smrgdnl for. Also, if architecture- or OS-specific flags are required for 214fee23f9Smrgdnl compilation, pick them up here. 224fee23f9Smrgdnl 234fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_HOST], [ 244fee23f9Smrg . $glibcxx_srcdir/configure.host 254fee23f9Smrg AC_MSG_NOTICE([CPU config directory is $cpu_include_dir]) 264fee23f9Smrg AC_MSG_NOTICE([OS config directory is $os_include_dir]) 274fee23f9Smrg]) 284fee23f9Smrg 294fee23f9Smrgdnl 304fee23f9Smrgdnl Initialize the rest of the library configury. At this point we have 314fee23f9Smrgdnl variables like $host. 324fee23f9Smrgdnl 334fee23f9Smrgdnl Sets: 344fee23f9Smrgdnl SUBDIRS 354fee23f9Smrgdnl Substs: 364fee23f9Smrgdnl glibcxx_builddir (absolute path) 374fee23f9Smrgdnl glibcxx_srcdir (absolute path) 3848fb7bfaSmrgdnl toplevel_builddir (absolute path) 394fee23f9Smrgdnl toplevel_srcdir (absolute path) 404fee23f9Smrgdnl with_cross_host 414fee23f9Smrgdnl with_newlib 424fee23f9Smrgdnl with_target_subdir 434fee23f9Smrgdnl plus 444fee23f9Smrgdnl - the variables in GLIBCXX_CHECK_HOST / configure.host 454fee23f9Smrgdnl - default settings for all AM_CONFITIONAL test variables 464fee23f9Smrgdnl - lots of tools, like CC and CXX 474fee23f9Smrgdnl 484fee23f9SmrgAC_DEFUN([GLIBCXX_CONFIGURE], [ 494fee23f9Smrg # Keep these sync'd with the list in Makefile.am. The first provides an 504fee23f9Smrg # expandable list at autoconf time; the second provides an expandable list 514fee23f9Smrg # (i.e., shell variable) at configure time. 52e9e6e0f6Smrg m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 src/c++17 src/c++20 src/filesystem src/libbacktrace doc python]) 534fee23f9Smrg SUBDIRS='glibcxx_SUBDIRS' 544fee23f9Smrg 554fee23f9Smrg # These need to be absolute paths, yet at the same time need to 564fee23f9Smrg # canonicalize only relative paths, because then amd will not unmount 574fee23f9Smrg # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd. 584fee23f9Smrg glibcxx_builddir=`${PWDCMD-pwd}` 594fee23f9Smrg case $srcdir in 604fee23f9Smrg [\\/$]* | ?:[\\/]*) glibcxx_srcdir=${srcdir} ;; 614fee23f9Smrg *) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;; 624fee23f9Smrg esac 6348fb7bfaSmrg toplevel_builddir=${glibcxx_builddir}/.. 644fee23f9Smrg toplevel_srcdir=${glibcxx_srcdir}/.. 654fee23f9Smrg AC_SUBST(glibcxx_builddir) 664fee23f9Smrg AC_SUBST(glibcxx_srcdir) 6748fb7bfaSmrg AC_SUBST(toplevel_builddir) 684fee23f9Smrg AC_SUBST(toplevel_srcdir) 694fee23f9Smrg 704fee23f9Smrg # We use these options to decide which functions to include. They are 714fee23f9Smrg # set from the top level. 724fee23f9Smrg AC_ARG_WITH([target-subdir], 734fee23f9Smrg AC_HELP_STRING([--with-target-subdir=SUBDIR], 744fee23f9Smrg [configuring in a subdirectory])) 754fee23f9Smrg 764fee23f9Smrg AC_ARG_WITH([cross-host], 774fee23f9Smrg AC_HELP_STRING([--with-cross-host=HOST], 784fee23f9Smrg [configuring with a cross compiler])) 794fee23f9Smrg 804fee23f9Smrg AC_ARG_WITH([newlib], 814fee23f9Smrg AC_HELP_STRING([--with-newlib], 824fee23f9Smrg [assume newlib as a system C library])) 834fee23f9Smrg 844fee23f9Smrg # Will set LN_S to either 'ln -s', 'ln', or 'cp -p' (if linking isn't 854fee23f9Smrg # available). Uncomment the next line to force a particular method. 864fee23f9Smrg AC_PROG_LN_S 874fee23f9Smrg #LN_S='cp -p' 884fee23f9Smrg 894fee23f9Smrg AC_CHECK_TOOL(AS, as) 904fee23f9Smrg AC_CHECK_TOOL(AR, ar) 914fee23f9Smrg AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error) 924fee23f9Smrg 934fee23f9Smrg AM_MAINTAINER_MODE 944fee23f9Smrg 954fee23f9Smrg # Set up safe default values for all subsequent AM_CONDITIONAL tests 964fee23f9Smrg # which are themselves conditionally expanded. 974fee23f9Smrg ## (Right now, this only matters for enable_wchar_t, but nothing prevents 984fee23f9Smrg ## other macros from doing the same. This should be automated.) -pme 994fee23f9Smrg 10048fb7bfaSmrg # Check for C library flavor since GNU/Linux platforms use different 10148fb7bfaSmrg # configuration directories depending on the C library in use. 1024fee23f9Smrg AC_EGREP_CPP([_using_uclibc], [ 1034fee23f9Smrg #include <stdio.h> 1044fee23f9Smrg #if __UCLIBC__ 1054fee23f9Smrg _using_uclibc 1064fee23f9Smrg #endif 1074fee23f9Smrg ], uclibc=yes, uclibc=no) 1084fee23f9Smrg 10948fb7bfaSmrg AC_EGREP_CPP([_using_bionic], [ 11048fb7bfaSmrg #include <stdio.h> 11148fb7bfaSmrg #if __BIONIC__ 11248fb7bfaSmrg _using_bionic 11348fb7bfaSmrg #endif 11448fb7bfaSmrg ], bionic=yes, bionic=no) 11548fb7bfaSmrg 1164fee23f9Smrg # Find platform-specific directories containing configuration info. 1174fee23f9Smrg # Also possibly modify flags used elsewhere, as needed by the platform. 1184fee23f9Smrg GLIBCXX_CHECK_HOST 1194fee23f9Smrg]) 1204fee23f9Smrg 1214fee23f9Smrg 1224fee23f9Smrgdnl 1234fee23f9Smrgdnl Tests for newer compiler features, or features that are present in newer 1244fee23f9Smrgdnl compiler versions but not older compiler versions still in use, should 1254fee23f9Smrgdnl be placed here. 1264fee23f9Smrgdnl 1274fee23f9Smrgdnl Defines: 1284fee23f9Smrgdnl WERROR='-Werror' if requested and possible; g++'s that lack the 1294fee23f9Smrgdnl new inlining code or the new system_header pragma will die on -Werror. 1304fee23f9Smrgdnl Leave it out by default and use maint-mode to use it. 1314fee23f9Smrgdnl SECTION_FLAGS='-ffunction-sections -fdata-sections' if 1324fee23f9Smrgdnl compiler supports it and the user has not requested debug mode. 1334fee23f9Smrgdnl 1344fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_COMPILER_FEATURES], [ 1354fee23f9Smrg # All these tests are for C++; save the language and the compiler flags. 1364fee23f9Smrg # The CXXFLAGS thing is suspicious, but based on similar bits previously 1374fee23f9Smrg # found in GLIBCXX_CONFIGURE. 1384fee23f9Smrg AC_LANG_SAVE 1394fee23f9Smrg AC_LANG_CPLUSPLUS 1404fee23f9Smrg ac_test_CXXFLAGS="${CXXFLAGS+set}" 1414fee23f9Smrg ac_save_CXXFLAGS="$CXXFLAGS" 1424fee23f9Smrg 1434fee23f9Smrg # Check for -ffunction-sections -fdata-sections 1444fee23f9Smrg AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections]) 1454fee23f9Smrg CXXFLAGS='-g -Werror -ffunction-sections -fdata-sections' 1464fee23f9Smrg AC_TRY_COMPILE([int foo; void bar() { };],, [ac_fdsections=yes], [ac_fdsections=no]) 1474fee23f9Smrg if test "$ac_test_CXXFLAGS" = set; then 1484fee23f9Smrg CXXFLAGS="$ac_save_CXXFLAGS" 1494fee23f9Smrg else 1504fee23f9Smrg # this is the suspicious part 1514fee23f9Smrg CXXFLAGS='' 1524fee23f9Smrg fi 1534fee23f9Smrg if test x"$ac_fdsections" = x"yes"; then 1544fee23f9Smrg SECTION_FLAGS='-ffunction-sections -fdata-sections' 1554fee23f9Smrg fi 1564fee23f9Smrg AC_MSG_RESULT($ac_fdsections) 1574fee23f9Smrg 1584fee23f9Smrg AC_LANG_RESTORE 1594fee23f9Smrg AC_SUBST(SECTION_FLAGS) 1604fee23f9Smrg]) 1614fee23f9Smrg 1624fee23f9Smrg 1634fee23f9Smrgdnl 1644fee23f9Smrgdnl If GNU ld is in use, check to see if tricky linker opts can be used. If 1654fee23f9Smrgdnl the native linker is in use, all variables will be defined to something 1664fee23f9Smrgdnl safe (like an empty string). 1674fee23f9Smrgdnl 1684fee23f9Smrgdnl Defines: 1694fee23f9Smrgdnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible 1704fee23f9Smrgdnl OPT_LDFLAGS='-Wl,-O1' and '-z,relro' if possible 1714fee23f9Smrgdnl LD (as a side effect of testing) 1724fee23f9Smrgdnl Sets: 1734fee23f9Smrgdnl with_gnu_ld 1744fee23f9Smrgdnl glibcxx_ld_is_gold (set to "no" or "yes") 175e9e6e0f6Smrgdnl glibcxx_ld_is_mold (set to "no" or "yes") 1764fee23f9Smrgdnl glibcxx_gnu_ld_version (possibly) 1774fee23f9Smrgdnl 1784fee23f9Smrgdnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will 1794fee23f9Smrgdnl set glibcxx_gnu_ld_version to 12345. Zeros cause problems. 1804fee23f9Smrgdnl 1814fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [ 1824fee23f9Smrg # If we're not using GNU ld, then there's no point in even trying these 1834fee23f9Smrg # tests. Check for that first. We should have already tested for gld 1844fee23f9Smrg # by now (in libtool), but require it now just to be safe... 1854fee23f9Smrg test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS='' 1864fee23f9Smrg test -z "$OPT_LDFLAGS" && OPT_LDFLAGS='' 1874fee23f9Smrg AC_REQUIRE([AC_PROG_LD]) 1884fee23f9Smrg AC_REQUIRE([AC_PROG_AWK]) 1894fee23f9Smrg 1904fee23f9Smrg # The name set by libtool depends on the version of libtool. Shame on us 1914fee23f9Smrg # for depending on an impl detail, but c'est la vie. Older versions used 1924fee23f9Smrg # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on 1934fee23f9Smrg # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually 1944fee23f9Smrg # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't 1954fee23f9Smrg # set (hence we're using an older libtool), then set it. 1964fee23f9Smrg if test x${with_gnu_ld+set} != xset; then 1974fee23f9Smrg if test x${ac_cv_prog_gnu_ld+set} != xset; then 1984fee23f9Smrg # We got through "ac_require(ac_prog_ld)" and still not set? Huh? 1994fee23f9Smrg with_gnu_ld=no 2004fee23f9Smrg else 2014fee23f9Smrg with_gnu_ld=$ac_cv_prog_gnu_ld 2024fee23f9Smrg fi 2034fee23f9Smrg fi 2044fee23f9Smrg 2054fee23f9Smrg # Start by getting the version number. I think the libtool test already 2064fee23f9Smrg # does some of this, but throws away the result. 2074fee23f9Smrg glibcxx_ld_is_gold=no 208e9e6e0f6Smrg glibcxx_ld_is_mold=no 2094fee23f9Smrg if test x"$with_gnu_ld" = x"yes"; then 2104fee23f9Smrg AC_MSG_CHECKING([for ld version]) 2114fee23f9Smrg changequote(,) 2124fee23f9Smrg if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then 2134fee23f9Smrg glibcxx_ld_is_gold=yes 214e9e6e0f6Smrg elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then 215e9e6e0f6Smrg glibcxx_ld_is_mold=yes 2164fee23f9Smrg fi 2174fee23f9Smrg ldver=`$LD --version 2>/dev/null | 21843265c03Smrg sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'` 2194fee23f9Smrg changequote([,]) 2204fee23f9Smrg glibcxx_gnu_ld_version=`echo $ldver | \ 2214fee23f9Smrg $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'` 2224fee23f9Smrg AC_MSG_RESULT($glibcxx_gnu_ld_version) 2234fee23f9Smrg fi 2244fee23f9Smrg 2254fee23f9Smrg # Set --gc-sections. 2264fee23f9Smrg glibcxx_have_gc_sections=no 227e9e6e0f6Smrg if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then 2284fee23f9Smrg if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then 2294fee23f9Smrg glibcxx_have_gc_sections=yes 2304fee23f9Smrg fi 2314fee23f9Smrg else 2324fee23f9Smrg glibcxx_gcsections_min_ld=21602 2334fee23f9Smrg if test x"$with_gnu_ld" = x"yes" && 2344fee23f9Smrg test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then 2354fee23f9Smrg glibcxx_have_gc_sections=yes 2364fee23f9Smrg fi 2374fee23f9Smrg fi 2384fee23f9Smrg if test "$glibcxx_have_gc_sections" = "yes"; then 2394fee23f9Smrg # Sufficiently young GNU ld it is! Joy and bunny rabbits! 2404fee23f9Smrg # NB: This flag only works reliably after 2.16.1. Configure tests 2414fee23f9Smrg # for this are difficult, so hard wire a value that should work. 2424fee23f9Smrg 2434fee23f9Smrg ac_test_CFLAGS="${CFLAGS+set}" 2444fee23f9Smrg ac_save_CFLAGS="$CFLAGS" 2454fee23f9Smrg CFLAGS='-Wl,--gc-sections' 2464fee23f9Smrg 2474fee23f9Smrg # Check for -Wl,--gc-sections 2484fee23f9Smrg AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections]) 2494fee23f9Smrg AC_TRY_LINK([ int one(void) { return 1; } 2504fee23f9Smrg int two(void) { return 2; } 2514fee23f9Smrg ], [ two(); ] , [ac_gcsections=yes], [ac_gcsections=no]) 2524fee23f9Smrg if test "$ac_gcsections" = "yes"; then 2534fee23f9Smrg rm -f conftest.c 2544fee23f9Smrg touch conftest.c 2554fee23f9Smrg if $CC -c conftest.c; then 2564fee23f9Smrg if $LD --gc-sections -o conftest conftest.o 2>&1 | \ 2574fee23f9Smrg grep "Warning: gc-sections option ignored" > /dev/null; then 2584fee23f9Smrg ac_gcsections=no 2594fee23f9Smrg fi 2604fee23f9Smrg fi 2614fee23f9Smrg rm -f conftest.c conftest.o conftest 2624fee23f9Smrg fi 2634fee23f9Smrg if test "$ac_gcsections" = "yes"; then 2644fee23f9Smrg SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS" 2654fee23f9Smrg fi 2664fee23f9Smrg AC_MSG_RESULT($ac_gcsections) 2674fee23f9Smrg 2684fee23f9Smrg if test "$ac_test_CFLAGS" = set; then 2694fee23f9Smrg CFLAGS="$ac_save_CFLAGS" 2704fee23f9Smrg else 2714fee23f9Smrg # this is the suspicious part 2724fee23f9Smrg CFLAGS='' 2734fee23f9Smrg fi 2744fee23f9Smrg fi 2754fee23f9Smrg 2764fee23f9Smrg # Set -z,relro. 2774fee23f9Smrg # Note this is only for shared objects. 2784fee23f9Smrg ac_ld_relro=no 2794fee23f9Smrg if test x"$with_gnu_ld" = x"yes"; then 280e9e6e0f6Smrg # cygwin and mingw uses PE, which has no ELF relro support, 281e9e6e0f6Smrg # multi target ld may confuse configure machinery 282e9e6e0f6Smrg case "$host" in 283e9e6e0f6Smrg *-*-cygwin*) 284e9e6e0f6Smrg ;; 285e9e6e0f6Smrg *-*-mingw*) 286e9e6e0f6Smrg ;; 287e9e6e0f6Smrg *) 2884fee23f9Smrg AC_MSG_CHECKING([for ld that supports -Wl,-z,relro]) 2894fee23f9Smrg cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"` 2904fee23f9Smrg if test -n "$cxx_z_relo"; then 2914fee23f9Smrg OPT_LDFLAGS="-Wl,-z,relro" 2924fee23f9Smrg ac_ld_relro=yes 2934fee23f9Smrg fi 2944fee23f9Smrg AC_MSG_RESULT($ac_ld_relro) 295e9e6e0f6Smrg esac 2964fee23f9Smrg fi 2974fee23f9Smrg 2984fee23f9Smrg # Set linker optimization flags. 2994fee23f9Smrg if test x"$with_gnu_ld" = x"yes"; then 3004fee23f9Smrg OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS" 3014fee23f9Smrg fi 3024fee23f9Smrg 3034fee23f9Smrg AC_SUBST(SECTION_LDFLAGS) 3044fee23f9Smrg AC_SUBST(OPT_LDFLAGS) 3054fee23f9Smrg]) 3064fee23f9Smrg 3074fee23f9Smrg 3084fee23f9Smrgdnl 3094fee23f9Smrgdnl Check for headers for, and arguments to, the setrlimit() function. 3104fee23f9Smrgdnl Used only in testsuite_hooks.h. Called from GLIBCXX_CONFIGURE_TESTSUITE. 3114fee23f9Smrgdnl 3124fee23f9Smrgdnl Defines: 3134fee23f9Smrgdnl _GLIBCXX_RES_LIMITS if we can set artificial resource limits 3144fee23f9Smrgdnl various HAVE_LIMIT_* for individual limit names 3154fee23f9Smrgdnl 3164fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_SETRLIMIT_ancilliary], [ 3174fee23f9Smrg AC_MSG_CHECKING([for RLIMIT_$1]) 3184fee23f9Smrg AC_TRY_COMPILE( 3194fee23f9Smrg [#include <unistd.h> 3204fee23f9Smrg #include <sys/time.h> 3214fee23f9Smrg #include <sys/resource.h> 3224fee23f9Smrg ], 3234fee23f9Smrg [ int f = RLIMIT_$1 ; ], 3244fee23f9Smrg [glibcxx_mresult=1], [glibcxx_mresult=0]) 3254fee23f9Smrg AC_DEFINE_UNQUOTED(HAVE_LIMIT_$1, $glibcxx_mresult, 3264fee23f9Smrg [Only used in build directory testsuite_hooks.h.]) 3274fee23f9Smrg if test $glibcxx_mresult = 1 ; then res=yes ; else res=no ; fi 3284fee23f9Smrg AC_MSG_RESULT($res) 3294fee23f9Smrg]) 3304fee23f9Smrg 3314fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_SETRLIMIT], [ 33243265c03Smrg AC_LANG_SAVE 33343265c03Smrg AC_LANG_CPLUSPLUS 3344fee23f9Smrg setrlimit_have_headers=yes 3354fee23f9Smrg AC_CHECK_HEADERS(unistd.h sys/time.h sys/resource.h, 3364fee23f9Smrg [], 3374fee23f9Smrg [setrlimit_have_headers=no]) 3384fee23f9Smrg # If don't have the headers, then we can't run the tests now, and we 3394fee23f9Smrg # won't be seeing any of these during testsuite compilation. 3404fee23f9Smrg if test $setrlimit_have_headers = yes; then 3414fee23f9Smrg # Can't do these in a loop, else the resulting syntax is wrong. 3424fee23f9Smrg GLIBCXX_CHECK_SETRLIMIT_ancilliary(DATA) 3434fee23f9Smrg GLIBCXX_CHECK_SETRLIMIT_ancilliary(RSS) 3444fee23f9Smrg GLIBCXX_CHECK_SETRLIMIT_ancilliary(VMEM) 3454fee23f9Smrg GLIBCXX_CHECK_SETRLIMIT_ancilliary(AS) 3464fee23f9Smrg GLIBCXX_CHECK_SETRLIMIT_ancilliary(FSIZE) 3474fee23f9Smrg 3484fee23f9Smrg # Check for rlimit, setrlimit. 349e9e6e0f6Smrg AC_CACHE_CHECK([for testsuite resource limits support], 350e9e6e0f6Smrg glibcxx_cv_setrlimit, [ 3514fee23f9Smrg AC_TRY_COMPILE( 3524fee23f9Smrg [#include <unistd.h> 3534fee23f9Smrg #include <sys/time.h> 3544fee23f9Smrg #include <sys/resource.h> 3554fee23f9Smrg ], 3564fee23f9Smrg [struct rlimit r; 3574fee23f9Smrg setrlimit(0, &r);], 3584fee23f9Smrg [glibcxx_cv_setrlimit=yes], [glibcxx_cv_setrlimit=no]) 3594fee23f9Smrg ]) 3604fee23f9Smrg 361e9e6e0f6Smrg if test $glibcxx_cv_setrlimit = yes; then 3624fee23f9Smrg AC_DEFINE(_GLIBCXX_RES_LIMITS, 1, 3634fee23f9Smrg [Define if using setrlimit to set resource limits during 3644fee23f9Smrg "make check"]) 365e9e6e0f6Smrg fi 3664fee23f9Smrg fi 36743265c03Smrg AC_LANG_RESTORE 3684fee23f9Smrg]) 3694fee23f9Smrg 3704fee23f9Smrg 3714fee23f9Smrgdnl 3724fee23f9Smrgdnl Check whether S_ISREG (Posix) or S_IFREG is available in <sys/stat.h>. 3734fee23f9Smrgdnl Define HAVE_S_ISREG / HAVE_S_IFREG appropriately. 3744fee23f9Smrgdnl 3754fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_S_ISREG_OR_S_IFREG], [ 3764fee23f9Smrg 3774fee23f9Smrg AC_LANG_SAVE 3784fee23f9Smrg AC_LANG_CPLUSPLUS 3794fee23f9Smrg ac_save_CXXFLAGS="$CXXFLAGS" 3804fee23f9Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 3814fee23f9Smrg 3824fee23f9Smrg AC_MSG_CHECKING([for S_ISREG or S_IFREG]) 3834fee23f9Smrg AC_CACHE_VAL(glibcxx_cv_S_ISREG, [ 3844fee23f9Smrg GCC_TRY_COMPILE_OR_LINK( 3854fee23f9Smrg [#include <sys/stat.h>], 3864fee23f9Smrg [struct stat buffer; 3874fee23f9Smrg fstat(0, &buffer); 3884fee23f9Smrg S_ISREG(buffer.st_mode);], 3894fee23f9Smrg [glibcxx_cv_S_ISREG=yes], 3904fee23f9Smrg [glibcxx_cv_S_ISREG=no]) 3914fee23f9Smrg ]) 3924fee23f9Smrg AC_CACHE_VAL(glibcxx_cv_S_IFREG, [ 3934fee23f9Smrg GCC_TRY_COMPILE_OR_LINK( 3944fee23f9Smrg [#include <sys/stat.h>], 3954fee23f9Smrg [struct stat buffer; 3964fee23f9Smrg fstat(0, &buffer); 3974fee23f9Smrg S_IFREG & buffer.st_mode;], 3984fee23f9Smrg [glibcxx_cv_S_IFREG=yes], 3994fee23f9Smrg [glibcxx_cv_S_IFREG=no]) 4004fee23f9Smrg ]) 4014fee23f9Smrg res=no 4024fee23f9Smrg if test $glibcxx_cv_S_ISREG = yes; then 4034fee23f9Smrg AC_DEFINE(HAVE_S_ISREG, 1, 404a41324a9Smrg [Define if S_ISREG is available in <sys/stat.h>.]) 4054fee23f9Smrg res=S_ISREG 4064fee23f9Smrg elif test $glibcxx_cv_S_IFREG = yes; then 4074fee23f9Smrg AC_DEFINE(HAVE_S_IFREG, 1, 4084fee23f9Smrg [Define if S_IFREG is available in <sys/stat.h>.]) 4094fee23f9Smrg res=S_IFREG 4104fee23f9Smrg fi 4114fee23f9Smrg AC_MSG_RESULT($res) 4124fee23f9Smrg 4134fee23f9Smrg CXXFLAGS="$ac_save_CXXFLAGS" 4144fee23f9Smrg AC_LANG_RESTORE 4154fee23f9Smrg]) 4164fee23f9Smrg 4174fee23f9Smrg 4184fee23f9Smrgdnl 4194fee23f9Smrgdnl Check whether poll is available in <poll.h>, and define HAVE_POLL. 4204fee23f9Smrgdnl 4214fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_POLL], [ 4224fee23f9Smrg 4234fee23f9Smrg AC_LANG_SAVE 4244fee23f9Smrg AC_LANG_CPLUSPLUS 4254fee23f9Smrg ac_save_CXXFLAGS="$CXXFLAGS" 4264fee23f9Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 4274fee23f9Smrg 428e9e6e0f6Smrg AC_CACHE_CHECK([for poll], glibcxx_cv_POLL, [ 4294fee23f9Smrg GCC_TRY_COMPILE_OR_LINK( 4304fee23f9Smrg [#include <poll.h>], 4314fee23f9Smrg [struct pollfd pfd[1]; 4324fee23f9Smrg pfd[0].events = POLLIN; 4334fee23f9Smrg poll(pfd, 1, 0);], 4344fee23f9Smrg [glibcxx_cv_POLL=yes], 4354fee23f9Smrg [glibcxx_cv_POLL=no]) 4364fee23f9Smrg ]) 4374fee23f9Smrg if test $glibcxx_cv_POLL = yes; then 4384fee23f9Smrg AC_DEFINE(HAVE_POLL, 1, [Define if poll is available in <poll.h>.]) 4394fee23f9Smrg fi 4404fee23f9Smrg 4414fee23f9Smrg CXXFLAGS="$ac_save_CXXFLAGS" 4424fee23f9Smrg AC_LANG_RESTORE 4434fee23f9Smrg]) 4444fee23f9Smrg 4454fee23f9Smrg 4464fee23f9Smrgdnl 4474fee23f9Smrgdnl Check whether writev is available in <sys/uio.h>, and define HAVE_WRITEV. 4484fee23f9Smrgdnl 4494fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_WRITEV], [ 4504fee23f9Smrg 4514fee23f9Smrg AC_LANG_SAVE 4524fee23f9Smrg AC_LANG_CPLUSPLUS 4534fee23f9Smrg ac_save_CXXFLAGS="$CXXFLAGS" 4544fee23f9Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 4554fee23f9Smrg 456e9e6e0f6Smrg AC_CACHE_CHECK([for writev], glibcxx_cv_WRITEV, [ 4574fee23f9Smrg GCC_TRY_COMPILE_OR_LINK( 4584fee23f9Smrg [#include <sys/uio.h>], 4594fee23f9Smrg [struct iovec iov[2]; 4604fee23f9Smrg writev(0, iov, 0);], 4614fee23f9Smrg [glibcxx_cv_WRITEV=yes], 4624fee23f9Smrg [glibcxx_cv_WRITEV=no]) 4634fee23f9Smrg ]) 4644fee23f9Smrg if test $glibcxx_cv_WRITEV = yes; then 4654fee23f9Smrg AC_DEFINE(HAVE_WRITEV, 1, [Define if writev is available in <sys/uio.h>.]) 4664fee23f9Smrg fi 4674fee23f9Smrg 4684fee23f9Smrg CXXFLAGS="$ac_save_CXXFLAGS" 4694fee23f9Smrg AC_LANG_RESTORE 4704fee23f9Smrg]) 4714fee23f9Smrg 4724fee23f9Smrg 4734fee23f9Smrgdnl 4744fee23f9Smrgdnl Check whether LFS support is available. 4754fee23f9Smrgdnl 4764fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_LFS], [ 4774fee23f9Smrg AC_LANG_SAVE 4784fee23f9Smrg AC_LANG_CPLUSPLUS 4794fee23f9Smrg ac_save_CXXFLAGS="$CXXFLAGS" 4804fee23f9Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 481e9e6e0f6Smrg AC_CACHE_CHECK([for LFS support], glibcxx_cv_LFS, [ 4824fee23f9Smrg GCC_TRY_COMPILE_OR_LINK( 4834fee23f9Smrg [#include <unistd.h> 4844fee23f9Smrg #include <stdio.h> 4854fee23f9Smrg #include <sys/stat.h> 4864fee23f9Smrg ], 4874fee23f9Smrg [FILE* fp; 4884fee23f9Smrg fopen64("t", "w"); 4894fee23f9Smrg fseeko64(fp, 0, SEEK_CUR); 4904fee23f9Smrg ftello64(fp); 4914fee23f9Smrg lseek64(1, 0, SEEK_CUR); 4924fee23f9Smrg struct stat64 buf; 4934fee23f9Smrg fstat64(1, &buf);], 4944fee23f9Smrg [glibcxx_cv_LFS=yes], 4954fee23f9Smrg [glibcxx_cv_LFS=no]) 4964fee23f9Smrg ]) 4974fee23f9Smrg if test $glibcxx_cv_LFS = yes; then 4984fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_LFS, 1, [Define if LFS support is available.]) 4994fee23f9Smrg fi 5004fee23f9Smrg CXXFLAGS="$ac_save_CXXFLAGS" 5014fee23f9Smrg AC_LANG_RESTORE 5024fee23f9Smrg]) 5034fee23f9Smrg 5044fee23f9Smrg 5054fee23f9Smrgdnl 506e9e6e0f6Smrgdnl Check whether the old Copy-On-Write basic_string should allocate a new 507e9e6e0f6Smrgdnl empty representation for every default-constructed basic_string. Without 508e9e6e0f6Smrgdnl this option, COW strings share a single empty rep in static storage, 509e9e6e0f6Smrgdnl but this only works if the linker can guarantee the static storage has 510e9e6e0f6Smrgdnl a unique definition in the process. It also doesn't work if basic_string 511e9e6e0f6Smrgdnl objects are stored in shared memory (see PR libstdc++/16612). 512e9e6e0f6Smrgdnl When fully dynamic strings are enabled, the static storage is not used 513e9e6e0f6Smrgdnl and a new empty string with reference-count == 1 is allocated each time. 514e9e6e0f6Smrgdnl Enabling this changes the libstdc++.so ABI. 5154fee23f9Smrgdnl 51648fb7bfaSmrgdnl --enable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING to 1 51748fb7bfaSmrgdnl --disable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING to 0 518e9e6e0f6Smrgdnl otherwise the macro is not defined. 5194fee23f9Smrgdnl + Usage: GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING[(DEFAULT)] 5204fee23f9Smrgdnl Where DEFAULT is either `yes' or `no'. 5214fee23f9Smrgdnl 5224fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING], [ 523e9e6e0f6Smrg GLIBCXX_ENABLE(fully-dynamic-string,$1,,[do not put empty strings in per-process static memory], [permit yes|no]) 5244fee23f9Smrg if test $enable_fully_dynamic_string = yes; then 52548fb7bfaSmrg enable_fully_dynamic_string_def=1 52648fb7bfaSmrg else 52748fb7bfaSmrg enable_fully_dynamic_string_def=0 5284fee23f9Smrg fi 52948fb7bfaSmrg AC_DEFINE_UNQUOTED([_GLIBCXX_FULLY_DYNAMIC_STRING], [${enable_fully_dynamic_string_def}], 53048fb7bfaSmrg [Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, undefined for platform defaults]) 5314fee23f9Smrg]) 5324fee23f9Smrg 5334fee23f9Smrg 5344fee23f9Smrgdnl 5354fee23f9Smrgdnl Does any necessary configuration of the testsuite directory. Generates 5364fee23f9Smrgdnl the testsuite_hooks.h header. 5374fee23f9Smrgdnl 5384fee23f9Smrgdnl GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE must be done before this. 5394fee23f9Smrgdnl 5404fee23f9Smrgdnl Sets: 5414fee23f9Smrgdnl enable_abi_check 5424fee23f9Smrgdnl GLIBCXX_TEST_WCHAR_T 5434fee23f9Smrgdnl GLIBCXX_TEST_THREAD 5444fee23f9Smrgdnl Substs: 5454fee23f9Smrgdnl baseline_dir 54648fb7bfaSmrgdnl baseline_subdir_switch 5474fee23f9Smrgdnl 5484fee23f9SmrgAC_DEFUN([GLIBCXX_CONFIGURE_TESTSUITE], [ 5494fee23f9Smrg # Do checks for resource limit functions. 5504fee23f9Smrg GLIBCXX_CHECK_SETRLIMIT 5514fee23f9Smrg 552a41324a9Smrg if $GLIBCXX_IS_NATIVE ; then 5534fee23f9Smrg # Look for setenv, so that extended locale tests can be performed. 5544fee23f9Smrg GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv) 5554fee23f9Smrg fi 5564fee23f9Smrg 5574fee23f9Smrg if $GLIBCXX_IS_NATIVE && test $is_hosted = yes && 5584fee23f9Smrg test $enable_symvers != no; then 5594fee23f9Smrg case "$host" in 5604fee23f9Smrg *-*-cygwin*) 5614fee23f9Smrg enable_abi_check=no ;; 5624fee23f9Smrg *) 5634fee23f9Smrg enable_abi_check=yes ;; 5644fee23f9Smrg esac 5654fee23f9Smrg else 5664fee23f9Smrg # Only build this as native, since automake does not understand 5674fee23f9Smrg # CXX_FOR_BUILD. 5684fee23f9Smrg enable_abi_check=no 5694fee23f9Smrg fi 5704fee23f9Smrg 5714fee23f9Smrg # Export file names for ABI checking. 5724fee23f9Smrg baseline_dir="$glibcxx_srcdir/config/abi/post/${abi_baseline_pair}" 5734fee23f9Smrg AC_SUBST(baseline_dir) 57448fb7bfaSmrg baseline_subdir_switch="$abi_baseline_subdir_switch" 57548fb7bfaSmrg AC_SUBST(baseline_subdir_switch) 57648fb7bfaSmrg]) 57748fb7bfaSmrg 57848fb7bfaSmrg 57948fb7bfaSmrgdnl 58048fb7bfaSmrgdnl Does any necessary configuration for docbook in the docs directory. 58148fb7bfaSmrgdnl 58248fb7bfaSmrgdnl XSLTPROC must be set before this 58348fb7bfaSmrgdnl 58448fb7bfaSmrgdnl Sets: 58548fb7bfaSmrgdnl glibcxx_stylesheets 58648fb7bfaSmrgdnl Substs: 58748fb7bfaSmrgdnl XSL_STYLE_DIR 58848fb7bfaSmrgdnl 58948fb7bfaSmrgAC_DEFUN([GLIBCXX_CONFIGURE_DOCBOOK], [ 59048fb7bfaSmrg 59183b68139Smrgglibcxx_docbook_url=http://docbook.sourceforge.net/release/xsl-ns/current/ 59248fb7bfaSmrg 59348fb7bfaSmrgAC_MSG_CHECKING([for local stylesheet directory]) 59448fb7bfaSmrgglibcxx_local_stylesheets=no 59583b68139Smrgif test x${XMLCATALOG} = xyes && xsl_style_dir=`xmlcatalog "" $glibcxx_docbook_url 2>/dev/null` 59683b68139Smrgthen 59783b68139Smrg XSL_STYLE_DIR=`echo $xsl_style_dir | sed -n 's;^file://;;p'` 59848fb7bfaSmrg glibcxx_local_stylesheets=yes 59983b68139Smrgelse 60083b68139Smrg for dir in \ 60183b68139Smrg /usr/share/sgml/docbook/xsl-ns-stylesheets \ 60283b68139Smrg /usr/share/xml/docbook/stylesheet/docbook-xsl-ns \ 60383b68139Smrg /usr/share/xml/docbook/stylesheet/nwalsh5/current \ 60483b68139Smrg /usr/share/xml/docbook/stylesheet/nwalsh/current 60583b68139Smrg do 60683b68139Smrg if test -d $dir; then 60748fb7bfaSmrg glibcxx_local_stylesheets=yes 60883b68139Smrg XSL_STYLE_DIR=$dir 60983b68139Smrg break 61048fb7bfaSmrg fi 61183b68139Smrg done 61248fb7bfaSmrgfi 61348fb7bfaSmrgAC_MSG_RESULT($glibcxx_local_stylesheets) 61448fb7bfaSmrg 61548fb7bfaSmrgif test x"$glibcxx_local_stylesheets" = x"yes"; then 61648fb7bfaSmrg AC_SUBST(XSL_STYLE_DIR) 61748fb7bfaSmrg AC_MSG_NOTICE($XSL_STYLE_DIR) 61883b68139Smrg 61983b68139Smrg AC_MSG_CHECKING([for docbook stylesheets for documentation creation]) 62083b68139Smrg glibcxx_stylesheets=no 62183b68139Smrg if test x${XMLCATALOG} = xno || xmlcatalog "" $glibcxx_docbook_url/xhtml/docbook.xsl >/dev/null 2>&1; then 62283b68139Smrg if test x${XSLTPROC} = xyes && echo '<title/>' | xsltproc --noout --nonet --xinclude $glibcxx_docbook_url/xhtml/docbook.xsl - 2>/dev/null; then 62383b68139Smrg glibcxx_stylesheets=yes 62483b68139Smrg fi 62583b68139Smrg fi 62683b68139Smrg AC_MSG_RESULT($glibcxx_stylesheets) 62783b68139Smrg 62848fb7bfaSmrgelse 62948fb7bfaSmrg glibcxx_stylesheets=no 63048fb7bfaSmrgfi 63148fb7bfaSmrg 63248fb7bfaSmrg# Check for epub3 dependencies. 63348fb7bfaSmrgAC_MSG_CHECKING([for epub3 stylesheets for documentation creation]) 63448fb7bfaSmrgglibcxx_epub_stylesheets=no 63548fb7bfaSmrgif test x"$glibcxx_local_stylesheets" = x"yes"; then 63648fb7bfaSmrg if test -f "$XSL_STYLE_DIR/epub3/chunk.xsl"; then 63748fb7bfaSmrg glibcxx_epub_stylesheets=yes 63848fb7bfaSmrg fi 63948fb7bfaSmrgfi 64048fb7bfaSmrgAC_MSG_RESULT($glibcxx_epub_stylesheets) 64148fb7bfaSmrgAM_CONDITIONAL(BUILD_EPUB, test x"$glibcxx_epub_stylesheets" = x"yes") 64248fb7bfaSmrg 6434fee23f9Smrg]) 6444fee23f9Smrg 6454fee23f9Smrg 6464fee23f9Smrgdnl 6474fee23f9Smrgdnl Set up *_INCLUDES variables for all sundry Makefile.am's. 6484fee23f9Smrgdnl 6494fee23f9Smrgdnl Substs: 6504fee23f9Smrgdnl GLIBCXX_INCLUDES 6514fee23f9Smrgdnl TOPLEVEL_INCLUDES 6524fee23f9Smrgdnl 6534fee23f9SmrgAC_DEFUN([GLIBCXX_EXPORT_INCLUDES], [ 6544fee23f9Smrg # Used for every C++ compile we perform. 6554fee23f9Smrg GLIBCXX_INCLUDES="\ 6564fee23f9Smrg-I$glibcxx_builddir/include/$host_alias \ 6574fee23f9Smrg-I$glibcxx_builddir/include \ 6584fee23f9Smrg-I$glibcxx_srcdir/libsupc++" 6594fee23f9Smrg 6604fee23f9Smrg # For Canadian crosses, pick this up too. 6614fee23f9Smrg if test $CANADIAN = yes; then 6624fee23f9Smrg GLIBCXX_INCLUDES="$GLIBCXX_INCLUDES -I\${includedir}" 6634fee23f9Smrg fi 6644fee23f9Smrg 6654fee23f9Smrg # Stuff in the actual top level. Currently only used by libsupc++ to 66648fb7bfaSmrg # get unwind* headers from the libgcc dir. 66748fb7bfaSmrg #TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/libgcc -I$(toplevel_srcdir)/include' 66848fb7bfaSmrg TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/libgcc' 6694fee23f9Smrg 6704fee23f9Smrg # Now, export this to all the little Makefiles.... 6714fee23f9Smrg AC_SUBST(GLIBCXX_INCLUDES) 6724fee23f9Smrg AC_SUBST(TOPLEVEL_INCLUDES) 6734fee23f9Smrg]) 6744fee23f9Smrg 6754fee23f9Smrg 6764fee23f9Smrgdnl 6774fee23f9Smrgdnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's. 6784fee23f9Smrgdnl (SECTION_FLAGS is done under CHECK_COMPILER_FEATURES.) 6794fee23f9Smrgdnl 6804fee23f9Smrgdnl Substs: 6814fee23f9Smrgdnl OPTIMIZE_CXXFLAGS 6824fee23f9Smrgdnl WARN_FLAGS 6834fee23f9Smrgdnl 6844fee23f9SmrgAC_DEFUN([GLIBCXX_EXPORT_FLAGS], [ 6854fee23f9Smrg # Optimization flags that are probably a good idea for thrill-seekers. Just 6864fee23f9Smrg # uncomment the lines below and make, everything else is ready to go... 6874fee23f9Smrg # Alternatively OPTIMIZE_CXXFLAGS can be set in configure.host. 6884fee23f9Smrg # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 6894fee23f9Smrg AC_SUBST(OPTIMIZE_CXXFLAGS) 6904fee23f9Smrg 691654d12c0Smrg WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2" 6924fee23f9Smrg AC_SUBST(WARN_FLAGS) 6934fee23f9Smrg]) 6944fee23f9Smrg 6954fee23f9Smrg 6964fee23f9Smrgdnl 6974fee23f9Smrgdnl All installation directory information is determined here. 6984fee23f9Smrgdnl 6994fee23f9Smrgdnl Substs: 7004fee23f9Smrgdnl gxx_install_dir 7014fee23f9Smrgdnl glibcxx_prefixdir 7024fee23f9Smrgdnl glibcxx_toolexecdir 7034fee23f9Smrgdnl glibcxx_toolexeclibdir 7044fee23f9Smrgdnl 7054fee23f9Smrgdnl Assumes cross_compiling bits already done, and with_cross_host in 7064fee23f9Smrgdnl particular. 7074fee23f9Smrgdnl 7084fee23f9Smrgdnl This logic must match gcc/configure.ac's setting of gcc_gxx_include_dir. 7094fee23f9Smrgdnl config/gxx-include-dir.m4 must be kept consistant with this as well. 7104fee23f9SmrgAC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO], [ 7114fee23f9Smrg glibcxx_toolexecdir=no 7124fee23f9Smrg glibcxx_toolexeclibdir=no 7134fee23f9Smrg glibcxx_prefixdir=$prefix 7144fee23f9Smrg 7154fee23f9Smrg AC_MSG_CHECKING([for gxx-include-dir]) 7164fee23f9Smrg AC_ARG_WITH([gxx-include-dir], 7174fee23f9Smrg AC_HELP_STRING([--with-gxx-include-dir=DIR], 7184fee23f9Smrg [installation directory for include files]), 7194fee23f9Smrg [case "$withval" in 7204fee23f9Smrg yes) AC_MSG_ERROR([Missing directory for --with-gxx-include-dir]) ;; 7214fee23f9Smrg no) gxx_include_dir=no ;; 7224fee23f9Smrg *) gxx_include_dir=$withval ;; 7234fee23f9Smrg esac], 7244fee23f9Smrg [gxx_include_dir=no]) 7254fee23f9Smrg AC_MSG_RESULT($gxx_include_dir) 7264fee23f9Smrg 7274fee23f9Smrg AC_MSG_CHECKING([for --enable-version-specific-runtime-libs]) 7284fee23f9Smrg AC_ARG_ENABLE([version-specific-runtime-libs], 7294fee23f9Smrg AC_HELP_STRING([--enable-version-specific-runtime-libs], 7304fee23f9Smrg [Specify that runtime libraries should be installed in a compiler-specific directory]), 7314fee23f9Smrg [case "$enableval" in 7324fee23f9Smrg yes) version_specific_libs=yes ;; 7334fee23f9Smrg no) version_specific_libs=no ;; 7344fee23f9Smrg *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);; 7354fee23f9Smrg esac], 7364fee23f9Smrg [version_specific_libs=no]) 7374fee23f9Smrg AC_MSG_RESULT($version_specific_libs) 7384fee23f9Smrg 73943265c03Smrg GCC_WITH_TOOLEXECLIBDIR 74043265c03Smrg 7414fee23f9Smrg # Default case for install directory for include files. 7424fee23f9Smrg if test $version_specific_libs = no && test $gxx_include_dir = no; then 7434fee23f9Smrg gxx_include_dir='include/c++/${gcc_version}' 7444fee23f9Smrg if test -n "$with_cross_host" && 7454fee23f9Smrg test x"$with_cross_host" != x"no"; then 7464fee23f9Smrg gxx_include_dir='${prefix}/${target_alias}/'"$gxx_include_dir" 7474fee23f9Smrg else 7484fee23f9Smrg gxx_include_dir='${prefix}/'"$gxx_include_dir" 7494fee23f9Smrg fi 7504fee23f9Smrg fi 7514fee23f9Smrg 7524fee23f9Smrg # Version-specific runtime libs processing. 7534fee23f9Smrg if test $version_specific_libs = yes; then 7544fee23f9Smrg # Need the gcc compiler version to know where to install libraries 7554fee23f9Smrg # and header files if --enable-version-specific-runtime-libs option 7564fee23f9Smrg # is selected. FIXME: these variables are misnamed, there are 7574fee23f9Smrg # no executables installed in _toolexecdir or _toolexeclibdir. 7584fee23f9Smrg if test x"$gxx_include_dir" = x"no"; then 7594fee23f9Smrg gxx_include_dir='${libdir}/gcc/${host_alias}/${gcc_version}/include/c++' 7604fee23f9Smrg fi 7614fee23f9Smrg glibcxx_toolexecdir='${libdir}/gcc/${host_alias}' 7624fee23f9Smrg glibcxx_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)' 7634fee23f9Smrg fi 7644fee23f9Smrg 7654fee23f9Smrg # Calculate glibcxx_toolexecdir, glibcxx_toolexeclibdir 7664fee23f9Smrg # Install a library built with a cross compiler in tooldir, not libdir. 7674fee23f9Smrg if test x"$glibcxx_toolexecdir" = x"no"; then 7684fee23f9Smrg if test -n "$with_cross_host" && 7694fee23f9Smrg test x"$with_cross_host" != x"no"; then 7704fee23f9Smrg glibcxx_toolexecdir='${exec_prefix}/${host_alias}' 77143265c03Smrg case ${with_toolexeclibdir} in 77243265c03Smrg no) 7734fee23f9Smrg glibcxx_toolexeclibdir='${toolexecdir}/lib' 77443265c03Smrg ;; 77543265c03Smrg *) 77643265c03Smrg glibcxx_toolexeclibdir=${with_toolexeclibdir} 77743265c03Smrg ;; 77843265c03Smrg esac 7794fee23f9Smrg else 7804fee23f9Smrg glibcxx_toolexecdir='${libdir}/gcc/${host_alias}' 7814fee23f9Smrg glibcxx_toolexeclibdir='${libdir}' 7824fee23f9Smrg fi 7834fee23f9Smrg multi_os_directory=`$CXX -print-multi-os-directory` 7844fee23f9Smrg case $multi_os_directory in 7854fee23f9Smrg .) ;; # Avoid trailing /. 7864fee23f9Smrg *) glibcxx_toolexeclibdir=$glibcxx_toolexeclibdir/$multi_os_directory ;; 7874fee23f9Smrg esac 7884fee23f9Smrg fi 7894fee23f9Smrg 7904fee23f9Smrg AC_MSG_CHECKING([for install location]) 7914fee23f9Smrg AC_MSG_RESULT($gxx_include_dir) 7924fee23f9Smrg 7934fee23f9Smrg AC_SUBST(glibcxx_prefixdir) 7944fee23f9Smrg AC_SUBST(gxx_include_dir) 7954fee23f9Smrg AC_SUBST(glibcxx_toolexecdir) 7964fee23f9Smrg AC_SUBST(glibcxx_toolexeclibdir) 7974fee23f9Smrg]) 7984fee23f9Smrg 7994fee23f9Smrg 8004fee23f9Smrgdnl 8014fee23f9Smrgdnl GLIBCXX_ENABLE 8024fee23f9Smrgdnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING) 8034fee23f9Smrgdnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c) 8044fee23f9Smrgdnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER) 8054fee23f9Smrgdnl 806d35849d0Smrgdnl See manual/appendix_porting.html#appendix.porting.build_hacking for 807d35849d0Smrgdnl documentation. 8084fee23f9Smrgdnl 8094fee23f9Smrgm4_define([GLIBCXX_ENABLE],[dnl 8104fee23f9Smrgm4_define([_g_switch],[--enable-$1])dnl 81148fb7bfaSmrgm4_define([_g_help],[AC_HELP_STRING([_g_switch$3],[$4 @<:@default=$2@:>@])])dnl 81248fb7bfaSmrg AC_ARG_ENABLE([$1],m4_dquote(_g_help), 8134fee23f9Smrg m4_bmatch([$5], 8144fee23f9Smrg [^permit ], 8154fee23f9Smrg [[ 8164fee23f9Smrg case "$enableval" in 8174fee23f9Smrg m4_bpatsubst([$5],[permit ])) ;; 8184fee23f9Smrg *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;; 8194fee23f9Smrg dnl Idea for future: generate a URL pointing to 8204fee23f9Smrg dnl "onlinedocs/configopts.html#whatever" 8214fee23f9Smrg esac 8224fee23f9Smrg ]], 8234fee23f9Smrg [^$], 8244fee23f9Smrg [[ 8254fee23f9Smrg case "$enableval" in 8264fee23f9Smrg yes|no) ;; 8274fee23f9Smrg *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;; 8284fee23f9Smrg esac 8294fee23f9Smrg ]], 8304fee23f9Smrg [[$5]]), 8314fee23f9Smrg [enable_]m4_bpatsubst([$1],-,_)[=][$2]) 8324fee23f9Smrgm4_undefine([_g_switch])dnl 8334fee23f9Smrgm4_undefine([_g_help])dnl 8344fee23f9Smrg]) 8354fee23f9Smrg 8364fee23f9Smrg 8374fee23f9Smrgdnl 8384fee23f9Smrgdnl Check for ISO/IEC 9899:1999 "C99" support. 8394fee23f9Smrgdnl 8404fee23f9Smrgdnl --enable-c99 defines _GLIBCXX_USE_C99 8414fee23f9Smrgdnl --disable-c99 leaves _GLIBCXX_USE_C99 undefined 8424fee23f9Smrgdnl + Usage: GLIBCXX_ENABLE_C99[(DEFAULT)] 8434fee23f9Smrgdnl Where DEFAULT is either `yes' or `no'. 8444fee23f9Smrgdnl + If 'C99' stuff is not available, ignores DEFAULT and sets `no'. 8454fee23f9Smrgdnl 8464fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_C99], [ 8474fee23f9Smrg GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support]) 8484fee23f9Smrg 8494fee23f9Smrg if test x"$enable_c99" = x"yes"; then 8504fee23f9Smrg AC_LANG_SAVE 8514fee23f9Smrg AC_LANG_CPLUSPLUS 8524fee23f9Smrg 853cdbfa754Smrg # Use -std=c++98 (instead of -std=gnu++98) because leaving __STRICT_ANSI__ 854cdbfa754Smrg # undefined may cause fake C99 facilities, like pre-standard snprintf, 855cdbfa754Smrg # to be spuriously enabled. 8564fee23f9Smrg ac_save_CXXFLAGS="$CXXFLAGS" 8574fee23f9Smrg CXXFLAGS="$CXXFLAGS -std=c++98" 8584fee23f9Smrg ac_save_LIBS="$LIBS" 8594fee23f9Smrg ac_save_gcc_no_link="$gcc_no_link" 8604fee23f9Smrg 8614fee23f9Smrg if test x$gcc_no_link != xyes; then 8624fee23f9Smrg # Use -fno-exceptions to that the C driver can link these tests without 8634fee23f9Smrg # hitting undefined references to personality routines. 8644fee23f9Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 865cdbfa754Smrg AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [ 8664fee23f9Smrg # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK 8674fee23f9Smrg gcc_no_link=yes 8684fee23f9Smrg ]) 8694fee23f9Smrg fi 8704fee23f9Smrg 8714fee23f9Smrg # Check for the existence of <math.h> functions used if C99 is enabled. 872e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support in <math.h> for C++98], 873e9e6e0f6Smrg glibcxx_cv_c99_math_cxx98, [ 8744fee23f9Smrg GCC_TRY_COMPILE_OR_LINK( 8754fee23f9Smrg [#include <math.h> 8764fee23f9Smrg volatile double d1, d2; 8774fee23f9Smrg volatile int i;], 8784fee23f9Smrg [i = fpclassify(d1); 8794fee23f9Smrg i = isfinite(d1); 8804fee23f9Smrg i = isinf(d1); 8814fee23f9Smrg i = isnan(d1); 8824fee23f9Smrg i = isnormal(d1); 8834fee23f9Smrg i = signbit(d1); 8844fee23f9Smrg i = isgreater(d1, d2); 8854fee23f9Smrg i = isgreaterequal(d1, d2); 8864fee23f9Smrg i = isless(d1, d2); 8874fee23f9Smrg i = islessequal(d1, d2); 8884fee23f9Smrg i = islessgreater(d1, d2); 8894fee23f9Smrg i = islessgreater(d1, d2); 8904fee23f9Smrg i = isunordered(d1, d2); 891cdbfa754Smrg ], [glibcxx_cv_c99_math_cxx98=yes], [glibcxx_cv_c99_math_cxx98=no]) 8924fee23f9Smrg ]) 893cdbfa754Smrg if test x"$glibcxx_cv_c99_math_cxx98" = x"yes"; then 894cdbfa754Smrg AC_DEFINE(_GLIBCXX98_USE_C99_MATH, 1, 8954fee23f9Smrg [Define if C99 functions or macros in <math.h> should be imported 896cdbfa754Smrg in <cmath> in namespace std for C++98.]) 8974fee23f9Smrg fi 8984fee23f9Smrg 8994fee23f9Smrg # Check for the existence of <complex.h> complex math functions. 9004fee23f9Smrg # This is necessary even though libstdc++ uses the builtin versions 9014fee23f9Smrg # of these functions, because if the builtin cannot be used, a reference 9024fee23f9Smrg # to the library function is emitted. 9034fee23f9Smrg AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no) 9044fee23f9Smrg AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no) 9054fee23f9Smrg if test x"$ac_has_complex_h" = x"yes"; then 906e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support in <complex.h> for C++98], 907e9e6e0f6Smrg glibcxx_cv_c99_complex_cxx98, [ 9084fee23f9Smrg GCC_TRY_COMPILE_OR_LINK( 9094fee23f9Smrg [#include <complex.h> 9104fee23f9Smrg typedef __complex__ float float_type; 9114fee23f9Smrg typedef __complex__ double double_type; 9124fee23f9Smrg typedef __complex__ long double ld_type; 9134fee23f9Smrg volatile float_type tmpf; 9144fee23f9Smrg volatile double_type tmpd; 9154fee23f9Smrg volatile ld_type tmpld; 9164fee23f9Smrg volatile float f; 9174fee23f9Smrg volatile double d; 9184fee23f9Smrg volatile long double ld;], 9194fee23f9Smrg [f = cabsf(tmpf); 9204fee23f9Smrg f = cargf(tmpf); 9214fee23f9Smrg tmpf = ccosf(tmpf); 9224fee23f9Smrg tmpf = ccoshf(tmpf); 9234fee23f9Smrg tmpf = cexpf(tmpf); 9244fee23f9Smrg tmpf = clogf(tmpf); 9254fee23f9Smrg tmpf = csinf(tmpf); 9264fee23f9Smrg tmpf = csinhf(tmpf); 9274fee23f9Smrg tmpf = csqrtf(tmpf); 9284fee23f9Smrg tmpf = ctanf(tmpf); 9294fee23f9Smrg tmpf = ctanhf(tmpf); 9304fee23f9Smrg tmpf = cpowf(tmpf, tmpf); 9314fee23f9Smrg tmpf = cprojf(tmpf); 9324fee23f9Smrg d = cabs(tmpd); 9334fee23f9Smrg d = carg(tmpd); 9344fee23f9Smrg tmpd = ccos(tmpd); 9354fee23f9Smrg tmpd = ccosh(tmpd); 9364fee23f9Smrg tmpd = cexp(tmpd); 9374fee23f9Smrg tmpd = clog(tmpd); 9384fee23f9Smrg tmpd = csin(tmpd); 9394fee23f9Smrg tmpd = csinh(tmpd); 9404fee23f9Smrg tmpd = csqrt(tmpd); 9414fee23f9Smrg tmpd = ctan(tmpd); 9424fee23f9Smrg tmpd = ctanh(tmpd); 9434fee23f9Smrg tmpd = cpow(tmpd, tmpd); 9444fee23f9Smrg tmpd = cproj(tmpd); 9454fee23f9Smrg ld = cabsl(tmpld); 9464fee23f9Smrg ld = cargl(tmpld); 9474fee23f9Smrg tmpld = ccosl(tmpld); 9484fee23f9Smrg tmpld = ccoshl(tmpld); 9494fee23f9Smrg tmpld = cexpl(tmpld); 9504fee23f9Smrg tmpld = clogl(tmpld); 9514fee23f9Smrg tmpld = csinl(tmpld); 9524fee23f9Smrg tmpld = csinhl(tmpld); 9534fee23f9Smrg tmpld = csqrtl(tmpld); 9544fee23f9Smrg tmpld = ctanl(tmpld); 9554fee23f9Smrg tmpld = ctanhl(tmpld); 9564fee23f9Smrg tmpld = cpowl(tmpld, tmpld); 9574fee23f9Smrg tmpld = cprojl(tmpld); 958cdbfa754Smrg ], [glibcxx_cv_c99_complex_cxx98=yes], [glibcxx_cv_c99_complex_cxx98=no]) 959cdbfa754Smrg ]) 9604fee23f9Smrg fi 961cdbfa754Smrg if test x"$glibcxx_cv_c99_complex_cxx98" = x"yes"; then 962cdbfa754Smrg AC_DEFINE(_GLIBCXX98_USE_C99_COMPLEX, 1, 9634fee23f9Smrg [Define if C99 functions in <complex.h> should be used in 964cdbfa754Smrg <complex> for C++98. Using compiler builtins for these functions 965cdbfa754Smrg requires corresponding C99 library functions to be present.]) 9664fee23f9Smrg fi 9674fee23f9Smrg 9684fee23f9Smrg # Check for the existence in <stdio.h> of vscanf, et. al. 969e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support in <stdio.h> for C++98], 970e9e6e0f6Smrg glibcxx_cv_c99_stdio_cxx98, [ 9714fee23f9Smrg GCC_TRY_COMPILE_OR_LINK( 9724fee23f9Smrg [#include <stdio.h> 9734fee23f9Smrg #include <stdarg.h> 9744fee23f9Smrg void foo(char* fmt, ...) 9754fee23f9Smrg { 9764fee23f9Smrg va_list args; va_start(args, fmt); 9774fee23f9Smrg vfscanf(stderr, "%i", args); 9784fee23f9Smrg vscanf("%i", args); 9794fee23f9Smrg vsnprintf(fmt, 0, "%i", args); 9804fee23f9Smrg vsscanf(fmt, "%i", args); 981*4fe0f936Smrg snprintf(fmt, 0, "%i", 1); 982d35849d0Smrg }], [], 983cdbfa754Smrg [glibcxx_cv_c99_stdio_cxx98=yes], [glibcxx_cv_c99_stdio_cxx98=no]) 9844fee23f9Smrg ]) 985cdbfa754Smrg if test x"$glibcxx_cv_c99_stdio_cxx98" = x"yes"; then 986cdbfa754Smrg AC_DEFINE(_GLIBCXX98_USE_C99_STDIO, 1, 987cdbfa754Smrg [Define if C99 functions or macros in <stdio.h> should be imported 988cdbfa754Smrg in <cstdio> in namespace std for C++98.]) 989cdbfa754Smrg fi 9904fee23f9Smrg 9914fee23f9Smrg # Check for the existence in <stdlib.h> of lldiv_t, et. al. 992e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support in <stdlib.h> for C++98], 993e9e6e0f6Smrg glibcxx_cv_c99_stdlib_cxx98, [ 9944fee23f9Smrg GCC_TRY_COMPILE_OR_LINK( 9954fee23f9Smrg [#include <stdlib.h> 9964fee23f9Smrg volatile float f; 9974fee23f9Smrg volatile long double ld; 9984fee23f9Smrg volatile unsigned long long ll; 9994fee23f9Smrg lldiv_t mydivt;], 10004fee23f9Smrg [char* tmp; 10014fee23f9Smrg f = strtof("gnu", &tmp); 10024fee23f9Smrg ld = strtold("gnu", &tmp); 10034fee23f9Smrg ll = strtoll("gnu", &tmp, 10); 10044fee23f9Smrg ll = strtoull("gnu", &tmp, 10); 10054fee23f9Smrg ll = llabs(10); 10064fee23f9Smrg mydivt = lldiv(10,1); 10074fee23f9Smrg ll = mydivt.quot; 10084fee23f9Smrg ll = mydivt.rem; 10094fee23f9Smrg ll = atoll("10"); 10104fee23f9Smrg _Exit(0); 1011cdbfa754Smrg ], [glibcxx_cv_c99_stdlib_cxx98=yes], [glibcxx_cv_c99_stdlib_cxx98=no]) 10124fee23f9Smrg ]) 1013cdbfa754Smrg if test x"$glibcxx_cv_c99_stdlib_cxx98" = x"yes"; then 1014cdbfa754Smrg AC_DEFINE(_GLIBCXX98_USE_C99_STDLIB, 1, 1015cdbfa754Smrg [Define if C99 functions or macros in <stdlib.h> should be imported 1016cdbfa754Smrg in <cstdlib> in namespace std for C++98.]) 1017cdbfa754Smrg fi 10184fee23f9Smrg 10194fee23f9Smrg # Check for the existence in <wchar.h> of wcstold, etc. 10204fee23f9Smrg if test x"$ac_has_wchar_h" = xyes && 10214fee23f9Smrg test x"$ac_has_wctype_h" = xyes; then 1022e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support in <wchar.h> for C++98], 1023e9e6e0f6Smrg glibcxx_cv_c99_wchar_cxx98, [ 10244fee23f9Smrg AC_TRY_COMPILE([#include <wchar.h> 10254fee23f9Smrg namespace test 10264fee23f9Smrg { 10274fee23f9Smrg using ::wcstold; 10284fee23f9Smrg using ::wcstoll; 10294fee23f9Smrg using ::wcstoull; 10304fee23f9Smrg } 1031cdbfa754Smrg ], [], [glibcxx_cv_c99_wchar_cxx98=yes], [glibcxx_cv_c99_wchar_cxx98=no]) 1032cdbfa754Smrg ]) 10334fee23f9Smrg 10344fee23f9Smrg # Checks for wide character functions that may not be present. 10354fee23f9Smrg # Injection of these is wrapped with guard macros. 10364fee23f9Smrg # NB: only put functions here, instead of immediately above, if 10374fee23f9Smrg # absolutely necessary. 10384fee23f9Smrg AC_TRY_COMPILE([#include <wchar.h> 10394fee23f9Smrg namespace test { using ::vfwscanf; }], [], 1040cdbfa754Smrg [AC_DEFINE(HAVE_VFWSCANF, 1, [Defined if vfwscanf exists.])], []) 10414fee23f9Smrg 10424fee23f9Smrg AC_TRY_COMPILE([#include <wchar.h> 10434fee23f9Smrg namespace test { using ::vswscanf; }], [], 1044cdbfa754Smrg [AC_DEFINE(HAVE_VSWSCANF, 1, [Defined if vswscanf exists.])], []) 10454fee23f9Smrg 10464fee23f9Smrg AC_TRY_COMPILE([#include <wchar.h> 10474fee23f9Smrg namespace test { using ::vwscanf; }], [], 10484fee23f9Smrg [AC_DEFINE(HAVE_VWSCANF, 1, [Defined if vwscanf exists.])], []) 10494fee23f9Smrg 10504fee23f9Smrg AC_TRY_COMPILE([#include <wchar.h> 10514fee23f9Smrg namespace test { using ::wcstof; }], [], 10524fee23f9Smrg [AC_DEFINE(HAVE_WCSTOF, 1, [Defined if wcstof exists.])], []) 10534fee23f9Smrg 10544fee23f9Smrg AC_TRY_COMPILE([#include <wctype.h>], 10554fee23f9Smrg [wint_t t; int i = iswblank(t);], 1056cdbfa754Smrg [AC_DEFINE(HAVE_ISWBLANK, 1, [Defined if iswblank exists.])], []) 10574fee23f9Smrg 1058cdbfa754Smrg if test x"$glibcxx_cv_c99_wchar_cxx98" = x"yes"; then 1059cdbfa754Smrg AC_DEFINE(_GLIBCXX98_USE_C99_WCHAR, 1, 1060cdbfa754Smrg [Define if C99 functions or macros in <wchar.h> should be imported 1061cdbfa754Smrg in <cwchar> in namespace std for C++98.]) 1062cdbfa754Smrg fi 10634fee23f9Smrg fi 10644fee23f9Smrg 10654fee23f9Smrg # Option parsed, now set things appropriately. 1066cdbfa754Smrg if test x"$glibcxx_cv_c99_math_cxx98" = x"no" || 1067cdbfa754Smrg test x"$glibcxx_cv_c99_complex_cxx98" = x"no" || 1068cdbfa754Smrg test x"$glibcxx_cv_c99_stdio_cxx98" = x"no" || 1069cdbfa754Smrg test x"$glibcxx_cv_c99_stdlib_cxx98" = x"no" || 1070cdbfa754Smrg test x"$glibcxx_cv_c99_wchar_cxx98" = x"no"; then 10714fee23f9Smrg enable_c99=no; 10724fee23f9Smrg else 10734fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_C99, 1, 10744fee23f9Smrg [Define if C99 functions or macros from <wchar.h>, <math.h>, 10754fee23f9Smrg <complex.h>, <stdio.h>, and <stdlib.h> can be used or exposed.]) 10764fee23f9Smrg fi 10774fee23f9Smrg 10784fee23f9Smrg gcc_no_link="$ac_save_gcc_no_link" 10794fee23f9Smrg LIBS="$ac_save_LIBS" 10804fee23f9Smrg CXXFLAGS="$ac_save_CXXFLAGS" 10814fee23f9Smrg AC_LANG_RESTORE 1082cdbfa754Smrg 1083cdbfa754Smrg AC_LANG_SAVE 1084cdbfa754Smrg AC_LANG_CPLUSPLUS 1085cdbfa754Smrg 1086cdbfa754Smrg # Use -std=c++11 and test again for C99 library feature in C++11 mode. 1087cdbfa754Smrg # For the reasons given above we use -std=c++11 not -std=gnu++11. 1088cdbfa754Smrg ac_save_CXXFLAGS="$CXXFLAGS" 1089cdbfa754Smrg CXXFLAGS="$CXXFLAGS -std=c++11" 1090cdbfa754Smrg ac_save_LIBS="$LIBS" 1091cdbfa754Smrg ac_save_gcc_no_link="$gcc_no_link" 1092cdbfa754Smrg 1093cdbfa754Smrg if test x$gcc_no_link != xyes; then 1094cdbfa754Smrg # Use -fno-exceptions to that the C driver can link these tests without 1095cdbfa754Smrg # hitting undefined references to personality routines. 1096cdbfa754Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 1097cdbfa754Smrg AC_CHECK_LIB(m, sin, [LIBS="$LIBS -lm"], [ 1098cdbfa754Smrg # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK 1099cdbfa754Smrg gcc_no_link=yes 1100cdbfa754Smrg ]) 1101cdbfa754Smrg fi 1102cdbfa754Smrg 1103cdbfa754Smrg # Check for the existence of <math.h> functions used if C99 is enabled. 1104e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support in <math.h> for C++11], 1105e9e6e0f6Smrg glibcxx_cv_c99_math_cxx11, [ 1106cdbfa754Smrg GCC_TRY_COMPILE_OR_LINK( 1107cdbfa754Smrg [#include <math.h> 1108cdbfa754Smrg volatile double d1, d2; 1109cdbfa754Smrg volatile int i;], 1110cdbfa754Smrg [i = fpclassify(d1); 1111cdbfa754Smrg i = isfinite(d1); 1112cdbfa754Smrg i = isinf(d1); 1113cdbfa754Smrg i = isnan(d1); 1114cdbfa754Smrg i = isnormal(d1); 1115cdbfa754Smrg i = signbit(d1); 1116cdbfa754Smrg i = isgreater(d1, d2); 1117cdbfa754Smrg i = isgreaterequal(d1, d2); 1118cdbfa754Smrg i = isless(d1, d2); 1119cdbfa754Smrg i = islessequal(d1, d2); 1120cdbfa754Smrg i = islessgreater(d1, d2); 1121cdbfa754Smrg i = islessgreater(d1, d2); 1122cdbfa754Smrg i = isunordered(d1, d2); 1123cdbfa754Smrg ], [glibcxx_cv_c99_math_cxx11=yes], [glibcxx_cv_c99_math_cxx11=no]) 1124cdbfa754Smrg ]) 1125cdbfa754Smrg if test x"$glibcxx_cv_c99_math_cxx11" = x"yes"; then 1126cdbfa754Smrg AC_DEFINE(_GLIBCXX11_USE_C99_MATH, 1, 1127cdbfa754Smrg [Define if C99 functions or macros in <math.h> should be imported 1128cdbfa754Smrg in <cmath> in namespace std for C++11.]) 1129cdbfa754Smrg fi 1130cdbfa754Smrg 1131cdbfa754Smrg # Check for the existence of <complex.h> complex math functions. 1132cdbfa754Smrg # This is necessary even though libstdc++ uses the builtin versions 1133cdbfa754Smrg # of these functions, because if the builtin cannot be used, a reference 1134cdbfa754Smrg # to the library function is emitted. 1135cdbfa754Smrg AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no) 1136cdbfa754Smrg AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no) 1137cdbfa754Smrg if test x"$ac_has_complex_h" = x"yes"; then 1138e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support in <complex.h> for C++11], 1139e9e6e0f6Smrg glibcxx_cv_c99_complex_cxx11, [ 1140cdbfa754Smrg GCC_TRY_COMPILE_OR_LINK( 1141cdbfa754Smrg [#include <complex.h> 1142cdbfa754Smrg typedef __complex__ float float_type; 1143cdbfa754Smrg typedef __complex__ double double_type; 1144cdbfa754Smrg typedef __complex__ long double ld_type; 1145cdbfa754Smrg volatile float_type tmpf; 1146cdbfa754Smrg volatile double_type tmpd; 1147cdbfa754Smrg volatile ld_type tmpld; 1148cdbfa754Smrg volatile float f; 1149cdbfa754Smrg volatile double d; 1150cdbfa754Smrg volatile long double ld;], 1151cdbfa754Smrg [f = cabsf(tmpf); 1152cdbfa754Smrg f = cargf(tmpf); 1153cdbfa754Smrg tmpf = ccosf(tmpf); 1154cdbfa754Smrg tmpf = ccoshf(tmpf); 1155cdbfa754Smrg tmpf = cexpf(tmpf); 1156cdbfa754Smrg tmpf = clogf(tmpf); 1157cdbfa754Smrg tmpf = csinf(tmpf); 1158cdbfa754Smrg tmpf = csinhf(tmpf); 1159cdbfa754Smrg tmpf = csqrtf(tmpf); 1160cdbfa754Smrg tmpf = ctanf(tmpf); 1161cdbfa754Smrg tmpf = ctanhf(tmpf); 1162cdbfa754Smrg tmpf = cpowf(tmpf, tmpf); 1163cdbfa754Smrg tmpf = cprojf(tmpf); 1164cdbfa754Smrg d = cabs(tmpd); 1165cdbfa754Smrg d = carg(tmpd); 1166cdbfa754Smrg tmpd = ccos(tmpd); 1167cdbfa754Smrg tmpd = ccosh(tmpd); 1168cdbfa754Smrg tmpd = cexp(tmpd); 1169cdbfa754Smrg tmpd = clog(tmpd); 1170cdbfa754Smrg tmpd = csin(tmpd); 1171cdbfa754Smrg tmpd = csinh(tmpd); 1172cdbfa754Smrg tmpd = csqrt(tmpd); 1173cdbfa754Smrg tmpd = ctan(tmpd); 1174cdbfa754Smrg tmpd = ctanh(tmpd); 1175cdbfa754Smrg tmpd = cpow(tmpd, tmpd); 1176cdbfa754Smrg tmpd = cproj(tmpd); 1177cdbfa754Smrg ld = cabsl(tmpld); 1178cdbfa754Smrg ld = cargl(tmpld); 1179cdbfa754Smrg tmpld = ccosl(tmpld); 1180cdbfa754Smrg tmpld = ccoshl(tmpld); 1181cdbfa754Smrg tmpld = cexpl(tmpld); 1182cdbfa754Smrg tmpld = clogl(tmpld); 1183cdbfa754Smrg tmpld = csinl(tmpld); 1184cdbfa754Smrg tmpld = csinhl(tmpld); 1185cdbfa754Smrg tmpld = csqrtl(tmpld); 1186cdbfa754Smrg tmpld = ctanl(tmpld); 1187cdbfa754Smrg tmpld = ctanhl(tmpld); 1188cdbfa754Smrg tmpld = cpowl(tmpld, tmpld); 1189cdbfa754Smrg tmpld = cprojl(tmpld); 1190cdbfa754Smrg ], [glibcxx_cv_c99_complex_cxx11=yes], [glibcxx_cv_c99_complex_cxx11=no]) 1191cdbfa754Smrg ]) 1192cdbfa754Smrg fi 1193cdbfa754Smrg if test x"$glibcxx_cv_c99_complex_cxx11" = x"yes"; then 1194cdbfa754Smrg AC_DEFINE(_GLIBCXX11_USE_C99_COMPLEX, 1, 1195cdbfa754Smrg [Define if C99 functions in <complex.h> should be used in 1196cdbfa754Smrg <complex> for C++11. Using compiler builtins for these functions 1197cdbfa754Smrg requires corresponding C99 library functions to be present.]) 1198cdbfa754Smrg fi 1199cdbfa754Smrg 1200cdbfa754Smrg # Check for the existence in <stdio.h> of vscanf, et. al. 1201e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support in <stdio.h> for C++11], 1202e9e6e0f6Smrg glibcxx_cv_c99_stdio_cxx11, [ 1203cdbfa754Smrg GCC_TRY_COMPILE_OR_LINK( 1204cdbfa754Smrg [#include <stdio.h> 1205cdbfa754Smrg #include <stdarg.h> 1206cdbfa754Smrg void foo(char* fmt, ...) 1207cdbfa754Smrg { 1208cdbfa754Smrg va_list args; va_start(args, fmt); 1209cdbfa754Smrg vfscanf(stderr, "%i", args); 1210cdbfa754Smrg vscanf("%i", args); 1211cdbfa754Smrg vsnprintf(fmt, 0, "%i", args); 1212cdbfa754Smrg vsscanf(fmt, "%i", args); 1213*4fe0f936Smrg snprintf(fmt, 0, "%i", 1); 1214cdbfa754Smrg }], [], 1215cdbfa754Smrg [glibcxx_cv_c99_stdio_cxx11=yes], [glibcxx_cv_c99_stdio_cxx11=no]) 1216cdbfa754Smrg ]) 1217cdbfa754Smrg if test x"$glibcxx_cv_c99_stdio_cxx11" = x"yes"; then 1218cdbfa754Smrg AC_DEFINE(_GLIBCXX11_USE_C99_STDIO, 1, 1219cdbfa754Smrg [Define if C99 functions or macros in <stdio.h> should be imported 1220cdbfa754Smrg in <cstdio> in namespace std for C++11.]) 1221cdbfa754Smrg fi 1222cdbfa754Smrg 1223cdbfa754Smrg # Check for the existence in <stdlib.h> of lldiv_t, et. al. 1224e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support in <stdlib.h> for C++11], 1225e9e6e0f6Smrg glibcxx_cv_c99_stdlib_cxx11, [ 1226cdbfa754Smrg GCC_TRY_COMPILE_OR_LINK( 1227cdbfa754Smrg [#include <stdlib.h> 1228cdbfa754Smrg volatile float f; 1229cdbfa754Smrg volatile long double ld; 1230cdbfa754Smrg volatile unsigned long long ll; 1231cdbfa754Smrg lldiv_t mydivt;], 1232cdbfa754Smrg [char* tmp; 1233cdbfa754Smrg f = strtof("gnu", &tmp); 1234cdbfa754Smrg ld = strtold("gnu", &tmp); 1235cdbfa754Smrg ll = strtoll("gnu", &tmp, 10); 1236cdbfa754Smrg ll = strtoull("gnu", &tmp, 10); 1237cdbfa754Smrg ll = llabs(10); 1238cdbfa754Smrg mydivt = lldiv(10,1); 1239cdbfa754Smrg ll = mydivt.quot; 1240cdbfa754Smrg ll = mydivt.rem; 1241cdbfa754Smrg ll = atoll("10"); 1242cdbfa754Smrg _Exit(0); 1243cdbfa754Smrg ], [glibcxx_cv_c99_stdlib_cxx11=yes], [glibcxx_cv_c99_stdlib_cxx11=no]) 1244cdbfa754Smrg ]) 1245cdbfa754Smrg if test x"$glibcxx_cv_c99_stdlib_cxx11" = x"yes"; then 1246cdbfa754Smrg AC_DEFINE(_GLIBCXX11_USE_C99_STDLIB, 1, 1247cdbfa754Smrg [Define if C99 functions or macros in <stdlib.h> should be imported 1248cdbfa754Smrg in <cstdlib> in namespace std for C++11.]) 1249cdbfa754Smrg fi 1250cdbfa754Smrg 1251cdbfa754Smrg # Check for the existence in <wchar.h> of wcstold, etc. 1252cdbfa754Smrg if test x"$ac_has_wchar_h" = xyes && 1253cdbfa754Smrg test x"$ac_has_wctype_h" = xyes; then 1254e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support in <wchar.h> for C++11], 1255e9e6e0f6Smrg glibcxx_cv_c99_wchar_cxx11, [ 1256cdbfa754Smrg AC_TRY_COMPILE([#include <wchar.h> 1257cdbfa754Smrg namespace test 1258cdbfa754Smrg { 1259cdbfa754Smrg using ::wcstold; 1260cdbfa754Smrg using ::wcstoll; 1261cdbfa754Smrg using ::wcstoull; 1262cdbfa754Smrg } 1263cdbfa754Smrg ], [], [glibcxx_cv_c99_wchar_cxx11=yes], [glibcxx_cv_c99_wchar_cxx11=no]) 1264cdbfa754Smrg ]) 1265cdbfa754Smrg 1266cdbfa754Smrg # Checks for wide character functions that may not be present. 1267cdbfa754Smrg # Injection of these is wrapped with guard macros. 1268cdbfa754Smrg # NB: only put functions here, instead of immediately above, if 1269cdbfa754Smrg # absolutely necessary. 1270cdbfa754Smrg AC_TRY_COMPILE([#include <wchar.h> 1271cdbfa754Smrg namespace test { using ::vfwscanf; }], [], 1272cdbfa754Smrg [AC_DEFINE(HAVE_VFWSCANF, 1, [Defined if vfwscanf exists.])], []) 1273cdbfa754Smrg 1274cdbfa754Smrg AC_TRY_COMPILE([#include <wchar.h> 1275cdbfa754Smrg namespace test { using ::vswscanf; }], [], 1276cdbfa754Smrg [AC_DEFINE(HAVE_VSWSCANF, 1, [Defined if vswscanf exists.])], []) 1277cdbfa754Smrg 1278cdbfa754Smrg AC_TRY_COMPILE([#include <wchar.h> 1279cdbfa754Smrg namespace test { using ::vwscanf; }], [], 1280cdbfa754Smrg [AC_DEFINE(HAVE_VWSCANF, 1, [Defined if vwscanf exists.])], []) 1281cdbfa754Smrg 1282cdbfa754Smrg AC_TRY_COMPILE([#include <wchar.h> 1283cdbfa754Smrg namespace test { using ::wcstof; }], [], 1284cdbfa754Smrg [AC_DEFINE(HAVE_WCSTOF, 1, [Defined if wcstof exists.])], []) 1285cdbfa754Smrg 1286cdbfa754Smrg AC_TRY_COMPILE([#include <wctype.h>], 1287cdbfa754Smrg [wint_t t; int i = iswblank(t);], 1288cdbfa754Smrg [AC_DEFINE(HAVE_ISWBLANK, 1, [Defined if iswblank exists.])], []) 1289cdbfa754Smrg 1290cdbfa754Smrg if test x"$glibcxx_cv_c99_wchar_cxx11" = x"yes"; then 1291cdbfa754Smrg AC_DEFINE(_GLIBCXX11_USE_C99_WCHAR, 1, 1292cdbfa754Smrg [Define if C99 functions or macros in <wchar.h> should be imported 1293cdbfa754Smrg in <cwchar> in namespace std for C++11.]) 1294cdbfa754Smrg fi 1295cdbfa754Smrg fi 1296cdbfa754Smrg 1297cdbfa754Smrg gcc_no_link="$ac_save_gcc_no_link" 1298cdbfa754Smrg LIBS="$ac_save_LIBS" 1299cdbfa754Smrg CXXFLAGS="$ac_save_CXXFLAGS" 1300cdbfa754Smrg AC_LANG_RESTORE 13014fee23f9Smrg fi 13024fee23f9Smrg 13034fee23f9Smrg AC_MSG_CHECKING([for fully enabled ISO C99 support]) 13044fee23f9Smrg AC_MSG_RESULT($enable_c99) 13054fee23f9Smrg]) 13064fee23f9Smrg 13074fee23f9Smrg 13084fee23f9Smrgdnl 13094fee23f9Smrgdnl Check for clock_gettime, nanosleep and sched_yield, used in the 131048fb7bfaSmrgdnl implementation of 20.11.7 [time.clock], and 30.3.2 [thread.thread.this] 131148fb7bfaSmrgdnl in the C++11 standard. 13124fee23f9Smrgdnl 13134fee23f9Smrgdnl --enable-libstdcxx-time 13144fee23f9Smrgdnl --enable-libstdcxx-time=yes 13154fee23f9Smrgdnl checks for the availability of monotonic and realtime clocks, 1316e9e6e0f6Smrgdnl nanosleep and sched_yield in libc. 13174fee23f9Smrgdnl --enable-libstdcxx-time=rt 131848fb7bfaSmrgdnl also searches (and, if needed, links) librt. Note that this is 1319d35849d0Smrgdnl not always desirable because, in glibc 2.16 and earlier, for 1320d35849d0Smrgdnl example, in turn it triggers the linking of libpthread too, 1321d35849d0Smrgdnl which activates locking, 13224fee23f9Smrgdnl a large overhead for single-thread programs. 13234fee23f9Smrgdnl --enable-libstdcxx-time=no 13244fee23f9Smrgdnl --disable-libstdcxx-time 13254fee23f9Smrgdnl disables the checks completely 13264fee23f9Smrgdnl 132748fb7bfaSmrgdnl N.B. Darwin provides nanosleep but doesn't support the whole POSIX 132848fb7bfaSmrgdnl Timers option, so doesn't define _POSIX_TIMERS. Because the test 132948fb7bfaSmrgdnl below fails Darwin unconditionally defines _GLIBCXX_USE_NANOSLEEP in 133048fb7bfaSmrgdnl os_defines.h and also defines _GLIBCXX_USE_SCHED_YIELD. 133148fb7bfaSmrgdnl 13324fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ 13334fee23f9Smrg 1334d35849d0Smrg GLIBCXX_ENABLE(libstdcxx-time,auto,[[[=KIND]]], 13354fee23f9Smrg [use KIND for check type], 13364fee23f9Smrg [permit yes|no|rt]) 13374fee23f9Smrg 13384fee23f9Smrg AC_LANG_SAVE 13394fee23f9Smrg AC_LANG_CPLUSPLUS 13404fee23f9Smrg ac_save_CXXFLAGS="$CXXFLAGS" 13414fee23f9Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 13424fee23f9Smrg ac_save_LIBS="$LIBS" 13434fee23f9Smrg 13444fee23f9Smrg ac_has_clock_monotonic=no 13454fee23f9Smrg ac_has_clock_realtime=no 1346d35849d0Smrg ac_has_nanosleep=no 1347d35849d0Smrg ac_has_sched_yield=no 13484fee23f9Smrg 1349d35849d0Smrg if test x"$enable_libstdcxx_time" = x"auto"; then 1350d35849d0Smrg 1351d35849d0Smrg case "${target_os}" in 1352d35849d0Smrg cygwin*) 1353d35849d0Smrg ac_has_nanosleep=yes 1354d35849d0Smrg ;; 1355d35849d0Smrg darwin*) 1356d35849d0Smrg ac_has_nanosleep=yes 1357d35849d0Smrg ac_has_sched_yield=yes 1358d35849d0Smrg ;; 135943265c03Smrg # VxWorks has nanosleep as soon as the kernel is configured with 136043265c03Smrg # INCLUDE_POSIX_TIMERS, which is normally/most-often the case. 136143265c03Smrg vxworks*) 136243265c03Smrg ac_has_nanosleep=yes 136343265c03Smrg ;; 1364d35849d0Smrg gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) 136583b68139Smrg # Don't use link test for freestanding library, in case gcc_no_link=yes 136683b68139Smrg if test x"$is_hosted" = xyes; then 136783b68139Smrg # Versions of glibc before 2.17 needed -lrt for clock_gettime. 136883b68139Smrg AC_SEARCH_LIBS(clock_gettime, [rt]) 136983b68139Smrg if test x"$ac_cv_search_clock_gettime" = x"none required"; then 1370d35849d0Smrg ac_has_clock_monotonic=yes 1371d35849d0Smrg ac_has_clock_realtime=yes 1372d35849d0Smrg fi 137383b68139Smrg fi 1374d35849d0Smrg ac_has_nanosleep=yes 1375d35849d0Smrg ac_has_sched_yield=yes 1376d35849d0Smrg ;; 13773f8cba22Smrg freebsd*|netbsd*|dragonfly*|rtems*) 1378d35849d0Smrg ac_has_clock_monotonic=yes 1379d35849d0Smrg ac_has_clock_realtime=yes 1380d35849d0Smrg ac_has_nanosleep=yes 1381d35849d0Smrg ac_has_sched_yield=yes 1382d35849d0Smrg ;; 1383d35849d0Smrg openbsd*) 1384d35849d0Smrg ac_has_clock_monotonic=yes 1385d35849d0Smrg ac_has_clock_realtime=yes 1386d35849d0Smrg ac_has_nanosleep=yes 1387d35849d0Smrg ;; 1388d35849d0Smrg solaris*) 1389d35849d0Smrg ac_has_clock_monotonic=yes 1390d35849d0Smrg ac_has_clock_realtime=yes 1391d35849d0Smrg ac_has_nanosleep=yes 1392d35849d0Smrg ac_has_sched_yield=yes 1393d35849d0Smrg ;; 139443265c03Smrg uclinux*) 139543265c03Smrg ac_has_nanosleep=yes 139643265c03Smrg ac_has_sched_yield=yes 1397d35849d0Smrg esac 1398d35849d0Smrg 1399d35849d0Smrg elif test x"$enable_libstdcxx_time" != x"no"; then 14004fee23f9Smrg 14014fee23f9Smrg if test x"$enable_libstdcxx_time" = x"rt"; then 1402e9e6e0f6Smrg AC_SEARCH_LIBS(clock_gettime, [rt]) 1403e9e6e0f6Smrg AC_SEARCH_LIBS(nanosleep, [rt]) 14044fee23f9Smrg else 1405e9e6e0f6Smrg AC_CHECK_FUNC(clock_gettime) 1406e9e6e0f6Smrg AC_CHECK_FUNC(nanosleep) 14074fee23f9Smrg fi 14084fee23f9Smrg 14094fee23f9Smrg case "$ac_cv_search_clock_gettime" in 14104fee23f9Smrg -l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime 14114fee23f9Smrg ;; 14124fee23f9Smrg esac 14134fee23f9Smrg case "$ac_cv_search_nanosleep" in 14144fee23f9Smrg -l*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_nanosleep" 14154fee23f9Smrg ;; 14164fee23f9Smrg esac 14174fee23f9Smrg 1418e9e6e0f6Smrg AC_SEARCH_LIBS(sched_yield, [rt]) 14194fee23f9Smrg 14204fee23f9Smrg case "$ac_cv_search_sched_yield" in 14214fee23f9Smrg -lrt*) 14224fee23f9Smrg if test x"$enable_libstdcxx_time" = x"rt"; then 14234fee23f9Smrg GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield" 1424d35849d0Smrg ac_has_sched_yield=yes 14254fee23f9Smrg fi 14264fee23f9Smrg ;; 14274fee23f9Smrg *) 1428d35849d0Smrg ac_has_sched_yield=yes 14294fee23f9Smrg ;; 14304fee23f9Smrg esac 14314fee23f9Smrg 14324fee23f9Smrg AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no) 14334fee23f9Smrg 14344fee23f9Smrg if test x"$ac_has_unistd_h" = x"yes"; then 14354fee23f9Smrg AC_MSG_CHECKING([for monotonic clock]) 14364fee23f9Smrg AC_TRY_LINK( 14374fee23f9Smrg [#include <unistd.h> 14384fee23f9Smrg #include <time.h> 14394fee23f9Smrg ], 14404fee23f9Smrg [#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) 14414fee23f9Smrg timespec tp; 14424fee23f9Smrg #endif 14434fee23f9Smrg clock_gettime(CLOCK_MONOTONIC, &tp); 14444fee23f9Smrg ], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no]) 14454fee23f9Smrg 14464fee23f9Smrg AC_MSG_RESULT($ac_has_clock_monotonic) 14474fee23f9Smrg 14484fee23f9Smrg AC_MSG_CHECKING([for realtime clock]) 14494fee23f9Smrg AC_TRY_LINK( 14504fee23f9Smrg [#include <unistd.h> 14514fee23f9Smrg #include <time.h> 14524fee23f9Smrg ], 14534fee23f9Smrg [#if _POSIX_TIMERS > 0 14544fee23f9Smrg timespec tp; 14554fee23f9Smrg #endif 14564fee23f9Smrg clock_gettime(CLOCK_REALTIME, &tp); 14574fee23f9Smrg ], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no]) 14584fee23f9Smrg 14594fee23f9Smrg AC_MSG_RESULT($ac_has_clock_realtime) 14604fee23f9Smrg 14614fee23f9Smrg AC_MSG_CHECKING([for nanosleep]) 14624fee23f9Smrg AC_TRY_LINK( 14634fee23f9Smrg [#include <unistd.h> 14644fee23f9Smrg #include <time.h> 14654fee23f9Smrg ], 14664fee23f9Smrg [#if _POSIX_TIMERS > 0 14674fee23f9Smrg timespec tp; 14684fee23f9Smrg #endif 14694fee23f9Smrg nanosleep(&tp, 0); 14704fee23f9Smrg ], [ac_has_nanosleep=yes], [ac_has_nanosleep=no]) 14714fee23f9Smrg 14724fee23f9Smrg AC_MSG_RESULT($ac_has_nanosleep) 14734fee23f9Smrg fi 14744fee23f9Smrg fi 14754fee23f9Smrg 147648fb7bfaSmrg if test x"$ac_has_clock_monotonic" != x"yes"; then 147748fb7bfaSmrg case ${target_os} in 147843265c03Smrg linux* | uclinux*) 147948fb7bfaSmrg AC_MSG_CHECKING([for clock_gettime syscall]) 148048fb7bfaSmrg AC_TRY_COMPILE( 148148fb7bfaSmrg [#include <unistd.h> 148248fb7bfaSmrg #include <time.h> 148348fb7bfaSmrg #include <sys/syscall.h> 148448fb7bfaSmrg ], 148548fb7bfaSmrg [#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) 148648fb7bfaSmrg timespec tp; 148748fb7bfaSmrg #endif 148848fb7bfaSmrg syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &tp); 148948fb7bfaSmrg syscall(SYS_clock_gettime, CLOCK_REALTIME, &tp); 1490e9e6e0f6Smrg ], [ac_has_clock_gettime_syscall=yes], [ac_has_clock_gettime_syscall=no]) 1491e9e6e0f6Smrg AC_MSG_RESULT($ac_has_clock_gettime_syscall) 1492e9e6e0f6Smrg if test x"$ac_has_clock_gettime_syscall" = x"yes"; then 149348fb7bfaSmrg AC_DEFINE(_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL, 1, 149448fb7bfaSmrg [Defined if clock_gettime syscall has monotonic and realtime clock support. ]) 149548fb7bfaSmrg ac_has_clock_monotonic=yes 149648fb7bfaSmrg ac_has_clock_realtime=yes 1497e9e6e0f6Smrg AC_MSG_CHECKING([for struct timespec that matches syscall]) 1498e9e6e0f6Smrg AC_TRY_COMPILE( 1499e9e6e0f6Smrg [#include <time.h> 1500e9e6e0f6Smrg #include <sys/syscall.h> 1501e9e6e0f6Smrg ], 1502e9e6e0f6Smrg [#ifdef SYS_clock_gettime64 1503e9e6e0f6Smrg #if SYS_clock_gettime64 != SYS_clock_gettime 1504e9e6e0f6Smrg // We need to use SYS_clock_gettime and libc appears to 1505e9e6e0f6Smrg // also know about the SYS_clock_gettime64 syscall. 1506e9e6e0f6Smrg // Check that userspace doesn't use time64 version of timespec. 1507e9e6e0f6Smrg static_assert(sizeof(timespec::tv_sec) == sizeof(long), 1508e9e6e0f6Smrg "struct timespec must be compatible with SYS_clock_gettime"); 1509e9e6e0f6Smrg #endif 1510e9e6e0f6Smrg #endif 1511e9e6e0f6Smrg ], 1512e9e6e0f6Smrg [ac_timespec_matches_syscall=yes], 1513e9e6e0f6Smrg [ac_timespec_matches_syscall=no]) 1514e9e6e0f6Smrg AC_MSG_RESULT($ac_timespec_matches_syscall) 1515e9e6e0f6Smrg if test x"$ac_timespec_matches_syscall" = no; then 1516e9e6e0f6Smrg AC_MSG_ERROR([struct timespec is not compatible with SYS_clock_gettime, please report a bug to http://gcc.gnu.org/bugzilla]) 1517e9e6e0f6Smrg fi 151848fb7bfaSmrg fi;; 151948fb7bfaSmrg esac 152048fb7bfaSmrg fi 152148fb7bfaSmrg 15224fee23f9Smrg if test x"$ac_has_clock_monotonic" = x"yes"; then 15234fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC, 1, 15244fee23f9Smrg [ Defined if clock_gettime has monotonic clock support. ]) 15254fee23f9Smrg fi 15264fee23f9Smrg 15274fee23f9Smrg if test x"$ac_has_clock_realtime" = x"yes"; then 15284fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_CLOCK_REALTIME, 1, 15294fee23f9Smrg [ Defined if clock_gettime has realtime clock support. ]) 15304fee23f9Smrg fi 15314fee23f9Smrg 1532d35849d0Smrg if test x"$ac_has_sched_yield" = x"yes"; then 1533d35849d0Smrg AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, 1534d35849d0Smrg [ Defined if sched_yield is available. ]) 1535d35849d0Smrg fi 1536d35849d0Smrg 15374fee23f9Smrg if test x"$ac_has_nanosleep" = x"yes"; then 15384fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1, 15394fee23f9Smrg [ Defined if nanosleep is available. ]) 154048fb7bfaSmrg else 154148fb7bfaSmrg AC_MSG_CHECKING([for sleep]) 154248fb7bfaSmrg AC_TRY_COMPILE([#include <unistd.h>], 154348fb7bfaSmrg [sleep(1)], 154448fb7bfaSmrg [ac_has_sleep=yes],[ac_has_sleep=no]) 154548fb7bfaSmrg if test x"$ac_has_sleep" = x"yes"; then 154648fb7bfaSmrg AC_DEFINE(HAVE_SLEEP,1, [Defined if sleep exists.]) 154748fb7bfaSmrg fi 154848fb7bfaSmrg AC_MSG_RESULT($ac_has_sleep) 154948fb7bfaSmrg AC_MSG_CHECKING([for usleep]) 155048fb7bfaSmrg AC_TRY_COMPILE([#include <unistd.h>], 155148fb7bfaSmrg [sleep(1); 155248fb7bfaSmrg usleep(100);], 155348fb7bfaSmrg [ac_has_usleep=yes],[ac_has_usleep=no]) 155448fb7bfaSmrg if test x"$ac_has_usleep" = x"yes"; then 155548fb7bfaSmrg AC_DEFINE(HAVE_USLEEP,1, [Defined if usleep exists.]) 155648fb7bfaSmrg fi 155748fb7bfaSmrg AC_MSG_RESULT($ac_has_usleep) 155848fb7bfaSmrg fi 155948fb7bfaSmrg 156048fb7bfaSmrg if test x"$ac_has_nanosleep$ac_has_sleep" = x"nono"; then 1561e9e6e0f6Smrg ac_no_sleep=yes 156248fb7bfaSmrg AC_MSG_CHECKING([for Sleep]) 156348fb7bfaSmrg AC_TRY_COMPILE([#include <windows.h>], 156448fb7bfaSmrg [Sleep(1)], 156548fb7bfaSmrg [ac_has_win32_sleep=yes],[ac_has_win32_sleep=no]) 156648fb7bfaSmrg if test x"$ac_has_win32_sleep" = x"yes"; then 156748fb7bfaSmrg AC_DEFINE(HAVE_WIN32_SLEEP,1, [Defined if Sleep exists.]) 1568e9e6e0f6Smrg ac_no_sleep=no 156948fb7bfaSmrg fi 157048fb7bfaSmrg AC_MSG_RESULT($ac_has_win32_sleep) 15714fee23f9Smrg fi 15724fee23f9Smrg 1573e9e6e0f6Smrg if test x"$ac_no_sleep" = x"yes"; then 1574e9e6e0f6Smrg AC_DEFINE(_GLIBCXX_NO_SLEEP,1, [Defined if no way to sleep is available.]) 1575e9e6e0f6Smrg fi 1576e9e6e0f6Smrg 15774fee23f9Smrg AC_SUBST(GLIBCXX_LIBS) 15784fee23f9Smrg 15794fee23f9Smrg CXXFLAGS="$ac_save_CXXFLAGS" 15804fee23f9Smrg LIBS="$ac_save_LIBS" 15814fee23f9Smrg AC_LANG_RESTORE 15824fee23f9Smrg]) 15834fee23f9Smrg 15844fee23f9Smrgdnl 158548fb7bfaSmrgdnl Check for gettimeofday, used in the implementation of 20.11.7 158648fb7bfaSmrgdnl [time.clock] in the C++11 standard. 15874fee23f9Smrgdnl 15884fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [ 15894fee23f9Smrg 15904fee23f9Smrg AC_MSG_CHECKING([for gettimeofday]) 15914fee23f9Smrg 15924fee23f9Smrg AC_LANG_SAVE 15934fee23f9Smrg AC_LANG_CPLUSPLUS 15944fee23f9Smrg ac_save_CXXFLAGS="$CXXFLAGS" 15954fee23f9Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 15964fee23f9Smrg 15974fee23f9Smrg ac_has_gettimeofday=no; 15984fee23f9Smrg AC_CHECK_HEADERS(sys/time.h, ac_has_sys_time_h=yes, ac_has_sys_time_h=no) 15994fee23f9Smrg if test x"$ac_has_sys_time_h" = x"yes"; then 16004fee23f9Smrg AC_MSG_CHECKING([for gettimeofday]) 16014fee23f9Smrg GCC_TRY_COMPILE_OR_LINK([#include <sys/time.h>], 16024fee23f9Smrg [timeval tv; gettimeofday(&tv, 0);], 16034fee23f9Smrg [ac_has_gettimeofday=yes], [ac_has_gettimeofday=no]) 16044fee23f9Smrg 16054fee23f9Smrg AC_MSG_RESULT($ac_has_gettimeofday) 16064fee23f9Smrg fi 16074fee23f9Smrg 16084fee23f9Smrg if test x"$ac_has_gettimeofday" = x"yes"; then 16094fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_GETTIMEOFDAY, 1, 16104fee23f9Smrg [ Defined if gettimeofday is available. ]) 16114fee23f9Smrg fi 16124fee23f9Smrg 16134fee23f9Smrg CXXFLAGS="$ac_save_CXXFLAGS" 16144fee23f9Smrg AC_LANG_RESTORE 16154fee23f9Smrg]) 16164fee23f9Smrg 16174fee23f9Smrgdnl 16184fee23f9Smrgdnl Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1" 16194fee23f9Smrgdnl facilities in Chapter 8, "C compatibility". 16204fee23f9Smrgdnl 16214fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_C99_TR1], [ 16224fee23f9Smrg 16234fee23f9Smrg AC_LANG_SAVE 16244fee23f9Smrg AC_LANG_CPLUSPLUS 16254fee23f9Smrg 1626*4fe0f936Smrg # Use -std=c++98 because -std=gnu++98 leaves __STRICT_ANSI__ 16274fee23f9Smrg # undefined and fake C99 facilities may be spuriously enabled. 16284fee23f9Smrg ac_save_CXXFLAGS="$CXXFLAGS" 16294fee23f9Smrg CXXFLAGS="$CXXFLAGS -std=c++98" 16304fee23f9Smrg 16314fee23f9Smrg # Check for the existence of <complex.h> complex math functions used 16324fee23f9Smrg # by tr1/complex. 16334fee23f9Smrg AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no) 16344fee23f9Smrg ac_c99_complex_tr1=no; 16354fee23f9Smrg if test x"$ac_has_complex_h" = x"yes"; then 16364fee23f9Smrg AC_MSG_CHECKING([for ISO C99 support to TR1 in <complex.h>]) 16374fee23f9Smrg AC_TRY_COMPILE([#include <complex.h>], 16384fee23f9Smrg [typedef __complex__ float float_type; float_type tmpf; 16394fee23f9Smrg cacosf(tmpf); 16404fee23f9Smrg casinf(tmpf); 16414fee23f9Smrg catanf(tmpf); 16424fee23f9Smrg cacoshf(tmpf); 16434fee23f9Smrg casinhf(tmpf); 16444fee23f9Smrg catanhf(tmpf); 16454fee23f9Smrg typedef __complex__ double double_type; double_type tmpd; 16464fee23f9Smrg cacos(tmpd); 16474fee23f9Smrg casin(tmpd); 16484fee23f9Smrg catan(tmpd); 16494fee23f9Smrg cacosh(tmpd); 16504fee23f9Smrg casinh(tmpd); 16514fee23f9Smrg catanh(tmpd); 16524fee23f9Smrg typedef __complex__ long double ld_type; ld_type tmpld; 16534fee23f9Smrg cacosl(tmpld); 16544fee23f9Smrg casinl(tmpld); 16554fee23f9Smrg catanl(tmpld); 16564fee23f9Smrg cacoshl(tmpld); 16574fee23f9Smrg casinhl(tmpld); 16584fee23f9Smrg catanhl(tmpld); 16594fee23f9Smrg ],[ac_c99_complex_tr1=yes], [ac_c99_complex_tr1=no]) 16604fee23f9Smrg fi 16614fee23f9Smrg AC_MSG_RESULT($ac_c99_complex_tr1) 16624fee23f9Smrg if test x"$ac_c99_complex_tr1" = x"yes"; then 16634fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX_TR1, 1, 16644fee23f9Smrg [Define if C99 functions in <complex.h> should be used in 16654fee23f9Smrg <tr1/complex>. Using compiler builtins for these functions 16664fee23f9Smrg requires corresponding C99 library functions to be present.]) 16674fee23f9Smrg fi 16684fee23f9Smrg 16694fee23f9Smrg # Check for the existence of <ctype.h> functions. 1670e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support to TR1 in <ctype.h>], 1671e9e6e0f6Smrg glibcxx_cv_c99_ctype_tr1, [ 16724fee23f9Smrg AC_TRY_COMPILE([#include <ctype.h>], 16734fee23f9Smrg [int ch; 16744fee23f9Smrg int ret; 16754fee23f9Smrg ret = isblank(ch); 16764fee23f9Smrg ],[glibcxx_cv_c99_ctype_tr1=yes], 16774fee23f9Smrg [glibcxx_cv_c99_ctype_tr1=no]) 16784fee23f9Smrg ]) 16794fee23f9Smrg if test x"$glibcxx_cv_c99_ctype_tr1" = x"yes"; then 16804fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_C99_CTYPE_TR1, 1, 16814fee23f9Smrg [Define if C99 functions in <ctype.h> should be imported in 16824fee23f9Smrg <tr1/cctype> in namespace std::tr1.]) 16834fee23f9Smrg fi 16844fee23f9Smrg 16854fee23f9Smrg # Check for the existence of <fenv.h> functions. 16864fee23f9Smrg AC_CHECK_HEADERS(fenv.h, ac_has_fenv_h=yes, ac_has_fenv_h=no) 16874fee23f9Smrg ac_c99_fenv_tr1=no; 16884fee23f9Smrg if test x"$ac_has_fenv_h" = x"yes"; then 16894fee23f9Smrg AC_MSG_CHECKING([for ISO C99 support to TR1 in <fenv.h>]) 16904fee23f9Smrg AC_TRY_COMPILE([#include <fenv.h>], 16914fee23f9Smrg [int except, mode; 16924fee23f9Smrg fexcept_t* pflag; 16934fee23f9Smrg fenv_t* penv; 16944fee23f9Smrg int ret; 16954fee23f9Smrg ret = feclearexcept(except); 16964fee23f9Smrg ret = fegetexceptflag(pflag, except); 16974fee23f9Smrg ret = feraiseexcept(except); 16984fee23f9Smrg ret = fesetexceptflag(pflag, except); 16994fee23f9Smrg ret = fetestexcept(except); 17004fee23f9Smrg ret = fegetround(); 17014fee23f9Smrg ret = fesetround(mode); 17024fee23f9Smrg ret = fegetenv(penv); 17034fee23f9Smrg ret = feholdexcept(penv); 17044fee23f9Smrg ret = fesetenv(penv); 17054fee23f9Smrg ret = feupdateenv(penv); 17064fee23f9Smrg ],[ac_c99_fenv_tr1=yes], [ac_c99_fenv_tr1=no]) 17074fee23f9Smrg AC_MSG_RESULT($ac_c99_fenv_tr1) 1708e9e6e0f6Smrg fi 17094fee23f9Smrg if test x"$ac_c99_fenv_tr1" = x"yes"; then 17104fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_C99_FENV_TR1, 1, 17114fee23f9Smrg [Define if C99 functions in <fenv.h> should be imported in 17124fee23f9Smrg <tr1/cfenv> in namespace std::tr1.]) 17134fee23f9Smrg fi 17144fee23f9Smrg 17154fee23f9Smrg # Check for the existence of <stdint.h> types. 1716e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support to TR1 in <stdint.h>], 1717e9e6e0f6Smrg glibcxx_cv_c99_stdint_tr1, [ 17184fee23f9Smrg AC_TRY_COMPILE([#define __STDC_LIMIT_MACROS 17194fee23f9Smrg #define __STDC_CONSTANT_MACROS 17204fee23f9Smrg #include <stdint.h>], 17214fee23f9Smrg [typedef int8_t my_int8_t; 17224fee23f9Smrg my_int8_t i8 = INT8_MIN; 17234fee23f9Smrg i8 = INT8_MAX; 17244fee23f9Smrg typedef int16_t my_int16_t; 17254fee23f9Smrg my_int16_t i16 = INT16_MIN; 17264fee23f9Smrg i16 = INT16_MAX; 17274fee23f9Smrg typedef int32_t my_int32_t; 17284fee23f9Smrg my_int32_t i32 = INT32_MIN; 17294fee23f9Smrg i32 = INT32_MAX; 17304fee23f9Smrg typedef int64_t my_int64_t; 17314fee23f9Smrg my_int64_t i64 = INT64_MIN; 17324fee23f9Smrg i64 = INT64_MAX; 17334fee23f9Smrg typedef int_fast8_t my_int_fast8_t; 17344fee23f9Smrg my_int_fast8_t if8 = INT_FAST8_MIN; 17354fee23f9Smrg if8 = INT_FAST8_MAX; 17364fee23f9Smrg typedef int_fast16_t my_int_fast16_t; 17374fee23f9Smrg my_int_fast16_t if16 = INT_FAST16_MIN; 17384fee23f9Smrg if16 = INT_FAST16_MAX; 17394fee23f9Smrg typedef int_fast32_t my_int_fast32_t; 17404fee23f9Smrg my_int_fast32_t if32 = INT_FAST32_MIN; 17414fee23f9Smrg if32 = INT_FAST32_MAX; 17424fee23f9Smrg typedef int_fast64_t my_int_fast64_t; 17434fee23f9Smrg my_int_fast64_t if64 = INT_FAST64_MIN; 17444fee23f9Smrg if64 = INT_FAST64_MAX; 17454fee23f9Smrg typedef int_least8_t my_int_least8_t; 17464fee23f9Smrg my_int_least8_t il8 = INT_LEAST8_MIN; 17474fee23f9Smrg il8 = INT_LEAST8_MAX; 17484fee23f9Smrg typedef int_least16_t my_int_least16_t; 17494fee23f9Smrg my_int_least16_t il16 = INT_LEAST16_MIN; 17504fee23f9Smrg il16 = INT_LEAST16_MAX; 17514fee23f9Smrg typedef int_least32_t my_int_least32_t; 17524fee23f9Smrg my_int_least32_t il32 = INT_LEAST32_MIN; 17534fee23f9Smrg il32 = INT_LEAST32_MAX; 17544fee23f9Smrg typedef int_least64_t my_int_least64_t; 17554fee23f9Smrg my_int_least64_t il64 = INT_LEAST64_MIN; 17564fee23f9Smrg il64 = INT_LEAST64_MAX; 17574fee23f9Smrg typedef intmax_t my_intmax_t; 17584fee23f9Smrg my_intmax_t im = INTMAX_MAX; 17594fee23f9Smrg im = INTMAX_MIN; 17604fee23f9Smrg typedef intptr_t my_intptr_t; 17614fee23f9Smrg my_intptr_t ip = INTPTR_MAX; 17624fee23f9Smrg ip = INTPTR_MIN; 17634fee23f9Smrg typedef uint8_t my_uint8_t; 17644fee23f9Smrg my_uint8_t ui8 = UINT8_MAX; 17654fee23f9Smrg ui8 = UINT8_MAX; 17664fee23f9Smrg typedef uint16_t my_uint16_t; 17674fee23f9Smrg my_uint16_t ui16 = UINT16_MAX; 17684fee23f9Smrg ui16 = UINT16_MAX; 17694fee23f9Smrg typedef uint32_t my_uint32_t; 17704fee23f9Smrg my_uint32_t ui32 = UINT32_MAX; 17714fee23f9Smrg ui32 = UINT32_MAX; 17724fee23f9Smrg typedef uint64_t my_uint64_t; 17734fee23f9Smrg my_uint64_t ui64 = UINT64_MAX; 17744fee23f9Smrg ui64 = UINT64_MAX; 17754fee23f9Smrg typedef uint_fast8_t my_uint_fast8_t; 17764fee23f9Smrg my_uint_fast8_t uif8 = UINT_FAST8_MAX; 17774fee23f9Smrg uif8 = UINT_FAST8_MAX; 17784fee23f9Smrg typedef uint_fast16_t my_uint_fast16_t; 17794fee23f9Smrg my_uint_fast16_t uif16 = UINT_FAST16_MAX; 17804fee23f9Smrg uif16 = UINT_FAST16_MAX; 17814fee23f9Smrg typedef uint_fast32_t my_uint_fast32_t; 17824fee23f9Smrg my_uint_fast32_t uif32 = UINT_FAST32_MAX; 17834fee23f9Smrg uif32 = UINT_FAST32_MAX; 17844fee23f9Smrg typedef uint_fast64_t my_uint_fast64_t; 17854fee23f9Smrg my_uint_fast64_t uif64 = UINT_FAST64_MAX; 17864fee23f9Smrg uif64 = UINT_FAST64_MAX; 17874fee23f9Smrg typedef uint_least8_t my_uint_least8_t; 17884fee23f9Smrg my_uint_least8_t uil8 = UINT_LEAST8_MAX; 17894fee23f9Smrg uil8 = UINT_LEAST8_MAX; 17904fee23f9Smrg typedef uint_least16_t my_uint_least16_t; 17914fee23f9Smrg my_uint_least16_t uil16 = UINT_LEAST16_MAX; 17924fee23f9Smrg uil16 = UINT_LEAST16_MAX; 17934fee23f9Smrg typedef uint_least32_t my_uint_least32_t; 17944fee23f9Smrg my_uint_least32_t uil32 = UINT_LEAST32_MAX; 17954fee23f9Smrg uil32 = UINT_LEAST32_MAX; 17964fee23f9Smrg typedef uint_least64_t my_uint_least64_t; 17974fee23f9Smrg my_uint_least64_t uil64 = UINT_LEAST64_MAX; 17984fee23f9Smrg uil64 = UINT_LEAST64_MAX; 17994fee23f9Smrg typedef uintmax_t my_uintmax_t; 18004fee23f9Smrg my_uintmax_t uim = UINTMAX_MAX; 18014fee23f9Smrg uim = UINTMAX_MAX; 18024fee23f9Smrg typedef uintptr_t my_uintptr_t; 18034fee23f9Smrg my_uintptr_t uip = UINTPTR_MAX; 18044fee23f9Smrg uip = UINTPTR_MAX; 18054fee23f9Smrg ],[glibcxx_cv_c99_stdint_tr1=yes], 18064fee23f9Smrg [glibcxx_cv_c99_stdint_tr1=no]) 18074fee23f9Smrg ]) 18084fee23f9Smrg if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then 18094fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_C99_STDINT_TR1, 1, 18104fee23f9Smrg [Define if C99 types in <stdint.h> should be imported in 18114fee23f9Smrg <tr1/cstdint> in namespace std::tr1.]) 18124fee23f9Smrg fi 18134fee23f9Smrg 18144fee23f9Smrg # Check for the existence of <math.h> functions. 1815e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 support to TR1 in <math.h>], 1816e9e6e0f6Smrg glibcxx_cv_c99_math_tr1, [ 18174fee23f9Smrg AC_TRY_COMPILE([#include <math.h>], 18184fee23f9Smrg [typedef double_t my_double_t; 18194fee23f9Smrg typedef float_t my_float_t; 18204fee23f9Smrg acosh(0.0); 18214fee23f9Smrg acoshf(0.0f); 18224fee23f9Smrg acoshl(0.0l); 18234fee23f9Smrg asinh(0.0); 18244fee23f9Smrg asinhf(0.0f); 18254fee23f9Smrg asinhl(0.0l); 18264fee23f9Smrg atanh(0.0); 18274fee23f9Smrg atanhf(0.0f); 18284fee23f9Smrg atanhl(0.0l); 18294fee23f9Smrg cbrt(0.0); 18304fee23f9Smrg cbrtf(0.0f); 18314fee23f9Smrg cbrtl(0.0l); 18324fee23f9Smrg copysign(0.0, 0.0); 18334fee23f9Smrg copysignf(0.0f, 0.0f); 18344fee23f9Smrg copysignl(0.0l, 0.0l); 18354fee23f9Smrg erf(0.0); 18364fee23f9Smrg erff(0.0f); 18374fee23f9Smrg erfl(0.0l); 18384fee23f9Smrg erfc(0.0); 18394fee23f9Smrg erfcf(0.0f); 18404fee23f9Smrg erfcl(0.0l); 18414fee23f9Smrg exp2(0.0); 18424fee23f9Smrg exp2f(0.0f); 18434fee23f9Smrg exp2l(0.0l); 18444fee23f9Smrg expm1(0.0); 18454fee23f9Smrg expm1f(0.0f); 18464fee23f9Smrg expm1l(0.0l); 18474fee23f9Smrg fdim(0.0, 0.0); 18484fee23f9Smrg fdimf(0.0f, 0.0f); 18494fee23f9Smrg fdiml(0.0l, 0.0l); 18504fee23f9Smrg fma(0.0, 0.0, 0.0); 18514fee23f9Smrg fmaf(0.0f, 0.0f, 0.0f); 18524fee23f9Smrg fmal(0.0l, 0.0l, 0.0l); 18534fee23f9Smrg fmax(0.0, 0.0); 18544fee23f9Smrg fmaxf(0.0f, 0.0f); 18554fee23f9Smrg fmaxl(0.0l, 0.0l); 18564fee23f9Smrg fmin(0.0, 0.0); 18574fee23f9Smrg fminf(0.0f, 0.0f); 18584fee23f9Smrg fminl(0.0l, 0.0l); 18594fee23f9Smrg hypot(0.0, 0.0); 18604fee23f9Smrg hypotf(0.0f, 0.0f); 18614fee23f9Smrg hypotl(0.0l, 0.0l); 18624fee23f9Smrg ilogb(0.0); 18634fee23f9Smrg ilogbf(0.0f); 18644fee23f9Smrg ilogbl(0.0l); 18654fee23f9Smrg lgamma(0.0); 18664fee23f9Smrg lgammaf(0.0f); 18674fee23f9Smrg lgammal(0.0l); 1868a41324a9Smrg #ifndef __APPLE__ /* see below */ 18694fee23f9Smrg llrint(0.0); 18704fee23f9Smrg llrintf(0.0f); 18714fee23f9Smrg llrintl(0.0l); 18724fee23f9Smrg llround(0.0); 18734fee23f9Smrg llroundf(0.0f); 18744fee23f9Smrg llroundl(0.0l); 1875a41324a9Smrg #endif 18764fee23f9Smrg log1p(0.0); 18774fee23f9Smrg log1pf(0.0f); 18784fee23f9Smrg log1pl(0.0l); 18794fee23f9Smrg log2(0.0); 18804fee23f9Smrg log2f(0.0f); 18814fee23f9Smrg log2l(0.0l); 18824fee23f9Smrg logb(0.0); 18834fee23f9Smrg logbf(0.0f); 18844fee23f9Smrg logbl(0.0l); 18854fee23f9Smrg lrint(0.0); 18864fee23f9Smrg lrintf(0.0f); 18874fee23f9Smrg lrintl(0.0l); 18884fee23f9Smrg lround(0.0); 18894fee23f9Smrg lroundf(0.0f); 18904fee23f9Smrg lroundl(0.0l); 1891*4fe0f936Smrg nan(""); 1892*4fe0f936Smrg nanf(""); 1893*4fe0f936Smrg nanl(""); 18944fee23f9Smrg nearbyint(0.0); 18954fee23f9Smrg nearbyintf(0.0f); 18964fee23f9Smrg nearbyintl(0.0l); 18974fee23f9Smrg nextafter(0.0, 0.0); 18984fee23f9Smrg nextafterf(0.0f, 0.0f); 18994fee23f9Smrg nextafterl(0.0l, 0.0l); 19004fee23f9Smrg nexttoward(0.0, 0.0); 19014fee23f9Smrg nexttowardf(0.0f, 0.0f); 19024fee23f9Smrg nexttowardl(0.0l, 0.0l); 19034fee23f9Smrg remainder(0.0, 0.0); 19044fee23f9Smrg remainderf(0.0f, 0.0f); 19054fee23f9Smrg remainderl(0.0l, 0.0l); 19064fee23f9Smrg remquo(0.0, 0.0, 0); 19074fee23f9Smrg remquof(0.0f, 0.0f, 0); 19084fee23f9Smrg remquol(0.0l, 0.0l, 0); 19094fee23f9Smrg rint(0.0); 19104fee23f9Smrg rintf(0.0f); 19114fee23f9Smrg rintl(0.0l); 19124fee23f9Smrg round(0.0); 19134fee23f9Smrg roundf(0.0f); 19144fee23f9Smrg roundl(0.0l); 19154fee23f9Smrg scalbln(0.0, 0l); 19164fee23f9Smrg scalblnf(0.0f, 0l); 19174fee23f9Smrg scalblnl(0.0l, 0l); 19184fee23f9Smrg scalbn(0.0, 0); 19194fee23f9Smrg scalbnf(0.0f, 0); 19204fee23f9Smrg scalbnl(0.0l, 0); 19214fee23f9Smrg tgamma(0.0); 19224fee23f9Smrg tgammaf(0.0f); 19234fee23f9Smrg tgammal(0.0l); 19244fee23f9Smrg trunc(0.0); 19254fee23f9Smrg truncf(0.0f); 19264fee23f9Smrg truncl(0.0l); 19274fee23f9Smrg ],[glibcxx_cv_c99_math_tr1=yes], [glibcxx_cv_c99_math_tr1=no]) 19284fee23f9Smrg ]) 19294fee23f9Smrg if test x"$glibcxx_cv_c99_math_tr1" = x"yes"; then 19304fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_C99_MATH_TR1, 1, 19314fee23f9Smrg [Define if C99 functions or macros in <math.h> should be imported 19324fee23f9Smrg in <tr1/cmath> in namespace std::tr1.]) 1933a41324a9Smrg 1934a41324a9Smrg case "${target_os}" in 1935a41324a9Smrg darwin*) 1936e9e6e0f6Smrg AC_CACHE_CHECK([for ISO C99 rounding functions in <math.h>], 1937e9e6e0f6Smrg glibcxx_cv_c99_math_llround, [ 1938a41324a9Smrg AC_TRY_COMPILE([#include <math.h>], 1939a41324a9Smrg [llrint(0.0); 1940a41324a9Smrg llrintf(0.0f); 1941a41324a9Smrg llrintl(0.0l); 1942a41324a9Smrg llround(0.0); 1943a41324a9Smrg llroundf(0.0f); 1944a41324a9Smrg llroundl(0.0l); 1945a41324a9Smrg ], 1946a41324a9Smrg [glibcxx_cv_c99_math_llround=yes], 1947a41324a9Smrg [glibcxx_cv_c99_math_llround=no]) 1948a41324a9Smrg ]) 1949a41324a9Smrg ;; 1950a41324a9Smrg esac 1951a41324a9Smrg if test x"$glibcxx_cv_c99_math_llround" = x"no"; then 1952a41324a9Smrg AC_DEFINE(_GLIBCXX_NO_C99_ROUNDING_FUNCS, 1, 1953a41324a9Smrg [Define if C99 llrint and llround functions are missing from <math.h>.]) 1954a41324a9Smrg fi 19554fee23f9Smrg fi 19564fee23f9Smrg 19574fee23f9Smrg # Check for the existence of <inttypes.h> functions (NB: doesn't make 19584fee23f9Smrg # sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1). 19594fee23f9Smrg ac_c99_inttypes_tr1=no; 19604fee23f9Smrg if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then 19614fee23f9Smrg AC_MSG_CHECKING([for ISO C99 support to TR1 in <inttypes.h>]) 19624fee23f9Smrg AC_TRY_COMPILE([#include <inttypes.h>], 19634fee23f9Smrg [intmax_t i, numer, denom, base; 19644fee23f9Smrg const char* s; 19654fee23f9Smrg char** endptr; 19664fee23f9Smrg intmax_t ret = imaxabs(i); 19674fee23f9Smrg imaxdiv_t dret = imaxdiv(numer, denom); 19684fee23f9Smrg ret = strtoimax(s, endptr, base); 19694fee23f9Smrg uintmax_t uret = strtoumax(s, endptr, base); 19704fee23f9Smrg ],[ac_c99_inttypes_tr1=yes], [ac_c99_inttypes_tr1=no]) 19714fee23f9Smrg AC_MSG_RESULT($ac_c99_inttypes_tr1) 1972e9e6e0f6Smrg fi 19734fee23f9Smrg if test x"$ac_c99_inttypes_tr1" = x"yes"; then 19744fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_TR1, 1, 19754fee23f9Smrg [Define if C99 functions in <inttypes.h> should be imported in 19764fee23f9Smrg <tr1/cinttypes> in namespace std::tr1.]) 19774fee23f9Smrg fi 19784fee23f9Smrg 1979d35849d0Smrg # Check for the existence of wchar_t <inttypes.h> functions (NB: doesn't 19804fee23f9Smrg # make sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1). 19814fee23f9Smrg ac_c99_inttypes_wchar_t_tr1=no; 19824fee23f9Smrg if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then 19834fee23f9Smrg AC_MSG_CHECKING([for wchar_t ISO C99 support to TR1 in <inttypes.h>]) 19844fee23f9Smrg AC_TRY_COMPILE([#include <inttypes.h>], 19854fee23f9Smrg [intmax_t base; 19864fee23f9Smrg const wchar_t* s; 19874fee23f9Smrg wchar_t** endptr; 19884fee23f9Smrg intmax_t ret = wcstoimax(s, endptr, base); 19894fee23f9Smrg uintmax_t uret = wcstoumax(s, endptr, base); 19904fee23f9Smrg ],[ac_c99_inttypes_wchar_t_tr1=yes], 19914fee23f9Smrg [ac_c99_inttypes_wchar_t_tr1=no]) 19924fee23f9Smrg AC_MSG_RESULT($ac_c99_inttypes_wchar_t_tr1) 1993e9e6e0f6Smrg fi 19944fee23f9Smrg if test x"$ac_c99_inttypes_wchar_t_tr1" = x"yes"; then 19954fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1, 1, 19964fee23f9Smrg [Define if wchar_t C99 functions in <inttypes.h> should be 19974fee23f9Smrg imported in <tr1/cinttypes> in namespace std::tr1.]) 19984fee23f9Smrg fi 19994fee23f9Smrg 20004fee23f9Smrg # Check for the existence of the <stdbool.h> header. 20014fee23f9Smrg AC_CHECK_HEADERS(stdbool.h) 20024fee23f9Smrg 200348fb7bfaSmrg # Check for the existence of the <stdalign.h> header. 200448fb7bfaSmrg AC_CHECK_HEADERS(stdalign.h) 200548fb7bfaSmrg 20064fee23f9Smrg CXXFLAGS="$ac_save_CXXFLAGS" 20074fee23f9Smrg AC_LANG_RESTORE 20084fee23f9Smrg]) 20094fee23f9Smrg 20104fee23f9Smrgdnl 2011cdbfa754Smrgdnl Check for uchar.h and usability. 2012cdbfa754Smrgdnl 2013cdbfa754SmrgAC_DEFUN([GLIBCXX_CHECK_UCHAR_H], [ 2014cdbfa754Smrg 2015cdbfa754Smrg # Test uchar.h. 2016cdbfa754Smrg AC_CHECK_HEADERS(uchar.h, ac_has_uchar_h=yes, ac_has_uchar_h=no) 2017cdbfa754Smrg 2018cdbfa754Smrg AC_LANG_SAVE 2019cdbfa754Smrg AC_LANG_CPLUSPLUS 2020cdbfa754Smrg ac_save_CXXFLAGS="$CXXFLAGS" 2021cdbfa754Smrg CXXFLAGS="$CXXFLAGS -std=c++11" 2022cdbfa754Smrg 2023cdbfa754Smrg if test x"$ac_has_uchar_h" = x"yes"; then 2024cdbfa754Smrg AC_MSG_CHECKING([for ISO C11 support for <uchar.h>]) 2025cdbfa754Smrg AC_TRY_COMPILE([#include <uchar.h> 2026cdbfa754Smrg #ifdef __STDC_UTF_16__ 2027cdbfa754Smrg long i = __STDC_UTF_16__; 2028cdbfa754Smrg #endif 2029cdbfa754Smrg #ifdef __STDC_UTF_32__ 2030cdbfa754Smrg long j = __STDC_UTF_32__; 2031cdbfa754Smrg #endif 2032cdbfa754Smrg namespace test 2033cdbfa754Smrg { 2034cdbfa754Smrg using ::c16rtomb; 2035cdbfa754Smrg using ::c32rtomb; 2036cdbfa754Smrg using ::mbrtoc16; 2037cdbfa754Smrg using ::mbrtoc32; 2038cdbfa754Smrg } 2039cdbfa754Smrg ], 2040cdbfa754Smrg [], [ac_c11_uchar_cxx11=yes], [ac_c11_uchar_cxx11=no]) 2041e9e6e0f6Smrg AC_MSG_RESULT($ac_c11_uchar_cxx11) 2042cdbfa754Smrg else 2043cdbfa754Smrg ac_c11_uchar_cxx11=no 2044cdbfa754Smrg fi 2045cdbfa754Smrg if test x"$ac_c11_uchar_cxx11" = x"yes"; then 2046cdbfa754Smrg AC_DEFINE(_GLIBCXX_USE_C11_UCHAR_CXX11, 1, 2047cdbfa754Smrg [Define if C11 functions in <uchar.h> should be imported into 2048cdbfa754Smrg namespace std in <cuchar>.]) 2049cdbfa754Smrg fi 2050cdbfa754Smrg 2051e9e6e0f6Smrg CXXFLAGS="$CXXFLAGS -fchar8_t" 2052e9e6e0f6Smrg if test x"$ac_has_uchar_h" = x"yes"; then 2053e9e6e0f6Smrg AC_MSG_CHECKING([for c8rtomb and mbrtoc8 in <uchar.h> with -fchar8_t]) 2054e9e6e0f6Smrg AC_TRY_COMPILE([#include <uchar.h> 2055e9e6e0f6Smrg namespace test 2056e9e6e0f6Smrg { 2057e9e6e0f6Smrg using ::c8rtomb; 2058e9e6e0f6Smrg using ::mbrtoc8; 2059e9e6e0f6Smrg } 2060e9e6e0f6Smrg ], 2061e9e6e0f6Smrg [], [ac_uchar_c8rtomb_mbrtoc8_fchar8_t=yes], 2062e9e6e0f6Smrg [ac_uchar_c8rtomb_mbrtoc8_fchar8_t=no]) 2063e9e6e0f6Smrg AC_MSG_RESULT($ac_uchar_c8rtomb_mbrtoc8_fchar8_t) 2064e9e6e0f6Smrg else 2065e9e6e0f6Smrg ac_uchar_c8rtomb_mbrtoc8_fchar8_t=no 2066e9e6e0f6Smrg fi 2067e9e6e0f6Smrg if test x"$ac_uchar_c8rtomb_mbrtoc8_fchar8_t" = x"yes"; then 2068e9e6e0f6Smrg AC_DEFINE(_GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_FCHAR8_T, 1, 2069e9e6e0f6Smrg [Define if c8rtomb and mbrtoc8 functions in <uchar.h> should be 2070e9e6e0f6Smrg imported into namespace std in <cuchar> for -fchar8_t.]) 2071e9e6e0f6Smrg fi 2072e9e6e0f6Smrg 2073e9e6e0f6Smrg CXXFLAGS="$CXXFLAGS -std=c++20" 2074e9e6e0f6Smrg if test x"$ac_has_uchar_h" = x"yes"; then 2075e9e6e0f6Smrg AC_MSG_CHECKING([for c8rtomb and mbrtoc8 in <uchar.h> with -std=c++20]) 2076e9e6e0f6Smrg AC_TRY_COMPILE([#include <uchar.h> 2077e9e6e0f6Smrg namespace test 2078e9e6e0f6Smrg { 2079e9e6e0f6Smrg using ::c8rtomb; 2080e9e6e0f6Smrg using ::mbrtoc8; 2081e9e6e0f6Smrg } 2082e9e6e0f6Smrg ], 2083e9e6e0f6Smrg [], [ac_uchar_c8rtomb_mbrtoc8_cxx20=yes], 2084e9e6e0f6Smrg [ac_uchar_c8rtomb_mbrtoc8_cxx20=no]) 2085e9e6e0f6Smrg AC_MSG_RESULT($ac_uchar_c8rtomb_mbrtoc8_cxx20) 2086e9e6e0f6Smrg else 2087e9e6e0f6Smrg ac_uchar_c8rtomb_mbrtoc8_cxx20=no 2088e9e6e0f6Smrg fi 2089e9e6e0f6Smrg if test x"$ac_uchar_c8rtomb_mbrtoc8_cxx20" = x"yes"; then 2090e9e6e0f6Smrg AC_DEFINE(_GLIBCXX_USE_UCHAR_C8RTOMB_MBRTOC8_CXX20, 1, 2091e9e6e0f6Smrg [Define if c8rtomb and mbrtoc8 functions in <uchar.h> should be 2092e9e6e0f6Smrg imported into namespace std in <cuchar> for C++20.]) 2093e9e6e0f6Smrg fi 2094e9e6e0f6Smrg 2095cdbfa754Smrg CXXFLAGS="$ac_save_CXXFLAGS" 2096cdbfa754Smrg AC_LANG_RESTORE 2097cdbfa754Smrg]) 2098cdbfa754Smrg 2099cdbfa754Smrg 2100cdbfa754Smrgdnl 2101654d12c0Smrgdnl Check whether "/dev/random" and "/dev/urandom" are available for 2102654d12c0Smrgdnl class std::random_device from C++ 2011 [rand.device], and 21034fee23f9Smrgdnl random_device of "TR1" (Chapter 5.1, "Random number generation"). 21044fee23f9Smrgdnl 2105654d12c0SmrgAC_DEFUN([GLIBCXX_CHECK_DEV_RANDOM], [ 21064fee23f9Smrg 2107e9e6e0f6Smrg AC_CACHE_CHECK([for "/dev/random" and "/dev/urandom" for std::random_device], 2108e9e6e0f6Smrg glibcxx_cv_dev_random, [ 21094fee23f9Smrg if test -r /dev/random && test -r /dev/urandom; then 2110654d12c0Smrg ## For MSys environment the test above is detected as false-positive 2111654d12c0Smrg ## on mingw-targets. So disable it explicitly for them. 211248fb7bfaSmrg case ${target_os} in 2113654d12c0Smrg *mingw*) glibcxx_cv_dev_random=no ;; 2114654d12c0Smrg *) glibcxx_cv_dev_random=yes ;; 211548fb7bfaSmrg esac 21164fee23f9Smrg else 2117654d12c0Smrg glibcxx_cv_dev_random=no; 21184fee23f9Smrg fi 21194fee23f9Smrg ]) 21204fee23f9Smrg 2121654d12c0Smrg if test x"$glibcxx_cv_dev_random" = x"yes"; then 2122654d12c0Smrg AC_DEFINE(_GLIBCXX_USE_DEV_RANDOM, 1, 2123654d12c0Smrg [Define if /dev/random and /dev/urandom are available for 2124654d12c0Smrg std::random_device.]) 21254fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1, 1, 21264fee23f9Smrg [Define if /dev/random and /dev/urandom are available for 21274fee23f9Smrg the random_device of TR1 (Chapter 5.1).]) 21284fee23f9Smrg fi 21294fee23f9Smrg 21304fee23f9Smrg]) 21314fee23f9Smrg 21324fee23f9Smrgdnl 213348fb7bfaSmrgdnl Compute the EOF, SEEK_CUR, and SEEK_END integer constants. 21344fee23f9Smrgdnl 213548fb7bfaSmrgAC_DEFUN([GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS], [ 21364fee23f9Smrg 2137e9e6e0f6Smrgif test "$is_hosted" = yes; then 213848fb7bfaSmrg AC_CACHE_CHECK([for the value of EOF], glibcxx_cv_stdio_eof, [ 213948fb7bfaSmrg AC_COMPUTE_INT([glibcxx_cv_stdio_eof], [[EOF]], 214048fb7bfaSmrg [#include <stdio.h>], 214148fb7bfaSmrg [AC_MSG_ERROR([computing EOF failed])]) 21424fee23f9Smrg ]) 214348fb7bfaSmrg AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_EOF, $glibcxx_cv_stdio_eof, 214448fb7bfaSmrg [Define to the value of the EOF integer constant.]) 21454fee23f9Smrg 214648fb7bfaSmrg AC_CACHE_CHECK([for the value of SEEK_CUR], glibcxx_cv_stdio_seek_cur, [ 214748fb7bfaSmrg AC_COMPUTE_INT([glibcxx_cv_stdio_seek_cur], [[SEEK_CUR]], 214848fb7bfaSmrg [#include <stdio.h>], 214948fb7bfaSmrg [AC_MSG_ERROR([computing SEEK_CUR failed])]) 215048fb7bfaSmrg ]) 215148fb7bfaSmrg AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_SEEK_CUR, $glibcxx_cv_stdio_seek_cur, 215248fb7bfaSmrg [Define to the value of the SEEK_CUR integer constant.]) 215348fb7bfaSmrg 215448fb7bfaSmrg AC_CACHE_CHECK([for the value of SEEK_END], glibcxx_cv_stdio_seek_end, [ 215548fb7bfaSmrg AC_COMPUTE_INT([glibcxx_cv_stdio_seek_end], [[SEEK_END]], 215648fb7bfaSmrg [#include <stdio.h>], 215748fb7bfaSmrg [AC_MSG_ERROR([computing SEEK_END failed])]) 215848fb7bfaSmrg ]) 215948fb7bfaSmrg AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_SEEK_END, $glibcxx_cv_stdio_seek_end, 216048fb7bfaSmrg [Define to the value of the SEEK_END integer constant.]) 2161e9e6e0f6Smrgfi 216248fb7bfaSmrg]) 216348fb7bfaSmrg 216448fb7bfaSmrgdnl 216548fb7bfaSmrgdnl Check whether required C++ overloads are present in <stdio.h>. 216648fb7bfaSmrgdnl 216748fb7bfaSmrgAC_DEFUN([GLIBCXX_CHECK_STDIO_PROTO], [ 216848fb7bfaSmrg 216948fb7bfaSmrg AC_LANG_SAVE 217048fb7bfaSmrg AC_LANG_CPLUSPLUS 2171cdbfa754Smrg # Use C++11 because a conforming <stdio.h> won't define gets for C++14, 2172cdbfa754Smrg # and we don't need a declaration for C++14 anyway. 2173cdbfa754Smrg ac_save_CXXFLAGS="$CXXFLAGS" 2174cdbfa754Smrg CXXFLAGS="$CXXFLAGS -std=gnu++11" 217548fb7bfaSmrg 2176e9e6e0f6Smrg AC_CACHE_CHECK([for gets declaration], glibcxx_cv_gets, [ 217748fb7bfaSmrg AC_COMPILE_IFELSE([AC_LANG_SOURCE( 217848fb7bfaSmrg [#include <stdio.h> 217948fb7bfaSmrg namespace test 218048fb7bfaSmrg { 218148fb7bfaSmrg using ::gets; 218248fb7bfaSmrg } 218348fb7bfaSmrg ])], 218448fb7bfaSmrg [glibcxx_cv_gets=yes], 218548fb7bfaSmrg [glibcxx_cv_gets=no] 218648fb7bfaSmrg )]) 218748fb7bfaSmrg 218848fb7bfaSmrg if test $glibcxx_cv_gets = yes; then 2189cdbfa754Smrg AC_DEFINE(HAVE_GETS, 1, [Define if gets is available in <stdio.h> before C++14.]) 219048fb7bfaSmrg fi 219148fb7bfaSmrg 2192cdbfa754Smrg CXXFLAGS="$ac_save_CXXFLAGS" 219348fb7bfaSmrg AC_LANG_RESTORE 21944fee23f9Smrg]) 21954fee23f9Smrg 21964fee23f9Smrgdnl 21970c98858fSmrgdnl Check whether required C++11 overloads for floating point and integral 21980c98858fSmrgdnl types are present in <math.h>. 2199d35849d0Smrgdnl 2200d35849d0SmrgAC_DEFUN([GLIBCXX_CHECK_MATH11_PROTO], [ 2201d35849d0Smrg 2202d35849d0Smrg AC_LANG_SAVE 2203d35849d0Smrg AC_LANG_CPLUSPLUS 2204d35849d0Smrg ac_save_CXXFLAGS="$CXXFLAGS" 2205d35849d0Smrg CXXFLAGS="$CXXFLAGS -std=c++11" 2206d35849d0Smrg 2207d35849d0Smrg case "$host" in 2208d35849d0Smrg *-*-solaris2.*) 22090c98858fSmrg # Solaris 12 Build 86, Solaris 11.3 SRU 3.6, and Solaris 10 Patch 22100c98858fSmrg # 11996[67]-02 introduced the C++11 <math.h> floating point overloads. 2211e9e6e0f6Smrg AC_CACHE_CHECK([for C++11 <math.h> floating point overloads], 2212e9e6e0f6Smrg glibcxx_cv_math11_fp_overload, [ 2213d35849d0Smrg AC_COMPILE_IFELSE([AC_LANG_SOURCE( 2214d35849d0Smrg [#include <math.h> 2215d35849d0Smrg #undef isfinite 2216d35849d0Smrg namespace std { 2217d35849d0Smrg inline bool isfinite(float __x) 2218d35849d0Smrg { return __builtin_isfinite(__x); } 2219d35849d0Smrg } 2220d35849d0Smrg ])], 22210c98858fSmrg [glibcxx_cv_math11_fp_overload=no], 22220c98858fSmrg [glibcxx_cv_math11_fp_overload=yes] 2223d35849d0Smrg )]) 2224d35849d0Smrg 2225d35849d0Smrg # autoheader cannot handle indented templates. 22260c98858fSmrg AH_VERBATIM([__CORRECT_ISO_CPP11_MATH_H_PROTO_FP], 22270c98858fSmrg [/* Define if all C++11 floating point overloads are available in <math.h>. */ 2228d35849d0Smrg#if __cplusplus >= 201103L 22290c98858fSmrg#undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2230d35849d0Smrg#endif]) 2231d35849d0Smrg 22320c98858fSmrg if test $glibcxx_cv_math11_fp_overload = yes; then 22330c98858fSmrg AC_DEFINE(__CORRECT_ISO_CPP11_MATH_H_PROTO_FP) 2234d35849d0Smrg fi 22350c98858fSmrg 22360c98858fSmrg # Solaris 12 Build 90, Solaris 11.3 SRU 5.6, and Solaris 10 Patch 22370c98858fSmrg # 11996[67]-02 introduced the C++11 <math.h> integral type overloads. 2238e9e6e0f6Smrg AC_CACHE_CHECK([for C++11 <math.h> integral type overloads], 2239e9e6e0f6Smrg glibcxx_cv_math11_int_overload, [ 22400c98858fSmrg AC_COMPILE_IFELSE([AC_LANG_SOURCE( 22410c98858fSmrg [#include <math.h> 22420c98858fSmrg namespace std { 22430c98858fSmrg template<typename _Tp> 22440c98858fSmrg struct __is_integer; 22450c98858fSmrg template<> 22460c98858fSmrg struct __is_integer<int> 22470c98858fSmrg { 22480c98858fSmrg enum { __value = 1 }; 22490c98858fSmrg }; 22500c98858fSmrg } 22510c98858fSmrg namespace __gnu_cxx { 22520c98858fSmrg template<bool, typename> 22530c98858fSmrg struct __enable_if; 22540c98858fSmrg template<typename _Tp> 22550c98858fSmrg struct __enable_if<true, _Tp> 22560c98858fSmrg { typedef _Tp __type; }; 22570c98858fSmrg } 22580c98858fSmrg namespace std { 22590c98858fSmrg template<typename _Tp> 22600c98858fSmrg constexpr typename __gnu_cxx::__enable_if 22610c98858fSmrg <__is_integer<_Tp>::__value, double>::__type 22620c98858fSmrg log2(_Tp __x) 22630c98858fSmrg { return __builtin_log2(__x); } 22640c98858fSmrg } 22650c98858fSmrg int 22660c98858fSmrg main (void) 22670c98858fSmrg { 22680c98858fSmrg int i = 1000; 22690c98858fSmrg return std::log2(i); 22700c98858fSmrg } 22710c98858fSmrg ])], 22720c98858fSmrg [glibcxx_cv_math11_int_overload=no], 22730c98858fSmrg [glibcxx_cv_math11_int_overload=yes] 22740c98858fSmrg )]) 22750c98858fSmrg 22760c98858fSmrg # autoheader cannot handle indented templates. 22770c98858fSmrg AH_VERBATIM([__CORRECT_ISO_CPP11_MATH_H_PROTO_INT], 22780c98858fSmrg [/* Define if all C++11 integral type overloads are available in <math.h>. */ 22790c98858fSmrg#if __cplusplus >= 201103L 22800c98858fSmrg#undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 22810c98858fSmrg#endif]) 22820c98858fSmrg 22830c98858fSmrg if test $glibcxx_cv_math11_int_overload = yes; then 22840c98858fSmrg AC_DEFINE(__CORRECT_ISO_CPP11_MATH_H_PROTO_INT) 22850c98858fSmrg fi 2286d35849d0Smrg ;; 2287cdbfa754Smrg *) 2288cdbfa754Smrg # If <math.h> defines the obsolete isinf(double) and isnan(double) 2289cdbfa754Smrg # functions (instead of or as well as the C99 generic macros) then we 2290cdbfa754Smrg # can't define std::isinf(double) and std::isnan(double) in <cmath> 2291cdbfa754Smrg # and must use the ones from <math.h> instead. 2292e9e6e0f6Smrg AC_CACHE_CHECK([for obsolete isinf function in <math.h>], 2293e9e6e0f6Smrg glibcxx_cv_obsolete_isinf, [ 2294cdbfa754Smrg AC_COMPILE_IFELSE([AC_LANG_SOURCE( 2295cdbfa754Smrg [#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS 2296cdbfa754Smrg #include <math.h> 2297cdbfa754Smrg #undef isinf 2298cdbfa754Smrg namespace std { 2299cdbfa754Smrg using ::isinf; 2300cdbfa754Smrg bool isinf(float); 2301cdbfa754Smrg bool isinf(long double); 2302cdbfa754Smrg } 2303cdbfa754Smrg using std::isinf; 2304cdbfa754Smrg bool b = isinf(0.0); 2305cdbfa754Smrg ])], 2306cdbfa754Smrg [glibcxx_cv_obsolete_isinf=yes], 2307cdbfa754Smrg [glibcxx_cv_obsolete_isinf=no] 2308cdbfa754Smrg )]) 2309cdbfa754Smrg if test $glibcxx_cv_obsolete_isinf = yes; then 2310cdbfa754Smrg AC_DEFINE(HAVE_OBSOLETE_ISINF, 1, 2311cdbfa754Smrg [Define if <math.h> defines obsolete isinf function.]) 2312cdbfa754Smrg fi 2313cdbfa754Smrg 2314e9e6e0f6Smrg AC_CACHE_CHECK([for obsolete isnan function in <math.h>], 2315e9e6e0f6Smrg glibcxx_cv_obsolete_isnan, [ 2316cdbfa754Smrg AC_COMPILE_IFELSE([AC_LANG_SOURCE( 2317cdbfa754Smrg [#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS 2318cdbfa754Smrg #include <math.h> 2319cdbfa754Smrg #undef isnan 2320cdbfa754Smrg namespace std { 2321cdbfa754Smrg using ::isnan; 2322cdbfa754Smrg bool isnan(float); 2323cdbfa754Smrg bool isnan(long double); 2324cdbfa754Smrg } 2325cdbfa754Smrg using std::isnan; 2326cdbfa754Smrg bool b = isnan(0.0); 2327cdbfa754Smrg ])], 2328cdbfa754Smrg [glibcxx_cv_obsolete_isnan=yes], 2329cdbfa754Smrg [glibcxx_cv_obsolete_isnan=no] 2330cdbfa754Smrg )]) 2331cdbfa754Smrg if test $glibcxx_cv_obsolete_isnan = yes; then 2332cdbfa754Smrg AC_DEFINE(HAVE_OBSOLETE_ISNAN, 1, 2333cdbfa754Smrg [Define if <math.h> defines obsolete isnan function.]) 2334cdbfa754Smrg fi 2335cdbfa754Smrg ;; 2336d35849d0Smrg esac 2337d35849d0Smrg 2338d35849d0Smrg CXXFLAGS="$ac_save_CXXFLAGS" 2339d35849d0Smrg AC_LANG_RESTORE 2340d35849d0Smrg]) 2341d35849d0Smrg 2342d35849d0Smrgdnl 23434fee23f9Smrgdnl Check for what type of C headers to use. 23444fee23f9Smrgdnl 23454fee23f9Smrgdnl --enable-cheaders= [does stuff]. 23464fee23f9Smrgdnl --disable-cheaders [does not do anything, really]. 23474fee23f9Smrgdnl + Usage: GLIBCXX_ENABLE_CHEADERS[(DEFAULT)] 2348e9e6e0f6Smrgdnl Where DEFAULT is either 'c' or 'c_global' or 'c_std'. 2349e9e6e0f6Smrgdnl 2350e9e6e0f6Smrgdnl To use the obsolete 'c_std' headers use --enable-cheaders-obsolete as 2351e9e6e0f6Smrgdnl well as --enable-cheaders=c_std, otherwise configure will fail. 23524fee23f9Smrgdnl 23534fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_CHEADERS], [ 2354e9e6e0f6Smrg GLIBCXX_ENABLE(cheaders-obsolete,no,, 2355e9e6e0f6Smrg [allow use of obsolete "C" headers for g++]) 235648fb7bfaSmrg GLIBCXX_ENABLE(cheaders,$1,[[[=KIND]]], 2357e9e6e0f6Smrg [construct "C" headers for g++], [permit c|c_global|c_std]) 23584fee23f9Smrg AC_MSG_NOTICE("C" header strategy set to $enable_cheaders) 2359e9e6e0f6Smrg if test $enable_cheaders = c_std ; then 2360e9e6e0f6Smrg AC_MSG_WARN([the --enable-cheaders=c_std configuration is obsolete, c_global should be used instead]) 2361e9e6e0f6Smrg AC_MSG_WARN([if you are unable to use c_global please report a bug or inform libstdc++@gcc.gnu.org]) 2362e9e6e0f6Smrg if test $enable_cheaders_obsolete != yes ; then 2363e9e6e0f6Smrg AC_MSG_ERROR(use --enable-cheaders-obsolete to use c_std "C" headers) 2364e9e6e0f6Smrg fi 2365e9e6e0f6Smrg fi 23664fee23f9Smrg 23674fee23f9Smrg C_INCLUDE_DIR='${glibcxx_srcdir}/include/'$enable_cheaders 23684fee23f9Smrg 23694fee23f9Smrg # Allow overrides to configure.host here. 23704fee23f9Smrg if test $enable_cheaders = c_global; then 23714fee23f9Smrg c_compatibility=yes 23724fee23f9Smrg fi 23734fee23f9Smrg 23744fee23f9Smrg AC_SUBST(C_INCLUDE_DIR) 23754fee23f9Smrg GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C, test $enable_cheaders = c) 23764fee23f9Smrg GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_STD, test $enable_cheaders = c_std) 23774fee23f9Smrg GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_GLOBAL, test $enable_cheaders = c_global) 23784fee23f9Smrg GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_COMPATIBILITY, test $c_compatibility = yes) 23794fee23f9Smrg]) 23804fee23f9Smrg 23814fee23f9Smrg 23824fee23f9Smrgdnl 23834fee23f9Smrgdnl Check for which locale library to use. The choice is mapped to 23844fee23f9Smrgdnl a subdirectory of config/locale. 23854fee23f9Smrgdnl 23864fee23f9Smrgdnl Default is generic. 23874fee23f9Smrgdnl 23884fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [ 238948fb7bfaSmrg GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]], 23904fee23f9Smrg [use MODEL for target locale package], 239148fb7bfaSmrg [permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto]) 23924fee23f9Smrg 23934fee23f9Smrg # Deal with gettext issues. Default to not using it (=no) until we detect 23944fee23f9Smrg # support for it later. Let the user turn it off via --e/d, but let that 23954fee23f9Smrg # default to on for easier handling. 23964fee23f9Smrg USE_NLS=no 23974fee23f9Smrg AC_ARG_ENABLE(nls, 23984fee23f9Smrg AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]), 23994fee23f9Smrg [], 24004fee23f9Smrg [enable_nls=yes]) 24014fee23f9Smrg 240248fb7bfaSmrg # Either a known package, or "auto" 24034fee23f9Smrg if test $enable_clocale = no || test $enable_clocale = yes; then 24044fee23f9Smrg enable_clocale=auto 24054fee23f9Smrg fi 24064fee23f9Smrg enable_clocale_flag=$enable_clocale 24074fee23f9Smrg 24084fee23f9Smrg # Probe for locale model to use if none specified. 24094fee23f9Smrg # Default to "generic". 24104fee23f9Smrg if test $enable_clocale_flag = auto; then 24114fee23f9Smrg case ${target_os} in 24124fee23f9Smrg linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu) 24134fee23f9Smrg enable_clocale_flag=gnu 24144fee23f9Smrg ;; 2415cdbfa754Smrg darwin*) 24164fee23f9Smrg enable_clocale_flag=darwin 24174fee23f9Smrg ;; 2418e9e6e0f6Smrg vxworks*) 2419e9e6e0f6Smrg enable_clocale_flag=vxworks 2420e9e6e0f6Smrg ;; 2421062a414cSchristos dragonfly* | freebsd* | netbsd*) 2422d35849d0Smrg enable_clocale_flag=dragonfly 2423d35849d0Smrg ;; 242448fb7bfaSmrg openbsd*) 242548fb7bfaSmrg enable_clocale_flag=newlib 242648fb7bfaSmrg ;; 24274fee23f9Smrg *) 242848fb7bfaSmrg if test x"$with_newlib" = x"yes"; then 242948fb7bfaSmrg enable_clocale_flag=newlib 243048fb7bfaSmrg else 24314fee23f9Smrg enable_clocale_flag=generic 243248fb7bfaSmrg fi 24334fee23f9Smrg ;; 24344fee23f9Smrg esac 24354fee23f9Smrg fi 24364fee23f9Smrg 24374fee23f9Smrg # Sanity check model, and test for special functionality. 24384fee23f9Smrg if test $enable_clocale_flag = gnu; then 24394fee23f9Smrg AC_EGREP_CPP([_GLIBCXX_ok], [ 24404fee23f9Smrg #include <features.h> 244148fb7bfaSmrg #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(__UCLIBC__) 24424fee23f9Smrg _GLIBCXX_ok 24434fee23f9Smrg #endif 24444fee23f9Smrg ], enable_clocale_flag=gnu, enable_clocale_flag=generic) 24454fee23f9Smrg 24464fee23f9Smrg # Set it to scream when it hurts. 24474fee23f9Smrg ac_save_CFLAGS="$CFLAGS" 24484fee23f9Smrg CFLAGS="-Wimplicit-function-declaration -Werror" 24494fee23f9Smrg 24504fee23f9Smrg # Use strxfrm_l if available. 24514fee23f9Smrg AC_TRY_COMPILE([#define _GNU_SOURCE 1 24524fee23f9Smrg #include <string.h> 24534fee23f9Smrg #include <locale.h>], 24544fee23f9Smrg [char s[128]; __locale_t loc; strxfrm_l(s, "C", 5, loc);], 24554fee23f9Smrg AC_DEFINE(HAVE_STRXFRM_L, 1, 24564fee23f9Smrg [Define if strxfrm_l is available in <string.h>.]),) 24574fee23f9Smrg 24584fee23f9Smrg # Use strerror_l if available. 24594fee23f9Smrg AC_TRY_COMPILE([#define _GNU_SOURCE 1 24604fee23f9Smrg #include <string.h> 24614fee23f9Smrg #include <locale.h>], 24624fee23f9Smrg [__locale_t loc; strerror_l(5, loc);], 24634fee23f9Smrg AC_DEFINE(HAVE_STRERROR_L, 1, 24644fee23f9Smrg [Define if strerror_l is available in <string.h>.]),) 24654fee23f9Smrg 24664fee23f9Smrg CFLAGS="$ac_save_CFLAGS" 24674fee23f9Smrg fi 24684fee23f9Smrg 24694fee23f9Smrg # Perhaps use strerror_r if available, and strerror_l isn't. 24704fee23f9Smrg ac_save_CFLAGS="$CFLAGS" 24714fee23f9Smrg CFLAGS="-Wimplicit-function-declaration -Werror" 24724fee23f9Smrg AC_TRY_COMPILE([#define _GNU_SOURCE 1 24734fee23f9Smrg #include <string.h> 24744fee23f9Smrg #include <locale.h>], 24754fee23f9Smrg [char s[128]; strerror_r(5, s, 128);], 24764fee23f9Smrg AC_DEFINE(HAVE_STRERROR_R, 1, 24774fee23f9Smrg [Define if strerror_r is available in <string.h>.]),) 24784fee23f9Smrg CFLAGS="$ac_save_CFLAGS" 24794fee23f9Smrg 24804fee23f9Smrg # Set configure bits for specified locale package 24814fee23f9Smrg AC_MSG_CHECKING([for C locale to use]) 24824fee23f9Smrg case ${enable_clocale_flag} in 24834fee23f9Smrg generic) 24844fee23f9Smrg AC_MSG_RESULT(generic) 24854fee23f9Smrg 24864fee23f9Smrg CLOCALE_H=config/locale/generic/c_locale.h 24874fee23f9Smrg CLOCALE_CC=config/locale/generic/c_locale.cc 24884fee23f9Smrg CCODECVT_CC=config/locale/generic/codecvt_members.cc 24894fee23f9Smrg CCOLLATE_CC=config/locale/generic/collate_members.cc 24904fee23f9Smrg CCTYPE_CC=config/locale/generic/ctype_members.cc 24914fee23f9Smrg CMESSAGES_H=config/locale/generic/messages_members.h 24924fee23f9Smrg CMESSAGES_CC=config/locale/generic/messages_members.cc 24934fee23f9Smrg CMONEY_CC=config/locale/generic/monetary_members.cc 24944fee23f9Smrg CNUMERIC_CC=config/locale/generic/numeric_members.cc 24954fee23f9Smrg CTIME_H=config/locale/generic/time_members.h 24964fee23f9Smrg CTIME_CC=config/locale/generic/time_members.cc 24974fee23f9Smrg CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h 24984fee23f9Smrg ;; 24994fee23f9Smrg darwin) 2500cdbfa754Smrg AC_MSG_RESULT(darwin) 25014fee23f9Smrg 25024fee23f9Smrg CLOCALE_H=config/locale/generic/c_locale.h 25034fee23f9Smrg CLOCALE_CC=config/locale/generic/c_locale.cc 25044fee23f9Smrg CCODECVT_CC=config/locale/generic/codecvt_members.cc 25054fee23f9Smrg CCOLLATE_CC=config/locale/generic/collate_members.cc 25064fee23f9Smrg CCTYPE_CC=config/locale/darwin/ctype_members.cc 25074fee23f9Smrg CMESSAGES_H=config/locale/generic/messages_members.h 25084fee23f9Smrg CMESSAGES_CC=config/locale/generic/messages_members.cc 25094fee23f9Smrg CMONEY_CC=config/locale/generic/monetary_members.cc 25104fee23f9Smrg CNUMERIC_CC=config/locale/generic/numeric_members.cc 25114fee23f9Smrg CTIME_H=config/locale/generic/time_members.h 25124fee23f9Smrg CTIME_CC=config/locale/generic/time_members.cc 25134fee23f9Smrg CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h 25144fee23f9Smrg ;; 2515e9e6e0f6Smrg vxworks) 2516e9e6e0f6Smrg AC_MSG_RESULT(vxworks) 25174fee23f9Smrg 2518e9e6e0f6Smrg CLOCALE_H=config/locale/generic/c_locale.h 2519e9e6e0f6Smrg CLOCALE_CC=config/locale/generic/c_locale.cc 2520e9e6e0f6Smrg CCODECVT_CC=config/locale/generic/codecvt_members.cc 2521e9e6e0f6Smrg CCOLLATE_CC=config/locale/generic/collate_members.cc 2522e9e6e0f6Smrg CCTYPE_CC=config/locale/vxworks/ctype_members.cc 2523e9e6e0f6Smrg CMESSAGES_H=config/locale/generic/messages_members.h 2524e9e6e0f6Smrg CMESSAGES_CC=config/locale/generic/messages_members.cc 2525e9e6e0f6Smrg CMONEY_CC=config/locale/generic/monetary_members.cc 2526e9e6e0f6Smrg CNUMERIC_CC=config/locale/generic/numeric_members.cc 2527e9e6e0f6Smrg CTIME_H=config/locale/generic/time_members.h 2528e9e6e0f6Smrg CTIME_CC=config/locale/generic/time_members.cc 2529e9e6e0f6Smrg CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h 2530e9e6e0f6Smrg ;; 2531d35849d0Smrg dragonfly) 2532062a414cSchristos AC_MSG_RESULT(dragonfly or freebsd or netbsd) 2533d35849d0Smrg 2534cdbfa754Smrg CLOCALE_H=config/locale/dragonfly/c_locale.h 2535d35849d0Smrg CLOCALE_CC=config/locale/dragonfly/c_locale.cc 2536cdbfa754Smrg CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc 2537cdbfa754Smrg CCOLLATE_CC=config/locale/dragonfly/collate_members.cc 2538d35849d0Smrg CCTYPE_CC=config/locale/dragonfly/ctype_members.cc 2539d35849d0Smrg CMESSAGES_H=config/locale/generic/messages_members.h 2540d35849d0Smrg CMESSAGES_CC=config/locale/generic/messages_members.cc 2541cdbfa754Smrg CMONEY_CC=config/locale/dragonfly/monetary_members.cc 2542cdbfa754Smrg CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc 2543cdbfa754Smrg CTIME_H=config/locale/dragonfly/time_members.h 2544cdbfa754Smrg CTIME_CC=config/locale/dragonfly/time_members.cc 2545d35849d0Smrg CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h 2546d35849d0Smrg ;; 2547d35849d0Smrg 25484fee23f9Smrg gnu) 25494fee23f9Smrg AC_MSG_RESULT(gnu) 25504fee23f9Smrg 25514fee23f9Smrg # Declare intention to use gettext, and add support for specific 25524fee23f9Smrg # languages. 25534fee23f9Smrg # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT 25544fee23f9Smrg ALL_LINGUAS="de fr" 25554fee23f9Smrg 25564fee23f9Smrg # Don't call AM-GNU-GETTEXT here. Instead, assume glibc. 25574fee23f9Smrg AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no) 25584fee23f9Smrg if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then 25594fee23f9Smrg USE_NLS=yes 25604fee23f9Smrg fi 25614fee23f9Smrg # Export the build objects. 25624fee23f9Smrg for ling in $ALL_LINGUAS; do \ 25634fee23f9Smrg glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \ 25644fee23f9Smrg glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \ 25654fee23f9Smrg done 25664fee23f9Smrg AC_SUBST(glibcxx_MOFILES) 25674fee23f9Smrg AC_SUBST(glibcxx_POFILES) 25684fee23f9Smrg 25694fee23f9Smrg CLOCALE_H=config/locale/gnu/c_locale.h 25704fee23f9Smrg CLOCALE_CC=config/locale/gnu/c_locale.cc 25714fee23f9Smrg CCODECVT_CC=config/locale/gnu/codecvt_members.cc 25724fee23f9Smrg CCOLLATE_CC=config/locale/gnu/collate_members.cc 25734fee23f9Smrg CCTYPE_CC=config/locale/gnu/ctype_members.cc 25744fee23f9Smrg CMESSAGES_H=config/locale/gnu/messages_members.h 25754fee23f9Smrg CMESSAGES_CC=config/locale/gnu/messages_members.cc 25764fee23f9Smrg CMONEY_CC=config/locale/gnu/monetary_members.cc 25774fee23f9Smrg CNUMERIC_CC=config/locale/gnu/numeric_members.cc 25784fee23f9Smrg CTIME_H=config/locale/gnu/time_members.h 25794fee23f9Smrg CTIME_CC=config/locale/gnu/time_members.cc 25804fee23f9Smrg CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h 25814fee23f9Smrg ;; 25824fee23f9Smrg ieee_1003.1-2001) 25834fee23f9Smrg AC_MSG_RESULT(IEEE 1003.1) 25844fee23f9Smrg 25854fee23f9Smrg CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h 25864fee23f9Smrg CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc 25874fee23f9Smrg CCODECVT_CC=config/locale/generic/codecvt_members.cc 25884fee23f9Smrg CCOLLATE_CC=config/locale/generic/collate_members.cc 25894fee23f9Smrg CCTYPE_CC=config/locale/generic/ctype_members.cc 25904fee23f9Smrg CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h 25914fee23f9Smrg CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc 25924fee23f9Smrg CMONEY_CC=config/locale/generic/monetary_members.cc 25934fee23f9Smrg CNUMERIC_CC=config/locale/generic/numeric_members.cc 25944fee23f9Smrg CTIME_H=config/locale/generic/time_members.h 25954fee23f9Smrg CTIME_CC=config/locale/generic/time_members.cc 25964fee23f9Smrg CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h 25974fee23f9Smrg ;; 259848fb7bfaSmrg newlib) 259948fb7bfaSmrg AC_MSG_RESULT(newlib) 260048fb7bfaSmrg 260148fb7bfaSmrg CLOCALE_H=config/locale/generic/c_locale.h 260248fb7bfaSmrg CLOCALE_CC=config/locale/generic/c_locale.cc 260348fb7bfaSmrg CCODECVT_CC=config/locale/generic/codecvt_members.cc 260448fb7bfaSmrg CCOLLATE_CC=config/locale/generic/collate_members.cc 260548fb7bfaSmrg CCTYPE_CC=config/locale/newlib/ctype_members.cc 260648fb7bfaSmrg CMESSAGES_H=config/locale/generic/messages_members.h 260748fb7bfaSmrg CMESSAGES_CC=config/locale/generic/messages_members.cc 260848fb7bfaSmrg CMONEY_CC=config/locale/generic/monetary_members.cc 260948fb7bfaSmrg CNUMERIC_CC=config/locale/generic/numeric_members.cc 261048fb7bfaSmrg CTIME_H=config/locale/generic/time_members.h 261148fb7bfaSmrg CTIME_CC=config/locale/generic/time_members.cc 261248fb7bfaSmrg CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h 261348fb7bfaSmrg ;; 26144fee23f9Smrg esac 26154fee23f9Smrg 26164fee23f9Smrg # This is where the testsuite looks for locale catalogs, using the 26174fee23f9Smrg # -DLOCALEDIR define during testsuite compilation. 26184fee23f9Smrg glibcxx_localedir=${glibcxx_builddir}/po/share/locale 26194fee23f9Smrg AC_SUBST(glibcxx_localedir) 26204fee23f9Smrg 26214fee23f9Smrg # A standalone libintl (e.g., GNU libintl) may be in use. 26224fee23f9Smrg if test $USE_NLS = yes; then 26234fee23f9Smrg AC_CHECK_HEADERS([libintl.h], [], USE_NLS=no) 26244fee23f9Smrg AC_SEARCH_LIBS(gettext, intl, [], USE_NLS=no) 26254fee23f9Smrg fi 26264fee23f9Smrg if test $USE_NLS = yes; then 26274fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_NLS, 1, 26284fee23f9Smrg [Define if NLS translations are to be used.]) 26294fee23f9Smrg fi 26304fee23f9Smrg 26314fee23f9Smrg AC_SUBST(USE_NLS) 26324fee23f9Smrg AC_SUBST(CLOCALE_H) 26334fee23f9Smrg AC_SUBST(CMESSAGES_H) 26344fee23f9Smrg AC_SUBST(CCODECVT_CC) 26354fee23f9Smrg AC_SUBST(CCOLLATE_CC) 26364fee23f9Smrg AC_SUBST(CCTYPE_CC) 26374fee23f9Smrg AC_SUBST(CMESSAGES_CC) 26384fee23f9Smrg AC_SUBST(CMONEY_CC) 26394fee23f9Smrg AC_SUBST(CNUMERIC_CC) 26404fee23f9Smrg AC_SUBST(CTIME_H) 26414fee23f9Smrg AC_SUBST(CTIME_CC) 26424fee23f9Smrg AC_SUBST(CLOCALE_CC) 26434fee23f9Smrg AC_SUBST(CLOCALE_INTERNAL_H) 26444fee23f9Smrg]) 26454fee23f9Smrg 26464fee23f9Smrg 26474fee23f9Smrgdnl 26484fee23f9Smrgdnl Check for which std::allocator base class to use. The choice is 26494fee23f9Smrgdnl mapped from a subdirectory of include/ext. 26504fee23f9Smrgdnl 26514fee23f9Smrgdnl Default is new. 26524fee23f9Smrgdnl 26534fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_ALLOCATOR], [ 26544fee23f9Smrg AC_MSG_CHECKING([for std::allocator base class]) 265548fb7bfaSmrg GLIBCXX_ENABLE(libstdcxx-allocator,auto,[[[=KIND]]], 26564fee23f9Smrg [use KIND for target std::allocator base], 2657e9e6e0f6Smrg [permit new|malloc|yes|no|auto]) 26584fee23f9Smrg 26594fee23f9Smrg # If they didn't use this option switch, or if they specified --enable 26604fee23f9Smrg # with no specific model, we'll have to look for one. If they 26614fee23f9Smrg # specified --disable (???), do likewise. 26624fee23f9Smrg if test $enable_libstdcxx_allocator = no || 26634fee23f9Smrg test $enable_libstdcxx_allocator = yes; 26644fee23f9Smrg then 26654fee23f9Smrg enable_libstdcxx_allocator=auto 26664fee23f9Smrg fi 26674fee23f9Smrg 26684fee23f9Smrg # Either a known package, or "auto". Auto implies the default choice 26694fee23f9Smrg # for a particular platform. 26704fee23f9Smrg enable_libstdcxx_allocator_flag=$enable_libstdcxx_allocator 26714fee23f9Smrg 26724fee23f9Smrg # Probe for host-specific support if no specific model is specified. 26734fee23f9Smrg # Default to "new". 26744fee23f9Smrg if test $enable_libstdcxx_allocator_flag = auto; then 26754fee23f9Smrg case ${target_os} in 26764fee23f9Smrg linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu) 26774fee23f9Smrg enable_libstdcxx_allocator_flag=new 26784fee23f9Smrg ;; 26794fee23f9Smrg *) 26804fee23f9Smrg enable_libstdcxx_allocator_flag=new 26814fee23f9Smrg ;; 26824fee23f9Smrg esac 26834fee23f9Smrg fi 26844fee23f9Smrg AC_MSG_RESULT($enable_libstdcxx_allocator_flag) 26854fee23f9Smrg 26864fee23f9Smrg 26874fee23f9Smrg # Set configure bits for specified locale package 26884fee23f9Smrg case ${enable_libstdcxx_allocator_flag} in 26894fee23f9Smrg malloc) 26904fee23f9Smrg ALLOCATOR_H=config/allocator/malloc_allocator_base.h 26914fee23f9Smrg ALLOCATOR_NAME=__gnu_cxx::malloc_allocator 26924fee23f9Smrg ;; 26934fee23f9Smrg new) 26944fee23f9Smrg ALLOCATOR_H=config/allocator/new_allocator_base.h 26954fee23f9Smrg ALLOCATOR_NAME=__gnu_cxx::new_allocator 26964fee23f9Smrg ;; 26974fee23f9Smrg esac 26984fee23f9Smrg 2699cdbfa754Smrg GLIBCXX_CONDITIONAL(ENABLE_ALLOCATOR_NEW, 2700cdbfa754Smrg test $enable_libstdcxx_allocator_flag = new) 27014fee23f9Smrg AC_SUBST(ALLOCATOR_H) 27024fee23f9Smrg AC_SUBST(ALLOCATOR_NAME) 27034fee23f9Smrg]) 27044fee23f9Smrg 27054fee23f9Smrg 27064fee23f9Smrgdnl 27074fee23f9Smrgdnl Check for whether the Boost-derived checks should be turned on. 27084fee23f9Smrgdnl 27094fee23f9Smrgdnl --enable-concept-checks turns them on. 27104fee23f9Smrgdnl --disable-concept-checks leaves them off. 27114fee23f9Smrgdnl + Usage: GLIBCXX_ENABLE_CONCEPT_CHECKS[(DEFAULT)] 27124fee23f9Smrgdnl Where DEFAULT is either `yes' or `no'. 27134fee23f9Smrgdnl 27144fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_CONCEPT_CHECKS], [ 27154fee23f9Smrg GLIBCXX_ENABLE(concept-checks,$1,,[use Boost-derived template checks]) 27164fee23f9Smrg if test $enable_concept_checks = yes; then 27174fee23f9Smrg AC_DEFINE(_GLIBCXX_CONCEPT_CHECKS, 1, 27184fee23f9Smrg [Define to use concept checking code from the boost libraries.]) 27194fee23f9Smrg fi 27204fee23f9Smrg]) 27214fee23f9Smrg 27224fee23f9Smrgdnl 272348fb7bfaSmrgdnl Use extern templates. 272448fb7bfaSmrgdnl 272548fb7bfaSmrgdnl --enable-extern-template defines _GLIBCXX_EXTERN_TEMPLATE to 1 272648fb7bfaSmrgdnl --disable-extern-template defines _GLIBCXX_EXTERN_TEMPLATE to 0 272748fb7bfaSmrg 272848fb7bfaSmrgdnl + Usage: GLIBCXX_ENABLE_TEMPLATE[(DEFAULT)] 272948fb7bfaSmrgdnl Where DEFAULT is `yes' or `no'. 273048fb7bfaSmrgdnl 273148fb7bfaSmrgAC_DEFUN([GLIBCXX_ENABLE_EXTERN_TEMPLATE], [ 273248fb7bfaSmrg 273348fb7bfaSmrg GLIBCXX_ENABLE(extern-template,$1,,[enable extern template]) 273448fb7bfaSmrg 273548fb7bfaSmrg AC_MSG_CHECKING([for extern template support]) 273648fb7bfaSmrg AC_MSG_RESULT([$enable_extern_template]) 273748fb7bfaSmrg 273848fb7bfaSmrg GLIBCXX_CONDITIONAL(ENABLE_EXTERN_TEMPLATE, test $enable_extern_template = yes) 273948fb7bfaSmrg]) 274048fb7bfaSmrg 274148fb7bfaSmrgdnl 2742d35849d0Smrgdnl Use vtable verification. 2743d35849d0Smrgdnl 2744d35849d0Smrgdnl --enable-vtable-verify defines _GLIBCXX_VTABLE_VERIFY to 1 2745d35849d0Smrgdnl --disable-vtable-verify defines _GLIBCXX_VTABLE_VERIFY to 0 2746d35849d0Smrg 2747d35849d0Smrgdnl + Usage: GLIBCXX_ENABLE_VTABLE_VERIFY[(DEFAULT)] 2748d35849d0Smrgdnl Where DEFAULT is `yes' or `no'. 2749d35849d0Smrgdnl 2750d35849d0SmrgAC_DEFUN([GLIBCXX_ENABLE_VTABLE_VERIFY], [ 2751d35849d0Smrg 2752d35849d0Smrg GLIBCXX_ENABLE(vtable-verify,$1,,[enable vtable verify]) 2753d35849d0Smrg 2754d35849d0Smrg AC_MSG_CHECKING([for vtable verify support]) 2755d35849d0Smrg AC_MSG_RESULT([$enable_vtable_verify]) 2756d35849d0Smrg 2757d35849d0Smrg vtv_cygmin=no 2758d35849d0Smrg if test $enable_vtable_verify = yes; then 2759d35849d0Smrg case ${target_os} in 2760d35849d0Smrg cygwin*|mingw32*) 2761d35849d0Smrg VTV_CXXFLAGS="-fvtable-verify=std -Wl,-lvtv,-u_vtable_map_vars_start,-u_vtable_map_vars_end" 2762cdbfa754Smrg VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,--rpath -Wl,${toplevel_builddir}/libvtv/.libs" 2763d35849d0Smrg vtv_cygmin=yes 2764d35849d0Smrg ;; 2765cdbfa754Smrg darwin*) 2766cdbfa754Smrg VTV_CXXFLAGS="-fvtable-verify=std -Wl,-u,_vtable_map_vars_start -Wl,-u,_vtable_map_vars_end" 2767cdbfa754Smrg VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,-rpath,${toplevel_builddir}/libvtv/.libs" 2768cdbfa754Smrg ;; 2769cdbfa754Smrg solaris2*) 2770cdbfa754Smrg VTV_CXXFLAGS="-fvtable-verify=std -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end" 2771cdbfa754Smrg VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,-R -Wl,${toplevel_builddir}/libvtv/.libs" 2772cdbfa754Smrg ;; 2773d35849d0Smrg *) 2774d35849d0Smrg VTV_CXXFLAGS="-fvtable-verify=std -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end" 2775cdbfa754Smrg VTV_CXXLINKFLAGS="-L${toplevel_builddir}/libvtv/.libs -Wl,--rpath -Wl,${toplevel_builddir}/libvtv/.libs" 2776d35849d0Smrg ;; 2777d35849d0Smrg esac 2778d35849d0Smrg VTV_PCH_CXXFLAGS="-fvtable-verify=std" 2779d35849d0Smrg else 2780d35849d0Smrg VTV_CXXFLAGS= 2781d35849d0Smrg VTV_PCH_CXXFLAGS= 2782d35849d0Smrg VTV_CXXLINKFLAGS= 2783d35849d0Smrg fi 2784d35849d0Smrg 2785d35849d0Smrg AC_SUBST(VTV_CXXFLAGS) 2786d35849d0Smrg AC_SUBST(VTV_PCH_CXXFLAGS) 2787d35849d0Smrg AC_SUBST(VTV_CXXLINKFLAGS) 2788d35849d0Smrg AM_CONDITIONAL(VTV_CYGMIN, test x$vtv_cygmin = xyes) 2789d35849d0Smrg GLIBCXX_CONDITIONAL(ENABLE_VTABLE_VERIFY, test $enable_vtable_verify = yes) 2790d35849d0Smrg]) 2791d35849d0Smrg 2792d35849d0Smrgdnl 27934fee23f9Smrgdnl Check for parallel mode pre-requisites, including OpenMP support. 27944fee23f9Smrgdnl 27954fee23f9Smrgdnl + Usage: GLIBCXX_ENABLE_PARALLEL 27964fee23f9Smrgdnl 27974fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_PARALLEL], [ 27984fee23f9Smrg 27994fee23f9Smrg enable_parallel=no; 28004fee23f9Smrg 28014fee23f9Smrg # See if configured libgomp/omp.h exists. (libgomp may be in 28024fee23f9Smrg # noconfigdirs but not explicitly disabled.) 28034fee23f9Smrg if echo " ${TARGET_CONFIGDIRS} " | grep " libgomp " > /dev/null 2>&1 ; then 28044fee23f9Smrg enable_parallel=yes; 28054fee23f9Smrg else 28064fee23f9Smrg AC_MSG_NOTICE([target-libgomp not built]) 28074fee23f9Smrg fi 28084fee23f9Smrg 28094fee23f9Smrg AC_MSG_CHECKING([for parallel mode support]) 28104fee23f9Smrg AC_MSG_RESULT([$enable_parallel]) 28114fee23f9Smrg]) 28124fee23f9Smrg 28134fee23f9Smrg 28144fee23f9Smrgdnl 2815e9e6e0f6Smrgdnl Check for which I/O library to use: stdio and POSIX, or pure stdio. 28164fee23f9Smrgdnl 2817e9e6e0f6Smrgdnl Default is stdio_posix. 28184fee23f9Smrgdnl 28194fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_CSTDIO], [ 28204fee23f9Smrg AC_MSG_CHECKING([for underlying I/O to use]) 282148fb7bfaSmrg GLIBCXX_ENABLE(cstdio,stdio,[[[=PACKAGE]]], 2822e9e6e0f6Smrg [use target-specific I/O package], [permit stdio|stdio_posix|stdio_pure]) 28234fee23f9Smrg 2824e9e6e0f6Smrg # The only available I/O model is based on stdio, via basic_file_stdio. 2825e9e6e0f6Smrg # The default "stdio" is actually "stdio + POSIX" because it uses fdopen(3) 2826e9e6e0f6Smrg # to get a file descriptor and then uses read(3) and write(3) with it. 2827e9e6e0f6Smrg # The "stdio_pure" model doesn't use fdopen and only uses FILE* for I/O. 28284fee23f9Smrg case ${enable_cstdio} in 2829e9e6e0f6Smrg stdio*) 28304fee23f9Smrg CSTDIO_H=config/io/c_io_stdio.h 28314fee23f9Smrg BASIC_FILE_H=config/io/basic_file_stdio.h 28324fee23f9Smrg BASIC_FILE_CC=config/io/basic_file_stdio.cc 2833e9e6e0f6Smrg 2834e9e6e0f6Smrg if test "x$enable_cstdio" = "xstdio_pure" ; then 2835e9e6e0f6Smrg AC_MSG_RESULT([stdio (without POSIX read/write)]) 2836e9e6e0f6Smrg AC_DEFINE(_GLIBCXX_USE_STDIO_PURE, 1, 2837e9e6e0f6Smrg [Define to restrict std::__basic_file<> to stdio APIs.]) 2838e9e6e0f6Smrg else 2839e9e6e0f6Smrg AC_MSG_RESULT([stdio (with POSIX read/write)]) 2840e9e6e0f6Smrg fi 28414fee23f9Smrg ;; 28424fee23f9Smrg esac 28434fee23f9Smrg 28444fee23f9Smrg AC_SUBST(CSTDIO_H) 28454fee23f9Smrg AC_SUBST(BASIC_FILE_H) 28464fee23f9Smrg AC_SUBST(BASIC_FILE_CC) 28474fee23f9Smrg]) 28484fee23f9Smrg 28494fee23f9Smrg 28504fee23f9Smrgdnl 28514fee23f9Smrgdnl Check for "unusual" flags to pass to the compiler while building. 28524fee23f9Smrgdnl 28534fee23f9Smrgdnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing 28544fee23f9Smrgdnl experimental flags such as -fpch, -fIMI, -Dfloat=char, etc. 28554fee23f9Smrgdnl --disable-cxx-flags passes nothing. 28564fee23f9Smrgdnl + See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html 28574fee23f9Smrgdnl http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html 28584fee23f9Smrgdnl http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html 28594fee23f9Smrgdnl + Usage: GLIBCXX_ENABLE_CXX_FLAGS(default flags) 28604fee23f9Smrgdnl If "default flags" is an empty string, the effect is the same 28614fee23f9Smrgdnl as --disable or --enable=no. 28624fee23f9Smrgdnl 28634fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_CXX_FLAGS], [dnl 28644fee23f9Smrg AC_MSG_CHECKING([for extra compiler flags for building]) 28654fee23f9Smrg GLIBCXX_ENABLE(cxx-flags,$1,[=FLAGS], 28664fee23f9Smrg [pass compiler FLAGS when building library], 28674fee23f9Smrg [case "x$enable_cxx_flags" in 28684fee23f9Smrg xno | x) enable_cxx_flags= ;; 28694fee23f9Smrg x-*) ;; 28704fee23f9Smrg *) AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;; 28714fee23f9Smrg esac]) 28724fee23f9Smrg 28734fee23f9Smrg # Run through flags (either default or command-line) and set anything 28744fee23f9Smrg # extra (e.g., #defines) that must accompany particular g++ options. 28754fee23f9Smrg if test -n "$enable_cxx_flags"; then 28764fee23f9Smrg for f in $enable_cxx_flags; do 28774fee23f9Smrg case "$f" in 28784fee23f9Smrg -fhonor-std) ;; 28794fee23f9Smrg -*) ;; 28804fee23f9Smrg *) # and we're trying to pass /what/ exactly? 28814fee23f9Smrg AC_MSG_ERROR([compiler flags start with a -]) ;; 28824fee23f9Smrg esac 28834fee23f9Smrg done 28844fee23f9Smrg fi 28854fee23f9Smrg 28864fee23f9Smrg EXTRA_CXX_FLAGS="$enable_cxx_flags" 28874fee23f9Smrg AC_MSG_RESULT($EXTRA_CXX_FLAGS) 28884fee23f9Smrg AC_SUBST(EXTRA_CXX_FLAGS) 28894fee23f9Smrg]) 28904fee23f9Smrg 28914fee23f9Smrg 28924fee23f9Smrgdnl 28934fee23f9Smrgdnl Check to see if debugging libraries are to be built. 28944fee23f9Smrgdnl 28954fee23f9Smrgdnl --enable-libstdcxx-debug 28964fee23f9Smrgdnl builds a separate set of debugging libraries in addition to the 28974fee23f9Smrgdnl normal (shared, static) libstdc++ binaries. 28984fee23f9Smrgdnl 28994fee23f9Smrgdnl --disable-libstdcxx-debug 29004fee23f9Smrgdnl builds only one (non-debug) version of libstdc++. 29014fee23f9Smrgdnl 29024fee23f9Smrgdnl --enable-libstdcxx-debug-flags=FLAGS 29034fee23f9Smrgdnl iff --enable-debug == yes, then use FLAGS to build the debug library. 29044fee23f9Smrgdnl 29054fee23f9Smrgdnl + Usage: GLIBCXX_ENABLE_DEBUG[(DEFAULT)] 29064fee23f9Smrgdnl Where DEFAULT is either `yes' or `no'. 29074fee23f9Smrgdnl 29084fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_DEBUG], [ 29094fee23f9Smrg AC_MSG_CHECKING([for additional debug build]) 291043265c03Smrg skip_debug_build= 29114fee23f9Smrg GLIBCXX_ENABLE(libstdcxx-debug,$1,,[build extra debug library]) 291243265c03Smrg if test x$enable_libstdcxx_debug = xyes; then 291343265c03Smrg if test -f $toplevel_builddir/../stage_final \ 291443265c03Smrg && test -f $toplevel_builddir/../stage_current; then 291543265c03Smrg stage_final=`cat $toplevel_builddir/../stage_final` 291643265c03Smrg stage_current=`cat $toplevel_builddir/../stage_current` 291743265c03Smrg if test x$stage_current != x$stage_final ; then 291843265c03Smrg skip_debug_build=" (skipped for bootstrap stage $stage_current)" 291943265c03Smrg enable_libstdcxx_debug=no 292043265c03Smrg fi 292143265c03Smrg fi 292243265c03Smrg fi 292343265c03Smrg AC_MSG_RESULT($enable_libstdcxx_debug$skip_debug_build) 29244fee23f9Smrg GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_DEBUG, test $enable_libstdcxx_debug = yes) 29254fee23f9Smrg]) 29264fee23f9Smrg 29274fee23f9Smrg 29284fee23f9Smrgdnl 29294fee23f9Smrgdnl Check for explicit debug flags. 29304fee23f9Smrgdnl 29314fee23f9Smrgdnl --enable-libstdcxx-debug-flags='-O1' 29324fee23f9Smrgdnl is a general method for passing flags to be used when 2933cdbfa754Smrgdnl building debug libraries with --enable-libstdcxx-debug. 29344fee23f9Smrgdnl 29354fee23f9Smrgdnl --disable-libstdcxx-debug-flags does nothing. 29364fee23f9Smrgdnl + Usage: GLIBCXX_ENABLE_DEBUG_FLAGS(default flags) 29374fee23f9Smrgdnl If "default flags" is an empty string, the effect is the same 29384fee23f9Smrgdnl as --disable or --enable=no. 29394fee23f9Smrgdnl 29404fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_DEBUG_FLAGS], [ 29414fee23f9Smrg GLIBCXX_ENABLE(libstdcxx-debug-flags,[$1],[=FLAGS], 29424fee23f9Smrg [pass compiler FLAGS when building debug library], 29434fee23f9Smrg [case "x$enable_libstdcxx_debug_flags" in 29444fee23f9Smrg xno | x) enable_libstdcxx_debug_flags= ;; 29454fee23f9Smrg x-*) ;; 29464fee23f9Smrg *) AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;; 29474fee23f9Smrg esac]) 29484fee23f9Smrg 29494fee23f9Smrg # Option parsed, now set things appropriately 29504fee23f9Smrg DEBUG_FLAGS="$enable_libstdcxx_debug_flags" 29514fee23f9Smrg AC_SUBST(DEBUG_FLAGS) 29524fee23f9Smrg 29534fee23f9Smrg AC_MSG_NOTICE([Debug build flags set to $DEBUG_FLAGS]) 29544fee23f9Smrg]) 29554fee23f9Smrg 29564fee23f9Smrg 29574fee23f9Smrgdnl 29584fee23f9Smrgdnl Check if the user only wants a freestanding library implementation. 29594fee23f9Smrgdnl 29604fee23f9Smrgdnl --disable-hosted-libstdcxx will turn off most of the library build, 29614fee23f9Smrgdnl installing only the headers required by [17.4.1.3] and the language 29624fee23f9Smrgdnl support library. More than that will be built (to keep the Makefiles 29634fee23f9Smrgdnl conveniently clean), but not installed. 29644fee23f9Smrgdnl 29654fee23f9Smrgdnl Sets: 29664fee23f9Smrgdnl is_hosted (yes/no) 29674fee23f9Smrgdnl 29684fee23f9Smrgdnl Defines: 29694fee23f9Smrgdnl _GLIBCXX_HOSTED (always defined, either to 1 or 0) 29704fee23f9Smrgdnl 29714fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_HOSTED], [ 29724fee23f9Smrg AC_ARG_ENABLE([hosted-libstdcxx], 29734fee23f9Smrg AC_HELP_STRING([--disable-hosted-libstdcxx], 29744fee23f9Smrg [only build freestanding C++ runtime support]),, 29754fee23f9Smrg [case "$host" in 29764fee23f9Smrg arm*-*-symbianelf*) 29774fee23f9Smrg enable_hosted_libstdcxx=no 29784fee23f9Smrg ;; 29794fee23f9Smrg *) 29804fee23f9Smrg enable_hosted_libstdcxx=yes 29814fee23f9Smrg ;; 29824fee23f9Smrg esac]) 2983e9e6e0f6Smrg freestanding_flags= 29844fee23f9Smrg if test "$enable_hosted_libstdcxx" = no; then 29854fee23f9Smrg AC_MSG_NOTICE([Only freestanding libraries will be built]) 29864fee23f9Smrg is_hosted=no 29874fee23f9Smrg hosted_define=0 29884fee23f9Smrg enable_abi_check=no 29894fee23f9Smrg enable_libstdcxx_pch=no 2990e9e6e0f6Smrg if test "x$with_headers" = xno; then 2991e9e6e0f6Smrg freestanding_flags="-ffreestanding" 2992e9e6e0f6Smrg fi 29934fee23f9Smrg else 29944fee23f9Smrg is_hosted=yes 29954fee23f9Smrg hosted_define=1 29964fee23f9Smrg fi 29974fee23f9Smrg GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes) 29984fee23f9Smrg AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define, 29994fee23f9Smrg [Define to 1 if a full hosted library is built, or 0 if freestanding.]) 3000e9e6e0f6Smrg FREESTANDING_FLAGS="$freestanding_flags" 3001e9e6e0f6Smrg AC_SUBST(FREESTANDING_FLAGS) 30024fee23f9Smrg]) 30034fee23f9Smrg 30044fee23f9Smrg 30054fee23f9Smrgdnl 300648fb7bfaSmrgdnl Check if the user wants a non-verbose library implementation. 300748fb7bfaSmrgdnl 300848fb7bfaSmrgdnl --disable-libstdcxx-verbose will turn off descriptive messages to 300948fb7bfaSmrgdnl standard error on termination. 301048fb7bfaSmrgdnl 301148fb7bfaSmrgdnl Defines: 301248fb7bfaSmrgdnl _GLIBCXX_VERBOSE (always defined, either to 1 or 0) 301348fb7bfaSmrgdnl 301448fb7bfaSmrgAC_DEFUN([GLIBCXX_ENABLE_VERBOSE], [ 301548fb7bfaSmrg AC_ARG_ENABLE([libstdcxx-verbose], 301648fb7bfaSmrg AC_HELP_STRING([--disable-libstdcxx-verbose], 301748fb7bfaSmrg [disable termination messages to standard error]),, 301848fb7bfaSmrg [enable_libstdcxx_verbose=yes]) 301948fb7bfaSmrg if test x"$enable_libstdcxx_verbose" = xyes; then 302048fb7bfaSmrg verbose_define=1 302148fb7bfaSmrg else 302248fb7bfaSmrg AC_MSG_NOTICE([verbose termination messages are disabled]) 302348fb7bfaSmrg verbose_define=0 302448fb7bfaSmrg fi 302548fb7bfaSmrg AC_DEFINE_UNQUOTED(_GLIBCXX_VERBOSE, $verbose_define, 302648fb7bfaSmrg [Define to 1 if a verbose library is built, or 0 otherwise.]) 302748fb7bfaSmrg]) 302848fb7bfaSmrg 302948fb7bfaSmrg 303048fb7bfaSmrgdnl 30314fee23f9Smrgdnl Check for template specializations for the 'long long' type. 30324fee23f9Smrgdnl The result determines only whether 'long long' I/O is enabled; things 30334fee23f9Smrgdnl like numeric_limits<> specializations are always available. 30344fee23f9Smrgdnl 30354fee23f9Smrgdnl --enable-long-long defines _GLIBCXX_USE_LONG_LONG 30364fee23f9Smrgdnl --disable-long-long leaves _GLIBCXX_USE_LONG_LONG undefined 30374fee23f9Smrgdnl + Usage: GLIBCXX_ENABLE_LONG_LONG[(DEFAULT)] 30384fee23f9Smrgdnl Where DEFAULT is either `yes' or `no'. 30394fee23f9Smrgdnl 30404fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_LONG_LONG], [ 30414fee23f9Smrg GLIBCXX_ENABLE(long-long,$1,,[enable template specializations for 'long long']) 30424fee23f9Smrg if test $enable_long_long = yes; then 30434fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_LONG_LONG, 1, 30444fee23f9Smrg [Define if code specialized for long long should be used.]) 30454fee23f9Smrg fi 30464fee23f9Smrg AC_MSG_CHECKING([for enabled long long specializations]) 30474fee23f9Smrg AC_MSG_RESULT([$enable_long_long]) 30484fee23f9Smrg]) 30494fee23f9Smrg 30504fee23f9Smrg 30514fee23f9Smrgdnl 30524fee23f9Smrgdnl Check for decimal floating point. 30534fee23f9Smrgdnl See: 30544fee23f9Smrgdnl http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html#Decimal-Float 30554fee23f9Smrgdnl 30564fee23f9Smrgdnl This checks to see if the host supports decimal floating point types. 30574fee23f9Smrgdnl 30584fee23f9Smrgdnl Defines: 30594fee23f9Smrgdnl _GLIBCXX_USE_DECIMAL_FLOAT 30604fee23f9Smrgdnl 30614fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_DECIMAL_FLOAT], [ 30624fee23f9Smrg 30634fee23f9Smrg # Fake what AC_TRY_COMPILE does, without linking as this is 30644fee23f9Smrg # unnecessary for this test. 30654fee23f9Smrg 30664fee23f9Smrg cat > conftest.$ac_ext << EOF 30674fee23f9Smrg[#]line __oline__ "configure" 30684fee23f9Smrgint main() 30694fee23f9Smrg{ 30704fee23f9Smrg _Decimal32 d1; 30714fee23f9Smrg _Decimal64 d2; 30724fee23f9Smrg _Decimal128 d3; 30734fee23f9Smrg return 0; 30744fee23f9Smrg} 30754fee23f9SmrgEOF 30764fee23f9Smrg 30774fee23f9Smrg AC_MSG_CHECKING([for ISO/IEC TR 24733 ]) 30784fee23f9Smrg if AC_TRY_EVAL(ac_compile); then 30794fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_DECIMAL_FLOAT, 1, 30804fee23f9Smrg [Define if ISO/IEC TR 24733 decimal floating point types are supported on this host.]) 30814fee23f9Smrg enable_dfp=yes 30824fee23f9Smrg else 30834fee23f9Smrg enable_dfp=no 30844fee23f9Smrg fi 30854fee23f9Smrg AC_MSG_RESULT($enable_dfp) 30864fee23f9Smrg rm -f conftest* 30874fee23f9Smrg]) 30884fee23f9Smrg 30894fee23f9Smrgdnl 3090e9e6e0f6Smrgdnl Check for GNU 128-bit floating point type. 309148fb7bfaSmrgdnl 3092e9e6e0f6Smrgdnl Note: also checks that the type isn't a standard types. 309348fb7bfaSmrgdnl 309448fb7bfaSmrgdnl Defines: 3095a41324a9Smrgdnl ENABLE_FLOAT128 309648fb7bfaSmrgdnl 3097e9e6e0f6SmrgAC_DEFUN([GLIBCXX_ENABLE_FLOAT128], [ 309848fb7bfaSmrg 309948fb7bfaSmrg AC_LANG_SAVE 310048fb7bfaSmrg AC_LANG_CPLUSPLUS 310148fb7bfaSmrg 310248fb7bfaSmrg # Fake what AC_TRY_COMPILE does, without linking as this is 310348fb7bfaSmrg # unnecessary for this test. 310448fb7bfaSmrg 310548fb7bfaSmrg cat > conftest.$ac_ext << EOF 310648fb7bfaSmrg[#]line __oline__ "configure" 310748fb7bfaSmrgtemplate<typename T1, typename T2> 310848fb7bfaSmrg struct same 310948fb7bfaSmrg { typedef T2 type; }; 311048fb7bfaSmrg 311148fb7bfaSmrgtemplate<typename T> 311248fb7bfaSmrg struct same<T, T>; 311348fb7bfaSmrg 311448fb7bfaSmrgint main() 311548fb7bfaSmrg{ 311648fb7bfaSmrg typename same<double, __float128>::type f1; 311748fb7bfaSmrg typename same<long double, __float128>::type f2; 311848fb7bfaSmrg} 311948fb7bfaSmrgEOF 312048fb7bfaSmrg 312148fb7bfaSmrg AC_MSG_CHECKING([for __float128]) 312248fb7bfaSmrg if AC_TRY_EVAL(ac_compile); then 312348fb7bfaSmrg enable_float128=yes 312448fb7bfaSmrg else 312548fb7bfaSmrg enable_float128=no 312648fb7bfaSmrg fi 312748fb7bfaSmrg AC_MSG_RESULT($enable_float128) 3128a41324a9Smrg GLIBCXX_CONDITIONAL(ENABLE_FLOAT128, test $enable_float128 = yes) 312948fb7bfaSmrg rm -f conftest* 313048fb7bfaSmrg 313148fb7bfaSmrg AC_LANG_RESTORE 313248fb7bfaSmrg]) 313348fb7bfaSmrg 313448fb7bfaSmrgdnl 31354fee23f9Smrgdnl Check for template specializations for the 'wchar_t' type. 31364fee23f9Smrgdnl 31374fee23f9Smrgdnl --enable-wchar_t defines _GLIBCXX_USE_WCHAR_T 31384fee23f9Smrgdnl --disable-wchar_t leaves _GLIBCXX_USE_WCHAR_T undefined 31394fee23f9Smrgdnl + Usage: GLIBCXX_ENABLE_WCHAR_T[(DEFAULT)] 31404fee23f9Smrgdnl Where DEFAULT is either `yes' or `no'. 31414fee23f9Smrgdnl 31424fee23f9Smrgdnl Necessary support must also be present. 31434fee23f9Smrgdnl 31444fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_WCHAR_T], [ 31454fee23f9Smrg GLIBCXX_ENABLE(wchar_t,$1,,[enable template specializations for 'wchar_t']) 31464fee23f9Smrg 31474fee23f9Smrg # Test wchar.h for mbstate_t, which is needed for char_traits and fpos. 31484fee23f9Smrg AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no) 31494fee23f9Smrg AC_MSG_CHECKING([for mbstate_t]) 31504fee23f9Smrg AC_TRY_COMPILE([#include <wchar.h>], 31514fee23f9Smrg [mbstate_t teststate;], 31524fee23f9Smrg have_mbstate_t=yes, have_mbstate_t=no) 31534fee23f9Smrg AC_MSG_RESULT($have_mbstate_t) 31544fee23f9Smrg if test x"$have_mbstate_t" = xyes; then 31554fee23f9Smrg AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.]) 31564fee23f9Smrg fi 31574fee23f9Smrg 31584fee23f9Smrg # Test it always, for use in GLIBCXX_ENABLE_C99, together with 31594fee23f9Smrg # ac_has_wchar_h. 31604fee23f9Smrg AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no) 31614fee23f9Smrg 31624fee23f9Smrg if test x"$enable_wchar_t" = x"yes"; then 31634fee23f9Smrg 31644fee23f9Smrg AC_LANG_SAVE 31654fee23f9Smrg AC_LANG_CPLUSPLUS 31664fee23f9Smrg 31674fee23f9Smrg if test x"$ac_has_wchar_h" = xyes && 31684fee23f9Smrg test x"$ac_has_wctype_h" = xyes; then 31694fee23f9Smrg AC_TRY_COMPILE([#include <wchar.h> 31704fee23f9Smrg #include <stddef.h> 31714fee23f9Smrg wint_t i; 31724fee23f9Smrg long l = WEOF; 31734fee23f9Smrg long j = WCHAR_MIN; 31744fee23f9Smrg long k = WCHAR_MAX; 31754fee23f9Smrg namespace test 31764fee23f9Smrg { 31774fee23f9Smrg using ::btowc; 31784fee23f9Smrg using ::fgetwc; 31794fee23f9Smrg using ::fgetws; 31804fee23f9Smrg using ::fputwc; 31814fee23f9Smrg using ::fputws; 31824fee23f9Smrg using ::fwide; 31834fee23f9Smrg using ::fwprintf; 31844fee23f9Smrg using ::fwscanf; 31854fee23f9Smrg using ::getwc; 31864fee23f9Smrg using ::getwchar; 31874fee23f9Smrg using ::mbrlen; 31884fee23f9Smrg using ::mbrtowc; 31894fee23f9Smrg using ::mbsinit; 31904fee23f9Smrg using ::mbsrtowcs; 31914fee23f9Smrg using ::putwc; 31924fee23f9Smrg using ::putwchar; 31934fee23f9Smrg using ::swprintf; 31944fee23f9Smrg using ::swscanf; 31954fee23f9Smrg using ::ungetwc; 31964fee23f9Smrg using ::vfwprintf; 31974fee23f9Smrg using ::vswprintf; 31984fee23f9Smrg using ::vwprintf; 31994fee23f9Smrg using ::wcrtomb; 32004fee23f9Smrg using ::wcscat; 32014fee23f9Smrg using ::wcschr; 32024fee23f9Smrg using ::wcscmp; 32034fee23f9Smrg using ::wcscoll; 32044fee23f9Smrg using ::wcscpy; 32054fee23f9Smrg using ::wcscspn; 32064fee23f9Smrg using ::wcsftime; 32074fee23f9Smrg using ::wcslen; 32084fee23f9Smrg using ::wcsncat; 32094fee23f9Smrg using ::wcsncmp; 32104fee23f9Smrg using ::wcsncpy; 32114fee23f9Smrg using ::wcspbrk; 32124fee23f9Smrg using ::wcsrchr; 32134fee23f9Smrg using ::wcsrtombs; 32144fee23f9Smrg using ::wcsspn; 32154fee23f9Smrg using ::wcsstr; 32164fee23f9Smrg using ::wcstod; 32174fee23f9Smrg using ::wcstok; 32184fee23f9Smrg using ::wcstol; 32194fee23f9Smrg using ::wcstoul; 32204fee23f9Smrg using ::wcsxfrm; 32214fee23f9Smrg using ::wctob; 32224fee23f9Smrg using ::wmemchr; 32234fee23f9Smrg using ::wmemcmp; 32244fee23f9Smrg using ::wmemcpy; 32254fee23f9Smrg using ::wmemmove; 32264fee23f9Smrg using ::wmemset; 32274fee23f9Smrg using ::wprintf; 32284fee23f9Smrg using ::wscanf; 32294fee23f9Smrg } 32304fee23f9Smrg ],[],[], [enable_wchar_t=no]) 32314fee23f9Smrg else 32324fee23f9Smrg enable_wchar_t=no 32334fee23f9Smrg fi 32344fee23f9Smrg 32354fee23f9Smrg AC_LANG_RESTORE 32364fee23f9Smrg fi 32374fee23f9Smrg 32384fee23f9Smrg if test x"$enable_wchar_t" = x"yes"; then 32394fee23f9Smrg AC_DEFINE(_GLIBCXX_USE_WCHAR_T, 1, 32404fee23f9Smrg [Define if code specialized for wchar_t should be used.]) 32414fee23f9Smrg fi 32424fee23f9Smrg 32434fee23f9Smrg AC_MSG_CHECKING([for enabled wchar_t specializations]) 32444fee23f9Smrg AC_MSG_RESULT([$enable_wchar_t]) 32454fee23f9Smrg]) 32464fee23f9Smrg 32474fee23f9Smrg 32484fee23f9Smrgdnl 32494fee23f9Smrgdnl Check to see if building and using a C++ precompiled header can be done. 32504fee23f9Smrgdnl 32514fee23f9Smrgdnl --enable-libstdcxx-pch=yes 32524fee23f9Smrgdnl default, this shows intent to use stdc++.h.gch If it looks like it 32534fee23f9Smrgdnl may work, after some light-hearted attempts to puzzle out compiler 32544fee23f9Smrgdnl support, flip bits on in include/Makefile.am 32554fee23f9Smrgdnl 32564fee23f9Smrgdnl --disable-libstdcxx-pch 32574fee23f9Smrgdnl turns off attempts to use or build stdc++.h.gch. 32584fee23f9Smrgdnl 32594fee23f9Smrgdnl Substs: 32604fee23f9Smrgdnl glibcxx_PCHFLAGS 32614fee23f9Smrgdnl 32624fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_PCH], [ 32634fee23f9Smrg GLIBCXX_ENABLE(libstdcxx-pch,$1,,[build pre-compiled libstdc++ headers]) 32644fee23f9Smrg if test $enable_libstdcxx_pch = yes; then 32654fee23f9Smrg AC_CACHE_CHECK([for compiler with PCH support], 32664fee23f9Smrg [glibcxx_cv_prog_CXX_pch], 32674fee23f9Smrg [ac_save_CXXFLAGS="$CXXFLAGS" 32684fee23f9Smrg CXXFLAGS="$CXXFLAGS -Werror -Winvalid-pch -Wno-deprecated" 32694fee23f9Smrg AC_LANG_SAVE 32704fee23f9Smrg AC_LANG_CPLUSPLUS 32714fee23f9Smrg echo '#include <math.h>' > conftest.h 32724fee23f9Smrg if $CXX $CXXFLAGS $CPPFLAGS -x c++-header conftest.h \ 32734fee23f9Smrg -o conftest.h.gch 1>&5 2>&1 && 32744fee23f9Smrg echo '#error "pch failed"' > conftest.h && 32754fee23f9Smrg echo '#include "conftest.h"' > conftest.cc && 32764fee23f9Smrg $CXX -c $CXXFLAGS $CPPFLAGS conftest.cc 1>&5 2>&1 ; 32774fee23f9Smrg then 32784fee23f9Smrg glibcxx_cv_prog_CXX_pch=yes 32794fee23f9Smrg else 32804fee23f9Smrg glibcxx_cv_prog_CXX_pch=no 32814fee23f9Smrg fi 32824fee23f9Smrg rm -f conftest* 32834fee23f9Smrg CXXFLAGS=$ac_save_CXXFLAGS 32844fee23f9Smrg AC_LANG_RESTORE 32854fee23f9Smrg ]) 32864fee23f9Smrg enable_libstdcxx_pch=$glibcxx_cv_prog_CXX_pch 32874fee23f9Smrg fi 32884fee23f9Smrg 32894fee23f9Smrg AC_MSG_CHECKING([for enabled PCH]) 32904fee23f9Smrg AC_MSG_RESULT([$enable_libstdcxx_pch]) 32914fee23f9Smrg 32924fee23f9Smrg GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_PCH, test $enable_libstdcxx_pch = yes) 32934fee23f9Smrg if test $enable_libstdcxx_pch = yes; then 32944fee23f9Smrg glibcxx_PCHFLAGS="-include bits/stdc++.h" 32954fee23f9Smrg else 32964fee23f9Smrg glibcxx_PCHFLAGS="" 32974fee23f9Smrg fi 32984fee23f9Smrg AC_SUBST(glibcxx_PCHFLAGS) 32994fee23f9Smrg]) 33004fee23f9Smrg 33014fee23f9Smrg 33024fee23f9Smrgdnl 33034fee23f9Smrgdnl Check for atomic builtins. 33044fee23f9Smrgdnl See: 330548fb7bfaSmrgdnl http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html 33064fee23f9Smrgdnl 33074fee23f9Smrgdnl This checks to see if the host supports the compiler-generated 33084fee23f9Smrgdnl builtins for atomic operations for various integral sizes. Note, this 33094fee23f9Smrgdnl is intended to be an all-or-nothing switch, so all the atomic operations 33104fee23f9Smrgdnl that are used should be checked. 33114fee23f9Smrgdnl 33124fee23f9Smrgdnl Note: 33134fee23f9Smrgdnl libgomp and libgfortran use a link test, see CHECK_SYNC_FETCH_AND_ADD. 33144fee23f9Smrgdnl 33154fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [ 33164fee23f9Smrg AC_LANG_SAVE 33174fee23f9Smrg AC_LANG_CPLUSPLUS 33184fee23f9Smrg old_CXXFLAGS="$CXXFLAGS" 33194fee23f9Smrg 33204fee23f9Smrg # Do link tests if possible, instead asm tests, limited to some platforms 33214fee23f9Smrg # see discussion in PR target/40134, PR libstdc++/40133 and the thread 33224fee23f9Smrg # starting at http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00322.html 33234fee23f9Smrg atomic_builtins_link_tests=no 33244fee23f9Smrg if test x$gcc_no_link != xyes; then 33254fee23f9Smrg # Can do link tests. Limit to some tested platforms 33264fee23f9Smrg case "$host" in 33274fee23f9Smrg *-*-linux* | *-*-uclinux* | *-*-kfreebsd*-gnu | *-*-gnu*) 33284fee23f9Smrg atomic_builtins_link_tests=yes 33294fee23f9Smrg ;; 33304fee23f9Smrg esac 33314fee23f9Smrg fi 33324fee23f9Smrg 33334fee23f9Smrg if test x$atomic_builtins_link_tests = xyes; then 33344fee23f9Smrg 33354fee23f9Smrg # Do link tests. 33364fee23f9Smrg 33374fee23f9Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 33384fee23f9Smrg 3339e9e6e0f6Smrg AC_CACHE_CHECK([for atomic builtins for bool], 3340e9e6e0f6Smrg glibcxx_cv_atomic_bool, [ 33414fee23f9Smrg AC_TRY_LINK( 33424fee23f9Smrg [ ], 33434fee23f9Smrg [typedef bool atomic_type; 33444fee23f9Smrg atomic_type c1; 33454fee23f9Smrg atomic_type c2; 334648fb7bfaSmrg atomic_type c3(0); 3347cdbfa754Smrg // N.B. __atomic_fetch_add is not supported for bool. 334848fb7bfaSmrg __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL, 334948fb7bfaSmrg __ATOMIC_RELAXED); 335048fb7bfaSmrg __atomic_test_and_set(&c1, __ATOMIC_RELAXED); 335148fb7bfaSmrg __atomic_load_n(&c1, __ATOMIC_RELAXED); 335248fb7bfaSmrg ], 33534fee23f9Smrg [glibcxx_cv_atomic_bool=yes], 33544fee23f9Smrg [glibcxx_cv_atomic_bool=no]) 33554fee23f9Smrg ]) 33564fee23f9Smrg 3357e9e6e0f6Smrg AC_CACHE_CHECK([for atomic builtins for short], 3358e9e6e0f6Smrg glibcxx_cv_atomic_short, [ 33594fee23f9Smrg AC_TRY_LINK( 33604fee23f9Smrg [ ], 33614fee23f9Smrg [typedef short atomic_type; 33624fee23f9Smrg atomic_type c1; 33634fee23f9Smrg atomic_type c2; 336448fb7bfaSmrg atomic_type c3(0); 336548fb7bfaSmrg __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED); 336648fb7bfaSmrg __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL, 336748fb7bfaSmrg __ATOMIC_RELAXED); 336848fb7bfaSmrg __atomic_test_and_set(&c1, __ATOMIC_RELAXED); 336948fb7bfaSmrg __atomic_load_n(&c1, __ATOMIC_RELAXED); 337048fb7bfaSmrg ], 33714fee23f9Smrg [glibcxx_cv_atomic_short=yes], 33724fee23f9Smrg [glibcxx_cv_atomic_short=no]) 33734fee23f9Smrg ]) 33744fee23f9Smrg 3375e9e6e0f6Smrg AC_CACHE_CHECK([for atomic builtins for int], 3376e9e6e0f6Smrg glibcxx_cv_atomic_int, [ 33774fee23f9Smrg AC_TRY_LINK( 33784fee23f9Smrg [ ], 33794fee23f9Smrg [typedef int atomic_type; 33804fee23f9Smrg atomic_type c1; 33814fee23f9Smrg atomic_type c2; 338248fb7bfaSmrg atomic_type c3(0); 338348fb7bfaSmrg __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED); 338448fb7bfaSmrg __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL, 338548fb7bfaSmrg __ATOMIC_RELAXED); 338648fb7bfaSmrg __atomic_test_and_set(&c1, __ATOMIC_RELAXED); 338748fb7bfaSmrg __atomic_load_n(&c1, __ATOMIC_RELAXED); 338848fb7bfaSmrg ], 33894fee23f9Smrg [glibcxx_cv_atomic_int=yes], 33904fee23f9Smrg [glibcxx_cv_atomic_int=no]) 33914fee23f9Smrg ]) 33924fee23f9Smrg 3393e9e6e0f6Smrg AC_CACHE_CHECK([for atomic builtins for long long], 3394e9e6e0f6Smrg glibcxx_cv_atomic_long_long, [ 33954fee23f9Smrg AC_TRY_LINK( 33964fee23f9Smrg [ ], 33974fee23f9Smrg [typedef long long atomic_type; 33984fee23f9Smrg atomic_type c1; 33994fee23f9Smrg atomic_type c2; 340048fb7bfaSmrg atomic_type c3(0); 340148fb7bfaSmrg __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED); 340248fb7bfaSmrg __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL, 340348fb7bfaSmrg __ATOMIC_RELAXED); 340448fb7bfaSmrg __atomic_test_and_set(&c1, __ATOMIC_RELAXED); 340548fb7bfaSmrg __atomic_load_n(&c1, __ATOMIC_RELAXED); 340648fb7bfaSmrg ], 34074fee23f9Smrg [glibcxx_cv_atomic_long_long=yes], 34084fee23f9Smrg [glibcxx_cv_atomic_long_long=no]) 34094fee23f9Smrg ]) 34104fee23f9Smrg 34114fee23f9Smrg else 34124fee23f9Smrg 34134fee23f9Smrg # Do asm tests. 34144fee23f9Smrg 34154fee23f9Smrg # Compile unoptimized. 34164fee23f9Smrg CXXFLAGS='-O0 -S' 34174fee23f9Smrg 34184fee23f9Smrg # Fake what AC_TRY_COMPILE does. 34194fee23f9Smrg 34204fee23f9Smrg cat > conftest.$ac_ext << EOF 34214fee23f9Smrg[#]line __oline__ "configure" 34224fee23f9Smrgint main() 34234fee23f9Smrg{ 34244fee23f9Smrg typedef bool atomic_type; 34254fee23f9Smrg atomic_type c1; 34264fee23f9Smrg atomic_type c2; 342748fb7bfaSmrg atomic_type c3(0); 3428cdbfa754Smrg // N.B. __atomic_fetch_add is not supported for bool. 342948fb7bfaSmrg __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL, 343048fb7bfaSmrg __ATOMIC_RELAXED); 343148fb7bfaSmrg __atomic_test_and_set(&c1, __ATOMIC_RELAXED); 343248fb7bfaSmrg __atomic_load_n(&c1, __ATOMIC_RELAXED); 343348fb7bfaSmrg 34344fee23f9Smrg return 0; 34354fee23f9Smrg} 34364fee23f9SmrgEOF 34374fee23f9Smrg 34384fee23f9Smrg AC_MSG_CHECKING([for atomic builtins for bool]) 34394fee23f9Smrg if AC_TRY_EVAL(ac_compile); then 344048fb7bfaSmrg if grep __atomic_ conftest.s >/dev/null 2>&1 ; then 34414fee23f9Smrg glibcxx_cv_atomic_bool=no 34424fee23f9Smrg else 34434fee23f9Smrg glibcxx_cv_atomic_bool=yes 34444fee23f9Smrg fi 34454fee23f9Smrg fi 34464fee23f9Smrg AC_MSG_RESULT($glibcxx_cv_atomic_bool) 34474fee23f9Smrg rm -f conftest* 34484fee23f9Smrg 34494fee23f9Smrg cat > conftest.$ac_ext << EOF 34504fee23f9Smrg[#]line __oline__ "configure" 34514fee23f9Smrgint main() 34524fee23f9Smrg{ 34534fee23f9Smrg typedef short atomic_type; 34544fee23f9Smrg atomic_type c1; 34554fee23f9Smrg atomic_type c2; 345648fb7bfaSmrg atomic_type c3(0); 345748fb7bfaSmrg __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED); 345848fb7bfaSmrg __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL, 345948fb7bfaSmrg __ATOMIC_RELAXED); 346048fb7bfaSmrg __atomic_test_and_set(&c1, __ATOMIC_RELAXED); 346148fb7bfaSmrg __atomic_load_n(&c1, __ATOMIC_RELAXED); 346248fb7bfaSmrg 34634fee23f9Smrg return 0; 34644fee23f9Smrg} 34654fee23f9SmrgEOF 34664fee23f9Smrg 34674fee23f9Smrg AC_MSG_CHECKING([for atomic builtins for short]) 34684fee23f9Smrg if AC_TRY_EVAL(ac_compile); then 346948fb7bfaSmrg if grep __atomic_ conftest.s >/dev/null 2>&1 ; then 34704fee23f9Smrg glibcxx_cv_atomic_short=no 34714fee23f9Smrg else 34724fee23f9Smrg glibcxx_cv_atomic_short=yes 34734fee23f9Smrg fi 34744fee23f9Smrg fi 34754fee23f9Smrg AC_MSG_RESULT($glibcxx_cv_atomic_short) 34764fee23f9Smrg rm -f conftest* 34774fee23f9Smrg 34784fee23f9Smrg cat > conftest.$ac_ext << EOF 34794fee23f9Smrg[#]line __oline__ "configure" 34804fee23f9Smrgint main() 34814fee23f9Smrg{ 34824fee23f9Smrg // NB: _Atomic_word not necessarily int. 34834fee23f9Smrg typedef int atomic_type; 34844fee23f9Smrg atomic_type c1; 34854fee23f9Smrg atomic_type c2; 348648fb7bfaSmrg atomic_type c3(0); 348748fb7bfaSmrg __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED); 348848fb7bfaSmrg __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL, 348948fb7bfaSmrg __ATOMIC_RELAXED); 349048fb7bfaSmrg __atomic_test_and_set(&c1, __ATOMIC_RELAXED); 349148fb7bfaSmrg __atomic_load_n(&c1, __ATOMIC_RELAXED); 349248fb7bfaSmrg 34934fee23f9Smrg return 0; 34944fee23f9Smrg} 34954fee23f9SmrgEOF 34964fee23f9Smrg 34974fee23f9Smrg AC_MSG_CHECKING([for atomic builtins for int]) 34984fee23f9Smrg if AC_TRY_EVAL(ac_compile); then 349948fb7bfaSmrg if grep __atomic_ conftest.s >/dev/null 2>&1 ; then 35004fee23f9Smrg glibcxx_cv_atomic_int=no 35014fee23f9Smrg else 35024fee23f9Smrg glibcxx_cv_atomic_int=yes 35034fee23f9Smrg fi 35044fee23f9Smrg fi 35054fee23f9Smrg AC_MSG_RESULT($glibcxx_cv_atomic_int) 35064fee23f9Smrg rm -f conftest* 35074fee23f9Smrg 35084fee23f9Smrg cat > conftest.$ac_ext << EOF 35094fee23f9Smrg[#]line __oline__ "configure" 35104fee23f9Smrgint main() 35114fee23f9Smrg{ 35124fee23f9Smrg typedef long long atomic_type; 35134fee23f9Smrg atomic_type c1; 35144fee23f9Smrg atomic_type c2; 351548fb7bfaSmrg atomic_type c3(0); 351648fb7bfaSmrg __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED); 351748fb7bfaSmrg __atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL, 351848fb7bfaSmrg __ATOMIC_RELAXED); 351948fb7bfaSmrg __atomic_test_and_set(&c1, __ATOMIC_RELAXED); 352048fb7bfaSmrg __atomic_load_n(&c1, __ATOMIC_RELAXED); 352148fb7bfaSmrg 35224fee23f9Smrg return 0; 35234fee23f9Smrg} 35244fee23f9SmrgEOF 35254fee23f9Smrg 35264fee23f9Smrg AC_MSG_CHECKING([for atomic builtins for long long]) 35274fee23f9Smrg if AC_TRY_EVAL(ac_compile); then 352848fb7bfaSmrg if grep __atomic_ conftest.s >/dev/null 2>&1 ; then 35294fee23f9Smrg glibcxx_cv_atomic_long_long=no 35304fee23f9Smrg else 35314fee23f9Smrg glibcxx_cv_atomic_long_long=yes 35324fee23f9Smrg fi 35334fee23f9Smrg fi 35344fee23f9Smrg AC_MSG_RESULT($glibcxx_cv_atomic_long_long) 35354fee23f9Smrg rm -f conftest* 35364fee23f9Smrg 35374fee23f9Smrg fi 35384fee23f9Smrg 35394fee23f9Smrg CXXFLAGS="$old_CXXFLAGS" 35404fee23f9Smrg AC_LANG_RESTORE 35414fee23f9Smrg 3542cdbfa754Smrg # Set atomicity_dir to builtins if all but the long long test above passes, 3543cdbfa754Smrg # or if the builtins were already chosen (e.g. by configure.host). 3544cdbfa754Smrg if { test "$glibcxx_cv_atomic_bool" = yes \ 3545cdbfa754Smrg && test "$glibcxx_cv_atomic_short" = yes \ 3546cdbfa754Smrg && test "$glibcxx_cv_atomic_int" = yes; } \ 3547cdbfa754Smrg || test "$atomicity_dir" = "cpu/generic/atomicity_builtins"; then 354848fb7bfaSmrg AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS, 1, 354948fb7bfaSmrg [Define if the compiler supports C++11 atomics.]) 35504fee23f9Smrg atomicity_dir=cpu/generic/atomicity_builtins 35514fee23f9Smrg fi 35524fee23f9Smrg 35534fee23f9Smrg # If still generic, set to mutex. 35544fee23f9Smrg if test $atomicity_dir = "cpu/generic" ; then 35554fee23f9Smrg atomicity_dir=cpu/generic/atomicity_mutex 35564fee23f9Smrg AC_MSG_WARN([No native atomic operations are provided for this platform.]) 35574fee23f9Smrg if test "x$target_thread_file" = xsingle; then 35584fee23f9Smrg AC_MSG_WARN([They cannot be faked when thread support is disabled.]) 35594fee23f9Smrg AC_MSG_WARN([Thread-safety of certain classes is not guaranteed.]) 35604fee23f9Smrg else 35614fee23f9Smrg AC_MSG_WARN([They will be faked using a mutex.]) 35624fee23f9Smrg AC_MSG_WARN([Performance of certain classes will degrade as a result.]) 35634fee23f9Smrg fi 35644fee23f9Smrg fi 35654fee23f9Smrg 35664fee23f9Smrg]) 35674fee23f9Smrg 3568654d12c0Smrgdnl 3569654d12c0Smrgdnl Set default lock policy for synchronizing shared_ptr reference counting. 3570654d12c0Smrgdnl 3571654d12c0Smrgdnl --with-libstdcxx-lock-policy=auto 3572654d12c0Smrgdnl Use atomic operations for shared_ptr reference counting only if 3573654d12c0Smrgdnl the default target supports atomic compare-and-swap. 3574654d12c0Smrgdnl --with-libstdcxx-lock-policy=atomic 3575654d12c0Smrgdnl Use atomic operations for shared_ptr reference counting. 3576654d12c0Smrgdnl --with-libstdcxx-lock-policy=mutex 3577654d12c0Smrgdnl Use a mutex to synchronize shared_ptr reference counting. 3578654d12c0Smrgdnl 3579654d12c0Smrgdnl This controls the value of __gnu_cxx::__default_lock_policy, which 3580654d12c0Smrgdnl determines how shared_ptr reference counts are synchronized. 3581654d12c0Smrgdnl The option "atomic" means that atomic operations should be used, 3582654d12c0Smrgdnl "mutex" means that a mutex will be used. The default option, "auto", 3583654d12c0Smrgdnl will check if the target supports the compiler-generated builtins 3584654d12c0Smrgdnl for atomic compare-and-swap operations for 2-byte and 4-byte integers, 3585654d12c0Smrgdnl and will use "atomic" if supported, "mutex" otherwise. 3586654d12c0Smrgdnl This option is ignored if the thread model used by GCC is "single", 3587654d12c0Smrgdnl as no synchronization is used at all in that case. 3588654d12c0Smrgdnl This option affects the library ABI (except in the "single" thread model). 3589654d12c0Smrgdnl 3590654d12c0Smrgdnl Defines _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY to 1 if atomics should be used. 3591654d12c0Smrgdnl 3592654d12c0SmrgAC_DEFUN([GLIBCXX_ENABLE_LOCK_POLICY], [ 3593654d12c0Smrg 3594654d12c0Smrg AC_ARG_WITH([libstdcxx-lock-policy], 3595654d12c0Smrg AC_HELP_STRING([--with-libstdcxx-lock-policy={atomic,mutex,auto}], 3596654d12c0Smrg [synchronization policy for shared_ptr reference counting [default=auto]]), 3597654d12c0Smrg [libstdcxx_atomic_lock_policy=$withval], 3598654d12c0Smrg [libstdcxx_atomic_lock_policy=auto]) 3599654d12c0Smrg 3600654d12c0Smrg case "$libstdcxx_atomic_lock_policy" in 3601654d12c0Smrg atomic|mutex|auto) ;; 3602654d12c0Smrg *) AC_MSG_ERROR([Invalid argument for --with-libstdcxx-lock-policy]) ;; 3603654d12c0Smrg esac 3604654d12c0Smrg AC_MSG_CHECKING([for lock policy for shared_ptr reference counts]) 3605654d12c0Smrg 3606654d12c0Smrg if test x"$libstdcxx_atomic_lock_policy" = x"auto"; then 3607654d12c0Smrg AC_LANG_SAVE 3608654d12c0Smrg AC_LANG_CPLUSPLUS 3609654d12c0Smrg ac_save_CXXFLAGS="$CXXFLAGS" 3610654d12c0Smrg 3611654d12c0Smrg dnl Why do we care about 2-byte CAS on targets with 4-byte _Atomic_word?! 3612e9e6e0f6Smrg dnl Why don't we check 8-byte CAS for sparc64, where _Atomic_word is long?! 3613e9e6e0f6Smrg dnl New targets should only check for CAS for the _Atomic_word type. 3614654d12c0Smrg AC_TRY_COMPILE([ 3615e9e6e0f6Smrg #if defined __riscv 3616e9e6e0f6Smrg # error "Defaulting to mutex-based locks for ABI compatibility" 3617e9e6e0f6Smrg #endif 3618654d12c0Smrg #if ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 3619654d12c0Smrg # error "No 2-byte compare-and-swap" 3620654d12c0Smrg #elif ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 3621654d12c0Smrg # error "No 4-byte compare-and-swap" 3622654d12c0Smrg #endif 3623654d12c0Smrg ],, 3624654d12c0Smrg [libstdcxx_atomic_lock_policy=atomic], 3625654d12c0Smrg [libstdcxx_atomic_lock_policy=mutex]) 3626654d12c0Smrg AC_LANG_RESTORE 3627654d12c0Smrg CXXFLAGS="$ac_save_CXXFLAGS" 3628654d12c0Smrg fi 3629654d12c0Smrg 3630654d12c0Smrg if test x"$libstdcxx_atomic_lock_policy" = x"atomic"; then 3631654d12c0Smrg AC_MSG_RESULT(atomic) 3632654d12c0Smrg AC_DEFINE(HAVE_ATOMIC_LOCK_POLICY,1, 3633654d12c0Smrg [Defined if shared_ptr reference counting should use atomic operations.]) 3634654d12c0Smrg else 3635654d12c0Smrg AC_MSG_RESULT(mutex) 3636654d12c0Smrg fi 3637654d12c0Smrg 3638654d12c0Smrg]) 36394fee23f9Smrg 36404fee23f9Smrgdnl 36414fee23f9Smrgdnl Allow visibility attributes to be used on namespaces, objects, etc. 36424fee23f9Smrgdnl 364348fb7bfaSmrgdnl --enable-libstdcxx-visibility enables attempt to use visibility attributes. 364448fb7bfaSmrgdnl --disable-libstdcxx-visibility turns off all use of visibility attributes. 364548fb7bfaSmrgdnl + Usage: GLIBCXX_ENABLE_LIBSTDCXX_VISIBILITY[(DEFAULT)] 36464fee23f9Smrgdnl Where DEFAULT is 'yes'. 36474fee23f9Smrgdnl 364848fb7bfaSmrgAC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_VISIBILITY], [ 364948fb7bfaSmrgGLIBCXX_ENABLE(libstdcxx-visibility,$1,,[enables visibility safe usage]) 36504fee23f9Smrg 365148fb7bfaSmrgif test x$enable_libstdcxx_visibility = xyes ; then 36524fee23f9Smrg dnl all hail libgfortran 36534fee23f9Smrg dnl Check whether the target supports hidden visibility. 36544fee23f9Smrg AC_CACHE_CHECK([whether the target supports hidden visibility], 36554fee23f9Smrg glibcxx_cv_have_attribute_visibility, [ 36564fee23f9Smrg save_CFLAGS="$CFLAGS" 36574fee23f9Smrg CFLAGS="$CFLAGS -Werror" 36584fee23f9Smrg AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }], 36594fee23f9Smrg [], glibcxx_cv_have_attribute_visibility=yes, 36604fee23f9Smrg glibcxx_cv_have_attribute_visibility=no) 36614fee23f9Smrg CFLAGS="$save_CFLAGS"]) 36624fee23f9Smrg if test $glibcxx_cv_have_attribute_visibility = no; then 366348fb7bfaSmrg enable_libstdcxx_visibility=no 36644fee23f9Smrg fi 36654fee23f9Smrgfi 36664fee23f9Smrg 366748fb7bfaSmrgGLIBCXX_CONDITIONAL(ENABLE_VISIBILITY, test $enable_libstdcxx_visibility = yes) 366848fb7bfaSmrgAC_MSG_NOTICE([visibility supported: $enable_libstdcxx_visibility]) 36694fee23f9Smrg]) 36704fee23f9Smrg 36714fee23f9Smrg 36724fee23f9Smrgdnl 36734fee23f9Smrgdnl Add version tags to symbols in shared library (or not), additionally 36744fee23f9Smrgdnl marking other symbols as private/local (or not). 36754fee23f9Smrgdnl 367648fb7bfaSmrgdnl Sets libtool_VERSION, and determines shared library SONAME. 367748fb7bfaSmrgdnl 367848fb7bfaSmrgdnl This depends on GLIBCXX CHECK_LINKER_FEATURES, but without it assumes no. 367948fb7bfaSmrgdnl 36804fee23f9Smrgdnl --enable-symvers=style adds a version script to the linker call when 36814fee23f9Smrgdnl creating the shared library. The choice of version script is 36824fee23f9Smrgdnl controlled by 'style'. 36834fee23f9Smrgdnl --disable-symvers does not. 368448fb7bfaSmrgdnl 36854fee23f9Smrgdnl + Usage: GLIBCXX_ENABLE_SYMVERS[(DEFAULT)] 36864fee23f9Smrgdnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to 36874fee23f9Smrgdnl choose a default style based on linker characteristics. Passing 36884fee23f9Smrgdnl 'no' disables versioning. 36894fee23f9Smrgdnl 36904fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_SYMVERS], [ 36914fee23f9Smrg 369248fb7bfaSmrgGLIBCXX_ENABLE(symvers,$1,[[[=STYLE]]], 36934fee23f9Smrg [enables symbol versioning of the shared library], 369448fb7bfaSmrg [permit yes|no|gnu|gnu-versioned-namespace|darwin|darwin-export|sun]) 36954fee23f9Smrg 36964fee23f9Smrg# If we never went through the GLIBCXX_CHECK_LINKER_FEATURES macro, then we 36974fee23f9Smrg# don't know enough about $LD to do tricks... 36984fee23f9SmrgAC_REQUIRE([GLIBCXX_CHECK_LINKER_FEATURES]) 369948fb7bfaSmrg# Sun style symbol versions needs GNU c++filt for make_sunver.pl to work 370048fb7bfaSmrg# with extern "C++" in version scripts. 370148fb7bfaSmrgAC_REQUIRE([GCC_PROG_GNU_CXXFILT]) 37024fee23f9Smrg 37034fee23f9Smrg# Turn a 'yes' into a suitable default. 37044fee23f9Smrgif test x$enable_symvers = xyes ; then 37054fee23f9Smrg if test $enable_shared = no || test "x$LD" = x || test x$gcc_no_link = xyes; then 37064fee23f9Smrg enable_symvers=no 37074fee23f9Smrg else 37084fee23f9Smrg if test $with_gnu_ld = yes ; then 37094fee23f9Smrg case ${target_os} in 37104fee23f9Smrg hpux*) 37114fee23f9Smrg enable_symvers=no ;; 37124fee23f9Smrg *) 37134fee23f9Smrg enable_symvers=gnu ;; 37144fee23f9Smrg esac 37154fee23f9Smrg else 37164fee23f9Smrg case ${target_os} in 37174fee23f9Smrg darwin*) 37184fee23f9Smrg enable_symvers=darwin ;; 371948fb7bfaSmrg # Sun symbol versioning exists since Solaris 2.5. 372048fb7bfaSmrg solaris2.[[5-9]]* | solaris2.1[[0-9]]*) 372148fb7bfaSmrg # make_sunver.pl needs GNU c++filt to support extern "C++" in 372248fb7bfaSmrg # version scripts, so disable symbol versioning if none can be 372348fb7bfaSmrg # found. 372448fb7bfaSmrg if test -z "$ac_cv_path_CXXFILT"; then 372548fb7bfaSmrg AC_MSG_WARN([=== You have requested Sun symbol versioning, but]) 372648fb7bfaSmrg AC_MSG_WARN([=== no GNU c++filt could be found.]) 372748fb7bfaSmrg AC_MSG_WARN([=== Symbol versioning will be disabled.]) 372848fb7bfaSmrg enable_symvers=no 372948fb7bfaSmrg else 373048fb7bfaSmrg enable_symvers=sun 373148fb7bfaSmrg fi 373248fb7bfaSmrg ;; 37334fee23f9Smrg *) 37344fee23f9Smrg enable_symvers=no ;; 37354fee23f9Smrg esac 37364fee23f9Smrg fi 37374fee23f9Smrg fi 37384fee23f9Smrgfi 37394fee23f9Smrg 37404fee23f9Smrg# Check to see if 'darwin' or 'darwin-export' can win. 37414fee23f9Smrgif test x$enable_symvers = xdarwin-export ; then 37424fee23f9Smrg enable_symvers=darwin 37434fee23f9Smrgfi 37444fee23f9Smrg 374548fb7bfaSmrg# Check if 'sun' was requested on non-Solaris 2 platforms. 374648fb7bfaSmrgif test x$enable_symvers = xsun ; then 374748fb7bfaSmrg case ${target_os} in 374848fb7bfaSmrg solaris2*) 374948fb7bfaSmrg # All fine. 375048fb7bfaSmrg ;; 375148fb7bfaSmrg *) 375248fb7bfaSmrg # Unlikely to work. 375348fb7bfaSmrg AC_MSG_WARN([=== You have requested Sun symbol versioning, but]) 375448fb7bfaSmrg AC_MSG_WARN([=== you are not targetting Solaris 2.]) 375548fb7bfaSmrg AC_MSG_WARN([=== Symbol versioning will be disabled.]) 375648fb7bfaSmrg enable_symvers=no 375748fb7bfaSmrg ;; 375848fb7bfaSmrg esac 375948fb7bfaSmrgfi 376048fb7bfaSmrg 37614fee23f9Smrg# Check to see if 'gnu' can win. 376248fb7bfaSmrgif test $enable_symvers = gnu || 376348fb7bfaSmrg test $enable_symvers = gnu-versioned-namespace || 376448fb7bfaSmrg test $enable_symvers = sun; then 37654fee23f9Smrg # Check to see if libgcc_s exists, indicating that shared libgcc is possible. 37664fee23f9Smrg AC_MSG_CHECKING([for shared libgcc]) 37674fee23f9Smrg ac_save_CFLAGS="$CFLAGS" 37684fee23f9Smrg CFLAGS=' -lgcc_s' 37694fee23f9Smrg AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes, glibcxx_shared_libgcc=no) 37704fee23f9Smrg CFLAGS="$ac_save_CFLAGS" 37714fee23f9Smrg if test $glibcxx_shared_libgcc = no; then 37724fee23f9Smrg cat > conftest.c <<EOF 37734fee23f9Smrgint main (void) { return 0; } 37744fee23f9SmrgEOF 37754fee23f9Smrgchangequote(,)dnl 37764fee23f9Smrg glibcxx_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \ 37774fee23f9Smrg -shared -shared-libgcc -o conftest.so \ 37784fee23f9Smrg conftest.c -v 2>&1 >/dev/null \ 37794fee23f9Smrg | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'` 37804fee23f9Smrgchangequote([,])dnl 37814fee23f9Smrg rm -f conftest.c conftest.so 37824fee23f9Smrg if test x${glibcxx_libgcc_s_suffix+set} = xset; then 37834fee23f9Smrg CFLAGS=" -lgcc_s$glibcxx_libgcc_s_suffix" 37844fee23f9Smrg AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes) 37854fee23f9Smrg CFLAGS="$ac_save_CFLAGS" 37864fee23f9Smrg fi 37874fee23f9Smrg fi 37884fee23f9Smrg AC_MSG_RESULT($glibcxx_shared_libgcc) 37894fee23f9Smrg 37904fee23f9Smrg # For GNU ld, we need at least this version. The format is described in 37914fee23f9Smrg # GLIBCXX_CHECK_LINKER_FEATURES above. 37924fee23f9Smrg glibcxx_min_gnu_ld_version=21400 37934fee23f9Smrg 37944fee23f9Smrg # If no shared libgcc, can't win. 37954fee23f9Smrg if test $glibcxx_shared_libgcc != yes; then 37964fee23f9Smrg AC_MSG_WARN([=== You have requested GNU symbol versioning, but]) 37974fee23f9Smrg AC_MSG_WARN([=== you are not building a shared libgcc_s.]) 37984fee23f9Smrg AC_MSG_WARN([=== Symbol versioning will be disabled.]) 37994fee23f9Smrg enable_symvers=no 380048fb7bfaSmrg elif test $with_gnu_ld != yes && test $enable_symvers = sun; then 380148fb7bfaSmrg : All interesting versions of Sun ld support sun style symbol versioning. 38024fee23f9Smrg elif test $with_gnu_ld != yes ; then 38034fee23f9Smrg # just fail for now 38044fee23f9Smrg AC_MSG_WARN([=== You have requested GNU symbol versioning, but]) 38054fee23f9Smrg AC_MSG_WARN([=== you are not using the GNU linker.]) 38064fee23f9Smrg AC_MSG_WARN([=== Symbol versioning will be disabled.]) 38074fee23f9Smrg enable_symvers=no 38084fee23f9Smrg elif test $glibcxx_ld_is_gold = yes ; then 38094fee23f9Smrg : All versions of gold support symbol versioning. 3810e9e6e0f6Smrg elif test $glibcxx_ld_is_mold = yes ; then 3811e9e6e0f6Smrg : All versions of mold support symbol versioning. 38124fee23f9Smrg elif test $glibcxx_gnu_ld_version -lt $glibcxx_min_gnu_ld_version ; then 38134fee23f9Smrg # The right tools, the right setup, but too old. Fallbacks? 38144fee23f9Smrg AC_MSG_WARN(=== Linker version $glibcxx_gnu_ld_version is too old for) 38154fee23f9Smrg AC_MSG_WARN(=== full symbol versioning support in this release of GCC.) 38164fee23f9Smrg AC_MSG_WARN(=== You would need to upgrade your binutils to version) 38174fee23f9Smrg AC_MSG_WARN(=== $glibcxx_min_gnu_ld_version or later and rebuild GCC.) 38184fee23f9Smrg AC_MSG_WARN([=== Symbol versioning will be disabled.]) 38194fee23f9Smrg enable_symvers=no 38204fee23f9Smrg fi 38214fee23f9Smrgfi 38224fee23f9Smrg 382348fb7bfaSmrg# For libtool versioning info, format is CURRENT:REVISION:AGE 3824e9e6e0f6Smrglibtool_VERSION=6:30:0 382548fb7bfaSmrg 382648fb7bfaSmrg# Everything parsed; figure out what files and settings to use. 38274fee23f9Smrgcase $enable_symvers in 38284fee23f9Smrg no) 38294fee23f9Smrg SYMVER_FILE=config/abi/pre/none.ver 38304fee23f9Smrg ;; 38314fee23f9Smrg gnu) 38324fee23f9Smrg SYMVER_FILE=config/abi/pre/gnu.ver 38334fee23f9Smrg AC_DEFINE(_GLIBCXX_SYMVER_GNU, 1, 38344fee23f9Smrg [Define to use GNU versioning in the shared library.]) 38354fee23f9Smrg ;; 38364fee23f9Smrg gnu-versioned-namespace) 38373f8cba22Smrg libtool_VERSION=8:0:0 38384fee23f9Smrg SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver 38394fee23f9Smrg AC_DEFINE(_GLIBCXX_SYMVER_GNU_NAMESPACE, 1, 38404fee23f9Smrg [Define to use GNU namespace versioning in the shared library.]) 38414fee23f9Smrg ;; 38424fee23f9Smrg darwin) 38434fee23f9Smrg SYMVER_FILE=config/abi/pre/gnu.ver 38444fee23f9Smrg AC_DEFINE(_GLIBCXX_SYMVER_DARWIN, 1, 38454fee23f9Smrg [Define to use darwin versioning in the shared library.]) 38464fee23f9Smrg ;; 384748fb7bfaSmrg sun) 384848fb7bfaSmrg SYMVER_FILE=config/abi/pre/gnu.ver 384948fb7bfaSmrg AC_DEFINE(_GLIBCXX_SYMVER_SUN, 1, 385048fb7bfaSmrg [Define to use Sun versioning in the shared library.]) 385148fb7bfaSmrg ;; 38524fee23f9Smrgesac 38534fee23f9Smrg 38544fee23f9Smrgif test x$enable_symvers != xno ; then 38554fee23f9Smrg AC_DEFINE(_GLIBCXX_SYMVER, 1, 38564fee23f9Smrg [Define to use symbol versioning in the shared library.]) 38574fee23f9Smrgfi 38584fee23f9Smrg 38594fee23f9SmrgAC_CACHE_CHECK([whether the target supports .symver directive], 38604fee23f9Smrg glibcxx_cv_have_as_symver_directive, [ 38614fee23f9Smrg AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");], 38624fee23f9Smrg [], glibcxx_cv_have_as_symver_directive=yes, 38634fee23f9Smrg glibcxx_cv_have_as_symver_directive=no)]) 38644fee23f9Smrgif test $glibcxx_cv_have_as_symver_directive = yes; then 38654fee23f9Smrg AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1, 38664fee23f9Smrg [Define to 1 if the target assembler supports .symver directive.]) 38674fee23f9Smrgfi 38684fee23f9Smrg 38694fee23f9SmrgAC_SUBST(SYMVER_FILE) 38704fee23f9SmrgAC_SUBST(port_specific_symbol_files) 38714fee23f9SmrgGLIBCXX_CONDITIONAL(ENABLE_SYMVERS, test $enable_symvers != no) 38724fee23f9SmrgGLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU, test $enable_symvers = gnu) 38734fee23f9SmrgGLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU_NAMESPACE, test $enable_symvers = gnu-versioned-namespace) 38744fee23f9SmrgGLIBCXX_CONDITIONAL(ENABLE_SYMVERS_DARWIN, test $enable_symvers = darwin) 387548fb7bfaSmrgGLIBCXX_CONDITIONAL(ENABLE_SYMVERS_SUN, test $enable_symvers = sun) 38764fee23f9SmrgAC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers) 38774fee23f9Smrg 387848fb7bfaSmrgif test $enable_symvers != no ; then 387948fb7bfaSmrg case ${target_os} in 388048fb7bfaSmrg # The Solaris 2 runtime linker doesn't support the GNU extension of 388148fb7bfaSmrg # binding the same symbol to different versions 388248fb7bfaSmrg solaris2*) 388348fb7bfaSmrg ;; 388448fb7bfaSmrg # Other platforms with GNU symbol versioning (GNU/Linux, more?) do. 388548fb7bfaSmrg *) 388648fb7bfaSmrg AC_DEFINE(HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT, 1, 388748fb7bfaSmrg [Define to 1 if the target runtime linker supports binding the same symbol to different versions.]) 388848fb7bfaSmrg ;; 388948fb7bfaSmrg esac 389048fb7bfaSmrgfi 389148fb7bfaSmrg 38924fee23f9Smrg# Now, set up compatibility support, if any. 38934fee23f9Smrg# In addition, need this to deal with std::size_t mangling in 38944fee23f9Smrg# src/compatibility.cc. In a perfect world, could use 38954fee23f9Smrg# typeid(std::size_t).name()[0] to do direct substitution. 38964fee23f9SmrgAC_MSG_CHECKING([for size_t as unsigned int]) 38974fee23f9Smrgac_save_CFLAGS="$CFLAGS" 38984fee23f9SmrgCFLAGS="-Werror" 38994fee23f9SmrgAC_TRY_COMPILE(, [__SIZE_TYPE__* stp; unsigned int* uip; stp = uip;], 39004fee23f9Smrg [glibcxx_size_t_is_i=yes], [glibcxx_size_t_is_i=no]) 39014fee23f9SmrgCFLAGS=$ac_save_CFLAGS 39024fee23f9Smrgif test "$glibcxx_size_t_is_i" = yes; then 39034fee23f9Smrg AC_DEFINE(_GLIBCXX_SIZE_T_IS_UINT, 1, [Define if size_t is unsigned int.]) 39044fee23f9Smrgfi 39054fee23f9SmrgAC_MSG_RESULT([$glibcxx_size_t_is_i]) 39064fee23f9Smrg 39074fee23f9SmrgAC_MSG_CHECKING([for ptrdiff_t as int]) 39084fee23f9Smrgac_save_CFLAGS="$CFLAGS" 39094fee23f9SmrgCFLAGS="-Werror" 39104fee23f9SmrgAC_TRY_COMPILE(, [__PTRDIFF_TYPE__* ptp; int* ip; ptp = ip;], 39114fee23f9Smrg [glibcxx_ptrdiff_t_is_i=yes], [glibcxx_ptrdiff_t_is_i=no]) 39124fee23f9SmrgCFLAGS=$ac_save_CFLAGS 39134fee23f9Smrgif test "$glibcxx_ptrdiff_t_is_i" = yes; then 39144fee23f9Smrg AC_DEFINE(_GLIBCXX_PTRDIFF_T_IS_INT, 1, [Define if ptrdiff_t is int.]) 39154fee23f9Smrgfi 39164fee23f9SmrgAC_MSG_RESULT([$glibcxx_ptrdiff_t_is_i]) 39174fee23f9Smrg]) 39184fee23f9Smrg 39194fee23f9Smrg 39204fee23f9Smrgdnl 39214fee23f9Smrgdnl Setup to use the gcc gthr.h thread-specific memory and mutex model. 39224fee23f9Smrgdnl We must stage the required headers so that they will be installed 39234fee23f9Smrgdnl with the library (unlike libgcc, the STL implementation is provided 39244fee23f9Smrgdnl solely within headers). Since we must not inject random user-space 39254fee23f9Smrgdnl macro names into user-provided C++ code, we first stage into <file>-in 39264fee23f9Smrgdnl and process to <file> with an output command. The reason for a two- 39274fee23f9Smrgdnl stage process here is to correctly handle $srcdir!=$objdir without 39284fee23f9Smrgdnl having to write complex code (the sed commands to clean the macro 39294fee23f9Smrgdnl namespace are complex and fragile enough as it is). We must also 39304fee23f9Smrgdnl add a relative path so that -I- is supported properly. 39314fee23f9Smrgdnl 39324fee23f9Smrgdnl Substs: 393348fb7bfaSmrgdnl thread_header 39344fee23f9Smrgdnl 39354fee23f9SmrgAC_DEFUN([GLIBCXX_ENABLE_THREADS], [ 39364fee23f9Smrg AC_MSG_CHECKING([for thread model used by GCC]) 39374fee23f9Smrg target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'` 39384fee23f9Smrg AC_MSG_RESULT([$target_thread_file]) 393948fb7bfaSmrg GCC_AC_THREAD_HEADER([$target_thread_file]) 39404fee23f9Smrg]) 39414fee23f9Smrg 39424fee23f9Smrg 39434fee23f9Smrgdnl 39444fee23f9Smrgdnl Check if gthread implementation defines the types and functions 39454fee23f9Smrgdnl required by the c++0x thread library. Conforming gthread 39464fee23f9Smrgdnl implementations can define __GTHREADS_CXX0X to enable use with c++0x. 39474fee23f9Smrgdnl 394848fb7bfaSmrgdnl GLIBCXX_ENABLE_SYMVERS must be done before this. 394948fb7bfaSmrgdnl 39504fee23f9SmrgAC_DEFUN([GLIBCXX_CHECK_GTHREADS], [ 395148fb7bfaSmrg GLIBCXX_ENABLE(libstdcxx-threads,auto,,[enable C++11 threads support]) 395248fb7bfaSmrg 395348fb7bfaSmrg if test x$enable_libstdcxx_threads = xauto || 395448fb7bfaSmrg test x$enable_libstdcxx_threads = xyes; then 395548fb7bfaSmrg 39564fee23f9Smrg AC_LANG_SAVE 39574fee23f9Smrg AC_LANG_CPLUSPLUS 39584fee23f9Smrg 39594fee23f9Smrg ac_save_CXXFLAGS="$CXXFLAGS" 396048fb7bfaSmrg CXXFLAGS="$CXXFLAGS -fno-exceptions \ 396148fb7bfaSmrg -I${toplevel_srcdir}/libgcc -I${toplevel_builddir}/libgcc" 39624fee23f9Smrg 39634fee23f9Smrg target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'` 39644fee23f9Smrg case $target_thread_file in 39654fee23f9Smrg posix) 39664fee23f9Smrg CXXFLAGS="$CXXFLAGS -DSUPPORTS_WEAK -DGTHREAD_USE_WEAK -D_PTHREADS" 39674fee23f9Smrg esac 39684fee23f9Smrg 396948fb7bfaSmrg AC_MSG_CHECKING([whether it can be safely assumed that mutex_timedlock is available]) 397048fb7bfaSmrg 397148fb7bfaSmrg AC_TRY_COMPILE([#include <unistd.h>], 397248fb7bfaSmrg [ 397348fb7bfaSmrg // In case of POSIX threads check _POSIX_TIMEOUTS. 397448fb7bfaSmrg #if (defined(_PTHREADS) \ 397548fb7bfaSmrg && (!defined(_POSIX_TIMEOUTS) || _POSIX_TIMEOUTS <= 0)) 397648fb7bfaSmrg #error 397748fb7bfaSmrg #endif 397848fb7bfaSmrg ], [ac_gthread_use_mutex_timedlock=1], [ac_gthread_use_mutex_timedlock=0]) 397948fb7bfaSmrg 398048fb7bfaSmrg AC_DEFINE_UNQUOTED(_GTHREAD_USE_MUTEX_TIMEDLOCK, $ac_gthread_use_mutex_timedlock, 398148fb7bfaSmrg [Define to 1 if mutex_timedlock is available.]) 398248fb7bfaSmrg 398348fb7bfaSmrg if test $ac_gthread_use_mutex_timedlock = 1 ; then res_mutex_timedlock=yes ; 398448fb7bfaSmrg else res_mutex_timedlock=no ; fi 398548fb7bfaSmrg AC_MSG_RESULT([$res_mutex_timedlock]) 398648fb7bfaSmrg 39874fee23f9Smrg AC_MSG_CHECKING([for gthreads library]) 39884fee23f9Smrg 39894fee23f9Smrg AC_TRY_COMPILE([#include "gthr.h"], 39904fee23f9Smrg [ 39914fee23f9Smrg #ifndef __GTHREADS_CXX0X 39924fee23f9Smrg #error 39934fee23f9Smrg #endif 3994d35849d0Smrg ], [ac_has_gthreads=yes], [ac_has_gthreads=no]) 399548fb7bfaSmrg else 399648fb7bfaSmrg ac_has_gthreads=no 399748fb7bfaSmrg fi 39984fee23f9Smrg 39994fee23f9Smrg AC_MSG_RESULT([$ac_has_gthreads]) 40004fee23f9Smrg 40014fee23f9Smrg if test x"$ac_has_gthreads" = x"yes"; then 40024fee23f9Smrg AC_DEFINE(_GLIBCXX_HAS_GTHREADS, 1, 40034fee23f9Smrg [Define if gthreads library is available.]) 4004d35849d0Smrg 4005d35849d0Smrg # Also check for pthread_rwlock_t for std::shared_timed_mutex in C++14 400643265c03Smrg # but only do so if we're using pthread in the gthread library. 400743265c03Smrg # On VxWorks for example, pthread_rwlock_t is defined in sys/types.h 400843265c03Smrg # but the pthread library is not there by default and the gthread library 400943265c03Smrg # does not use it. 401043265c03Smrg AC_TRY_COMPILE([#include "gthr.h"], 401143265c03Smrg [ 401243265c03Smrg #if (!defined(_PTHREADS)) 401343265c03Smrg #error 401443265c03Smrg #endif 401543265c03Smrg ], [ac_gthread_use_pthreads=yes], [ac_gthread_use_pthreads=no]) 401643265c03Smrg if test x"$ac_gthread_use_pthreads" = x"yes"; then 4017d35849d0Smrg AC_CHECK_TYPE([pthread_rwlock_t], 4018d35849d0Smrg [AC_DEFINE([_GLIBCXX_USE_PTHREAD_RWLOCK_T], 1, 4019d35849d0Smrg [Define if POSIX read/write locks are available in <gthr.h>.])], 4020d35849d0Smrg [], 4021d35849d0Smrg [#include "gthr.h"]) 40224fee23f9Smrg fi 402343265c03Smrg fi 40244fee23f9Smrg 4025e9e6e0f6Smrg AC_CHECK_HEADER(semaphore.h, [ 4026e9e6e0f6Smrg AC_MSG_CHECKING([for POSIX Semaphores and sem_timedwait]) 4027e9e6e0f6Smrg AC_TRY_COMPILE([ 4028e9e6e0f6Smrg #include <unistd.h> 4029e9e6e0f6Smrg #include <semaphore.h> 4030e9e6e0f6Smrg #include <limits.h> 4031e9e6e0f6Smrg ], 4032e9e6e0f6Smrg [ 4033e9e6e0f6Smrg #if !defined _POSIX_TIMEOUTS || _POSIX_TIMEOUTS <= 0 4034e9e6e0f6Smrg # error "POSIX Timeouts option not supported" 4035e9e6e0f6Smrg #elif !defined _POSIX_SEMAPHORES || _POSIX_SEMAPHORES <= 0 4036e9e6e0f6Smrg # error "POSIX Semaphores option not supported" 4037e9e6e0f6Smrg #else 4038e9e6e0f6Smrg #if defined SEM_VALUE_MAX 4039e9e6e0f6Smrg constexpr int sem_value_max = SEM_VALUE_MAX; 4040e9e6e0f6Smrg #elif defined _POSIX_SEM_VALUE_MAX 4041e9e6e0f6Smrg constexpr int sem_value_max = _POSIX_SEM_VALUE_MAX; 4042e9e6e0f6Smrg #else 4043e9e6e0f6Smrg # error "SEM_VALUE_MAX not available" 4044e9e6e0f6Smrg #endif 4045e9e6e0f6Smrg sem_t sem; 4046e9e6e0f6Smrg sem_init(&sem, 0, sem_value_max); 4047e9e6e0f6Smrg struct timespec ts = { 0 }; 4048e9e6e0f6Smrg sem_timedwait(&sem, &ts); 4049e9e6e0f6Smrg #endif 4050e9e6e0f6Smrg ], 4051e9e6e0f6Smrg [ac_have_posix_semaphore=yes], 4052e9e6e0f6Smrg [ac_have_posix_semaphore=no])], 4053e9e6e0f6Smrg [ac_have_posix_semaphore=no]) 4054e9e6e0f6Smrg 4055e9e6e0f6Smrg if test $ac_have_posix_semaphore = yes ; then 4056e9e6e0f6Smrg AC_DEFINE(HAVE_POSIX_SEMAPHORE, 4057e9e6e0f6Smrg 1, 4058e9e6e0f6Smrg [Define to 1 if POSIX Semaphores with sem_timedwait are available in <semaphore.h>.]) 4059e9e6e0f6Smrg fi 4060e9e6e0f6Smrg AC_MSG_RESULT([$ac_have_posix_semaphore]) 4061e9e6e0f6Smrg 40624fee23f9Smrg CXXFLAGS="$ac_save_CXXFLAGS" 40634fee23f9Smrg AC_LANG_RESTORE 40644fee23f9Smrg]) 40654fee23f9Smrg 40664fee23f9Smrg 40674fee23f9Smrg# Check whether LC_MESSAGES is available in <locale.h>. 40684fee23f9Smrg# Ulrich Drepper <drepper@cygnus.com>, 1995. 40694fee23f9Smrg# 40704fee23f9Smrg# This file file be copied and used freely without restrictions. It can 40714fee23f9Smrg# be used in projects which are not available under the GNU Public License 40724fee23f9Smrg# but which still want to provide support for the GNU gettext functionality. 40734fee23f9Smrg# Please note that the actual code is *not* freely available. 40744fee23f9SmrgAC_DEFUN([AC_LC_MESSAGES], [ 40754fee23f9Smrg AC_CHECK_HEADER(locale.h, [ 40764fee23f9Smrg AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES, 40774fee23f9Smrg [AC_TRY_COMPILE([#include <locale.h>], [return LC_MESSAGES], 40784fee23f9Smrg ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)]) 40794fee23f9Smrg if test $ac_cv_val_LC_MESSAGES = yes; then 40804fee23f9Smrg AC_DEFINE(HAVE_LC_MESSAGES, 1, 40814fee23f9Smrg [Define if LC_MESSAGES is available in <locale.h>.]) 40824fee23f9Smrg fi 40834fee23f9Smrg ]) 40844fee23f9Smrg]) 40854fee23f9Smrg 408648fb7bfaSmrgdnl 408748fb7bfaSmrgdnl Check whether rdrand is supported in the assembler. 408848fb7bfaSmrgAC_DEFUN([GLIBCXX_CHECK_X86_RDRAND], [ 4089e9e6e0f6Smrg AC_CACHE_CHECK([for rdrand support in assembler], 4090e9e6e0f6Smrg ac_cv_x86_rdrand, [ 409148fb7bfaSmrg ac_cv_x86_rdrand=no 409248fb7bfaSmrg case "$target" in 409348fb7bfaSmrg i?86-*-* | \ 409448fb7bfaSmrg x86_64-*-*) 409548fb7bfaSmrg AC_TRY_COMPILE(, [asm("rdrand %eax");], 409648fb7bfaSmrg [ac_cv_x86_rdrand=yes], [ac_cv_x86_rdrand=no]) 409748fb7bfaSmrg esac 409848fb7bfaSmrg ]) 409948fb7bfaSmrg if test $ac_cv_x86_rdrand = yes; then 410048fb7bfaSmrg AC_DEFINE(_GLIBCXX_X86_RDRAND, 1, 410148fb7bfaSmrg [ Defined if as can handle rdrand. ]) 410248fb7bfaSmrg fi 410348fb7bfaSmrg]) 41044fee23f9Smrg 410548fb7bfaSmrgdnl 410643265c03Smrgdnl Check whether rdseed is supported in the assembler. 410743265c03SmrgAC_DEFUN([GLIBCXX_CHECK_X86_RDSEED], [ 4108e9e6e0f6Smrg AC_CACHE_CHECK([for rdseed support in assembler], 4109e9e6e0f6Smrg ac_cv_x86_rdseed, [ 411043265c03Smrg ac_cv_x86_rdseed=no 411143265c03Smrg case "$target" in 411243265c03Smrg i?86-*-* | \ 411343265c03Smrg x86_64-*-*) 411443265c03Smrg AC_TRY_COMPILE(, [asm("rdseed %eax");], 411543265c03Smrg [ac_cv_x86_rdseed=yes], [ac_cv_x86_rdseed=no]) 411643265c03Smrg esac 411743265c03Smrg ]) 411843265c03Smrg if test $ac_cv_x86_rdseed = yes; then 411943265c03Smrg AC_DEFINE(_GLIBCXX_X86_RDSEED, 1, 412043265c03Smrg [ Defined if as can handle rdseed. ]) 412143265c03Smrg fi 412243265c03Smrg]) 412343265c03Smrg 412443265c03Smrgdnl 412548fb7bfaSmrgdnl Check whether get_nprocs is available in <sys/sysinfo.h>, and define _GLIBCXX_USE_GET_NPROCS. 412648fb7bfaSmrgdnl 412748fb7bfaSmrgAC_DEFUN([GLIBCXX_CHECK_GET_NPROCS], [ 412848fb7bfaSmrg 412948fb7bfaSmrg AC_LANG_SAVE 413048fb7bfaSmrg AC_LANG_CPLUSPLUS 413148fb7bfaSmrg ac_save_CXXFLAGS="$CXXFLAGS" 413248fb7bfaSmrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 413348fb7bfaSmrg 4134e9e6e0f6Smrg AC_CACHE_CHECK([for get_nprocs], 4135e9e6e0f6Smrg glibcxx_cv_GET_NPROCS, [ 413648fb7bfaSmrg GCC_TRY_COMPILE_OR_LINK( 413748fb7bfaSmrg [#include <sys/sysinfo.h>], 413848fb7bfaSmrg [int n = get_nprocs();], 413948fb7bfaSmrg [glibcxx_cv_GET_NPROCS=yes], 414048fb7bfaSmrg [glibcxx_cv_GET_NPROCS=no]) 414148fb7bfaSmrg ]) 414248fb7bfaSmrg if test $glibcxx_cv_GET_NPROCS = yes; then 414348fb7bfaSmrg AC_DEFINE(_GLIBCXX_USE_GET_NPROCS, 1, [Define if get_nprocs is available in <sys/sysinfo.h>.]) 414448fb7bfaSmrg fi 414548fb7bfaSmrg 414648fb7bfaSmrg CXXFLAGS="$ac_save_CXXFLAGS" 414748fb7bfaSmrg AC_LANG_RESTORE 414848fb7bfaSmrg]) 414948fb7bfaSmrg 415048fb7bfaSmrgdnl 415148fb7bfaSmrgdnl Check whether sysconf(_SC_NPROCESSORS_ONLN) is available in <unistd.h>, and define _GLIBCXX_USE_SC_NPROCESSORS_ONLN. 415248fb7bfaSmrgdnl 415348fb7bfaSmrgAC_DEFUN([GLIBCXX_CHECK_SC_NPROCESSORS_ONLN], [ 415448fb7bfaSmrg 415548fb7bfaSmrg AC_LANG_SAVE 415648fb7bfaSmrg AC_LANG_CPLUSPLUS 415748fb7bfaSmrg ac_save_CXXFLAGS="$CXXFLAGS" 415848fb7bfaSmrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 415948fb7bfaSmrg 4160e9e6e0f6Smrg AC_CACHE_CHECK([for _SC_NPROCESSORS_ONLN], 4161e9e6e0f6Smrg glibcxx_cv_SC_NPROCESSORS_ONLN, [ 416248fb7bfaSmrg GCC_TRY_COMPILE_OR_LINK( 416348fb7bfaSmrg [#include <unistd.h>], 416448fb7bfaSmrg [int n = sysconf(_SC_NPROCESSORS_ONLN);], 416548fb7bfaSmrg [glibcxx_cv_SC_NPROCESSORS_ONLN=yes], 416648fb7bfaSmrg [glibcxx_cv_SC_NPROCESSORS_ONLN=no]) 416748fb7bfaSmrg ]) 416848fb7bfaSmrg if test $glibcxx_cv_SC_NPROCESSORS_ONLN = yes; then 416948fb7bfaSmrg AC_DEFINE(_GLIBCXX_USE_SC_NPROCESSORS_ONLN, 1, [Define if _SC_NPROCESSORS_ONLN is available in <unistd.h>.]) 417048fb7bfaSmrg fi 417148fb7bfaSmrg 417248fb7bfaSmrg CXXFLAGS="$ac_save_CXXFLAGS" 417348fb7bfaSmrg AC_LANG_RESTORE 417448fb7bfaSmrg]) 417548fb7bfaSmrg 417648fb7bfaSmrgdnl 417748fb7bfaSmrgdnl Check whether sysconf(_SC_NPROC_ONLN) is available in <unistd.h>, and define _GLIBCXX_USE_SC_NPROC_ONLN. 417848fb7bfaSmrgdnl 417948fb7bfaSmrgAC_DEFUN([GLIBCXX_CHECK_SC_NPROC_ONLN], [ 418048fb7bfaSmrg 418148fb7bfaSmrg AC_LANG_SAVE 418248fb7bfaSmrg AC_LANG_CPLUSPLUS 418348fb7bfaSmrg ac_save_CXXFLAGS="$CXXFLAGS" 418448fb7bfaSmrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 418548fb7bfaSmrg 4186e9e6e0f6Smrg AC_CACHE_CHECK([for _SC_NPROC_ONLN], 4187e9e6e0f6Smrg glibcxx_cv_SC_NPROC_ONLN, [ 418848fb7bfaSmrg GCC_TRY_COMPILE_OR_LINK( 418948fb7bfaSmrg [#include <unistd.h>], 419048fb7bfaSmrg [int n = sysconf(_SC_NPROC_ONLN);], 419148fb7bfaSmrg [glibcxx_cv_SC_NPROC_ONLN=yes], 419248fb7bfaSmrg [glibcxx_cv_SC_NPROC_ONLN=no]) 419348fb7bfaSmrg ]) 419448fb7bfaSmrg if test $glibcxx_cv_SC_NPROC_ONLN = yes; then 419548fb7bfaSmrg AC_DEFINE(_GLIBCXX_USE_SC_NPROC_ONLN, 1, [Define if _SC_NPROC_ONLN is available in <unistd.h>.]) 419648fb7bfaSmrg fi 419748fb7bfaSmrg 419848fb7bfaSmrg CXXFLAGS="$ac_save_CXXFLAGS" 419948fb7bfaSmrg AC_LANG_RESTORE 420048fb7bfaSmrg]) 420148fb7bfaSmrg 420248fb7bfaSmrgdnl 420348fb7bfaSmrgdnl Check whether pthread_num_processors_np is available in <pthread.h>, and define _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP. 420448fb7bfaSmrgdnl 420548fb7bfaSmrgAC_DEFUN([GLIBCXX_CHECK_PTHREADS_NUM_PROCESSORS_NP], [ 420648fb7bfaSmrg 420748fb7bfaSmrg AC_LANG_SAVE 420848fb7bfaSmrg AC_LANG_CPLUSPLUS 420948fb7bfaSmrg ac_save_CXXFLAGS="$CXXFLAGS" 421048fb7bfaSmrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 421148fb7bfaSmrg 4212e9e6e0f6Smrg AC_CACHE_CHECK([for pthreads_num_processors_np], 4213e9e6e0f6Smrg glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP, [ 421448fb7bfaSmrg GCC_TRY_COMPILE_OR_LINK( 421548fb7bfaSmrg [#include <pthread.h>], 421648fb7bfaSmrg [int n = pthread_num_processors_np();], 421748fb7bfaSmrg [glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP=yes], 421848fb7bfaSmrg [glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP=no]) 421948fb7bfaSmrg ]) 422048fb7bfaSmrg if test $glibcxx_cv_PTHREADS_NUM_PROCESSORS_NP = yes; then 422148fb7bfaSmrg AC_DEFINE(_GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP, 1, [Define if pthreads_num_processors_np is available in <pthread.h>.]) 422248fb7bfaSmrg fi 422348fb7bfaSmrg 422448fb7bfaSmrg CXXFLAGS="$ac_save_CXXFLAGS" 422548fb7bfaSmrg AC_LANG_RESTORE 422648fb7bfaSmrg]) 422748fb7bfaSmrg 422848fb7bfaSmrgdnl 422943265c03Smrgdnl Check whether pthread_cond_clockwait is available in <pthread.h> for std::condition_variable to use, 423043265c03Smrgdnl and define _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT. 423143265c03Smrgdnl 423243265c03SmrgAC_DEFUN([GLIBCXX_CHECK_PTHREAD_COND_CLOCKWAIT], [ 423343265c03Smrg 423443265c03Smrg AC_LANG_SAVE 423543265c03Smrg AC_LANG_CPLUSPLUS 423643265c03Smrg ac_save_CXXFLAGS="$CXXFLAGS" 423743265c03Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 423843265c03Smrg ac_save_LIBS="$LIBS" 423943265c03Smrg LIBS="$LIBS -lpthread" 424043265c03Smrg 4241e9e6e0f6Smrg AC_CACHE_CHECK([for pthread_cond_clockwait], 4242e9e6e0f6Smrg glibcxx_cv_PTHREAD_COND_CLOCKWAIT, [ 424343265c03Smrg GCC_TRY_COMPILE_OR_LINK( 424443265c03Smrg [#include <pthread.h>], 424543265c03Smrg [pthread_mutex_t mutex; pthread_cond_t cond; struct timespec ts; int n = pthread_cond_clockwait(&cond, &mutex, 0, &ts);], 424643265c03Smrg [glibcxx_cv_PTHREAD_COND_CLOCKWAIT=yes], 424743265c03Smrg [glibcxx_cv_PTHREAD_COND_CLOCKWAIT=no]) 424843265c03Smrg ]) 424943265c03Smrg if test $glibcxx_cv_PTHREAD_COND_CLOCKWAIT = yes; then 425043265c03Smrg AC_DEFINE(_GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT, 1, [Define if pthread_cond_clockwait is available in <pthread.h>.]) 425143265c03Smrg fi 425243265c03Smrg 425343265c03Smrg CXXFLAGS="$ac_save_CXXFLAGS" 425443265c03Smrg LIBS="$ac_save_LIBS" 425543265c03Smrg AC_LANG_RESTORE 425643265c03Smrg]) 425743265c03Smrg 425843265c03Smrgdnl 425943265c03Smrgdnl Check whether pthread_mutex_clocklock is available in <pthread.h> for std::timed_mutex to use, 426043265c03Smrgdnl and define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK. 426143265c03Smrgdnl 426243265c03SmrgAC_DEFUN([GLIBCXX_CHECK_PTHREAD_MUTEX_CLOCKLOCK], [ 426343265c03Smrg 426443265c03Smrg AC_LANG_SAVE 426543265c03Smrg AC_LANG_CPLUSPLUS 426643265c03Smrg ac_save_CXXFLAGS="$CXXFLAGS" 426743265c03Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 426843265c03Smrg ac_save_LIBS="$LIBS" 426943265c03Smrg LIBS="$LIBS -lpthread" 427043265c03Smrg 4271e9e6e0f6Smrg AC_CACHE_CHECK([for pthread_mutex_clocklock], 4272e9e6e0f6Smrg glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK, [ 427343265c03Smrg GCC_TRY_COMPILE_OR_LINK( 427443265c03Smrg [#include <pthread.h>], 427543265c03Smrg [pthread_mutex_t mutex; struct timespec ts; int n = pthread_mutex_clocklock(&mutex, CLOCK_REALTIME, &ts);], 427643265c03Smrg [glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK=yes], 427743265c03Smrg [glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK=no]) 427843265c03Smrg ]) 427943265c03Smrg if test $glibcxx_cv_PTHREAD_MUTEX_CLOCKLOCK = yes; then 428043265c03Smrg AC_DEFINE(_GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK, 1, [Define if pthread_mutex_clocklock is available in <pthread.h>.]) 428143265c03Smrg fi 428243265c03Smrg 428343265c03Smrg CXXFLAGS="$ac_save_CXXFLAGS" 428443265c03Smrg LIBS="$ac_save_LIBS" 428543265c03Smrg AC_LANG_RESTORE 428643265c03Smrg]) 428743265c03Smrg 428843265c03Smrgdnl 428943265c03Smrgdnl Check whether pthread_mutex_clocklock is available in <pthread.h> for std::timed_mutex to use, 429043265c03Smrgdnl and define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK. 429143265c03Smrgdnl 429243265c03SmrgAC_DEFUN([GLIBCXX_CHECK_PTHREAD_RWLOCK_CLOCKLOCK], [ 429343265c03Smrg 429443265c03Smrg AC_LANG_SAVE 429543265c03Smrg AC_LANG_CPLUSPLUS 429643265c03Smrg ac_save_CXXFLAGS="$CXXFLAGS" 429743265c03Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 429843265c03Smrg ac_save_LIBS="$LIBS" 429943265c03Smrg LIBS="$LIBS -lpthread" 430043265c03Smrg 4301e9e6e0f6Smrg AC_CACHE_CHECK([for pthread_rwlock_clockrdlock, pthread_wlock_clockwrlock], 4302e9e6e0f6Smrg glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK, [ 430343265c03Smrg GCC_TRY_COMPILE_OR_LINK( 430443265c03Smrg [#include <pthread.h>], 430543265c03Smrg [pthread_rwlock_t rwl; struct timespec ts;] 430643265c03Smrg [int n = pthread_rwlock_clockrdlock(&rwl, CLOCK_REALTIME, &ts);] 430743265c03Smrg [int m = pthread_rwlock_clockwrlock(&rwl, CLOCK_REALTIME, &ts);], 430843265c03Smrg [glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK=yes], 430943265c03Smrg [glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK=no]) 431043265c03Smrg ]) 431143265c03Smrg if test $glibcxx_cv_PTHREAD_RWLOCK_CLOCKLOCK = yes; then 431243265c03Smrg AC_DEFINE(_GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK, 1, [Define if pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock are available in <pthread.h>.]) 431343265c03Smrg fi 431443265c03Smrg 431543265c03Smrg CXXFLAGS="$ac_save_CXXFLAGS" 431643265c03Smrg LIBS="$ac_save_LIBS" 431743265c03Smrg AC_LANG_RESTORE 431843265c03Smrg]) 431943265c03Smrg 432043265c03Smrgdnl 432148fb7bfaSmrgdnl Check whether sysctl is available in <pthread.h>, and define _GLIBCXX_USE_SYSCTL_HW_NCPU. 432248fb7bfaSmrgdnl 432348fb7bfaSmrgAC_DEFUN([GLIBCXX_CHECK_SYSCTL_HW_NCPU], [ 432448fb7bfaSmrg 432548fb7bfaSmrg AC_LANG_SAVE 432648fb7bfaSmrg AC_LANG_CPLUSPLUS 432748fb7bfaSmrg ac_save_CXXFLAGS="$CXXFLAGS" 432848fb7bfaSmrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 432948fb7bfaSmrg 4330e9e6e0f6Smrg AC_CACHE_CHECK([for hw.ncpu sysctl], 4331e9e6e0f6Smrg glibcxx_cv_SYSCTL_HW_NCPU, [ 433248fb7bfaSmrg GCC_TRY_COMPILE_OR_LINK( 433348fb7bfaSmrg [ 433448fb7bfaSmrg #include <stddef.h> 433548fb7bfaSmrg #include <sys/sysctl.h> 433648fb7bfaSmrg ], 433748fb7bfaSmrg [ 433848fb7bfaSmrg int count; 433948fb7bfaSmrg size_t size = sizeof(count); 434048fb7bfaSmrg int mib[] = { CTL_HW, HW_NCPU }; 434148fb7bfaSmrg sysctl(mib, 2, &count, &size, NULL, 0); 434248fb7bfaSmrg ], 434348fb7bfaSmrg [glibcxx_cv_SYSCTL_HW_NCPU=yes], 434448fb7bfaSmrg [glibcxx_cv_SYSCTL_HW_NCPU=no]) 434548fb7bfaSmrg ]) 434648fb7bfaSmrg if test $glibcxx_cv_SYSCTL_HW_NCPU = yes; then 434748fb7bfaSmrg AC_DEFINE(_GLIBCXX_USE_SYSCTL_HW_NCPU, 1, [Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>.]) 434848fb7bfaSmrg fi 434948fb7bfaSmrg 435048fb7bfaSmrg CXXFLAGS="$ac_save_CXXFLAGS" 435148fb7bfaSmrg AC_LANG_RESTORE 435248fb7bfaSmrg]) 435348fb7bfaSmrg 435448fb7bfaSmrgdnl 435548fb7bfaSmrgdnl Check to see if python pretty printing can be activated. 435648fb7bfaSmrgdnl 435748fb7bfaSmrgdnl --with-python-dir=dir 435848fb7bfaSmrgdnl installs directory into $prefix/dir 435948fb7bfaSmrgAC_DEFUN([GLIBCXX_ENABLE_PYTHON], [ 436048fb7bfaSmrg 436148fb7bfaSmrgAC_MSG_CHECKING([for custom python install directory]) 436248fb7bfaSmrgAC_ARG_WITH([python-dir], 436348fb7bfaSmrg AS_HELP_STRING([--with-python-dir], 436448fb7bfaSmrg [the location to install Python modules. This path is relative starting from the prefix.]), 436548fb7bfaSmrg [with_python_dir=$withval], [with_python_dir="no"]) 436648fb7bfaSmrgAC_MSG_RESULT(${with_python_dir}) 436748fb7bfaSmrg 436848fb7bfaSmrg# Needed for installing Python modules during make install. 436948fb7bfaSmrgpython_mod_dir="${with_python_dir}" 437048fb7bfaSmrgAC_SUBST(python_mod_dir) 437148fb7bfaSmrgGLIBCXX_CONDITIONAL(ENABLE_PYTHONDIR, test $python_mod_dir != no) 437248fb7bfaSmrg]) 437348fb7bfaSmrg 437448fb7bfaSmrgdnl 437548fb7bfaSmrgdnl Check to see if -Werror is disabled. 437648fb7bfaSmrgdnl 437748fb7bfaSmrgdnl --enable-werror/--disable-werror 437848fb7bfaSmrgAC_DEFUN([GLIBCXX_ENABLE_WERROR], [ 437948fb7bfaSmrg AC_MSG_CHECKING([for -Werror]) 438048fb7bfaSmrg GLIBCXX_ENABLE(werror,$1,,[turns on -Werror]) 438148fb7bfaSmrg AC_MSG_RESULT($enable_werror) 438248fb7bfaSmrg GLIBCXX_CONDITIONAL(ENABLE_WERROR, test $enable_werror = yes) 438348fb7bfaSmrg]) 438448fb7bfaSmrg 4385d35849d0Smrgdnl 4386d35849d0Smrgdnl Check whether obsolescent tmpnam is available in <stdio.h>, 4387d35849d0Smrgdnl and define _GLIBCXX_USE_TMPNAM. 4388d35849d0Smrgdnl 4389d35849d0SmrgAC_DEFUN([GLIBCXX_CHECK_TMPNAM], [dnl 4390d35849d0Smrgdnl 4391d35849d0Smrg AC_LANG_SAVE 4392d35849d0Smrg AC_LANG_CPLUSPLUS 4393d35849d0Smrg ac_save_CXXFLAGS="$CXXFLAGS" 4394d35849d0Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 4395d35849d0Smrgdnl 4396e9e6e0f6Smrg AC_CACHE_CHECK([for tmpnam], glibcxx_cv_TMPNAM, [dnl 4397d35849d0Smrg GCC_TRY_COMPILE_OR_LINK( 4398d35849d0Smrg [#include <stdio.h>], 4399d35849d0Smrg [char *tmp = tmpnam(NULL);], 4400d35849d0Smrg [glibcxx_cv_TMPNAM=yes], 4401d35849d0Smrg [glibcxx_cv_TMPNAM=no]) 4402d35849d0Smrg ]) 4403d35849d0Smrg if test $glibcxx_cv_TMPNAM = yes; then 4404d35849d0Smrg AC_DEFINE(_GLIBCXX_USE_TMPNAM, 1, [Define if obsolescent tmpnam is available in <stdio.h>.]) 4405d35849d0Smrg fi 4406d35849d0Smrgdnl 4407d35849d0Smrg CXXFLAGS="$ac_save_CXXFLAGS" 4408d35849d0Smrg AC_LANG_RESTORE 4409d35849d0Smrg]) 441048fb7bfaSmrg 441148fb7bfaSmrgdnl 441248fb7bfaSmrgdnl Check to see if sys/sdt.h exists and that it is suitable for use. 441348fb7bfaSmrgdnl Some versions of sdt.h were not compatible with C++11. 441448fb7bfaSmrgdnl 441548fb7bfaSmrgAC_DEFUN([GLIBCXX_CHECK_SDT_H], [ 441648fb7bfaSmrg # Note that this test has to be run with the C language. 441748fb7bfaSmrg # Otherwise, sdt.h will try to include some headers from 441848fb7bfaSmrg # libstdc++ itself. 441948fb7bfaSmrg AC_LANG_SAVE 442048fb7bfaSmrg AC_LANG_C 4421e9e6e0f6Smrg AC_CACHE_CHECK([for suitable sys/sdt.h], 4422e9e6e0f6Smrg glibcxx_cv_sys_sdt_h, [ 442348fb7bfaSmrg # Because we have to run the test in C, we use grep rather 442448fb7bfaSmrg # than the compiler to check for the bug. The bug is that 442548fb7bfaSmrg # were strings without trailing whitespace, causing g++ 442648fb7bfaSmrg # to look for operator"". The pattern searches for the fixed 442748fb7bfaSmrg # output. 442848fb7bfaSmrg AC_EGREP_CPP([ \",\" ], [ 442948fb7bfaSmrg #include <sys/sdt.h> 443048fb7bfaSmrg int f() { STAP_PROBE(hi, bob); } 443148fb7bfaSmrg ], [glibcxx_cv_sys_sdt_h=yes], [glibcxx_cv_sys_sdt_h=no]) 443248fb7bfaSmrg ]) 443348fb7bfaSmrg AC_LANG_RESTORE 443448fb7bfaSmrg if test $glibcxx_cv_sys_sdt_h = yes; then 443548fb7bfaSmrg AC_DEFINE(HAVE_SYS_SDT_H, 1, 443648fb7bfaSmrg [Define to 1 if you have a suitable <sys/sdt.h> header file]) 443748fb7bfaSmrg fi 443848fb7bfaSmrg]) 443948fb7bfaSmrg 4440d35849d0Smrgdnl 4441d35849d0Smrgdnl Control whether the library should define symbols for old and new ABIs. 4442d35849d0Smrgdnl This affects definitions of strings, stringstreams and locale facets. 4443d35849d0Smrgdnl 4444d35849d0Smrgdnl --disable-libstdcxx-dual-abi will use old ABI for all types. 4445d35849d0Smrgdnl 4446d35849d0Smrgdnl Defines: 4447d35849d0Smrgdnl _GLIBCXX_USE_DUAL_ABI (always defined, either to 1 or 0) 4448d35849d0Smrgdnl 4449d35849d0SmrgAC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI], [ 4450d35849d0Smrg GLIBCXX_ENABLE(libstdcxx-dual-abi,$1,,[support two versions of std::string]) 4451d35849d0Smrg if test x$enable_symvers = xgnu-versioned-namespace; then 4452d35849d0Smrg # gnu-versioned-namespace is incompatible with the dual ABI. 4453d35849d0Smrg enable_libstdcxx_dual_abi="no" 4454d35849d0Smrg fi 4455d35849d0Smrg if test x"$enable_libstdcxx_dual_abi" != xyes; then 4456d35849d0Smrg AC_MSG_NOTICE([dual ABI is disabled]) 4457d35849d0Smrg default_libstdcxx_abi="gcc4-compatible" 4458d35849d0Smrg fi 4459d35849d0Smrg GLIBCXX_CONDITIONAL(ENABLE_DUAL_ABI, test $enable_libstdcxx_dual_abi = yes) 4460d35849d0Smrg]) 4461d35849d0Smrg 4462d35849d0Smrgdnl 4463d35849d0Smrgdnl Check to see which ABI should be enabled by default. 4464d35849d0Smrgdnl 4465d35849d0Smrgdnl --with-default-libstdcxx-abi={gcc4-compatible,new} 4466d35849d0Smrgdnl 4467d35849d0Smrgdnl Defines: 4468d35849d0Smrgdnl _GLIBCXX_USE_CXX11_ABI (always defined, either to 1 or 0) 4469d35849d0Smrgdnl 4470d35849d0SmrgAC_DEFUN([GLIBCXX_DEFAULT_ABI], [ 4471d35849d0Smrg if test x$enable_libstdcxx_dual_abi = xyes; then 4472d35849d0Smrg AC_MSG_CHECKING([for default std::string ABI to use]) 4473d35849d0Smrg AC_ARG_WITH([default-libstdcxx-abi], 4474d35849d0Smrg AS_HELP_STRING([--with-default-libstdcxx-abi], 4475d35849d0Smrg [set the std::string ABI to use by default]), 4476d35849d0Smrg [case "$withval" in 4477d35849d0Smrg gcc4-compatible) default_libstdcxx_abi="gcc4-compatible" ;; 4478d35849d0Smrg new|cxx11) default_libstdcxx_abi="new" ;; 4479d35849d0Smrg c++*|gnu++*) AC_MSG_ERROR([Supported arguments for --with-default-libstdcxx-abi have changed, use "new" or "gcc4-compatible"]) ;; 4480d35849d0Smrg *) AC_MSG_ERROR([Invalid argument for --with-default-libstdcxx-abi]) ;; 4481d35849d0Smrg esac 4482d35849d0Smrg ], 4483d35849d0Smrg [default_libstdcxx_abi="new"]) 4484d35849d0Smrg AC_MSG_RESULT(${default_libstdcxx_abi}) 4485d35849d0Smrg fi 4486d35849d0Smrg if test $default_libstdcxx_abi = "new"; then 4487d35849d0Smrg glibcxx_cxx11_abi=1 4488d35849d0Smrg glibcxx_cxx98_abi=0 4489d35849d0Smrg else 4490d35849d0Smrg glibcxx_cxx11_abi=0 4491d35849d0Smrg glibcxx_cxx98_abi=1 4492d35849d0Smrg fi 4493d35849d0Smrg AC_SUBST(glibcxx_cxx98_abi) 4494d35849d0Smrg GLIBCXX_CONDITIONAL(ENABLE_CXX11_ABI, test $glibcxx_cxx11_abi = 1) 4495d35849d0Smrg]) 4496d35849d0Smrg 4497d35849d0Smrgdnl 4498d35849d0Smrgdnl Check to see whether to build libstdc++fs.a 4499d35849d0Smrgdnl 4500d35849d0Smrgdnl --enable-libstdcxx-filesystem-ts 4501d35849d0Smrgdnl 4502d35849d0SmrgAC_DEFUN([GLIBCXX_ENABLE_FILESYSTEM_TS], [ 4503d35849d0Smrg GLIBCXX_ENABLE(libstdcxx-filesystem-ts,auto,, 4504d35849d0Smrg [turns on ISO/IEC TS 18822 support], 4505d35849d0Smrg [permit yes|no|auto]) 4506d35849d0Smrg 4507d35849d0Smrg AC_MSG_CHECKING([whether to build Filesystem TS support]) 4508d35849d0Smrg if test x"$ac_cv_header_dirent_h" != x"yes"; then 4509d35849d0Smrg enable_libstdcxx_filesystem_ts=no 4510d35849d0Smrg fi 4511d35849d0Smrg if test x"$enable_libstdcxx_filesystem_ts" = x"auto"; then 4512d35849d0Smrg case "${target_os}" in 4513d35849d0Smrg freebsd*|netbsd*|openbsd*|dragonfly*|darwin*) 4514d35849d0Smrg enable_libstdcxx_filesystem_ts=yes 4515d35849d0Smrg ;; 451643265c03Smrg gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu | uclinux*) 4517d35849d0Smrg enable_libstdcxx_filesystem_ts=yes 4518d35849d0Smrg ;; 45193f8cba22Smrg rtems*) 45203f8cba22Smrg enable_libstdcxx_filesystem_ts=yes 45213f8cba22Smrg ;; 4522d35849d0Smrg solaris*) 4523d35849d0Smrg enable_libstdcxx_filesystem_ts=yes 4524d35849d0Smrg ;; 452543265c03Smrg mingw*) 452643265c03Smrg enable_libstdcxx_filesystem_ts=yes 452743265c03Smrg ;; 4528d35849d0Smrg *) 4529d35849d0Smrg enable_libstdcxx_filesystem_ts=no 4530d35849d0Smrg ;; 4531d35849d0Smrg esac 4532d35849d0Smrg fi 4533d35849d0Smrg AC_MSG_RESULT($enable_libstdcxx_filesystem_ts) 4534d35849d0Smrg GLIBCXX_CONDITIONAL(ENABLE_FILESYSTEM_TS, test $enable_libstdcxx_filesystem_ts = yes) 4535d35849d0Smrg]) 4536d35849d0Smrg 4537d35849d0Smrgdnl 453843265c03Smrgdnl Check whether the library calls required by the C++17 Filesystem library 453943265c03Smrgdnl and the Filesystem TS are present. 4540654d12c0Smrgdnl Defines: 4541654d12c0Smrgdnl HAVE_STRUCT_DIRENT_D_TYPE 4542654d12c0Smrgdnl _GLIBCXX_USE_REALPATH 4543654d12c0Smrgdnl _GLIBCXX_USE_UTIMENSAT 4544654d12c0Smrgdnl _GLIBCXX_USE_ST_MTIM 4545654d12c0Smrgdnl _GLIBCXX_USE_FCHMOD 4546654d12c0Smrgdnl _GLIBCXX_USE_FCHMODAT 4547654d12c0Smrgdnl _GLIBCXX_USE_SENDFILE 4548654d12c0Smrgdnl HAVE_LINK 4549654d12c0Smrgdnl HAVE_READLINK 4550654d12c0Smrgdnl HAVE_SYMLINK 4551d35849d0Smrgdnl 4552d35849d0SmrgAC_DEFUN([GLIBCXX_CHECK_FILESYSTEM_DEPS], [dnl 4553d35849d0Smrgdnl 4554d35849d0Smrg AC_LANG_SAVE 4555d35849d0Smrg AC_LANG_CPLUSPLUS 4556d35849d0Smrg ac_save_CXXFLAGS="$CXXFLAGS" 4557d35849d0Smrg CXXFLAGS="$CXXFLAGS -fno-exceptions" 4558d35849d0Smrgdnl 4559e9e6e0f6Smrg AC_CACHE_CHECK([for struct dirent.d_type], glibcxx_cv_dirent_d_type, [dnl 4560d35849d0Smrg GCC_TRY_COMPILE_OR_LINK( 4561d35849d0Smrg [#include <dirent.h>], 4562d35849d0Smrg [ 4563d35849d0Smrg struct dirent d; 4564d35849d0Smrg if (sizeof d.d_type) return 0; 4565d35849d0Smrg ], 4566d35849d0Smrg [glibcxx_cv_dirent_d_type=yes], 4567d35849d0Smrg [glibcxx_cv_dirent_d_type=no]) 4568d35849d0Smrg ]) 4569d35849d0Smrg if test $glibcxx_cv_dirent_d_type = yes; then 4570d35849d0Smrg AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE, 1, [Define to 1 if `d_type' is a member of `struct dirent'.]) 4571d35849d0Smrg fi 4572d35849d0Smrgdnl 4573*4fe0f936Smrg AC_CACHE_CHECK([for chmod], glibcxx_cv_chmod, [dnl 4574*4fe0f936Smrg GCC_TRY_COMPILE_OR_LINK( 4575*4fe0f936Smrg [ 4576*4fe0f936Smrg #include <sys/stat.h> 4577*4fe0f936Smrg ], 4578*4fe0f936Smrg [ 4579*4fe0f936Smrg int i = chmod("", S_IRUSR); 4580*4fe0f936Smrg ], 4581*4fe0f936Smrg [glibcxx_cv_chmod=yes], 4582*4fe0f936Smrg [glibcxx_cv_chmod=no]) 4583*4fe0f936Smrg ]) 4584*4fe0f936Smrg if test $glibcxx_cv_chmod = yes; then 4585*4fe0f936Smrg AC_DEFINE(_GLIBCXX_USE_CHMOD, 1, [Define if usable chmod is available in <sys/stat.h>.]) 4586*4fe0f936Smrg fi 4587*4fe0f936Smrgdnl 4588*4fe0f936Smrg AC_CACHE_CHECK([for mkdir], glibcxx_cv_mkdir, [dnl 4589*4fe0f936Smrg GCC_TRY_COMPILE_OR_LINK( 4590*4fe0f936Smrg [ 4591*4fe0f936Smrg #include <sys/stat.h> 4592*4fe0f936Smrg ], 4593*4fe0f936Smrg [ 4594*4fe0f936Smrg int i = mkdir("", S_IRUSR); 4595*4fe0f936Smrg ], 4596*4fe0f936Smrg [glibcxx_cv_mkdir=yes], 4597*4fe0f936Smrg [glibcxx_cv_mkdir=no]) 4598*4fe0f936Smrg ]) 4599*4fe0f936Smrg if test $glibcxx_cv_mkdir = yes; then 4600*4fe0f936Smrg AC_DEFINE(_GLIBCXX_USE_MKDIR, 1, [Define if usable mkdir is available in <sys/stat.h>.]) 4601*4fe0f936Smrg fi 4602*4fe0f936Smrgdnl 4603*4fe0f936Smrg AC_CACHE_CHECK([for chdir], glibcxx_cv_chdir, [dnl 4604*4fe0f936Smrg GCC_TRY_COMPILE_OR_LINK( 4605*4fe0f936Smrg [ 4606*4fe0f936Smrg #include <unistd.h> 4607*4fe0f936Smrg ], 4608*4fe0f936Smrg [ 4609*4fe0f936Smrg int i = chdir(""); 4610*4fe0f936Smrg ], 4611*4fe0f936Smrg [glibcxx_cv_chdir=yes], 4612*4fe0f936Smrg [glibcxx_cv_chdir=no]) 4613*4fe0f936Smrg ]) 4614*4fe0f936Smrg if test $glibcxx_cv_chdir = yes; then 4615*4fe0f936Smrg AC_DEFINE(_GLIBCXX_USE_CHDIR, 1, [Define if usable chdir is available in <unistd.h>.]) 4616*4fe0f936Smrg fi 4617*4fe0f936Smrgdnl 4618*4fe0f936Smrg AC_CACHE_CHECK([for getcwd], glibcxx_cv_getcwd, [dnl 4619*4fe0f936Smrg GCC_TRY_COMPILE_OR_LINK( 4620*4fe0f936Smrg [ 4621*4fe0f936Smrg #include <unistd.h> 4622*4fe0f936Smrg ], 4623*4fe0f936Smrg [ 4624*4fe0f936Smrg char* s = getcwd((char*)0, 1); 4625*4fe0f936Smrg ], 4626*4fe0f936Smrg [glibcxx_cv_getcwd=yes], 4627*4fe0f936Smrg [glibcxx_cv_getcwd=no]) 4628*4fe0f936Smrg ]) 4629*4fe0f936Smrg if test $glibcxx_cv_getcwd = yes; then 4630*4fe0f936Smrg AC_DEFINE(_GLIBCXX_USE_GETCWD, 1, [Define if usable getcwd is available in <unistd.h>.]) 4631*4fe0f936Smrg fi 4632*4fe0f936Smrgdnl 4633e9e6e0f6Smrg AC_CACHE_CHECK([for realpath], glibcxx_cv_realpath, [dnl 4634d35849d0Smrg GCC_TRY_COMPILE_OR_LINK( 4635d35849d0Smrg [ 46360c98858fSmrg #include <limits.h> 4637d35849d0Smrg #include <stdlib.h> 4638d35849d0Smrg #include <unistd.h> 4639d35849d0Smrg ], 4640d35849d0Smrg [ 4641d35849d0Smrg #if _XOPEN_VERSION < 500 4642d35849d0Smrg #error 4643d35849d0Smrg #elif _XOPEN_VERSION >= 700 || defined(PATH_MAX) 4644d35849d0Smrg char *tmp = realpath((const char*)NULL, (char*)NULL); 4645d35849d0Smrg #else 4646d35849d0Smrg #error 4647d35849d0Smrg #endif 4648d35849d0Smrg ], 4649d35849d0Smrg [glibcxx_cv_realpath=yes], 4650d35849d0Smrg [glibcxx_cv_realpath=no]) 4651d35849d0Smrg ]) 4652d35849d0Smrg if test $glibcxx_cv_realpath = yes; then 4653d35849d0Smrg AC_DEFINE(_GLIBCXX_USE_REALPATH, 1, [Define if usable realpath is available in <stdlib.h>.]) 4654d35849d0Smrg fi 4655d35849d0Smrgdnl 4656e9e6e0f6Smrg AC_CACHE_CHECK([for utimensat], glibcxx_cv_utimensat, [dnl 4657d35849d0Smrg GCC_TRY_COMPILE_OR_LINK( 4658d35849d0Smrg [ 4659d35849d0Smrg #include <fcntl.h> 4660d35849d0Smrg #include <sys/stat.h> 4661d35849d0Smrg ], 4662d35849d0Smrg [ 4663d35849d0Smrg struct timespec ts[2] = { { 0, UTIME_OMIT }, { 1, 1 } }; 4664d35849d0Smrg int i = utimensat(AT_FDCWD, "path", ts, 0); 4665d35849d0Smrg ], 4666d35849d0Smrg [glibcxx_cv_utimensat=yes], 4667d35849d0Smrg [glibcxx_cv_utimensat=no]) 4668d35849d0Smrg ]) 4669d35849d0Smrg if test $glibcxx_cv_utimensat = yes; then 4670d35849d0Smrg AC_DEFINE(_GLIBCXX_USE_UTIMENSAT, 1, [Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and AT_FDCWD in <fcntl.h>.]) 4671d35849d0Smrg fi 4672d35849d0Smrgdnl 4673e9e6e0f6Smrg AC_CACHE_CHECK([for utime], glibcxx_cv_utime, [dnl 4674654d12c0Smrg GCC_TRY_COMPILE_OR_LINK( 4675654d12c0Smrg [ 4676654d12c0Smrg #include <utime.h> 4677654d12c0Smrg ], 4678654d12c0Smrg [ 4679654d12c0Smrg struct utimbuf t = { 1, 1 }; 4680654d12c0Smrg int i = utime("path", &t); 4681654d12c0Smrg ], 4682654d12c0Smrg [glibcxx_cv_utime=yes], 4683654d12c0Smrg [glibcxx_cv_utime=no]) 4684654d12c0Smrg ]) 4685654d12c0Smrg if test $glibcxx_cv_utime = yes; then 4686654d12c0Smrg AC_DEFINE(_GLIBCXX_USE_UTIME, 1, [Define if utime is available in <utime.h>.]) 4687654d12c0Smrg fi 4688654d12c0Smrgdnl 4689e9e6e0f6Smrg AC_CACHE_CHECK([for lstat], glibcxx_cv_lstat, [dnl 4690654d12c0Smrg GCC_TRY_COMPILE_OR_LINK( 4691654d12c0Smrg [ #include <sys/stat.h> ], 4692654d12c0Smrg [ 4693654d12c0Smrg struct stat st; 4694654d12c0Smrg int i = lstat("path", &st); 4695654d12c0Smrg ], 4696654d12c0Smrg [glibcxx_cv_lstat=yes], 4697654d12c0Smrg [glibcxx_cv_lstat=no]) 4698654d12c0Smrg ]) 4699654d12c0Smrg if test $glibcxx_cv_lstat = yes; then 4700654d12c0Smrg AC_DEFINE(_GLIBCXX_USE_LSTAT, 1, [Define if lstat is available in <sys/stat.h>.]) 4701654d12c0Smrg fi 4702654d12c0Smrgdnl 4703e9e6e0f6Smrg AC_CACHE_CHECK([for struct stat.st_mtim.tv_nsec], 4704e9e6e0f6Smrg glibcxx_cv_st_mtim, [dnl 4705d35849d0Smrg GCC_TRY_COMPILE_OR_LINK( 4706d35849d0Smrg [ #include <sys/stat.h> ], 4707d35849d0Smrg [ 4708d35849d0Smrg struct stat st; 4709d35849d0Smrg return st.st_mtim.tv_nsec; 4710d35849d0Smrg ], 4711d35849d0Smrg [glibcxx_cv_st_mtim=yes], 4712d35849d0Smrg [glibcxx_cv_st_mtim=no]) 4713d35849d0Smrg ]) 4714d35849d0Smrg if test $glibcxx_cv_st_mtim = yes; then 4715d35849d0Smrg AC_DEFINE(_GLIBCXX_USE_ST_MTIM, 1, [Define if struct stat has timespec members.]) 4716d35849d0Smrg fi 4717d35849d0Smrgdnl 4718e9e6e0f6Smrg AC_CACHE_CHECK([for fchmod], 4719e9e6e0f6Smrg glibcxx_cv_fchmod, [dnl 4720d35849d0Smrg GCC_TRY_COMPILE_OR_LINK( 4721d35849d0Smrg [#include <sys/stat.h>], 4722d35849d0Smrg [fchmod(1, S_IWUSR);], 4723d35849d0Smrg [glibcxx_cv_fchmod=yes], 4724d35849d0Smrg [glibcxx_cv_fchmod=no]) 4725d35849d0Smrg ]) 4726d35849d0Smrg if test $glibcxx_cv_fchmod = yes; then 4727d35849d0Smrg AC_DEFINE(_GLIBCXX_USE_FCHMOD, 1, [Define if fchmod is available in <sys/stat.h>.]) 4728d35849d0Smrg fi 4729d35849d0Smrgdnl 4730e9e6e0f6Smrg AC_CACHE_CHECK([for fchmodat], 4731e9e6e0f6Smrg glibcxx_cv_fchmodat, [dnl 4732d35849d0Smrg GCC_TRY_COMPILE_OR_LINK( 4733d35849d0Smrg [ 4734d35849d0Smrg #include <fcntl.h> 4735d35849d0Smrg #include <sys/stat.h> 4736d35849d0Smrg ], 4737d35849d0Smrg [fchmodat(AT_FDCWD, "", 0, AT_SYMLINK_NOFOLLOW);], 4738d35849d0Smrg [glibcxx_cv_fchmodat=yes], 4739d35849d0Smrg [glibcxx_cv_fchmodat=no]) 4740d35849d0Smrg ]) 4741d35849d0Smrg if test $glibcxx_cv_fchmodat = yes; then 4742d35849d0Smrg AC_DEFINE(_GLIBCXX_USE_FCHMODAT, 1, [Define if fchmodat is available in <sys/stat.h>.]) 4743d35849d0Smrg fi 4744d35849d0Smrgdnl 4745e9e6e0f6Smrg AC_CACHE_CHECK([for sendfile that can copy files], 4746e9e6e0f6Smrg glibcxx_cv_sendfile, [dnl 4747d35849d0Smrg case "${target_os}" in 474843265c03Smrg gnu* | linux* | solaris* | uclinux*) 4749d35849d0Smrg GCC_TRY_COMPILE_OR_LINK( 4750d35849d0Smrg [#include <sys/sendfile.h>], 47510c98858fSmrg [sendfile(1, 2, (off_t*)0, sizeof 1);], 4752d35849d0Smrg [glibcxx_cv_sendfile=yes], 4753d35849d0Smrg [glibcxx_cv_sendfile=no]) 4754d35849d0Smrg ;; 4755d35849d0Smrg *) 4756d35849d0Smrg glibcxx_cv_sendfile=no 4757d35849d0Smrg ;; 4758d35849d0Smrg esac 4759d35849d0Smrg ]) 4760d35849d0Smrg if test $glibcxx_cv_sendfile = yes; then 47610c98858fSmrg AC_DEFINE(_GLIBCXX_USE_SENDFILE, 1, [Define if sendfile is available in <sys/sendfile.h>.]) 4762d35849d0Smrg fi 4763d35849d0Smrgdnl 4764e9e6e0f6Smrg AC_CACHE_CHECK([for link], 4765e9e6e0f6Smrg glibcxx_cv_link, [dnl 4766654d12c0Smrg GCC_TRY_COMPILE_OR_LINK( 4767654d12c0Smrg [#include <unistd.h>], 4768654d12c0Smrg [link("", "");], 4769654d12c0Smrg [glibcxx_cv_link=yes], 4770654d12c0Smrg [glibcxx_cv_link=no]) 4771654d12c0Smrg ]) 4772654d12c0Smrg if test $glibcxx_cv_link = yes; then 4773654d12c0Smrg AC_DEFINE(HAVE_LINK, 1, [Define if link is available in <unistd.h>.]) 4774654d12c0Smrg fi 4775654d12c0Smrgdnl 4776e9e6e0f6Smrg AC_CACHE_CHECK([for readlink], 4777e9e6e0f6Smrg glibcxx_cv_readlink, [dnl 4778654d12c0Smrg GCC_TRY_COMPILE_OR_LINK( 4779654d12c0Smrg [#include <unistd.h>], 4780654d12c0Smrg [char buf[32]; readlink("", buf, sizeof(buf));], 4781654d12c0Smrg [glibcxx_cv_readlink=yes], 4782654d12c0Smrg [glibcxx_cv_readlink=no]) 4783654d12c0Smrg ]) 4784654d12c0Smrg if test $glibcxx_cv_readlink = yes; then 4785654d12c0Smrg AC_DEFINE(HAVE_READLINK, 1, [Define if readlink is available in <unistd.h>.]) 4786654d12c0Smrg fi 4787654d12c0Smrgdnl 4788e9e6e0f6Smrg AC_CACHE_CHECK([for symlink], 4789e9e6e0f6Smrg glibcxx_cv_symlink, [dnl 4790654d12c0Smrg GCC_TRY_COMPILE_OR_LINK( 4791654d12c0Smrg [#include <unistd.h>], 4792654d12c0Smrg [symlink("", "");], 4793654d12c0Smrg [glibcxx_cv_symlink=yes], 4794654d12c0Smrg [glibcxx_cv_symlink=no]) 4795654d12c0Smrg ]) 4796654d12c0Smrg if test $glibcxx_cv_symlink = yes; then 4797654d12c0Smrg AC_DEFINE(HAVE_SYMLINK, 1, [Define if symlink is available in <unistd.h>.]) 4798654d12c0Smrg fi 4799654d12c0Smrgdnl 4800e9e6e0f6Smrg AC_CACHE_CHECK([for truncate], 4801e9e6e0f6Smrg glibcxx_cv_truncate, [dnl 4802654d12c0Smrg GCC_TRY_COMPILE_OR_LINK( 4803654d12c0Smrg [#include <unistd.h>], 4804654d12c0Smrg [truncate("", 99);], 4805654d12c0Smrg [glibcxx_cv_truncate=yes], 4806654d12c0Smrg [glibcxx_cv_truncate=no]) 4807654d12c0Smrg ]) 4808654d12c0Smrg if test $glibcxx_cv_truncate = yes; then 4809654d12c0Smrg AC_DEFINE(HAVE_TRUNCATE, 1, [Define if truncate is available in <unistd.h>.]) 4810654d12c0Smrg fi 4811e9e6e0f6Smrgdnl 4812e9e6e0f6Smrg AC_CACHE_CHECK([for fdopendir], 4813e9e6e0f6Smrg glibcxx_cv_fdopendir, [dnl 4814e9e6e0f6Smrg GCC_TRY_COMPILE_OR_LINK( 4815e9e6e0f6Smrg [#include <dirent.h>], 4816e9e6e0f6Smrg [::DIR* dir = ::fdopendir(1);], 4817e9e6e0f6Smrg [glibcxx_cv_fdopendir=yes], 4818e9e6e0f6Smrg [glibcxx_cv_fdopendir=no]) 4819e9e6e0f6Smrg ]) 4820e9e6e0f6Smrg if test $glibcxx_cv_fdopendir = yes; then 4821e9e6e0f6Smrg AC_DEFINE(HAVE_FDOPENDIR, 1, [Define if fdopendir is available in <dirent.h>.]) 4822e9e6e0f6Smrg fi 4823e9e6e0f6Smrgdnl 4824e9e6e0f6Smrg AC_CACHE_CHECK([for dirfd], 4825e9e6e0f6Smrg glibcxx_cv_dirfd, [dnl 4826e9e6e0f6Smrg GCC_TRY_COMPILE_OR_LINK( 4827e9e6e0f6Smrg [#include <dirent.h>], 4828e9e6e0f6Smrg [int fd = ::dirfd((::DIR*)0);], 4829e9e6e0f6Smrg [glibcxx_cv_dirfd=yes], 4830e9e6e0f6Smrg [glibcxx_cv_dirfd=no]) 4831e9e6e0f6Smrg ]) 4832e9e6e0f6Smrg if test $glibcxx_cv_dirfd = yes; then 4833e9e6e0f6Smrg AC_DEFINE(HAVE_DIRFD, 1, [Define if dirfd is available in <dirent.h>.]) 4834e9e6e0f6Smrg fi 4835e9e6e0f6Smrgdnl 4836e9e6e0f6Smrg AC_CACHE_CHECK([for openat], 4837e9e6e0f6Smrg glibcxx_cv_openat, [dnl 4838e9e6e0f6Smrg GCC_TRY_COMPILE_OR_LINK( 4839e9e6e0f6Smrg [#include <fcntl.h>], 4840e9e6e0f6Smrg [int fd = ::openat(AT_FDCWD, "", 0);], 4841e9e6e0f6Smrg [glibcxx_cv_openat=yes], 4842e9e6e0f6Smrg [glibcxx_cv_openat=no]) 4843e9e6e0f6Smrg ]) 4844e9e6e0f6Smrg if test $glibcxx_cv_openat = yes; then 4845e9e6e0f6Smrg AC_DEFINE(HAVE_OPENAT, 1, [Define if openat is available in <fcntl.h>.]) 4846e9e6e0f6Smrg fi 4847e9e6e0f6Smrgdnl 4848e9e6e0f6Smrg AC_CACHE_CHECK([for unlinkat], 4849e9e6e0f6Smrg glibcxx_cv_unlinkat, [dnl 4850e9e6e0f6Smrg GCC_TRY_COMPILE_OR_LINK( 4851e9e6e0f6Smrg [#include <fcntl.h> 4852e9e6e0f6Smrg #include <unistd.h>], 4853e9e6e0f6Smrg [::unlinkat(AT_FDCWD, "", AT_REMOVEDIR);], 4854e9e6e0f6Smrg [glibcxx_cv_unlinkat=yes], 4855e9e6e0f6Smrg [glibcxx_cv_unlinkat=no]) 4856e9e6e0f6Smrg ]) 4857e9e6e0f6Smrg if test $glibcxx_cv_unlinkat = yes; then 4858e9e6e0f6Smrg AC_DEFINE(HAVE_UNLINKAT, 1, [Define if unlinkat is available in <fcntl.h>.]) 4859e9e6e0f6Smrg fi 4860654d12c0Smrgdnl 4861d35849d0Smrg CXXFLAGS="$ac_save_CXXFLAGS" 4862d35849d0Smrg AC_LANG_RESTORE 4863d35849d0Smrg]) 4864d35849d0Smrg 4865cdbfa754Smrgdnl 4866cdbfa754Smrgdnl Check how size_t is mangled. Copied from libitm. 4867cdbfa754Smrgdnl 4868cdbfa754SmrgAC_DEFUN([GLIBCXX_CHECK_SIZE_T_MANGLING], [ 4869cdbfa754Smrg AC_CACHE_CHECK([how size_t is mangled], 4870cdbfa754Smrg glibcxx_cv_size_t_mangling, [ 4871cdbfa754Smrg AC_TRY_COMPILE([], [extern __SIZE_TYPE__ x; extern unsigned long x;], 4872cdbfa754Smrg [glibcxx_cv_size_t_mangling=m], [ 4873cdbfa754Smrg AC_TRY_COMPILE([], [extern __SIZE_TYPE__ x; extern unsigned int x;], 4874cdbfa754Smrg [glibcxx_cv_size_t_mangling=j], [ 4875cdbfa754Smrg AC_TRY_COMPILE([], 4876cdbfa754Smrg [extern __SIZE_TYPE__ x; extern unsigned long long x;], 4877cdbfa754Smrg [glibcxx_cv_size_t_mangling=y], [ 4878cdbfa754Smrg AC_TRY_COMPILE([], 4879cdbfa754Smrg [extern __SIZE_TYPE__ x; extern unsigned short x;], 4880cdbfa754Smrg [glibcxx_cv_size_t_mangling=t], [ 4881cdbfa754Smrg AC_TRY_COMPILE([], 4882cdbfa754Smrg [extern __SIZE_TYPE__ x; extern __int20 unsigned x;], 4883cdbfa754Smrg [glibcxx_cv_size_t_mangling=u6uint20], 4884cdbfa754Smrg [glibcxx_cv_size_t_mangling=x]) 4885cdbfa754Smrg ]) 4886cdbfa754Smrg ]) 4887cdbfa754Smrg ]) 4888cdbfa754Smrg ]) 4889cdbfa754Smrg ]) 4890cdbfa754Smrg if test $glibcxx_cv_size_t_mangling = x; then 4891cdbfa754Smrg AC_MSG_ERROR([Unknown underlying type for size_t]) 4892cdbfa754Smrg fi 4893cdbfa754Smrg AC_DEFINE_UNQUOTED(_GLIBCXX_MANGLE_SIZE_T, [$glibcxx_cv_size_t_mangling], 4894cdbfa754Smrg [Define to the letter to which size_t is mangled.]) 4895cdbfa754Smrg]) 4896cdbfa754Smrg 4897a41324a9Smrgdnl 4898a41324a9Smrgdnl Determine whether std::exception_ptr symbols should be exported with 4899a41324a9Smrgdnl the symbol versions from GCC 4.6.0 or GCC 7.1.0, depending on which 4900a41324a9Smrgdnl release first added support for std::exception_ptr. Originally it was 4901a41324a9Smrgdnl only supported for targets with always-lock-free atomics for int, but 4902a41324a9Smrgdnl since GCC 7.1 it is supported for all targets. 4903a41324a9Smrgdnl 4904a41324a9SmrgAC_DEFUN([GLIBCXX_CHECK_EXCEPTION_PTR_SYMVER], [ 4905a41324a9Smrg if test $enable_symvers != no; then 4906a41324a9Smrg AC_MSG_CHECKING([for first version to support std::exception_ptr]) 4907a41324a9Smrg case ${target} in 4908a41324a9Smrg aarch64-*-* | alpha-*-* | hppa*-*-* | i?86-*-* | x86_64-*-* | \ 4909a41324a9Smrg m68k-*-* | powerpc*-*-* | s390*-*-* | *-*-solaris* ) 4910a41324a9Smrg ac_exception_ptr_since_gcc46=yes 4911a41324a9Smrg ;; 4912a41324a9Smrg *) 4913a41324a9Smrg # If the value of this macro changes then we will need to hardcode 4914a41324a9Smrg # yes/no here for additional targets based on the original value. 4915a41324a9Smrg AC_TRY_COMPILE([], [ 4916a41324a9Smrg #if __GCC_ATOMIC_INT_LOCK_FREE <= 1 4917a41324a9Smrg # error atomic int not always lock free 4918a41324a9Smrg #endif 4919a41324a9Smrg ], 4920a41324a9Smrg [ac_exception_ptr_since_gcc46=yes], 4921a41324a9Smrg [ac_exception_ptr_since_gcc46=no]) 4922a41324a9Smrg ;; 4923a41324a9Smrg esac 4924a41324a9Smrg if test x"$ac_exception_ptr_since_gcc46" = x"yes" ; then 4925a41324a9Smrg AC_DEFINE(HAVE_EXCEPTION_PTR_SINCE_GCC46, 1, 4926a41324a9Smrg [Define to 1 if GCC 4.6 supported std::exception_ptr for the target]) 4927a41324a9Smrg AC_MSG_RESULT([4.6.0]) 4928a41324a9Smrg else 4929a41324a9Smrg AC_MSG_RESULT([7.1.0]) 4930a41324a9Smrg fi 4931a41324a9Smrg fi 4932a41324a9Smrg]) 4933a41324a9Smrg 4934e9e6e0f6Smrgdnl 4935e9e6e0f6Smrgdnl Check whether getentropy is present in <unistd.h>. 4936e9e6e0f6Smrgdnl 4937e9e6e0f6SmrgAC_DEFUN([GLIBCXX_CHECK_GETENTROPY], [ 4938e9e6e0f6Smrg 4939e9e6e0f6Smrg AC_LANG_SAVE 4940e9e6e0f6Smrg AC_LANG_CPLUSPLUS 4941e9e6e0f6Smrg AC_CACHE_CHECK([for getentropy], glibcxx_cv_getentropy, [ 4942e9e6e0f6Smrg GCC_TRY_COMPILE_OR_LINK( 4943e9e6e0f6Smrg [#include <unistd.h>], 4944e9e6e0f6Smrg [unsigned i; 4945e9e6e0f6Smrg ::getentropy(&i, sizeof(i));], 4946e9e6e0f6Smrg [glibcxx_cv_getentropy=yes], [glibcxx_cv_getentropy=no]) 4947e9e6e0f6Smrg ]) 4948e9e6e0f6Smrg 4949e9e6e0f6Smrg if test $glibcxx_cv_getentropy = yes; then 4950e9e6e0f6Smrg AC_DEFINE(HAVE_GETENTROPY, 1, [Define if getentropy is available in <unistd.h>.]) 4951e9e6e0f6Smrg fi 4952e9e6e0f6Smrg AC_LANG_RESTORE 4953e9e6e0f6Smrg]) 4954e9e6e0f6Smrg 4955e9e6e0f6Smrgdnl 4956e9e6e0f6Smrgdnl Check whether arc4random is present in <stdlib.h>. 4957e9e6e0f6Smrgdnl 4958e9e6e0f6SmrgAC_DEFUN([GLIBCXX_CHECK_ARC4RANDOM], [ 4959e9e6e0f6Smrg 4960e9e6e0f6Smrg AC_LANG_SAVE 4961e9e6e0f6Smrg AC_LANG_CPLUSPLUS 4962e9e6e0f6Smrg AC_CACHE_CHECK([for arc4random], glibcxx_cv_arc4random, [ 4963e9e6e0f6Smrg GCC_TRY_COMPILE_OR_LINK( 4964e9e6e0f6Smrg [#include <stdlib.h>], 4965e9e6e0f6Smrg [unsigned i = ::arc4random();], 4966e9e6e0f6Smrg [glibcxx_cv_arc4random=yes], [glibcxx_cv_arc4random=no]) 4967e9e6e0f6Smrg ]) 4968e9e6e0f6Smrg 4969e9e6e0f6Smrg if test $glibcxx_cv_arc4random = yes; then 4970e9e6e0f6Smrg AC_DEFINE(HAVE_ARC4RANDOM, 1, [Define if arc4random is available in <stdlib.h>.]) 4971e9e6e0f6Smrg fi 4972e9e6e0f6Smrg AC_LANG_RESTORE 4973e9e6e0f6Smrg]) 4974e9e6e0f6Smrg 4975e9e6e0f6Smrgdnl 4976e9e6e0f6Smrgdnl Check to see whether to build libstdc++_libbacktrace.a 4977e9e6e0f6Smrgdnl 4978e9e6e0f6Smrgdnl --enable-libstdcxx-backtrace 4979e9e6e0f6Smrgdnl 4980e9e6e0f6SmrgAC_DEFUN([GLIBCXX_ENABLE_BACKTRACE], [ 4981e9e6e0f6Smrg GLIBCXX_ENABLE(libstdcxx-backtrace,auto,, 4982e9e6e0f6Smrg [turns on libbacktrace support], 4983e9e6e0f6Smrg [permit yes|no|auto]) 4984e9e6e0f6Smrg 4985e9e6e0f6Smrg # Most of this is adapted from libsanitizer/configure.ac 4986e9e6e0f6Smrg 4987*4fe0f936Smrg BACKTRACE_CPPFLAGS="-D_GNU_SOURCE" 4988e9e6e0f6Smrg 4989e9e6e0f6Smrg # libbacktrace only needs atomics for int, which we've already tested 4990e9e6e0f6Smrg if test "$glibcxx_cv_atomic_int" = "yes"; then 4991e9e6e0f6Smrg BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_ATOMIC_FUNCTIONS=1" 4992e9e6e0f6Smrg fi 4993e9e6e0f6Smrg 4994e9e6e0f6Smrg # Test for __sync support. 4995e9e6e0f6Smrg AC_CACHE_CHECK([__sync extensions], 4996e9e6e0f6Smrg [glibcxx_cv_sys_sync], 4997e9e6e0f6Smrg [GCC_TRY_COMPILE_OR_LINK( 4998e9e6e0f6Smrg [int i;], 4999e9e6e0f6Smrg [__sync_bool_compare_and_swap (&i, i, i); 5000e9e6e0f6Smrg __sync_lock_test_and_set (&i, 1); 5001e9e6e0f6Smrg __sync_lock_release (&i);], 5002e9e6e0f6Smrg [glibcxx_cv_sys_sync=yes], 5003e9e6e0f6Smrg [glibcxx_cv_sys_sync=no]) 5004e9e6e0f6Smrg ]) 5005e9e6e0f6Smrg if test "$glibcxx_cv_sys_sync" = "yes"; then 5006e9e6e0f6Smrg BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_SYNC_FUNCTIONS=1" 5007e9e6e0f6Smrg fi 5008e9e6e0f6Smrg 5009e9e6e0f6Smrg # Check for dl_iterate_phdr. 5010e9e6e0f6Smrg AC_CHECK_HEADERS(link.h) 5011e9e6e0f6Smrg if test "$ac_cv_header_link_h" = "no"; then 5012e9e6e0f6Smrg have_dl_iterate_phdr=no 5013e9e6e0f6Smrg else 5014e9e6e0f6Smrg # When built as a GCC target library, we can't do a link test. 5015*4fe0f936Smrg ac_save_CPPFLAGS="$CPPFLAGS" 5016*4fe0f936Smrg CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" 5017e9e6e0f6Smrg AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes], 5018e9e6e0f6Smrg [have_dl_iterate_phdr=no]) 5019*4fe0f936Smrg CPPFLAGS="$ac_save_CPPFLAGS" 5020e9e6e0f6Smrg fi 5021e9e6e0f6Smrg if test "$have_dl_iterate_phdr" = "yes"; then 5022e9e6e0f6Smrg BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_DL_ITERATE_PHDR=1" 5023e9e6e0f6Smrg fi 5024e9e6e0f6Smrg 5025e9e6e0f6Smrg # Check for the fcntl function. 5026e9e6e0f6Smrg if test -n "${with_target_subdir}"; then 5027e9e6e0f6Smrg case "${host}" in 5028e9e6e0f6Smrg *-*-mingw*) have_fcntl=no ;; 5029e9e6e0f6Smrg *) have_fcntl=yes ;; 5030e9e6e0f6Smrg esac 5031e9e6e0f6Smrg else 5032e9e6e0f6Smrg AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no]) 5033e9e6e0f6Smrg fi 5034e9e6e0f6Smrg if test "$have_fcntl" = "yes"; then 5035e9e6e0f6Smrg BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_FCNTL=1" 5036e9e6e0f6Smrg fi 5037e9e6e0f6Smrg 5038e9e6e0f6Smrg AC_CHECK_DECLS(strnlen) 5039e9e6e0f6Smrg 5040e9e6e0f6Smrg # Check for getexecname function. 5041e9e6e0f6Smrg if test -n "${with_target_subdir}"; then 5042e9e6e0f6Smrg case "${host}" in 5043e9e6e0f6Smrg *-*-solaris2*) have_getexecname=yes ;; 5044e9e6e0f6Smrg *) have_getexecname=no ;; 5045e9e6e0f6Smrg esac 5046e9e6e0f6Smrg else 5047e9e6e0f6Smrg AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no]) 5048e9e6e0f6Smrg fi 5049e9e6e0f6Smrg if test "$have_getexecname" = "yes"; then 5050e9e6e0f6Smrg BACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DHAVE_GETEXECNAME=1" 5051e9e6e0f6Smrg fi 5052e9e6e0f6Smrg 5053e9e6e0f6Smrg# The library needs to be able to read the executable itself. Compile 5054e9e6e0f6Smrg# a file to determine the executable format. The awk script 5055e9e6e0f6Smrg# filetype.awk prints out the file type. 5056e9e6e0f6SmrgAC_CACHE_CHECK([output filetype], 5057e9e6e0f6Smrg[glibcxx_cv_sys_filetype], 5058e9e6e0f6Smrg[filetype= 5059e9e6e0f6SmrgAC_COMPILE_IFELSE( 5060e9e6e0f6Smrg [AC_LANG_PROGRAM([int i;], [int j;])], 5061e9e6e0f6Smrg [filetype=`${AWK} -f $srcdir/../libbacktrace/filetype.awk conftest.$ac_objext`], 5062e9e6e0f6Smrg [AC_MSG_FAILURE([compiler failed])]) 5063e9e6e0f6Smrgglibcxx_cv_sys_filetype=$filetype]) 5064e9e6e0f6Smrg 5065e9e6e0f6Smrg# Match the file type to decide what files to compile. 5066e9e6e0f6SmrgFORMAT_FILE= 5067e9e6e0f6Smrgcase "$glibcxx_cv_sys_filetype" in 5068e9e6e0f6Smrgelf*) FORMAT_FILE="elf.lo" ;; 5069e9e6e0f6Smrg*) AC_MSG_WARN([could not determine output file type]) 5070e9e6e0f6Smrg FORMAT_FILE="unknown.lo" 5071e9e6e0f6Smrg enable_libstdcxx_backtrace=no 5072e9e6e0f6Smrg ;; 5073e9e6e0f6Smrgesac 5074e9e6e0f6SmrgAC_SUBST(FORMAT_FILE) 5075e9e6e0f6Smrg 5076e9e6e0f6Smrg# ELF defines. 5077e9e6e0f6Smrgelfsize= 5078e9e6e0f6Smrgcase "$glibcxx_cv_sys_filetype" in 5079e9e6e0f6Smrgelf32) elfsize=32 ;; 5080e9e6e0f6Smrgelf64) elfsize=64 ;; 5081e9e6e0f6Smrgesac 5082e9e6e0f6SmrgBACKTRACE_CPPFLAGS="$BACKTRACE_CPPFLAGS -DBACKTRACE_ELF_SIZE=$elfsize" 5083e9e6e0f6Smrg 5084e9e6e0f6Smrg AC_MSG_CHECKING([whether to build libbacktrace support]) 5085e9e6e0f6Smrg if test "$enable_libstdcxx_backtrace" = "auto"; then 5086e9e6e0f6Smrg enable_libstdcxx_backtrace=no 5087e9e6e0f6Smrg fi 5088e9e6e0f6Smrg AC_MSG_RESULT($enable_libstdcxx_backtrace) 5089e9e6e0f6Smrg if test "$enable_libstdcxx_backtrace" = "yes"; then 5090e9e6e0f6Smrg BACKTRACE_SUPPORTED=1 5091e9e6e0f6Smrg 5092e9e6e0f6Smrg AC_CHECK_HEADERS(sys/mman.h) 5093e9e6e0f6Smrg case "${host}" in 5094e9e6e0f6Smrg *-*-msdosdjgpp) # DJGPP has sys/man.h, but no mmap 5095e9e6e0f6Smrg have_mmap=no ;; 5096e9e6e0f6Smrg *-*-*) 5097e9e6e0f6Smrg have_mmap="$ac_cv_header_sys_mman_h" ;; 5098e9e6e0f6Smrg esac 5099e9e6e0f6Smrg 5100e9e6e0f6Smrg if test "$have_mmap" = "no"; then 5101e9e6e0f6Smrg VIEW_FILE=read.lo 5102e9e6e0f6Smrg ALLOC_FILE=alloc.lo 5103e9e6e0f6Smrg else 5104e9e6e0f6Smrg VIEW_FILE=mmapio.lo 5105e9e6e0f6Smrg AC_PREPROC_IFELSE([AC_LANG_SOURCE([ 5106e9e6e0f6Smrg #include <sys/mman.h> 5107e9e6e0f6Smrg #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) 5108e9e6e0f6Smrg #error no MAP_ANONYMOUS 5109e9e6e0f6Smrg #endif 5110e9e6e0f6Smrg ])], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo]) 5111e9e6e0f6Smrg fi 5112e9e6e0f6Smrg AC_SUBST(VIEW_FILE) 5113e9e6e0f6Smrg AC_SUBST(ALLOC_FILE) 5114e9e6e0f6Smrg 5115e9e6e0f6Smrg BACKTRACE_USES_MALLOC=0 5116e9e6e0f6Smrg if test "$ALLOC_FILE" = "alloc.lo"; then 5117e9e6e0f6Smrg BACKTRACE_USES_MALLOC=1 5118e9e6e0f6Smrg fi 5119e9e6e0f6Smrg 5120e9e6e0f6Smrg if test "$ac_has_gthreads" = "yes"; then 5121e9e6e0f6Smrg BACKTRACE_SUPPORTS_THREADS=1 5122e9e6e0f6Smrg else 5123e9e6e0f6Smrg BACKTRACE_SUPPORTS_THREADS=0 5124e9e6e0f6Smrg fi 5125e9e6e0f6Smrg AC_SUBST(BACKTRACE_CPPFLAGS) 5126e9e6e0f6Smrg AC_SUBST(BACKTRACE_SUPPORTED) 5127e9e6e0f6Smrg AC_SUBST(BACKTRACE_USES_MALLOC) 5128e9e6e0f6Smrg AC_SUBST(BACKTRACE_SUPPORTS_THREADS) 5129e9e6e0f6Smrg AC_DEFINE(HAVE_STACKTRACE, 1, [Define if the <stacktrace> header is supported.]) 5130e9e6e0f6Smrg else 5131e9e6e0f6Smrg BACKTRACE_SUPPORTED=0 5132e9e6e0f6Smrg BACKTRACE_USES_MALLOC=0 5133e9e6e0f6Smrg BACKTRACE_SUPPORTS_THREADS=0 5134e9e6e0f6Smrg fi 5135e9e6e0f6Smrg GLIBCXX_CONDITIONAL(ENABLE_BACKTRACE, [test "$enable_libstdcxx_backtrace" = yes]) 5136e9e6e0f6Smrg]) 5137e9e6e0f6Smrg 513848fb7bfaSmrg# Macros from the top-level gcc directory. 513948fb7bfaSmrgm4_include([../config/gc++filt.m4]) 514048fb7bfaSmrgm4_include([../config/tls.m4]) 514148fb7bfaSmrgm4_include([../config/gthr.m4]) 51423f8cba22Smrgm4_include([../config/cet.m4]) 5143