From 7749c18a0641a127aa16c6630a2e81604c3ef107 Mon Sep 17 00:00:00 2001 From: Jittapan Pluemsumran Date: Wed, 3 May 2017 22:32:46 +0700 Subject: [PATCH 1/2] Prepared the project for mixing C++ code in --- .travis.yml | 7 +- configure | 1225 ++++++++++++++++++++++++---------------- configure.in | 16 +- src/common/Makefile.in | 10 + src/common/core.c | 31 +- src/common/core.h | 14 + src/common/db.h | 8 +- src/common/ers.h | 8 + src/common/malloc.h | 7 + src/common/mempool.c | 30 +- src/common/mempool.h | 19 +- src/common/showmsg.h | 8 + src/common/socket.h | 8 + src/common/sql.h | 7 + src/common/strlib.h | 14 + src/common/thread.c | 28 +- src/common/thread.h | 23 +- src/common/timer.h | 8 + 18 files changed, 903 insertions(+), 568 deletions(-) diff --git a/.travis.yml b/.travis.yml index d98204a2f3..270132a191 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ -language: c +language: cpp compiler: - clang - gcc +dist: trusty before_script: - uname -a @@ -24,6 +25,10 @@ before_script: - mysql -u $DB_ROOT $DB_NAME < sql-files/mob_skill_db2_re.sql || aborterror "Unable to import renewal monster skill 2 table." - mysql -u $DB_ROOT $DB_NAME < sql-files/roulette_default_data.sql || aborterror "Unable to import roulette table." - mysql -u $DB_ROOT -e "GRANT ALL ON *.* TO '$DB_USER'@'$DB_HOST' IDENTIFIED BY '$DB_PASS';" + - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + - sudo apt-get update -q + - sudo apt-get install gcc-4.8 -y + - sudo apt-get install g++-4.8 -y script: - ./configure $CONFIGURE_FLAGS diff --git a/configure b/configure index c39bcf3a43..2eec370f6b 100755 --- a/configure +++ b/configure @@ -634,9 +634,13 @@ MYSQL_CFLAGS MYSQL_VERSION HAVE_MYSQL MYSQL_CONFIG_HOME +CXXCPP WITH_PLUGINS SOFLAGS AR +ac_ct_CXX +CXXFLAGS +CXX SET_MAKE OMAP OCHR @@ -670,6 +674,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -721,7 +726,11 @@ CFLAGS LDFLAGS LIBS CPPFLAGS -CPP' +CPP +CXX +CXXFLAGS +CCC +CXXCPP' # Initialize some variables set by options. @@ -760,6 +769,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' @@ -1012,6 +1022,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1149,7 +1168,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1302,6 +1321,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1336,8 +1356,8 @@ Optional Features: (available options: yes, no, gdb) --enable-prere[=ARG] Compiles serv in prere mode. (disabled by default) (available options: yes, no) - --enable-vip[=ARG] Compiles serv with vip features. (disabled by default) - (available options: yes, no) + --enable-vip[=ARG] Compiles serv with vip features. (disabled by + default) (available options: yes, no) --enable-warn[=ARG] Compiles with warnings. (disabled by default) (available options: yes, no, extra) --enable-buildbot[=ARG] (available options: yes, no) @@ -1389,6 +1409,9 @@ Some influential environment variables: CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor + CXX C++ compiler command + CXXFLAGS C++ compiler flags + CXXCPP C++ preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1705,10 +1728,90 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_header_compile -# ac_fn_c_try_link LINENO -# ----------------------- +# ac_fn_cxx_try_compile LINENO +# ---------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_compile + +# ac_fn_cxx_try_run LINENO +# ------------------------ +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_cxx_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_run + +# ac_fn_cxx_try_link LINENO +# ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () +ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext @@ -1728,7 +1831,7 @@ $as_echo "$ac_try_echo"; } >&5 fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || + test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || @@ -1749,12 +1852,12 @@ fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval -} # ac_fn_c_try_link +} # ac_fn_cxx_try_link -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- +# ac_fn_cxx_check_func LINENO FUNC VAR +# ------------------------------------ # Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () +ac_fn_cxx_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 @@ -1803,7 +1906,7 @@ return $2 (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_cxx_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" @@ -1816,7 +1919,162 @@ eval ac_res=\$$3 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno -} # ac_fn_c_check_func +} # ac_fn_cxx_check_func + +# ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES +# --------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_cxx_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_cxx_check_header_compile + +# ac_fn_cxx_try_cpp LINENO +# ------------------------ +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_cpp + +# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES +# --------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_cxx_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_cxx_check_header_mongrel cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -4386,137 +4644,257 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP + done +IFS=$as_save_IFS fi - CPP=$ac_cv_prog_CPP +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } else - ac_cv_prog_CPP=$CPP + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : + done +IFS=$as_save_IFS +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if ${ac_cv_cxx_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if ${ac_cv_prog_cxx_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +else + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4563,11 +4941,11 @@ $as_echo "no" >&6; } fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu @@ -4575,6 +4953,7 @@ CFLAGS="$CFLAGS -pipe -ffast-math -Wall" CPPFLAGS="$CPPFLAGS -I../common" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : @@ -4590,7 +4969,7 @@ else typedef int dummy; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. @@ -4635,7 +5014,7 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -4653,7 +5032,7 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no @@ -4679,7 +5058,7 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -4696,7 +5075,7 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no @@ -4735,7 +5114,7 @@ return use_ascii (foo) == use_ebcdic (foo); return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi @@ -4770,7 +5149,7 @@ main () return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_cxx_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes @@ -4816,7 +5195,7 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : pointers_fit_in_ints="yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -4834,7 +5213,7 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : pointers_fit_in_ints="yes (with -m32)" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -4868,7 +5247,7 @@ else } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_cxx_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -4893,7 +5272,7 @@ else int main(int argc, char **argv) { return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_cxx_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -4946,7 +5325,7 @@ else } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_cxx_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -4994,7 +5373,7 @@ else } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_cxx_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5033,7 +5412,7 @@ else } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_cxx_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5068,7 +5447,7 @@ $as_echo_n "checking whether $CC supports -Wno-unused-parameter... " >&6; } /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : # Recent versions of gcc don't fail if -Wno-foo is not recognized # (unless there are also other warnings), so we also check for -Wfoo @@ -5078,7 +5457,7 @@ if ac_fn_c_try_compile "$LINENO"; then : /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5092,7 +5471,7 @@ $as_echo_n "checking whether $CC can actually use -Wno-unused-parameter... " >&6 /* end confdefs.h. */ int foo(int bar) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: not needed but enabled" >&5 $as_echo "not needed but enabled" >&6; } @@ -5105,7 +5484,7 @@ else /* end confdefs.h. */ int foo(int bar) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5156,7 +5535,7 @@ $as_echo_n "checking whether $CC supports -Wno-maybe-uninitialized... " >&6; } /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : # Recent versions of gcc don't fail if -Wno-foo is not recognized # (unless there are also other warnings), so we also check for -Wfoo @@ -5166,7 +5545,7 @@ if ac_fn_c_try_compile "$LINENO"; then : /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5180,7 +5559,7 @@ $as_echo_n "checking whether $CC can actually use -Wno-maybe-uninitialized... " /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: not needed but enabled" >&5 $as_echo "not needed but enabled" >&6; } @@ -5193,7 +5572,7 @@ else /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5244,7 +5623,7 @@ $as_echo_n "checking whether $CC supports -Wno-clobbered... " >&6; } /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : # Recent versions of gcc don't fail if -Wno-foo is not recognized # (unless there are also other warnings), so we also check for -Wfoo @@ -5254,7 +5633,7 @@ if ac_fn_c_try_compile "$LINENO"; then : /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5268,7 +5647,7 @@ $as_echo_n "checking whether $CC can actually use -Wno-clobbered... " >&6; } /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: not needed but enabled" >&5 $as_echo "not needed but enabled" >&6; } @@ -5281,7 +5660,7 @@ else /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5332,7 +5711,7 @@ $as_echo_n "checking whether $CC supports -Wempty-body... " >&6; } /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5346,7 +5725,7 @@ $as_echo_n "checking whether $CC can actually use -Wempty-body... " >&6; } /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -5372,300 +5751,12 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wnewline-eof" >&5 -$as_echo_n "checking whether $CC supports -Wnewline-eof... " >&6; } - OLD_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror -Wnewline-eof" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo; -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wnewline-eof" - # Optionally, run a test - if test "x" != "x"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wnewline-eof" >&5 -$as_echo_n "checking whether $CC can actually use -Wnewline-eof... " >&6; } - CFLAGS="$OLD_CFLAGS -Werror -Wnewline-eof" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wnewline-eof" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wint-conversion" >&5 -$as_echo_n "checking whether $CC supports -Wint-conversion... " >&6; } - OLD_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror -Wint-conversion" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo; -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wint-conversion" - # Optionally, run a test - if test "x" != "x"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wint-conversion" >&5 -$as_echo_n "checking whether $CC can actually use -Wint-conversion... " >&6; } - CFLAGS="$OLD_CFLAGS -Werror -Wint-conversion" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wint-conversion" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wenum-conversion" >&5 -$as_echo_n "checking whether $CC supports -Wenum-conversion... " >&6; } - OLD_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror -Wenum-conversion" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo; -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wenum-conversion" - # Optionally, run a test - if test "x" != "x"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wenum-conversion" >&5 -$as_echo_n "checking whether $CC can actually use -Wenum-conversion... " >&6; } - CFLAGS="$OLD_CFLAGS -Werror -Wenum-conversion" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wenum-conversion" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wshorten-64-to-32" >&5 -$as_echo_n "checking whether $CC supports -Wshorten-64-to-32... " >&6; } - OLD_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror -Wshorten-64-to-32" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo; -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wshorten-64-to-32" - # Optionally, run a test - if test "x" != "x"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wshorten-64-to-32" >&5 -$as_echo_n "checking whether $CC can actually use -Wshorten-64-to-32... " >&6; } - CFLAGS="$OLD_CFLAGS -Werror -Wshorten-64-to-32" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wshorten-64-to-32" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wconstant-conversion" >&5 -$as_echo_n "checking whether $CC supports -Wconstant-conversion... " >&6; } - OLD_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror -Wconstant-conversion" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo; -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wconstant-conversion" - # Optionally, run a test - if test "x" != "x"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wconstant-conversion" >&5 -$as_echo_n "checking whether $CC can actually use -Wconstant-conversion... " >&6; } - CFLAGS="$OLD_CFLAGS -Werror -Wconstant-conversion" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wconstant-conversion" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wbool-conversion" >&5 -$as_echo_n "checking whether $CC supports -Wbool-conversion... " >&6; } - OLD_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Werror -Wbool-conversion" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo; -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wbool-conversion" - # Optionally, run a test - if test "x" != "x"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wbool-conversion" >&5 -$as_echo_n "checking whether $CC can actually use -Wbool-conversion... " >&6; } - CFLAGS="$OLD_CFLAGS -Werror -Wbool-conversion" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - CFLAGS="$OLD_CFLAGS -Wbool-conversion" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - CFLAGS="$OLD_CFLAGS" - - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - - +#AC_CHECK_COMPILER_WFLAG(newline-eof) +#AC_CHECK_COMPILER_WFLAG(int-conversion) +#AC_CHECK_COMPILER_WFLAG(enum-conversion) +#AC_CHECK_COMPILER_WFLAG(shorten-64-to-32) +#AC_CHECK_COMPILER_WFLAG(constant-conversion) +#AC_CHECK_COMPILER_WFLAG(bool-conversion) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-switch" >&5 $as_echo_n "checking whether $CC supports -Wno-switch... " >&6; } @@ -5675,7 +5766,7 @@ $as_echo_n "checking whether $CC supports -Wno-switch... " >&6; } /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : # Recent versions of gcc don't fail if -Wno-foo is not recognized # (unless there are also other warnings), so we also check for -Wfoo @@ -5685,7 +5776,7 @@ if ac_fn_c_try_compile "$LINENO"; then : /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5699,7 +5790,7 @@ $as_echo_n "checking whether $CC can actually use -Wno-switch... " >&6; } /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: not needed but enabled" >&5 $as_echo "not needed but enabled" >&6; } @@ -5712,7 +5803,7 @@ else /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5763,7 +5854,7 @@ $as_echo_n "checking whether $CC supports -Wno-missing-field-initializers... " > /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : # Recent versions of gcc don't fail if -Wno-foo is not recognized # (unless there are also other warnings), so we also check for -Wfoo @@ -5773,7 +5864,7 @@ if ac_fn_c_try_compile "$LINENO"; then : /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5787,7 +5878,7 @@ $as_echo_n "checking whether $CC can actually use -Wno-missing-field-initializer /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: not needed but enabled" >&5 $as_echo "not needed but enabled" >&6; } @@ -5800,7 +5891,7 @@ else /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5856,7 +5947,7 @@ $as_echo_n "checking whether $CC supports -Wshadow... " >&6; } /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5870,7 +5961,7 @@ $as_echo_n "checking whether $CC can actually use -Wshadow... " >&6; } /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -5913,7 +6004,7 @@ $as_echo_n "checking whether $CC can efficiently use -Wshadow... " >&6; } } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5938,7 +6029,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -5979,7 +6070,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_cxx_try_link "$LINENO"; then : compiler_shared_objects="-shared" compiler_supports_shared_objects="yes" @@ -6001,7 +6092,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_cxx_try_link "$LINENO"; then : compiler_shared_objects="-nostart" compiler_supports_shared_objects="yes" @@ -6039,7 +6130,7 @@ $as_echo_n "checking whether $CC needs -Wl,--no-undefined to check for undefined } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_cxx_try_link "$LINENO"; then : CFLAGS="$SOFLAGS -Wl,--no-undefined" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6052,7 +6143,7 @@ if ac_fn_c_try_link "$LINENO"; then : } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_cxx_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -6099,7 +6190,7 @@ $as_echo_n "checking whether $CC needs -fPIC for shared objects... " >&6; } } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_cxx_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -6121,7 +6212,7 @@ else } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_cxx_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -6167,7 +6258,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else @@ -6189,7 +6280,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # # setrlimit - used to set the socket limit # -ac_fn_c_check_func "$LINENO" "setrlimit" "ac_cv_func_setrlimit" +ac_fn_cxx_check_func "$LINENO" "setrlimit" "ac_cv_func_setrlimit" if test "x$ac_cv_func_setrlimit" = xyes; then : CPPFLAGS="$CPPFLAGS -DHAVE_SETRLIMIT" fi @@ -6199,7 +6290,7 @@ fi # # strnlen - string length with upper scan bound # -ac_fn_c_check_func "$LINENO" "strnlen" "ac_cv_func_strnlen" +ac_fn_cxx_check_func "$LINENO" "strnlen" "ac_cv_func_strnlen" if test "x$ac_cv_func_strnlen" = xyes; then : CPPFLAGS="$CPPFLAGS -DHAVE_STRNLEN" fi @@ -6208,7 +6299,7 @@ fi # libconfig for ac_func in uselocale do : - ac_fn_c_check_func "$LINENO" "uselocale" "ac_cv_func_uselocale" + ac_fn_cxx_check_func "$LINENO" "uselocale" "ac_cv_func_uselocale" if test "x$ac_cv_func_uselocale" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_USELOCALE 1 @@ -6219,7 +6310,7 @@ done for ac_func in newlocale do : - ac_fn_c_check_func "$LINENO" "newlocale" "ac_cv_func_newlocale" + ac_fn_cxx_check_func "$LINENO" "newlocale" "ac_cv_func_newlocale" if test "x$ac_cv_func_newlocale" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NEWLOCALE 1 @@ -6230,7 +6321,7 @@ done for ac_func in freelocale do : - ac_fn_c_check_func "$LINENO" "freelocale" "ac_cv_func_freelocale" + ac_fn_cxx_check_func "$LINENO" "freelocale" "ac_cv_func_freelocale" if test "x$ac_cv_func_freelocale" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_FREELOCALE 1 @@ -6241,7 +6332,7 @@ done for ac_header in xlocale.h do : - ac_fn_c_check_header_compile "$LINENO" "xlocale.h" "ac_cv_header_xlocale_h" " + ac_fn_cxx_check_header_compile "$LINENO" "xlocale.h" "ac_cv_header_xlocale_h" " #ifdef HAVE_XLOCALE_H # include #endif @@ -6269,7 +6360,141 @@ case $enable_manager in ;; "memwatch") CPPFLAGS="$CPPFLAGS -DMEMWATCH" - ac_fn_c_check_header_mongrel "$LINENO" "memwatch.h" "ac_cv_header_memwatch_h" "$ac_includes_default" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 +$as_echo_n "checking how to run the C++ preprocessor... " >&6; } +if test -z "$CXXCPP"; then + if ${ac_cv_prog_CXXCPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 +$as_echo "$CXXCPP" >&6; } +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +ac_fn_cxx_check_header_mongrel "$LINENO" "memwatch.h" "ac_cv_header_memwatch_h" "$ac_includes_default" if test "x$ac_cv_header_memwatch_h" = xyes; then : else @@ -6281,7 +6506,7 @@ fi "dmalloc") CPPFLAGS="$CPPFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK" LIBS="$LIBS -ldmalloc" - ac_fn_c_check_header_mongrel "$LINENO" "dmalloc.h" "ac_cv_header_dmalloc_h" "$ac_includes_default" + ac_fn_cxx_check_header_mongrel "$LINENO" "dmalloc.h" "ac_cv_header_dmalloc_h" "$ac_includes_default" if test "x$ac_cv_header_dmalloc_h" = xyes; then : else @@ -6293,7 +6518,7 @@ fi "gcollect") CPPFLAGS="$CPPFLAGS -DGCOLLECT" LIBS="$LIBS -lgc" - ac_fn_c_check_header_mongrel "$LINENO" "gc.h" "ac_cv_header_gc_h" "$ac_includes_default" + ac_fn_cxx_check_header_mongrel "$LINENO" "gc.h" "ac_cv_header_gc_h" "$ac_includes_default" if test "x$ac_cv_header_gc_h" = xyes; then : else @@ -6462,7 +6687,7 @@ for ac_lib in '' z; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_inflateEnd=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -6489,7 +6714,7 @@ else as_fn_error $? "zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping" "$LINENO" 5 fi -ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "#ifdef HAVE_ZLIB_H +ac_fn_cxx_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "#ifdef HAVE_ZLIB_H # include #endif @@ -6537,7 +6762,7 @@ for ac_lib in '' m; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_sqrt=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -6600,7 +6825,7 @@ for ac_lib in '' rt; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_clock_gettime=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -6659,7 +6884,7 @@ else } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_cxx_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -6714,7 +6939,7 @@ for ac_lib in '' pthread; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_pthread_create=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -6772,7 +6997,7 @@ for ac_lib in '' pthread; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_pthread_sigmask=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -6830,7 +7055,7 @@ for ac_lib in '' pthread; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_pthread_attr_init=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -6888,7 +7113,7 @@ for ac_lib in '' pthread; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_pthread_attr_setstacksize=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -6946,7 +7171,7 @@ for ac_lib in '' pthread; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_pthread_attr_destroy=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -7004,7 +7229,7 @@ for ac_lib in '' pthread; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_pthread_cancel=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -7062,7 +7287,7 @@ for ac_lib in '' pthread; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_pthread_join=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -7178,7 +7403,7 @@ return mysql_init (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_mysqlclient_mysql_init=yes else ac_cv_lib_mysqlclient_mysql_init=no @@ -7193,7 +7418,7 @@ if test "x$ac_cv_lib_mysqlclient_mysql_init" = xyes; then : HAVE_MYSQL="yes" fi -ac_fn_c_check_header_mongrel "$LINENO" "mysql.h" "ac_cv_header_mysql_h" "$ac_includes_default" +ac_fn_cxx_check_header_mongrel "$LINENO" "mysql.h" "ac_cv_header_mysql_h" "$ac_includes_default" if test "x$ac_cv_header_mysql_h" = xyes; then : else @@ -7267,7 +7492,7 @@ for ac_lib in '' pcre; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_search_pcre_study=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ @@ -7323,7 +7548,7 @@ return pcre_compile (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_cxx_try_link "$LINENO"; then : ac_cv_lib_pcre_pcre_compile=yes else ac_cv_lib_pcre_pcre_compile=no diff --git a/configure.in b/configure.in index 9ce551c468..f3b47b7830 100644 --- a/configure.in +++ b/configure.in @@ -433,9 +433,9 @@ AC_ARG_WITH( AC_PROG_MAKE_SET AC_PROG_CC -AC_PROG_CPP +AC_PROG_CXX AC_PATH_PROG(AR, ar) -AC_LANG([C]) +AC_LANG([C++]) CFLAGS="$CFLAGS -pipe -ffast-math -Wall" @@ -700,12 +700,12 @@ AC_CHECK_COMPILER_WNOFLAG(unused-parameter, [int foo(int bar) { return 0; }]) AC_CHECK_COMPILER_WNOFLAG(maybe-uninitialized) AC_CHECK_COMPILER_WNOFLAG(clobbered) AC_CHECK_COMPILER_WFLAG(empty-body) -AC_CHECK_COMPILER_WFLAG(newline-eof) -AC_CHECK_COMPILER_WFLAG(int-conversion) -AC_CHECK_COMPILER_WFLAG(enum-conversion) -AC_CHECK_COMPILER_WFLAG(shorten-64-to-32) -AC_CHECK_COMPILER_WFLAG(constant-conversion) -AC_CHECK_COMPILER_WFLAG(bool-conversion) +#AC_CHECK_COMPILER_WFLAG(newline-eof) +#AC_CHECK_COMPILER_WFLAG(int-conversion) +#AC_CHECK_COMPILER_WFLAG(enum-conversion) +#AC_CHECK_COMPILER_WFLAG(shorten-64-to-32) +#AC_CHECK_COMPILER_WFLAG(constant-conversion) +#AC_CHECK_COMPILER_WFLAG(bool-conversion) AC_CHECK_COMPILER_WNOFLAG(switch) AC_CHECK_COMPILER_WNOFLAG(missing-field-initializers) diff --git a/src/common/Makefile.in b/src/common/Makefile.in index a3f10e69cb..08791a6a6b 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -23,6 +23,8 @@ else endif ALL_DEPENDS=server +CXXFLAG =-std=c++11 + @SET_MAKE@ ##################################################################### @@ -63,10 +65,18 @@ obj/%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) @echo " CC $<" @@CC@ @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj/%.o: %.cpp $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) + @echo " CXX $<" + @@CXX@ $(CXXFLAG) @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + obj/mini%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) @echo " CC $<" @@CC@ @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj/mini%.o: %.cpp $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) + @echo " CXX $<" + @@CXX@ $(CXXFLAG) @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + # missing object files $(MT19937AR_OBJ): @$(MAKE) -C ../../3rdparty/mt19937ar diff --git a/src/common/core.c b/src/common/core.c index ee86e617ec..22f5a3d147 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -2,6 +2,7 @@ // For more information, see LICENCE in the main folder #include "mmo.h" +#include "cbasetypes.h" #include "showmsg.h" #include "malloc.h" #include "core.h" @@ -164,14 +165,14 @@ const char* get_svn_revision(void) { // - ignores database file structure // - assumes the data in NODES.dav_cache column ends with "!svn/ver//)" // - since it's a cache column, the data might not even exist - if( (fp = fopen(".svn"PATHSEP_STR"wc.db", "rb")) != NULL || (fp = fopen(".."PATHSEP_STR".svn"PATHSEP_STR"wc.db", "rb")) != NULL ) + if( (fp = fopen(".svn" PATHSEP_STR "wc.db", "rb")) != NULL || (fp = fopen(".." PATHSEP_STR ".svn" PATHSEP_STR "wc.db", "rb")) != NULL ) { #ifndef SVNNODEPATH //not sure how to handle branches, so i'll leave this overridable define until a better solution comes up #define SVNNODEPATH trunk #endif const char* prefix = "!svn/ver/"; - const char* postfix = "/"EXPAND_AND_QUOTE(SVNNODEPATH)")"; // there should exist only 1 entry like this + const char* postfix = "/" EXPAND_AND_QUOTE(SVNNODEPATH) ")"; // there should exist only 1 entry like this size_t prefix_len = strlen(prefix); size_t postfix_len = strlen(postfix); size_t i,j,len; @@ -257,7 +258,7 @@ const char *get_git_hash (void) { if( GitHash[0] != '\0' ) return GitHash; - if( (fp = fopen(".git/"GIT_ORIGIN, "r")) != NULL ) { + if( (fp = fopen(".git/" GIT_ORIGIN, "r")) != NULL ) { char line[64]; char *rev = (char*)malloc(sizeof(char) * 50); @@ -286,21 +287,21 @@ static void display_title(void) { const char* git = get_git_hash(); ShowMessage("\n"); - ShowMessage(""CL_PASS" "CL_BOLD" "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BT_WHITE" rAthena Development Team presents "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" ___ __ __ "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" _____/ | / /_/ /_ ___ ____ ____ _ "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" / ___/ /| |/ __/ __ \\/ _ \\/ __ \\/ __ `/ "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" / / / ___ / /_/ / / / __/ / / / /_/ / "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" /_/ /_/ |_\\__/_/ /_/\\___/_/ /_/\\__,_/ "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_GREEN" http://rathena.org/board/ "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" "CL_PASS""CL_CLL""CL_NORMAL"\n"); + ShowMessage("" CL_PASS " " CL_BOLD " " CL_PASS"" CL_CLL "" CL_NORMAL "\n"); + ShowMessage("" CL_PASS " " CL_BT_WHITE " rAthena Development Team presents " CL_PASS "" CL_CLL "" CL_NORMAL "\n"); + ShowMessage("" CL_PASS " " CL_BOLD " ___ __ __ " CL_PASS "" CL_CLL "" CL_NORMAL "\n"); + ShowMessage("" CL_PASS " " CL_BOLD " _____/ | / /_/ /_ ___ ____ ____ _ " CL_PASS "" CL_CLL "" CL_NORMAL "\n"); + ShowMessage("" CL_PASS " " CL_BOLD " / ___/ /| |/ __/ __ \\/ _ \\/ __ \\/ __ `/ " CL_PASS "" CL_CLL "" CL_NORMAL "\n"); + ShowMessage("" CL_PASS " " CL_BOLD " / / / ___ / /_/ / / / __/ / / / /_/ / " CL_PASS "" CL_CLL "" CL_NORMAL "\n"); + ShowMessage("" CL_PASS " " CL_BOLD " /_/ /_/ |_\\__/_/ /_/\\___/_/ /_/\\__,_/ " CL_PASS "" CL_CLL "" CL_NORMAL "\n"); + ShowMessage("" CL_PASS " " CL_BOLD " " CL_PASS "" CL_CLL "" CL_NORMAL "\n"); + ShowMessage("" CL_PASS " " CL_GREEN " http://rathena.org/board/ " CL_PASS "" CL_CLL "" CL_NORMAL "\n"); + ShowMessage("" CL_PASS " " CL_BOLD " " CL_PASS "" CL_CLL "" CL_NORMAL "\n"); if( svn[0] != UNKNOWN_VERSION ) - ShowInfo("SVN Revision: '"CL_WHITE"%s"CL_RESET"'\n", svn); + ShowInfo("SVN Revision: '" CL_WHITE "%s" CL_RESET "'\n", svn); else if( git[0] != UNKNOWN_VERSION ) - ShowInfo("Git Hash: '"CL_WHITE"%s"CL_RESET"'\n", git); + ShowInfo("Git Hash: '" CL_WHITE "%s" CL_RESET "'\n", git); } // Warning if executed as superuser (root) diff --git a/src/common/core.h b/src/common/core.h index 6d01a54930..5db34ae850 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -4,6 +4,10 @@ #ifndef _CORE_H_ #define _CORE_H_ +#ifdef __cplusplus +extern "C" { +#endif + /* so that developers with --enable-debug can raise signals from any section of the code they'd like */ #ifdef DEBUG #include @@ -34,12 +38,18 @@ enum { extern char SERVER_TYPE; extern int parse_console(const char* buf); +#ifdef __cplusplus +extern "C" { +#endif const char *get_svn_revision(void); const char *get_git_hash(void); extern int do_init(int,char**); extern void set_server_type(void); extern void do_abort(void); extern void do_final(void); +#ifdef __cplusplus +} +#endif /// The main loop continues until runflag is CORE_ST_STOP enum E_CORE_ST @@ -53,4 +63,8 @@ enum E_CORE_ST /// If NULL, runflag is set to CORE_ST_STOP instead. extern void (*shutdown_callback)(void); +#ifdef __cplusplus +} +#endif + #endif /* _CORE_H_ */ diff --git a/src/common/db.h b/src/common/db.h index 3dcc473349..8e460294e1 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -42,6 +42,10 @@ #ifndef _DB_H_ #define _DB_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "cbasetypes.h" #include @@ -1655,6 +1659,8 @@ void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...); /// @return negative if v1 is top, positive if v2 is top, 0 if equal #define BHEAP_MAXTOPCMP(v1,v2) ( v1 == v2 ? 0 : v1 > v2 ? -1 : 1 ) - +#ifdef __cplusplus +} +#endif #endif /* _DB_H_ */ diff --git a/src/common/ers.h b/src/common/ers.h index d4bc71ac23..8a1f617540 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -40,6 +40,10 @@ #ifndef _ERS_H_ #define _ERS_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "cbasetypes.h" /*****************************************************************************\ @@ -175,4 +179,8 @@ void ers_report(void); void ers_final(void); #endif /* DISABLE_ERS / not DISABLE_ERS */ +#ifdef __cplusplus +} +#endif + #endif /* _ERS_H_ */ diff --git a/src/common/malloc.h b/src/common/malloc.h index 6483af430c..1f273c9335 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -4,6 +4,9 @@ #ifndef _MALLOC_H_ #define _MALLOC_H_ +#ifdef __cplusplus +extern "C" { +#endif #include "cbasetypes.h" #define ALC_MARK __FILE__, __LINE__, __func__ @@ -89,4 +92,8 @@ size_t malloc_usage (void); void malloc_init (void); void malloc_final (void); +#ifdef __cplusplus +} +#endif + #endif /* _MALLOC_H_ */ diff --git a/src/common/mempool.c b/src/common/mempool.c index 596165f7c5..b43a04db2c 100644 --- a/src/common/mempool.c +++ b/src/common/mempool.c @@ -51,7 +51,7 @@ struct ra_align(16) node{ // The Pointer to this struct is the base address of the segment itself. struct pool_segment{ - mempool pool; // pool, this segment belongs to + pMempool pool; // pool, this segment belongs to struct pool_segment *next; int64 num_nodes_total; int64 num_bytes; @@ -96,17 +96,17 @@ struct mempool{ /// // Implementation: // -static void segment_allocate_add(mempool p, uint64 count); +static void segment_allocate_add(pMempool p, uint64 count); static SPIN_LOCK l_mempoolListLock; -static mempool l_mempoolList = NULL; -static rAthread l_async_thread = NULL; +static pMempool l_mempoolList = NULL; +static prAthread l_async_thread = NULL; static ramutex l_async_lock = NULL; static racond l_async_cond = NULL; static volatile int32 l_async_terminate = 0; static void *mempool_async_allocator(void *x){ - mempool p; + pMempool p; while(1){ @@ -167,7 +167,7 @@ void mempool_init(){ void mempool_final(){ - mempool p, pn; + pMempool p, pn; if( rand()%2 + 1 ) return; @@ -205,7 +205,7 @@ void mempool_final(){ }//end: mempool_final() -static void segment_allocate_add(mempool p, uint64 count){ +static void segment_allocate_add(pMempool p, uint64 count){ // Required Memory: // sz( segment ) @@ -303,7 +303,7 @@ static void segment_allocate_add(mempool p, uint64 count){ }//end: segment_allocate_add() -mempool mempool_create(const char *name, +pMempool mempool_create(const char *name, uint64 elem_size, uint64 initial_count, uint64 realloc_count, @@ -311,8 +311,8 @@ mempool mempool_create(const char *name, memPoolOnNodeDeallocationProc onNodeDealloc){ //.. uint64 realloc_thresh; - mempool pool; - pool = (mempool)aCalloc( 1, sizeof(struct mempool) ); + pMempool pool; + pool = (pMempool)aCalloc( 1, sizeof(struct mempool) ); if(pool == NULL){ ShowFatalError("mempool_create: Failed to allocate %u bytes memory.\n", sizeof(struct mempool) ); @@ -369,10 +369,10 @@ mempool mempool_create(const char *name, }//end: mempool_create() -void mempool_destroy(mempool p){ +void mempool_destroy(pMempool p){ struct pool_segment *seg, *segnext; struct node *niter; - mempool piter, pprev; + pMempool piter, pprev; char *ptr; int64 i; @@ -472,7 +472,7 @@ void mempool_destroy(mempool p){ }//end: mempool_destroy() -void *mempool_node_get(mempool p){ +void *mempool_node_get(pMempool p){ struct node *node; int64 num_used; @@ -511,7 +511,7 @@ void *mempool_node_get(mempool p){ }//end: mempool_node_get() -void mempool_node_put(mempool p, void *data){ +void mempool_node_put(pMempool p, void *data){ struct node *node; node = DATA_TO_NODE(data); @@ -544,7 +544,7 @@ void mempool_node_put(mempool p, void *data){ }//end: mempool_node_put() -mempool_stats mempool_get_stats(mempool pool){ +mempool_stats mempool_get_stats(pMempool pool){ mempool_stats stats; // initialize all with zeros diff --git a/src/common/mempool.h b/src/common/mempool.h index f6fa7438f8..bfd30ef1a0 100644 --- a/src/common/mempool.h +++ b/src/common/mempool.h @@ -1,9 +1,13 @@ #ifndef _rA_MEMPOOL_H_ #define _rA_MEMPOOL_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "cbasetypes.h" -typedef struct mempool *mempool; +typedef struct mempool *pMempool; typedef void (*memPoolOnNodeAllocationProc)(void *ptr); typedef void (*memPoolOnNodeDeallocationProc)(void *ptr); @@ -45,7 +49,7 @@ void mempool_final(); * * @return not NULL */ -mempool mempool_create(const char *name, +pMempool mempool_create(const char *name, uint64 elem_size, uint64 initial_count, uint64 realloc_count, @@ -63,7 +67,7 @@ mempool mempool_create(const char *name, * Everything gets deallocated, regardless if everything was freed properly! * So you have to ensure that all references are cleared properly! */ -void mempool_destroy(mempool pool); +void mempool_destroy(pMempool pool); /** @@ -73,7 +77,7 @@ void mempool_destroy(mempool pool); * * @return Address of empty Node */ -void *mempool_node_get(mempool pool); +void *mempool_node_get(pMempool pool); /** @@ -82,7 +86,7 @@ void *mempool_node_get(mempool pool); * @param pool - the pool to put the node, to * @param node - the node to return */ -void mempool_node_put(mempool pool, void *node); +void mempool_node_put(pMempool pool, void *node); /** @@ -94,7 +98,10 @@ void mempool_node_put(mempool pool, void *node); * * @return stats struct */ -mempool_stats mempool_get_stats(mempool pool); +mempool_stats mempool_get_stats(pMempool pool); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/common/showmsg.h b/src/common/showmsg.h index ef92218b59..29935f991a 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -4,6 +4,10 @@ #ifndef _SHOWMSG_H_ #define _SHOWMSG_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "../../3rdparty/libconfig/libconfig.h" // for help with the console colors look here: @@ -97,4 +101,8 @@ extern void ShowError(const char *, ...); extern void ShowFatalError(const char *, ...); extern void ShowConfigWarning(config_setting_t *config, const char *string, ...); +#ifdef __cplusplus +} +#endif + #endif /* _SHOWMSG_H_ */ diff --git a/src/common/socket.h b/src/common/socket.h index d1344dc984..844db868d9 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -17,6 +17,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #define FIFOSIZE_SERVERLINK 256*1024 // socket I/O macros @@ -182,4 +186,8 @@ void send_shortlist_add_fd(int fd); void send_shortlist_do_sends(); #endif +#ifdef __cplusplus +} +#endif + #endif /* _SOCKET_H_ */ diff --git a/src/common/sql.h b/src/common/sql.h index 07c080549e..828b000654 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -4,6 +4,10 @@ #ifndef _COMMON_SQL_H_ #define _COMMON_SQL_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "cbasetypes.h" #include // va_list @@ -341,5 +345,8 @@ void SqlStmt_Free(SqlStmt* self); void Sql_Init(void); +#ifdef __cplusplus +} +#endif #endif /* _COMMON_SQL_H_ */ diff --git a/src/common/strlib.h b/src/common/strlib.h index f049d05ee3..441d51993e 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -4,12 +4,22 @@ #ifndef _STRLIB_H_ #define _STRLIB_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "cbasetypes.h" #include +#if !defined(__USE_GNU) #define __USE_GNU // required to enable strnlen on some platforms +#define __USED_GNU +#endif #include +#if defined(__USED_GNU) #undef __USE_GNU +#undef __USED_GNU +#endif char* jstrescape (char* pt); char* jstrescapecpy (char* pt, const char* spt); @@ -152,4 +162,8 @@ void StringBuf_Clear(StringBuf* self); void StringBuf_Destroy(StringBuf* self); void StringBuf_Free(StringBuf* self); +#ifdef __cplusplus +} +#endif + #endif /* _STRLIB_H_ */ diff --git a/src/common/thread.c b/src/common/thread.c index 8ee788a5bd..85f9904a01 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -96,7 +96,7 @@ void rathread_final(){ // gets called whenever a thread terminated .. -static void rat_thread_terminated( rAthread handle ){ +static void rat_thread_terminated( prAthread handle ){ int id_backup = handle->myID; @@ -117,7 +117,7 @@ static void *_raThreadMainRedirector( void *p ){ // Update myID @ TLS to right id. #ifdef HAS_TLS - g_rathread_ID = ((rAthread)p)->myID; + g_rathread_ID = ((prAthread)p)->myID; #endif #ifndef WIN32 @@ -135,13 +135,13 @@ static void *_raThreadMainRedirector( void *p ){ #endif - ret = ((rAthread)p)->proc( ((rAthread)p)->param ) ; + ret = ((prAthread)p)->proc( ((prAthread)p)->param ) ; #ifdef WIN32 - CloseHandle( ((rAthread)p)->hThread ); + CloseHandle( ((prAthread)p)->hThread ); #endif - rat_thread_terminated( (rAthread)p ); + rat_thread_terminated( (prAthread)p ); #ifdef WIN32 return (DWORD)ret; #else @@ -156,18 +156,18 @@ static void *_raThreadMainRedirector( void *p ){ /// /// API Level /// -rAthread rathread_create( rAthreadProc entryPoint, void *param ){ +prAthread rathread_create( rAthreadProc entryPoint, void *param ){ return rathread_createEx( entryPoint, param, (1<<23) /*8MB*/, RAT_PRIO_NORMAL ); }//end: rathread_create() -rAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szStack, RATHREAD_PRIO prio ){ +prAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szStack, RATHREAD_PRIO prio ){ #ifndef WIN32 pthread_attr_t attr; #endif size_t tmp; unsigned int i; - rAthread handle = NULL; + prAthread handle = NULL; // given stacksize aligned to systems pagesize? @@ -214,7 +214,7 @@ rAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szSta }//end: rathread_createEx -void rathread_destroy ( rAthread handle ){ +void rathread_destroy ( prAthread handle ){ #ifdef WIN32 if( TerminateThread(handle->hThread, 0) != FALSE){ CloseHandle(handle->hThread); @@ -233,9 +233,9 @@ void rathread_destroy ( rAthread handle ){ #endif }//end: rathread_destroy() -rAthread rathread_self( ){ +prAthread rathread_self( ){ #ifdef HAS_TLS - rAthread handle = &l_threads[g_rathread_ID]; + prAthread handle = &l_threads[g_rathread_ID]; if(handle->proc != NULL) // entry point set, so its used! return handle; @@ -279,7 +279,7 @@ int rathread_get_tid(){ }//end: rathread_get_tid() -bool rathread_wait( rAthread handle, void* *out_exitCode ){ +bool rathread_wait( prAthread handle, void* *out_exitCode ){ // Hint: // no thread data cleanup routine call here! @@ -297,13 +297,13 @@ bool rathread_wait( rAthread handle, void* *out_exitCode ){ }//end: rathread_wait() -void rathread_prio_set( rAthread handle, RATHREAD_PRIO prio ){ +void rathread_prio_set( prAthread handle, RATHREAD_PRIO prio ){ handle->prio = RAT_PRIO_NORMAL; //@TODO }//end: rathread_prio_set() -RATHREAD_PRIO rathread_prio_get( rAthread handle){ +RATHREAD_PRIO rathread_prio_get( prAthread handle){ return handle->prio; }//end: rathread_prio_get() diff --git a/src/common/thread.h b/src/common/thread.h index 79519ef5cd..56748866fc 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -5,9 +5,13 @@ #ifndef _rA_THREAD_H_ #define _rA_THREAD_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "cbasetypes.h" -typedef struct rAthread *rAthread; +typedef struct rAthread *prAthread; typedef void* (*rAthreadProc)(void*); typedef enum RATHREAD_PRIO { @@ -25,7 +29,7 @@ typedef enum RATHREAD_PRIO { * * @return not NULL if success */ -rAthread rathread_create( rAthreadProc entryPoint, void *param ); +prAthread rathread_create( rAthreadProc entryPoint, void *param ); /** @@ -38,7 +42,7 @@ rAthread rathread_create( rAthreadProc entryPoint, void *param ); * * @return not NULL if success */ -rAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szStack, RATHREAD_PRIO prio ); +prAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szStack, RATHREAD_PRIO prio ); /** @@ -48,7 +52,7 @@ rAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szSta * * @param handle - thread to destroy. */ -void rathread_destroy ( rAthread handle ); +void rathread_destroy ( prAthread handle ); /** @@ -59,7 +63,7 @@ void rathread_destroy ( rAthread handle ); * * @return not NULL if success */ -rAthread rathread_self( ); +prAthread rathread_self( ); /** @@ -81,7 +85,7 @@ int rathread_get_tid(); * * @return true - if the given thread has been terminated. */ -bool rathread_wait( rAthread handle, void* *out_exitCode ); +bool rathread_wait( prAthread handle, void* *out_exitCode ); /** @@ -90,7 +94,7 @@ bool rathread_wait( rAthread handle, void* *out_exitCode ); * @param handle - thread to set prio for * @param rio - the priority (RAT_PRIO_LOW ... ) */ -void rathread_prio_set( rAthread handle, RATHREAD_PRIO prio ); +void rathread_prio_set( prAthread handle, RATHREAD_PRIO prio ); /** @@ -98,7 +102,7 @@ void rathread_prio_set( rAthread handle, RATHREAD_PRIO prio ); * * @param handle - the thread to get the prio for. */ -RATHREAD_PRIO rathread_prio_get( rAthread handle); +RATHREAD_PRIO rathread_prio_get( prAthread handle); /** @@ -115,5 +119,8 @@ void rathread_yield(); void rathread_init(); void rathread_final(); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/common/timer.h b/src/common/timer.h index c0200b38bc..8e3b2be76e 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -4,6 +4,10 @@ #ifndef _TIMER_H_ #define _TIMER_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "cbasetypes.h" #include @@ -60,4 +64,8 @@ int do_timer(unsigned int tick); void timer_init(void); void timer_final(void); +#ifdef __cplusplus +} +#endif + #endif /* _TIMER_H_ */ From 2e524f18fc98271e89f2adb9553d82d4ff347d91 Mon Sep 17 00:00:00 2001 From: Jittapan Pluemsumran Date: Fri, 5 May 2017 16:50:58 +0700 Subject: [PATCH 2/2] Removed an extra C linkage declaration in core.h --- src/common/core.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/common/core.h b/src/common/core.h index 5db34ae850..43551a2b42 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -38,18 +38,12 @@ enum { extern char SERVER_TYPE; extern int parse_console(const char* buf); -#ifdef __cplusplus -extern "C" { -#endif const char *get_svn_revision(void); const char *get_git_hash(void); extern int do_init(int,char**); extern void set_server_type(void); extern void do_abort(void); extern void do_final(void); -#ifdef __cplusplus -} -#endif /// The main loop continues until runflag is CORE_ST_STOP enum E_CORE_ST