# HG changeset patch # User Yasumasa Suenaga # Date 1500898613 -32400 # Node ID b3d1289e4539100757825899945ffe6fd33ac269 # Parent 354b87b559efaabb1dff9ab4539b40c79c177103 Bug 3429: [REGRESSION] Cannot build HeapStats Agent on RHEL Reviewed-by: ykubota https://github.com/HeapStats/heapstats/pull/114 diff -r 354b87b559ef -r b3d1289e4539 ChangeLog --- a/ChangeLog Sat Jul 22 19:04:47 2017 +0900 +++ b/ChangeLog Mon Jul 24 21:16:53 2017 +0900 @@ -1,3 +1,7 @@ +2017-07-24 Yasumasa Suenaga + + * Bug 3429: [REGRESSION] Cannot build HeapStats Agent on RHEL + 2017-07-22 Yasumasa Suenaga * Bug 3424: HeapStats Agent might crash when thread recorder is disabled via realoading configuration diff -r 354b87b559ef -r b3d1289e4539 agent/src/heapstats-engines/callbackRegister.hpp --- a/agent/src/heapstats-engines/callbackRegister.hpp Sat Jul 22 19:04:47 2017 +0900 +++ b/agent/src/heapstats-engines/callbackRegister.hpp Mon Jul 24 21:16:53 2017 +0900 @@ -66,8 +66,15 @@ static void unregisterCallback(T callback) { pthread_rwlock_wrlock(&callbackLock); { - for (auto itr = callbackList.cbegin(); - itr != callbackList.cend(); itr++) { +#ifdef USE_N2350 + // C++11 support + auto list_begin = callbackList.cbegin(); + auto list_end = callbackList.cend(); +#else + auto list_begin = callbackList.begin(); + auto list_end = callbackList.end(); +#endif + for (auto itr = list_begin; itr != list_end; itr++) { if (*itr == callback) { callbackList.erase(itr); break; diff -r 354b87b559ef -r b3d1289e4539 agent/src/heapstats-engines/jniCallbackRegister.hpp --- a/agent/src/heapstats-engines/jniCallbackRegister.hpp Sat Jul 22 19:04:47 2017 +0900 +++ b/agent/src/heapstats-engines/jniCallbackRegister.hpp Mon Jul 24 21:16:53 2017 +0900 @@ -89,8 +89,15 @@ pthread_rwlock_wrlock(&callbackLock); { if (prologue != NULL) { - for (auto itr = prologueCallbackList.cbegin(); - itr != prologueCallbackList.cend(); itr++) { +#ifdef USE_N2350 + // C++11 support + auto prologue_begin = prologueCallbackList.cbegin(); + auto prologue_end = prologueCallbackList.cend(); +#else + auto prologue_begin = prologueCallbackList.begin(); + auto prologue_end = prologueCallbackList.end(); +#endif + for (auto itr = prologue_begin; itr != prologue_end; itr++) { if (prologue == *itr) { prologueCallbackList.erase(itr); break; @@ -99,8 +106,15 @@ } if (epilogue != NULL) { - for (auto itr = epilogueCallbackList.cbegin(); - itr != epilogueCallbackList.cend(); itr++) { +#ifdef USE_N2350 + // C++11 support + auto epilogue_begin = prologueCallbackList.cbegin(); + auto epilogue_end = prologueCallbackList.cend(); +#else + auto epilogue_begin = prologueCallbackList.begin(); + auto epilogue_end = prologueCallbackList.end(); +#endif + for (auto itr = epilogue_begin; itr != epilogue_end; itr++) { if (epilogue == *itr) { epilogueCallbackList.erase(itr); break; diff -r 354b87b559ef -r b3d1289e4539 configure --- a/configure Sat Jul 22 19:04:47 2017 +0900 +++ b/configure Mon Jul 24 21:16:53 2017 +0900 @@ -6501,6 +6501,53 @@ fi +# Check Container insert/erase and iterator constness (N2350) +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for N2350" >&5 +$as_echo_n "checking for N2350... " >&6; } + +if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + +int +main () +{ + + std::list test; + test.push_back(0); + test.erase(test.cbegin()); + + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + $as_echo "#define USE_N2350 1" >>confdefs.h + + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + # Check for atomic operation for ac_header in atomic do : diff -r 354b87b559ef -r b3d1289e4539 configure.ac --- a/configure.ac Sat Jul 22 19:04:47 2017 +0900 +++ b/configure.ac Mon Jul 24 21:16:53 2017 +0900 @@ -110,6 +110,26 @@ ) AM_CONDITIONAL(USE_PCRE, test -n "${ac_cv_header_pcre_h}") +# Check Container insert/erase and iterator constness (N2350) +AC_MSG_CHECKING([for N2350]) + +AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[ + #include + ]], [[ + std::list test; + test.push_back(0); + test.erase(test.cbegin()); + ]] + )], [ + AC_MSG_RESULT([yes]) + AC_DEFINE(USE_N2350, 1) + ], [ + AC_MSG_RESULT([no]) + ] +) + # Check for atomic operation AC_CHECK_HEADERS([atomic], [], [