diff --git a/autoconf/configure.ac b/autoconf/configure.ac index a56cdbc23..efd38b127 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -94,14 +94,14 @@ AC_PROG_AWK AC_PROG_CC AC_PROG_CXX -dnl do not test gcc version on mac. clang as gcc will return version and it's not >= 4.8 +dnl do not test gcc version on mac. clang as gcc will return version and it's not >= 5 AS_IF([test "$ON_MAC" = "no"],[TR_GCC_VERSION],[]) -dnl if the compiler is gcc, test for gcc >= 4.8 +dnl if the compiler is gcc, test for gcc >= 5 AS_IF([test "x$GCC_VERSION" = "x"],[], - [AC_MSG_CHECKING([gcc version >= 4.8]) - AX_COMPARE_VERSION([$GCC_VERSION],[ge],[4.8], [AC_MSG_RESULT([yes])], + [AC_MSG_CHECKING([gcc version >= 5]) + AX_COMPARE_VERSION([$GCC_VERSION],[ge],[5], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - AC_MSG_ERROR([Trick requires gcc version >= 4.8]) + AC_MSG_ERROR([Trick requires gcc version >= 5]) ]) ]) dnl Save the full path of the compiler @@ -210,12 +210,12 @@ AS_IF([test "$ac_cv_path_CLANG" = "noclang"],AC_MSG_ERROR([could not find clang] AC_SUBST([LLVM_HOME]) TR_CLANG_VERSION -dnl if llvm/clang, test for version >= 3.4.2 +dnl if llvm/clang, test for version >= 5 AS_IF([test "x$CLANG_VERSION" = "x"],[], - [AC_MSG_CHECKING([clang version >= 3.4.2]) - AX_COMPARE_VERSION([$CLANG_VERSION],[ge],[3.4.2], [AC_MSG_RESULT([yes])], + [AC_MSG_CHECKING([clang version >= 5]) + AX_COMPARE_VERSION([$CLANG_VERSION],[ge],[5], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - AC_MSG_ERROR([Trick requires llvm/clang version >= 3.4.2]) + AC_MSG_ERROR([Trick requires llvm/clang version >= 5]) ]) ]) diff --git a/configure b/configure index a45fa995a..bcb84b84c 100755 --- a/configure +++ b/configure @@ -642,7 +642,6 @@ CLANG LLVM_CONFIG PTHREAD_CFLAGS PTHREAD_LIBS -PTHREAD_CXX PTHREAD_CC ax_pthread_config CPP @@ -4768,8 +4767,8 @@ fi if test "x$GCC_VERSION" = "x"; then : else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking gcc version >= 4.8" >&5 -$as_echo_n "checking gcc version >= 4.8... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking gcc version >= 5" >&5 +$as_echo_n "checking gcc version >= 5... " >&6; } @@ -4789,7 +4788,7 @@ $as_echo_n "checking gcc version >= 4.8... " >&6; } -e 's/[^0-9]//g'` - ax_compare_version_B=`echo "4.8" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + ax_compare_version_B=`echo "5" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ @@ -4806,7 +4805,7 @@ x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - as_fn_error $? "Trick requires gcc version >= 4.8" "$LINENO" 5 + as_fn_error $? "Trick requires gcc version >= 5" "$LINENO" 5 fi @@ -5758,9 +5757,7 @@ done if test -z "$SWIG" ; then as_fn_error $? "Trick requires SWIG version >= 3.0" "$LINENO" 5 - elif test -z "3.0" ; then - : - else + elif test -n "3.0" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking SWIG version" >&5 $as_echo_n "checking SWIG version... " >&6; } swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'` @@ -5773,12 +5770,12 @@ $as_echo "$swig_version" >&6; } if test -z "$required_major" ; then required_major=0 fi - required=`echo $required. | sed 's/[0-9]*[^0-9]//'` + required=`echo $required | sed 's/[0-9]*[^0-9]//'` required_minor=`echo $required | sed 's/[^0-9].*//'` if test -z "$required_minor" ; then required_minor=0 fi - required=`echo $required. | sed 's/[0-9]*[^0-9]//'` + required=`echo $required | sed 's/[0-9]*[^0-9]//'` required_patch=`echo $required | sed 's/[^0-9].*//'` if test -z "$required_patch" ; then required_patch=0 @@ -5815,7 +5812,7 @@ $as_echo "$as_me: WARNING: SWIG version >= 3.0 is required. You have $swig_vers else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SWIG library" >&5 $as_echo_n "checking for SWIG library... " >&6; } - SWIG_LIB=`$SWIG -swiglib | tr '\r\n' ' '` + SWIG_LIB=`$SWIG -swiglib` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SWIG_LIB" >&5 $as_echo "$SWIG_LIB" >&6; } @@ -5881,9 +5878,7 @@ done if test -z "$SWIG" ; then as_fn_error $? "Trick requires SWIG version >= 3.0" "$LINENO" 5 - elif test -z "3.0" ; then - : - else + elif test -n "3.0" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking SWIG version" >&5 $as_echo_n "checking SWIG version... " >&6; } swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'` @@ -5896,12 +5891,12 @@ $as_echo "$swig_version" >&6; } if test -z "$required_major" ; then required_major=0 fi - required=`echo $required. | sed 's/[0-9]*[^0-9]//'` + required=`echo $required | sed 's/[0-9]*[^0-9]//'` required_minor=`echo $required | sed 's/[^0-9].*//'` if test -z "$required_minor" ; then required_minor=0 fi - required=`echo $required. | sed 's/[0-9]*[^0-9]//'` + required=`echo $required | sed 's/[0-9]*[^0-9]//'` required_patch=`echo $required | sed 's/[^0-9].*//'` if test -z "$required_patch" ; then required_patch=0 @@ -5938,7 +5933,7 @@ $as_echo "$as_me: WARNING: SWIG version >= 3.0 is required. You have $swig_vers else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SWIG library" >&5 $as_echo_n "checking for SWIG library... " >&6; } - SWIG_LIB=`$SWIG -swiglib | tr '\r\n' ' '` + SWIG_LIB=`$SWIG -swiglib` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SWIG_LIB" >&5 $as_echo "$SWIG_LIB" >&6; } @@ -6384,9 +6379,6 @@ if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then ax_pthread_save_LIBS="$LIBS" if test "x$PTHREAD_CC" != "x"; then : CC="$PTHREAD_CC" -fi - if test "x$PTHREAD_CXX" != "x"; then : - CXX="$PTHREAD_CXX" fi CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" @@ -6431,12 +6423,10 @@ fi # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). -# Create a list of thread flags to try. Items with a "," contain both -# C compiler flags (before ",") and linker flags (after ","). Other items -# starting with a "-" are C compiler flags, and remaining items are -# library names, except for "none" which indicates that we try without -# any flags at all, and "pthread-config" which is a program returning -# the flags for the Pth emulation library. +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" @@ -6512,9 +6502,38 @@ rm -f conftest* # that too in a future libc.) So we'll check first for the # standard Solaris way of linking pthreads (-mt -lpthread). - ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags" + ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" + ;; +esac + +# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) + +if test "x$GCC" = "xyes"; then : + ax_pthread_flags="-pthread -pthreads $ax_pthread_flags" +fi + +# The presence of a feature test macro requesting re-entrant function +# definitions is, on some systems, a strong hint that pthreads support is +# correctly enabled + +case $host_os in + darwin* | hpux* | linux* | osf* | solaris*) + ax_pthread_check_macro="_REENTRANT" + ;; + + aix*) + ax_pthread_check_macro="_THREAD_SAFE" + ;; + + *) + ax_pthread_check_macro="--" ;; esac +if test "x$ax_pthread_check_macro" = "x--"; then : + ax_pthread_check_cond=0 +else + ax_pthread_check_cond="!defined($ax_pthread_check_macro)" +fi # Are we compiling with Clang? @@ -6547,51 +6566,107 @@ fi $as_echo "$ax_cv_PTHREAD_CLANG" >&6; } ax_pthread_clang="$ax_cv_PTHREAD_CLANG" +ax_pthread_clang_warning=no -# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) - -# Note that for GCC and Clang -pthread generally implies -lpthread, -# except when -nostdlib is passed. -# This is problematic using libtool to build C++ shared libraries with pthread: -# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460 -# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333 -# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555 -# To solve this, first try -pthread together with -lpthread for GCC +# Clang needs special handling, because older versions handle the -pthread +# option in a rather... idiosyncratic way -if test "x$GCC" = "xyes"; then : - ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags" -fi +if test "x$ax_pthread_clang" = "xyes"; then -# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first + # Clang takes -pthread; it has never supported any other flag -if test "x$ax_pthread_clang" = "xyes"; then : - ax_pthread_flags="-pthread,-lpthread -pthread" -fi + # (Note 1: This will need to be revisited if a system that Clang + # supports has POSIX threads in a separate library. This tends not + # to be the way of modern systems, but it's conceivable.) + # (Note 2: On some systems, notably Darwin, -pthread is not needed + # to get POSIX threads support; the API is always present and + # active. We could reasonably leave PTHREAD_CFLAGS empty. But + # -pthread does define _REENTRANT, and while the Darwin headers + # ignore this macro, third-party headers might not.) -# The presence of a feature test macro requesting re-entrant function -# definitions is, on some systems, a strong hint that pthreads support is -# correctly enabled + PTHREAD_CFLAGS="-pthread" + PTHREAD_LIBS= -case $host_os in - darwin* | hpux* | linux* | osf* | solaris*) - ax_pthread_check_macro="_REENTRANT" - ;; + ax_pthread_ok=yes - aix*) - ax_pthread_check_macro="_THREAD_SAFE" - ;; + # However, older versions of Clang make a point of warning the user + # that, in an invocation where only linking and no compilation is + # taking place, the -pthread option has no effect ("argument unused + # during compilation"). They expect -pthread to be passed in only + # when source code is being compiled. + # + # Problem is, this is at odds with the way Automake and most other + # C build frameworks function, which is that the same flags used in + # compilation (CFLAGS) are also used in linking. Many systems + # supported by AX_PTHREAD require exactly this for POSIX threads + # support, and in fact it is often not straightforward to specify a + # flag that is used only in the compilation phase and not in + # linking. Such a scenario is extremely rare in practice. + # + # Even though use of the -pthread flag in linking would only print + # a warning, this can be a nuisance for well-run software projects + # that build with -Werror. So if the active version of Clang has + # this misfeature, we search for an option to squash it. - *) - ax_pthread_check_macro="--" - ;; -esac -if test "x$ax_pthread_check_macro" = "x--"; then : - ax_pthread_check_cond=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Clang needs flag to prevent \"argument unused\" warning when linking with -pthread" >&5 +$as_echo_n "checking whether Clang needs flag to prevent \"argument unused\" warning when linking with -pthread... " >&6; } +if ${ax_cv_PTHREAD_CLANG_NO_WARN_FLAG+:} false; then : + $as_echo_n "(cached) " >&6 else - ax_pthread_check_cond="!defined($ax_pthread_check_macro)" + ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown + # Create an alternate version of $ac_link that compiles and + # links in two steps (.c -> .o, .o -> exe) instead of one + # (.c -> exe), because the warning occurs only in the second + # step + ax_pthread_save_ac_link="$ac_link" + ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' + ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"` + ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" + ax_pthread_save_CFLAGS="$CFLAGS" + for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do + if test "x$ax_pthread_try" = "xunknown"; then : + break +fi + CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" + ac_link="$ax_pthread_save_ac_link" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int main(void){return 0;} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_link="$ax_pthread_2step_ac_link" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int main(void){return 0;} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + break fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + done + ac_link="$ax_pthread_save_ac_link" + CFLAGS="$ax_pthread_save_CFLAGS" + if test "x$ax_pthread_try" = "x"; then : + ax_pthread_try=no +fi + ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" >&5 +$as_echo "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" >&6; } + + case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in + no | unknown) ;; + *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; + esac + +fi # $ax_pthread_clang = yes if test "x$ax_pthread_ok" = "xno"; then for ax_pthread_try_flag in $ax_pthread_flags; do @@ -6602,11 +6677,11 @@ for ax_pthread_try_flag in $ax_pthread_flags; do $as_echo_n "checking whether pthreads work without any flags... " >&6; } ;; - *,*) - PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"` - PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with \"$PTHREAD_CFLAGS\" and \"$PTHREAD_LIBS\"" >&5 -$as_echo_n "checking whether pthreads work with \"$PTHREAD_CFLAGS\" and \"$PTHREAD_LIBS\"... " >&6; } + -mt,pthread) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with -mt -lpthread" >&5 +$as_echo_n "checking whether pthreads work with -mt -lpthread... " >&6; } + PTHREAD_CFLAGS="-mt" + PTHREAD_LIBS="-lpthread" ;; -*) @@ -6689,13 +6764,7 @@ $as_echo_n "checking for the pthreads library -l$ax_pthread_try_flag... " >&6; } # if $ax_pthread_check_cond # error "$ax_pthread_check_macro must be defined" # endif - static void *some_global = NULL; - static void routine(void *a) - { - /* To avoid any unused-parameter or - unused-but-set-parameter warning. */ - some_global = a; - } + static void routine(void *a) { a = 0; } static void *start_routine(void *a) { return a; } int main () @@ -6730,104 +6799,6 @@ fi done fi - -# Clang needs special handling, because older versions handle the -pthread -# option in a rather... idiosyncratic way - -if test "x$ax_pthread_clang" = "xyes"; then - - # Clang takes -pthread; it has never supported any other flag - - # (Note 1: This will need to be revisited if a system that Clang - # supports has POSIX threads in a separate library. This tends not - # to be the way of modern systems, but it's conceivable.) - - # (Note 2: On some systems, notably Darwin, -pthread is not needed - # to get POSIX threads support; the API is always present and - # active. We could reasonably leave PTHREAD_CFLAGS empty. But - # -pthread does define _REENTRANT, and while the Darwin headers - # ignore this macro, third-party headers might not.) - - # However, older versions of Clang make a point of warning the user - # that, in an invocation where only linking and no compilation is - # taking place, the -pthread option has no effect ("argument unused - # during compilation"). They expect -pthread to be passed in only - # when source code is being compiled. - # - # Problem is, this is at odds with the way Automake and most other - # C build frameworks function, which is that the same flags used in - # compilation (CFLAGS) are also used in linking. Many systems - # supported by AX_PTHREAD require exactly this for POSIX threads - # support, and in fact it is often not straightforward to specify a - # flag that is used only in the compilation phase and not in - # linking. Such a scenario is extremely rare in practice. - # - # Even though use of the -pthread flag in linking would only print - # a warning, this can be a nuisance for well-run software projects - # that build with -Werror. So if the active version of Clang has - # this misfeature, we search for an option to squash it. - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Clang needs flag to prevent \"argument unused\" warning when linking with -pthread" >&5 -$as_echo_n "checking whether Clang needs flag to prevent \"argument unused\" warning when linking with -pthread... " >&6; } -if ${ax_cv_PTHREAD_CLANG_NO_WARN_FLAG+:} false; then : - $as_echo_n "(cached) " >&6 -else - ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown - # Create an alternate version of $ac_link that compiles and - # links in two steps (.c -> .o, .o -> exe) instead of one - # (.c -> exe), because the warning occurs only in the second - # step - ax_pthread_save_ac_link="$ac_link" - ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' - ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"` - ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" - ax_pthread_save_CFLAGS="$CFLAGS" - for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do - if test "x$ax_pthread_try" = "xunknown"; then : - break -fi - CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" - ac_link="$ax_pthread_save_ac_link" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int main(void){return 0;} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_link="$ax_pthread_2step_ac_link" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int main(void){return 0;} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - break -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - done - ac_link="$ax_pthread_save_ac_link" - CFLAGS="$ax_pthread_save_CFLAGS" - if test "x$ax_pthread_try" = "x"; then : - ax_pthread_try=no -fi - ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" >&5 -$as_echo "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" >&6; } - - case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in - no | unknown) ;; - *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; - esac - -fi # $ax_pthread_clang = yes - - - # Various other checks: if test "x$ax_pthread_ok" = "xyes"; then ax_pthread_save_CFLAGS="$CFLAGS" @@ -6909,7 +6880,6 @@ int main () { int i = PTHREAD_PRIO_INHERIT; - return i; ; return 0; } @@ -6946,19 +6916,11 @@ fi #handle absolute path differently from PATH based program lookup case "x$CC" in #( x/*) : - - if as_fn_executable_p ${CC}_r; then : + if as_fn_executable_p ${CC}_r; then : PTHREAD_CC="${CC}_r" -fi - if test "x${CXX}" != "x"; then : - if as_fn_executable_p ${CXX}_r; then : - PTHREAD_CXX="${CXX}_r" -fi -fi - ;; #( +fi ;; #( *) : - - for ac_prog in ${CC}_r + for ac_prog in ${CC}_r do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -7000,56 +6962,8 @@ fi test -n "$PTHREAD_CC" && break done test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" - - if test "x${CXX}" != "x"; then : - for ac_prog in ${CXX}_r -do - # 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_PTHREAD_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PTHREAD_CXX"; then - ac_cv_prog_PTHREAD_CXX="$PTHREAD_CXX" # Let the user override the test. -else -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_PTHREAD_CXX="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PTHREAD_CXX=$ac_cv_prog_PTHREAD_CXX -if test -n "$PTHREAD_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CXX" >&5 -$as_echo "$PTHREAD_CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$PTHREAD_CXX" && break -done -test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" - -fi - - ;; -esac - ;; #( + ;; +esac ;; #( *) : ;; esac @@ -7059,8 +6973,6 @@ esac fi test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" -test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" - @@ -7457,8 +7369,8 @@ fi if test "x$CLANG_VERSION" = "x"; then : else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking clang version >= 3.4.2" >&5 -$as_echo_n "checking clang version >= 3.4.2... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking clang version >= 5" >&5 +$as_echo_n "checking clang version >= 5... " >&6; } @@ -7478,7 +7390,7 @@ $as_echo_n "checking clang version >= 3.4.2... " >&6; } -e 's/[^0-9]//g'` - ax_compare_version_B=`echo "3.4.2" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + ax_compare_version_B=`echo "5" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ @@ -7495,7 +7407,7 @@ x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - as_fn_error $? "Trick requires llvm/clang version >= 3.4.2" "$LINENO" 5 + as_fn_error $? "Trick requires llvm/clang version >= 5" "$LINENO" 5 fi @@ -7763,6 +7675,7 @@ then LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" fi + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -7831,6 +7744,8 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # If both library and header were found, action-if-found # + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" LIBS="-lz $LIBS" $as_echo "#define HAVE_LIBZ 1" >>confdefs.h @@ -8385,9 +8300,6 @@ $as_echo "no" >&6; } PKG_CONFIG="" fi fi -if test -z "$PKG_CONFIG"; then - as_fn_error $? "pkg-config not found" "$LINENO" 5 -fi # Check whether --with-gtest was given. diff --git a/docs/documentation/install_guide/Install-Guide.md b/docs/documentation/install_guide/Install-Guide.md index f52b22151..8920b66e0 100644 --- a/docs/documentation/install_guide/Install-Guide.md +++ b/docs/documentation/install_guide/Install-Guide.md @@ -11,8 +11,8 @@ Trick requires various free third party utilities in order to function. All the | Utility | Version | Description | Usage | Notes | | --------------: | :-----: | :---------------------: | :------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| [gcc] and `g++` | 4.8+ | C/C++ Compiler | Compiles Trick and Trick simulations. | | -| [clang]/[llvm] | <=22 | C/C++ Compiler | Utilized by the interface code generator. | Trick Versions <= 19.3 should use LLVM <= 9. Trick Versions < 25.0 should use LLVM < 20. Please open an issue if you encounter a problem related to newer versions of LLVM. | +| [gcc] and `g++` | 5+ | C/C++ Compiler | Compiles Trick and Trick simulations. | | +| [clang]/[llvm] | 5 - 22 | C/C++ Compiler | Utilized by the interface code generator. | Trick Versions <= 19.3 should use LLVM <= 9. Trick Versions < 25.0 should use LLVM < 20. Please open an issue if you encounter a problem related to newer versions of LLVM. | | [python] | 3.x | Programming Language | Lets the user interact with a simulation. | Trick has been tested up to python 3.13.2 as of 04/2025. | | [perl] | 5.6+ | Programming Language | Allows executable scripts in the bin directory to run. | | | [java] | 11+ | Programming Language | Necessary for Trick GUIs. | | diff --git a/docs/not_referenced/Monte-Carlo.md b/docs/not_referenced/Monte-Carlo.md index fb7417b96..1974b0f2f 100644 --- a/docs/not_referenced/Monte-Carlo.md +++ b/docs/not_referenced/Monte-Carlo.md @@ -184,27 +184,17 @@ generate the value for the variable from run to run. (use Trick::MonteVarRandom::set_min_is_relative, Trick::MonteVarRandom::set_max_is_relative) - FLAT: Uniform distribution. No bell. Returns uniform random values between (-\f$\infty\f$, +\f$\infty\f$) bracketed optionally by [min, max]. (use Trick::MonteVarRandom::set_min, Trick::MonteVarRandom::set_max) - - engine - the C++11 predefined pseudo-random engine type. NO_ENGINE is the default (results in Trick coded random number engine). - Other options using the C++11 facilities of the Standard Template Library: - (Requires --std=c++0x or --std=c++11 on Trick configure command line when building Trick.) - - TRICK_DEFAULT_ENGINE - SUGGESTED FOR USE. std::ranlux_base_01 for c++0x, std::mt19937 for c++11 - - C++ TR1 options: (pre-C++11 compiler, GCC versions 4.4 through 4.6). - (Requires --std=c++0x on Trick configure command line when building Trick.) - - RANLUX_BASE_01_ENGINE - std::ranlux_base_01 Engine - - RANLUX_64_BASE_01_ENGINE - std::ranlux64_base_01 Engine - - (others such as std::mt19937 not provided, because they return - outside the canonical 0 <= x < 1 range in some GCC versions, - which can cause infinite loops in distributions.) - - C++11 options: (C++11 compiler, versions 4.7, 4.8). - (Requires --std=c++11 on Trick configure command line when building Trick.) - - MINSTD_RAND_ENGINE - std::minstd_rand Minimal Standard Linear Congruential Engine - - MT19937_ENGINE - std::mt19937 Mersenne Twister Engine. Said to provide better behavior than Linear Congruential Engines. - - MT19937_64_ENGINE - std::mt19937_64 64 bit Mersenne Twister Engine. - - RANLUX_24_BASE_ENGINE - std::ranlux24_base Engine - - RANLUX_44_BASE_ENGINE - std::ranlux48_base Engine - - RANLUX_24_ENGINE - std::ranlux24 Engine - - RANLUX_44_ENGINE - std::ranlux48 Engine - - KNUTH_B_ENGINE - std::knuth_b Engine + - engine - the predefined pseudo-random engine type. NO_ENGINE is the default (results in Trick coded random number engine). + All other options use the <random> facilities of the C++ Standard Library: + - TRICK_DEFAULT_ENGINE - SUGGESTED FOR USE. std::mt19937 Mersenne Twister Engine + - MINSTD_RAND_ENGINE - std::minstd_rand Minimal Standard Linear Congruential Engine + - MT19937_ENGINE - std::mt19937 Mersenne Twister Engine. Said to provide better behavior than Linear Congruential Engines. + - MT19937_64_ENGINE - std::mt19937_64 64 bit Mersenne Twister Engine. + - RANLUX_24_BASE_ENGINE - std::ranlux24_base Engine + - RANLUX_44_BASE_ENGINE - std::ranlux48_base Engine + - RANLUX_24_ENGINE - std::ranlux24 Engine + - RANLUX_44_ENGINE - std::ranlux48 Engine + - KNUTH_B_ENGINE - std::knuth_b Engine After constructing such a variable, it can be added via: @@ -429,4 +419,4 @@ This is the order in which jobs are executed in a MonteCarlo sim: - ::mc_read - ::mc_get_connection_device - ::mc_set_current_run -- ::mc_get_current_run \ No newline at end of file +- ::mc_get_current_run diff --git a/include/trick/Euler_Cromer_Integrator.hh b/include/trick/Euler_Cromer_Integrator.hh index d62ef8315..87a993cef 100644 --- a/include/trick/Euler_Cromer_Integrator.hh +++ b/include/trick/Euler_Cromer_Integrator.hh @@ -108,13 +108,9 @@ namespace Trick { void deriv2_in(double* arg1, ...) #ifndef SWIGPYTHON - #ifdef __GNUC__ - #if __GNUC__ >= 4 - __attribute__((sentinel)) - #endif - #endif + __attribute__((sentinel)) #endif - ; + ; void initialize( int State_size, double Dt); int integrate(); Integrator_type get_Integrator_type() { return(Euler_Cromer); } ; diff --git a/include/trick/Event.hh b/include/trick/Event.hh index d54dd0fbe..2773ff6af 100644 --- a/include/trick/Event.hh +++ b/include/trick/Event.hh @@ -204,16 +204,13 @@ class Event { #ifndef SWIG - // No need to inherit from binary_function for c++11 or later - #if __cplusplus >= 201103L - struct CompareEventPtrs { - #else - struct CompareEventPtrs : public std::binary_function { - #endif - bool operator()(const Trick::Event * lhs, const Trick::Event * rhs) const { - return lhs->get_next_tics() < rhs->get_next_tics(); - } - }; +struct CompareEventPtrs +{ + bool operator()(const Trick::Event* lhs, const Trick::Event* rhs) const + { + return lhs->get_next_tics() < rhs->get_next_tics(); + } +}; #endif } diff --git a/include/trick/ExecutiveException.hh b/include/trick/ExecutiveException.hh index d3b5b152b..49919b84b 100644 --- a/include/trick/ExecutiveException.hh +++ b/include/trick/ExecutiveException.hh @@ -34,11 +34,10 @@ namespace Trick { /** This constructor assignes ret_code, file, and message to the incoming arguments */ ExecutiveException( int in_ret , std::string in_file , int line , std::string in_message ) ; - virtual ~ExecutiveException() throw () ; - virtual const char* what() const throw() ; + virtual ~ExecutiveException(); + virtual const char* what() const noexcept; } ; } #endif - diff --git a/include/trick/Integrator.hh b/include/trick/Integrator.hh index eb055f621..84b85b56e 100644 --- a/include/trick/Integrator.hh +++ b/include/trick/Integrator.hh @@ -71,52 +71,36 @@ namespace Trick { #ifndef SWIGPYTHON virtual void state_in(double* arg1, va_list argp); #endif - void state_in (double* arg1, ...) + void state_in(double* arg1, ...) #ifndef SWIGPYTHON - #ifdef __GNUC__ - #if __GNUC__ >= 4 - __attribute__((sentinel)) - #endif - #endif + __attribute__((sentinel)) #endif - ; + ; #ifndef SWIGPYTHON virtual void deriv_in(double* arg1, va_list argp); #endif - void deriv_in (double* arg1, ...) + void deriv_in(double* arg1, ...) #ifndef SWIGPYTHON - #ifdef __GNUC__ - #if __GNUC__ >= 4 - __attribute__((sentinel)) - #endif - #endif + __attribute__((sentinel)) #endif - ; + ; #ifndef SWIGPYTHON virtual void state_out(double* arg1, va_list argp); #endif void state_out(double* arg1, ...) #ifndef SWIGPYTHON - #ifdef __GNUC__ - #if __GNUC__ >= 4 - __attribute__((sentinel)) - #endif - #endif + __attribute__((sentinel)) #endif - ; + ; #ifndef SWIGPYTHON virtual void deriv2_in(double* arg1, va_list argp); #endif - void deriv2_in (double* arg1, ...) + void deriv2_in(double* arg1, ...) #ifndef SWIGPYTHON - #ifdef __GNUC__ - #if __GNUC__ >= 4 - __attribute__((sentinel)) - #endif - #endif + __attribute__((sentinel)) #endif - ; + ; int num_state; diff --git a/include/trick/MonteVarRandom.hh b/include/trick/MonteVarRandom.hh index 12867c450..bb8d836d8 100644 --- a/include/trick/MonteVarRandom.hh +++ b/include/trick/MonteVarRandom.hh @@ -42,47 +42,33 @@ namespace Trick { class MonteVarRandom : public Trick::MonteVar { public: - ///@brief Random number generation engine type. - /// - ///@details Used for TR1 and C++11 random number generation facilities - /// - ///@note: Values for this type must match those of StlRandomGenerator::StlEngine - /// - enum StlEngine { - NO_ENGINE = 0, /**< -- This selection causes the Trick hand coded fallback algorithms to be used */ - - TRICK_DEFAULT_ENGINE = 1, /**< -- std::ranlux_base_01 for TR1, std::mt19937 for _HAVE_STD_RANDOM */ - -#ifdef _HAVE_TR1_RANDOM - RANLUX_BASE_01_ENGINE = 2, /**< -- TR1 only std::ranlux_base_01 Engine, note: replaced for c++11 */ - RANLUX_64_BASE_01_ENGINE = 3, /**< -- TR1 only std::ranlux64_base_01 Engine, note: replaced for c++11 */ -#endif - -#ifdef _HAVE_STL_RANDOM - // NOTE: MINSTD_RAND_ENGINE and MT19937_ENGINE return out of canonical range - // for (at least) GCC 4.4.7,so are not provided for _HAVE_TR1_RANDOM - - MINSTD_RAND_ENGINE = 2, /**< -- std::minstd_rand Minimal Standard Linear Congruential Engine */ - MT19937_ENGINE = 3, /**< -- std::mt19937 Mersenne Twister Engine */ - - MT19937_64_ENGINE = 4, /**< -- std::mt19937_64 64 bit Mersenne Twister Engine. Not available TR1 */ - - RANLUX_24_BASE_ENGINE = 5, /**< -- std::ranlux24_base Engine */ - RANLUX_44_BASE_ENGINE = 6, /**< -- std::ranlux48_base Engine */ - - RANLUX_24_ENGINE = 7, /**< -- std::ranlux24 Engine */ - RANLUX_44_ENGINE = 8, /**< -- std::ranlux48 Engine */ - - KNUTH_B_ENGINE = 9 /**< -- std::knuth_b Engine */ -#endif - }; - - /** A random distribution. */ - enum Distribution { - GAUSSIAN = TRICK_GSL_GAUSS, /**< Gaussian distribution */ - FLAT = TRICK_GSL_FLAT, /**< flat distribution */ - POISSON = TRICK_GSL_POISSON /**< Poisson distribution */ - }; + ///@brief Random number generation engine type. + /// + ///@details Used for the C++ number generation facilities + /// + ///@note: Values for this type must match those of StlRandomGenerator::StlEngine + /// + enum StlEngine + { + NO_ENGINE = 0, /**< -- This selection causes the Trick hand coded fallback algorithms to be used */ + TRICK_DEFAULT_ENGINE = 1, /**< -- std::mt19937 Mersenne Twister Engine */ + MINSTD_RAND_ENGINE = 2, /**< -- std::minstd_rand Minimal Standard Linear Congruential Engine */ + MT19937_ENGINE = 3, /**< -- std::mt19937 Mersenne Twister Engine */ + MT19937_64_ENGINE = 4, /**< -- std::mt19937_64 64 bit Mersenne Twister Engine */ + RANLUX_24_BASE_ENGINE = 5, /**< -- std::ranlux24_base Engine */ + RANLUX_44_BASE_ENGINE = 6, /**< -- std::ranlux48_base Engine */ + RANLUX_24_ENGINE = 7, /**< -- std::ranlux24 Engine */ + RANLUX_44_ENGINE = 8, /**< -- std::ranlux48 Engine */ + KNUTH_B_ENGINE = 9 /**< -- std::knuth_b Engine */ + }; + + /** A random distribution. */ + enum Distribution + { + GAUSSIAN = TRICK_GSL_GAUSS, /**< Gaussian distribution */ + FLAT = TRICK_GSL_FLAT, /**< flat distribution */ + POISSON = TRICK_GSL_POISSON /**< Poisson distribution */ + }; protected: /** Engine. */ diff --git a/include/trick/StlRandomGenerator.hh b/include/trick/StlRandomGenerator.hh index d3524a5e9..b8cd13bf6 100644 --- a/include/trick/StlRandomGenerator.hh +++ b/include/trick/StlRandomGenerator.hh @@ -35,19 +35,13 @@ #include "trick/rand_generator.h" -#if (defined(_HAVE_TR1_RANDOM) || defined(_HAVE_STL_RANDOM)) #include -// The template types of the std::poisson_distribution differ between c++0x and c++11 -#if (defined(_HAVE_TR1_RANDOM) && !defined(STL_POISSON_TEMPLATE_TYPES)) -#define STL_POISSON_TEMPLATE_TYPES int, double -#endif - -#if (defined(_HAVE_STL_RANDOM) && !defined(STL_POISSON_TEMPLATE_TYPES)) -#define STL_POISSON_TEMPLATE_TYPES int -#endif - -#endif +///@brief The concrete engine that StlRandomGenerator::TRICK_DEFAULT_ENGINE selects. +/// +///@details This is the single source of truth for Trick's default engine. Change it +/// here to re-point TRICK_DEFAULT_ENGINE; the factory follows automatically. +using TrickDefaultEngine = std::mt19937; class StlRandomGeneratorFactory; @@ -55,99 +49,74 @@ class StlRandomGeneratorFactory; ///@brief Abstract Base class for object that contains a specified engine and distribution together class StlRandomGenerator { -public: - - /**@brief A random number generation engine type enum. - Used for TR1 and C++11 random number generation facilities - */ - ///@warning with GCC 4.4.7, -std=c++0x, MINSTD_RAND_ENGINE,MT19937_ENGINE - /// 'engines' return pseudo-random numbers outside the cannonical range of 0 <= x < 1. - /// - /// This causes an __INFINITE LOOP__ within the std::normal_distribution. - /// - /// - /// For TR1 compilers with this problem, use RANLUX_BASE_01_ENGINE or RANLUX_64_BASE_01_ENGINE - /// which return within the cannonical range. - /// - ///@note when adding new engine types, coordinate values with MonteVarRandom. - enum StlEngine { - TRICK_DEFAULT_ENGINE = 1, /**< -- std::ranlux_base_01 for TR1, std::mt19937 for _HAVE_STD_RANDOM */ - -#ifdef _HAVE_TR1_RANDOM - RANLUX_BASE_01_ENGINE = 2, /**< -- TR1 only std::ranlux_base_01 Engine, note: replaced for c++11 */ - RANLUX_64_BASE_01_ENGINE = 3, /**< -- TR1 only std::ranlux64_base_01 Engine, note: replaced for c++11 */ -#endif - -#ifdef _HAVE_STL_RANDOM - // NOTE: MINSTD_RAND_ENGINE and MT19937_ENGINE return out of canonical range - // for (at least) GCC 4.4.7,so are not provided for _HAVE_TR1_RANDOM - MINSTD_RAND_ENGINE = 2, /**< -- std::minstd_rand Minimal Standard Linear Congruential Engine */ - MT19937_ENGINE = 3, /**< -- std::mt19937 Mersenne Twister Engine */ - - MT19937_64_ENGINE = 4, /**< -- std::mt19937_64 64 bit Mersenne Twister Engine. Not available TR1 */ - - RANLUX_24_BASE_ENGINE = 5, /**< -- std::ranlux24_base Engine */ - RANLUX_44_BASE_ENGINE = 6, /**< -- std::ranlux48_base Engine */ - - RANLUX_24_ENGINE = 7, /**< -- std::ranlux24 Engine */ - RANLUX_44_ENGINE = 8, /**< -- std::ranlux48 Engine */ - - KNUTH_B_ENGINE = 9 /**< -- std::knuth_b Engine */ -#endif - }; - - /** A random distribution. */ - enum StlDistribution { - GAUSSIAN = TRICK_GSL_GAUSS, /**< -- Gaussian distribution */ - FLAT = TRICK_GSL_FLAT, /**< -- flat distribution */ - POISSON = TRICK_GSL_POISSON /**< -- Poisson distribution */ - }; - - ///@param in_param_a first parameter in distribution::param_type - /// min for FLAT, mean for GAUSSIAN and POISSON - /// - ///@param in_param_b second parameter in distribution::param_type - /// max for FLAT, std deviation for GAUSSIAN, (unused for POISSON) - /// - ///@param in_seed starting seed for random number engine - ///@param in_engine_type Engine type enumeration for random number engine - ///@param in_dist_type Distribution type enumeration for random number distribution - /// - explicit StlRandomGenerator(double in_param_a = 0.0, - double in_param_b = 1.0, - unsigned long in_seed = 12345, - StlRandomGenerator::StlDistribution in_dist_type = StlRandomGenerator::FLAT, - StlRandomGenerator::StlEngine in_engine_type = StlRandomGenerator::TRICK_DEFAULT_ENGINE - ); - - virtual ~StlRandomGenerator(); - - ///@brief return next pseudo-random number - ///@note POISSON distribution returns an int type, - /// so this would need to either cast to double or return a union class like - /// the Trick rand routines already do in order to fit in. - virtual TRICK_GSL_RETURN_TYPE operator()() = 0; - - ///@brief reset seed for pseudo-random number engine - virtual void set_seed(unsigned long in_seed) = 0; - - ///@brief reset parameters for the distribution - ///@param a is min for FLAT, mean for GAUSSION and POISSON - ///@param b is max for FLAT, sigma for GAUSSION and unused for POISSON - ///@note For TR1, set_param replaces the distribution via operator= - virtual void set_param(double a, double b = 0.0) = 0; - - double get_param_a() const { return param_a; } - double get_param_b() const { return param_b; } - -protected: - - double param_a; /**< -- first param in distribution::param_type, min for FLAT, mean for GAUSSIAN and POISSON */ - double param_b; /**< -- second param in distribution::param_type, max for FLAT, std deviation for GAUSSIAN, (unused for POISSON) */ - int initialSeed; /**< -- starting seed */ - - StlEngine engineEnum; /**< -- STL random number engine type enumeration */ - StlDistribution distEnum; /**< -- STL random number distribution type enumeration */ + public: + /**@brief A random number generation engine type enum. + Used for the C++ number generation facilities + */ + ///@note when adding new engine types, coordinate values with MonteVarRandom. + enum StlEngine + { + TRICK_DEFAULT_ENGINE = 1, /**< -- whichever engine ::TrickDefaultEngine names */ + MINSTD_RAND_ENGINE = 2, /**< -- std::minstd_rand Minimal Standard Linear Congruential Engine */ + MT19937_ENGINE = 3, /**< -- std::mt19937 Mersenne Twister Engine */ + MT19937_64_ENGINE = 4, /**< -- std::mt19937_64 64 bit Mersenne Twister Engine */ + RANLUX_24_BASE_ENGINE = 5, /**< -- std::ranlux24_base Engine */ + RANLUX_44_BASE_ENGINE = 6, /**< -- std::ranlux48_base Engine */ + RANLUX_24_ENGINE = 7, /**< -- std::ranlux24 Engine */ + RANLUX_44_ENGINE = 8, /**< -- std::ranlux48 Engine */ + KNUTH_B_ENGINE = 9 /**< -- std::knuth_b Engine */ + }; + + /** A random distribution. */ + enum StlDistribution + { + GAUSSIAN = TRICK_GSL_GAUSS, /**< -- Gaussian distribution */ + FLAT = TRICK_GSL_FLAT, /**< -- flat distribution */ + POISSON = TRICK_GSL_POISSON /**< -- Poisson distribution */ + }; + + ///@param in_param_a first parameter in distribution::param_type + /// min for FLAT, mean for GAUSSIAN and POISSON + /// + ///@param in_param_b second parameter in distribution::param_type + /// max for FLAT, std deviation for GAUSSIAN, (unused for POISSON) + /// + ///@param in_seed starting seed for random number engine + ///@param in_engine_type Engine type enumeration for random number engine + ///@param in_dist_type Distribution type enumeration for random number distribution + /// + explicit StlRandomGenerator(double in_param_a = 0.0, double in_param_b = 1.0, unsigned long in_seed = 12345, + StlRandomGenerator::StlDistribution in_dist_type = StlRandomGenerator::FLAT, + StlRandomGenerator::StlEngine in_engine_type + = StlRandomGenerator::TRICK_DEFAULT_ENGINE); + + virtual ~StlRandomGenerator(); + + ///@brief return next pseudo-random number + ///@note POISSON distribution returns an int type, + /// so this would need to either cast to double or return a union class like + /// the Trick rand routines already do in order to fit in. + virtual TRICK_GSL_RETURN_TYPE operator()() = 0; + + ///@brief reset seed for pseudo-random number engine + virtual void set_seed(unsigned long in_seed) = 0; + + ///@brief reset parameters for the distribution + ///@param a is min for FLAT, mean for GAUSSION and POISSON + ///@param b is max for FLAT, sigma for GAUSSION and unused for POISSON + virtual void set_param(double a, double b = 0.0) = 0; + + double get_param_a() const { return param_a; } + double get_param_b() const { return param_b; } + + protected: + double param_a; /**< -- first param in distribution::param_type, min for FLAT, mean for GAUSSIAN and POISSON */ + double param_b; /**< -- second param in distribution::param_type, max for FLAT, std deviation for GAUSSIAN, + (unused for POISSON) */ + int initialSeed; /**< -- starting seed */ + + StlEngine engineEnum; /**< -- STL random number engine type enumeration */ + StlDistribution distEnum; /**< -- STL random number distribution type enumeration */ }; ///@brief Factory for StlRandomGenerator objects @@ -168,19 +137,7 @@ protected: ~StlRandomGeneratorFactory() { } }; - - -#if (defined(_HAVE_TR1_RANDOM) || defined(_HAVE_STL_RANDOM)) - // include StlRandomGenerator subclass #include "trick/StlRandomGeneratorSub.hh" - -#else - // do nothing class may be needed if no ?? - // may not if the base class is always a pointer (nullpointer) if not instantiated. - -#endif // _HAVE_TR1_RANDOM or _HAVE_STL_RANDOM - - #endif // StlRandomGenerator_EXISTS diff --git a/include/trick/StlRandomGeneratorSub.hh b/include/trick/StlRandomGeneratorSub.hh index aa93e9961..e4552d602 100644 --- a/include/trick/StlRandomGeneratorSub.hh +++ b/include/trick/StlRandomGeneratorSub.hh @@ -2,8 +2,6 @@ #ifndef STLRANDOMGENERATORSUB_HH #define STLRANDOMGENERATORSUB_HH -#ifdef _HAVE_STL_RANDOM - ///@brief return the correct param_type loaded with the input values /// ///@details Provides a way for a common input interface to return the correct param_type @@ -38,9 +36,12 @@ public: param(__attribute__((unused)) const std::normal_distribution& dist, double mean, double std_dev = 0.0) { return std::normal_distribution::param_type(mean,std_dev); } - static std::poisson_distribution::param_type - param(__attribute__((unused)) const std::poisson_distribution& dist, double mean, __attribute__((unused)) double unused = 0.0) - { return std::poisson_distribution::param_type(mean); } + static std::poisson_distribution::param_type param(__attribute__((unused)) + const std::poisson_distribution& dist, + double mean, __attribute__((unused)) double unused = 0.0) + { + return std::poisson_distribution::param_type(mean); + } ///@} private: @@ -48,22 +49,12 @@ private: ~ParamWrapper(); }; -#endif - - -#if (defined(_HAVE_TR1_RANDOM) || defined(_HAVE_STL_RANDOM)) - ///@brief Return the appropriate union bit pattern for each distribution ///@note Implement one for each available distribution type. class StlReturnWrapper { public: - -#ifdef _HAVE_TR1_RANDOM - static TRICK_GSL_RETURN_TYPE return_value(__attribute__((unused)) const std::uniform_real& dist, double ret_val) -#endif -#ifdef _HAVE_STL_RANDOM - static TRICK_GSL_RETURN_TYPE return_value(__attribute__((unused)) const std::uniform_real_distribution& dist, double ret_val) -#endif + static TRICK_GSL_RETURN_TYPE + return_value(__attribute__((unused)) const std::uniform_real_distribution& dist, double ret_val) { TRICK_GSL_RETURN_TYPE output; output.d = ret_val; @@ -77,73 +68,43 @@ public: return output; } - static TRICK_GSL_RETURN_TYPE return_value(__attribute__((unused)) const std::poisson_distribution& dist, int ret_val) + static TRICK_GSL_RETURN_TYPE return_value(__attribute__((unused)) const std::poisson_distribution& dist, + int ret_val) { TRICK_GSL_RETURN_TYPE output; output.ii = ret_val; return output; } - }; -#endif ///@brief Sub class for object that includes a engine and a distribution /// -///@note partial specialization exists for Distribution = std::poisson_distribution -/// because TR1 doesn't implement param_type system, thus has no way to generally -/// init the class! (No way to use a common 2 parameter interface and ignore the -/// second parameter for single parameter param_type distributions.) -/// -///@note The partial specialization is NOT required when c++0x support is dropped. -/// -/// Also, TR1 Distributions can not have their parameters changed after construction. -/// This results in the need for template full method specialization to provide the type specific init. -/// template class StlRandomGeneratorSub : public StlRandomGenerator { -public: - -#ifdef _HAVE_STD_RANDOM // (Concept doesn't exist in TR1) - typedef typename Distribution::param_type ParamType; -#endif - - ///@note The input in_engine_type and in_dist_type must match the template parameters. - /// This is intended to be assured by using StlRandomGeneratorFactory for construction. - /// - explicit StlRandomGeneratorSub( - double in_param_a = 0.0, - double in_param_b = 1.0, - unsigned long in_seed = 12345, - StlRandomGenerator::StlDistribution in_dist_type = FLAT, - StlRandomGenerator::StlEngine in_engine_type = TRICK_DEFAULT_ENGINE - ) - : StlRandomGenerator(in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type), - engine(in_seed) - { - // (Note: distribution member can't be input initialized in the initializer list - // because various distributions have different signatures. - // - // NOTE: For the TR1 implementation, The set_param method - // _re-constructs_ the object with the desired parameters. - // (TR1 Distributions can only be initialized at construction time.) - // - set_param(in_param_a, in_param_b); - } + public: + typedef typename Distribution::param_type ParamType; + + ///@note The input in_engine_type and in_dist_type must match the template parameters. + /// This is intended to be assured by using StlRandomGeneratorFactory for construction. + /// + explicit StlRandomGeneratorSub(double in_param_a = 0.0, double in_param_b = 1.0, unsigned long in_seed = 12345, + StlRandomGenerator::StlDistribution in_dist_type = FLAT, + StlRandomGenerator::StlEngine in_engine_type = TRICK_DEFAULT_ENGINE) + : StlRandomGenerator(in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) + , engine(in_seed) + { + // (Note: distribution member can't be input initialized in the initializer list + // because various distributions have different signatures. + set_param(in_param_a, in_param_b); + } virtual ~StlRandomGeneratorSub() { } ///@brief return next pseudo-random number virtual TRICK_GSL_RETURN_TYPE operator()() { -#if (defined(_HAVE_TR1_RANDOM) || defined(_HAVE_STL_RANDOM)) return StlReturnWrapper::return_value(distribution, distribution(engine)); -#else - // without either, won't ever be called. But to compile, return zero. - TRICK_GSL_RETURN_TYPE output; - output.d = 0.0; - return output; -#endif } ///@brief reset seed for underlying uniform pseudo-random number generator @@ -158,107 +119,18 @@ public: ///@param a is min for FLAT, mean for GAUSSION and POISSON ///@param b is max for FLAT, sigma for GAUSSION and unused for POISSON /// - ///@note For the TR1 implementation, The set_param method - /// _re-constructs_ the object with the desired parameters. - /// - /// (C++11 allows changing the parameters on the fly.) - /// virtual void set_param(double a, double b = 0.0) { param_a = a; param_b = b; -#ifdef _HAVE_STL_RANDOM - // (this param_type interface is not provided in TR1) - distribution.param( ParamWrapper::param(distribution, a,b) ); -#else - // TR1 implementation must use this hokey - // full template specialization solution. - tr1_init_distribution(a, b); -#endif + distribution.param(ParamWrapper::param(distribution, a, b)); } protected: Engine engine; /**< -- STL random number engine object */ - Distribution distribution; /**< -- STL random number distribution object */ - -private: - -#ifdef _HAVE_TR1_RANDOM - ///@brief For TR1, replace the default initialized distribution with a new one. - /// - ///@details because TR1 only allows initialization of Distribution parameters at - /// construction time (C++11 provides the param_type system for doing this post-construction), - /// this method with full template specializations is used to get around this - /// lack of generality for the few so-far implemented distribution options. - /// - /// Once C++11 is required, these can be removed and the simpler C++11 set_param - /// method used for all. - /// - void tr1_init_distribution(double a, double b) - { - // All two parameter signature distributions can use this method. - // Deviant sets must implement a full template specialization for this method. - distribution = Distribution(a, b); - } -#endif - + Distribution distribution; /**< -- STL random number distribution object */ }; -#ifdef _HAVE_TR1_RANDOM - -// implement one of these template FULL specializations -// for each implemented TR1 StlRandomGenerator::StlEngine enums -// -// So far, only the Poisson distribution requires a single parameter, -// causing the issue. - -/* -// these engines are no longer allowed for TR1 (caused infinite loops in normal_distribution) - -template<> -inline -void -StlRandomGeneratorSub - >::tr1_init_distribution(double a, double __attribute__((unused)) b) -{ - distribution = std::poisson_distribution(a); -} - -template<> -inline -void -StlRandomGeneratorSub - >::tr1_init_distribution(double a, double __attribute__((unused)) b) -{ - distribution = std::poisson_distribution(a); -} - -*/ - -template<> -inline -void -StlRandomGeneratorSub - >::tr1_init_distribution(double a, double __attribute__((unused)) b) -{ - distribution = std::poisson_distribution(a); -} - -template<> -inline -void -StlRandomGeneratorSub - >::tr1_init_distribution(double a, double __attribute__((unused)) b) -{ - distribution = std::poisson_distribution(a); -} - -#endif - #endif diff --git a/include/trick/checkpoint_map.hh b/include/trick/checkpoint_map.hh index 65916c384..7264d8295 100644 --- a/include/trick/checkpoint_map.hh +++ b/include/trick/checkpoint_map.hh @@ -8,22 +8,21 @@ #ifndef CHECKPOINT_MAP_HH #define CHECKPOINT_MAP_HH -#include -#include -#include -#include -#include -#include -#ifdef __GNUC__ -#include -#endif - +#include "checkpoint_fwd_declare.hh" #include "checkpoint_is_stl_container.hh" #include "checkpoint_stl_protos.hh" -#include "checkpoint_fwd_declare.hh" + #include "trick/memorymanager_c_intf.h" #include "trick/message_proto.h" +#include +#include +#include +#include +#include +#include +#include + /* =================================================================================================*/ /* For all of the checkpoint_map_stl variations. Declare 2 memory manager arrays to hold diff --git a/include/trick/checkpoint_pair.hh b/include/trick/checkpoint_pair.hh index c4fc014db..cbe6f0a2b 100644 --- a/include/trick/checkpoint_pair.hh +++ b/include/trick/checkpoint_pair.hh @@ -6,23 +6,22 @@ #ifndef CHECKPOINT_PAIR_HH #define CHECKPOINT_PAIR_HH -#include -#include -#include -#include -#include -#include -#include -#ifdef __GNUC__ -#include -#endif - +#include "checkpoint_fwd_declare.hh" #include "checkpoint_is_stl_container.hh" #include "checkpoint_stl_protos.hh" -#include "checkpoint_fwd_declare.hh" + #include "trick/memorymanager_c_intf.h" #include "trick/message_proto.h" +#include +#include +#include +#include +#include +#include +#include +#include + // intrinsic first , intrinsic second template ::value && !is_stl_container::value >::type* > diff --git a/include/trick/checkpoint_queue.hh b/include/trick/checkpoint_queue.hh index b9ec67409..878237780 100644 --- a/include/trick/checkpoint_queue.hh +++ b/include/trick/checkpoint_queue.hh @@ -6,23 +6,21 @@ #ifndef CHECKPOINT_QUEUE_HH #define CHECKPOINT_QUEUE_HH -#include -#include -#include -#include -#include - -#ifdef __GNUC__ -#include -#endif - -#include "checkpoint_is_stl_container.hh" -#include "checkpoint_stl_protos.hh" #include "checkpoint_fwd_declare.hh" +#include "checkpoint_is_stl_container.hh" #include "checkpoint_sequence_stl.hh" +#include "checkpoint_stl_protos.hh" + #include "trick/memorymanager_c_intf.h" #include "trick/message_proto.h" +#include +#include +#include +#include +#include +#include + /* =================================================================================================*/ diff --git a/include/trick/checkpoint_sequence_stl.hh b/include/trick/checkpoint_sequence_stl.hh index 11c147d00..1e43e7466 100644 --- a/include/trick/checkpoint_sequence_stl.hh +++ b/include/trick/checkpoint_sequence_stl.hh @@ -6,25 +6,24 @@ #ifndef CHECKPOINT_SEQUENCE_STL_HH #define CHECKPOINT_SEQUENCE_STL_HH -#include +#include "checkpoint_fwd_declare.hh" +#include "checkpoint_is_stl_container.hh" +#include "checkpoint_stl_protos.hh" + +#include "trick/memorymanager_c_intf.h" +#include "trick/message_proto.h" + +#include #include -#include -#include +#include #include +#include #include -#include -#include #include +#include #include -#ifdef __GNUC__ -#include -#endif - -#include "checkpoint_is_stl_container.hh" -#include "checkpoint_stl_protos.hh" -#include "checkpoint_fwd_declare.hh" -#include "trick/memorymanager_c_intf.h" -#include "trick/message_proto.h" +#include +#include /* =================================================================================================*/ diff --git a/include/trick/checkpoint_stack.hh b/include/trick/checkpoint_stack.hh index 4279d2633..251f5e62e 100644 --- a/include/trick/checkpoint_stack.hh +++ b/include/trick/checkpoint_stack.hh @@ -6,21 +6,19 @@ #ifndef CHECKPOINT_STACK_HH #define CHECKPOINT_STACK_HH -#include -#include -#include -#include -#include - -#ifdef __GNUC__ -#include -#endif +#include "checkpoint_stl_protos.hh" #include "trick/checkpoint_sequence_stl.hh" -#include "checkpoint_stl_protos.hh" #include "trick/memorymanager_c_intf.h" #include "trick/message_proto.h" +#include +#include +#include +#include +#include +#include + /* =================================================================================================*/ // stack: intrinsic diff --git a/share/trick/makefiles/Makefile.tricklib b/share/trick/makefiles/Makefile.tricklib index 27109b438..2690465b6 100644 --- a/share/trick/makefiles/Makefile.tricklib +++ b/share/trick/makefiles/Makefile.tricklib @@ -96,11 +96,7 @@ $(IO_C_OBJS): $(OBJ_DIR)/%.o : $(IO_SRC_DIR)%.c | $(OBJ_DIR) $(IO_CPP_OBJS): TRICK_SYSTEM_CXXFLAGS += -Wno-invalid-offsetof ifeq ($(IS_CC_CLANG), 0) - # cannot get an "expr" command to work on all platforms. Falling back to reliable perl. :) - GCCVERSIONGTEQ48 := $(shell perl -e 'printf "%d\n", ($(GCC_MAJOR)>4)||(($(GCC_MAJOR)==4)&&($(GCC_MINOR)>=8)) ;' ) - ifeq ($(GCCVERSIONGTEQ48), 1) - $(IO_CPP_OBJS): TRICK_CXXFLAGS += -Wno-unused-but-set-variable - endif + $(IO_CPP_OBJS): TRICK_CXXFLAGS += -Wno-unused-but-set-variable endif $(IO_CPP_OBJS): $(OBJ_DIR)/%.o : $(IO_SRC_DIR)%.cpp | $(OBJ_DIR) diff --git a/share/trick/makefiles/config_Linux.mk b/share/trick/makefiles/config_Linux.mk index 1ba864666..1057e87e4 100644 --- a/share/trick/makefiles/config_Linux.mk +++ b/share/trick/makefiles/config_Linux.mk @@ -52,18 +52,4 @@ HAVE_BFD := 1 PLATFORM_LIBS += -lbfd endif -# determine if -std=c++0x or -std=c++11 compile flags are desired -ifeq "" "c++0x" -TRICK_ADDITIONAL_CXXFLAGS += -std=c++0x -D_HAVE_TR1_RANDOM -endif - -ifeq "" "c++11" -TRICK_ADDITIONAL_CXXFLAGS += -std=c++11 -D_HAVE_STL_RANDOM -endif - -ifeq "" "c++14" -TRICK_ADDITIONAL_CXXFLAGS += -std=c++14 -D_HAVE_STL_RANDOM -endif - TRICK_ADDITIONAL_TEST_FLAGS += -std=c++17 - diff --git a/trick_sims/Cannon/SIM_monte/RUN_test/gauss.py b/trick_sims/Cannon/SIM_monte/RUN_test/gauss.py index b2f52ebb9..56ece4a96 100644 --- a/trick_sims/Cannon/SIM_monte/RUN_test/gauss.py +++ b/trick_sims/Cannon/SIM_monte/RUN_test/gauss.py @@ -1,29 +1,36 @@ - exec(open("Modified_data/cannon_aero.dr").read()) dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 6) trick.mc_set_enabled(1) -#trick.mc_set_dry_run(1) +# trick.mc_set_dry_run(1) trick.mc_set_num_runs(50) -#trick.mc_add_range(5) +# trick.mc_add_range(5) # Inline method below -# If configure trick build with -std=c++0x or -std=c++11 if available, -# can use trick.MonteVarRandom.TRICK_DEFAULT_ENGINE, or other selections. +# Use trick.MonteVarRandom.TRICK_DEFAULT_ENGINE, or other selections, # to use C++11 pseudo-random number generators -var0 = trick.MonteVarRandom("dyn.baseball.time_to_fire_jet_1",trick.MonteVarRandom.GAUSSIAN,"s",trick.MonteVarRandom.NO_ENGINE) # NO_ENGINE is default +var0 = trick.MonteVarRandom( + "dyn.baseball.time_to_fire_jet_1", + trick.MonteVarRandom.GAUSSIAN, + "s", + trick.MonteVarRandom.NO_ENGINE, +) # NO_ENGINE is default var0.set_seed(1) var0.set_sigma(0.6667) var0.set_mu(4.0) var0.set_min(-4.0) var0.set_max(4.0) -var0.set_min_is_relative(True) # default is True -var0.set_max_is_relative(True) # default is True -var0.set_sigma_range(0) # 1 is default, so usually set to zero to turn off the algorithm - -var1 = trick.MonteVarRandom("dyn.baseball.time_to_fire_jet_2",trick.MonteVarRandom.GAUSSIAN) +var0.set_min_is_relative(True) # default is True +var0.set_max_is_relative(True) # default is True +var0.set_sigma_range( + 0 +) # 1 is default, so usually set to zero to turn off the algorithm + +var1 = trick.MonteVarRandom( + "dyn.baseball.time_to_fire_jet_2", trick.MonteVarRandom.GAUSSIAN +) var1.set_seed(2) var1.set_sigma(0.6667) var1.set_mu(4.0) @@ -31,7 +38,9 @@ var1.set_max(4.0) var1.set_sigma_range(0) -var2 = trick.MonteVarRandom("dyn.baseball.time_to_fire_jet_3",trick.MonteVarRandom.GAUSSIAN,"s") +var2 = trick.MonteVarRandom( + "dyn.baseball.time_to_fire_jet_3", trick.MonteVarRandom.GAUSSIAN, "s" +) var2.set_seed(3) var2.set_sigma(0.6667) var2.set_mu(4.0) @@ -39,7 +48,9 @@ var2.set_max(4.0) var2.set_sigma_range(0) -var3 = trick.MonteVarRandom("dyn.baseball.time_to_fire_jet_4",trick.MonteVarRandom.GAUSSIAN) +var3 = trick.MonteVarRandom( + "dyn.baseball.time_to_fire_jet_4", trick.MonteVarRandom.GAUSSIAN +) var3.set_seed(4) var3.set_sigma(0.6667) var3.set_mu(4.0) @@ -62,10 +73,9 @@ dyn.baseball.vel[1] = 0.0 dyn.baseball.vel[2] = 25.0 -dyn.baseball.theta = trick.attach_units("d" , -90.0) -dyn.baseball.phi = trick.attach_units("d" , 1.0) -dyn.baseball.omega0 = trick.attach_units("rev/s" , 30.0) +dyn.baseball.theta = trick.attach_units("d", -90.0) +dyn.baseball.phi = trick.attach_units("d", 1.0) +dyn.baseball.omega0 = trick.attach_units("rev/s", 30.0) trick.stop(10.0) - diff --git a/trick_source/codegen/Interface_Code_Gen/BraceMacro.hh b/trick_source/codegen/Interface_Code_Gen/BraceMacro.hh index b0c4b1e33..af6249155 100644 --- a/trick_source/codegen/Interface_Code_Gen/BraceMacro.hh +++ b/trick_source/codegen/Interface_Code_Gen/BraceMacro.hh @@ -1,11 +1,7 @@ #ifndef BRACEMACRO_HH #define BRACEMACRO_HH -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 9)) #define RBRACELOC getBraceRange().getEnd -#else -#define RBRACELOC getRBraceLoc -#endif #if (LIBCLANG_MAJOR >=8) #define GETLOCEND getEndLoc diff --git a/trick_source/codegen/Interface_Code_Gen/CommentSaver.cpp b/trick_source/codegen/Interface_Code_Gen/CommentSaver.cpp index 33e3b74b2..514dead49 100644 --- a/trick_source/codegen/Interface_Code_Gen/CommentSaver.cpp +++ b/trick_source/codegen/Interface_Code_Gen/CommentSaver.cpp @@ -14,12 +14,9 @@ CommentSaver::CommentSaver(clang::CompilerInstance & in_ci , HeaderSearchDirs & bool CommentSaver::HandleComment(clang::Preprocessor &PP, clang::SourceRange Comment) { //Comment.getBegin().dump(sm) ; - if ( isInUserOrTrickCode( ci , Comment.getBegin() , hsd ) ) { -#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported - std::string file_name = ci.getSourceManager().getBufferName(Comment.getBegin()) ; -#else - std::string file_name = ci.getSourceManager().getBufferName(Comment.getBegin()).str() ; -#endif + if (isInUserOrTrickCode(ci, Comment.getBegin(), hsd)) + { + std::string file_name = ci.getSourceManager().getBufferName(Comment.getBegin()).str(); char * resolved_path = almostRealPath( file_name.c_str() ) ; if ( resolved_path != NULL ) { unsigned int line_no = ci.getSourceManager().getSpellingLineNumber(Comment.getBegin()) ; diff --git a/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp b/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp index 9501b1fc9..9753472e0 100644 --- a/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp @@ -5,8 +5,12 @@ #include "FindTrickICG.hh" #include "Utilities.hh" -FindTrickICG::FindTrickICG(clang::CompilerInstance & in_ci, HeaderSearchDirs & in_hsd , bool in_print_msgs ) - : ci(in_ci) , hsd(in_hsd) , print_msgs(in_print_msgs) , header_printed(false) { } +FindTrickICG::FindTrickICG(clang::CompilerInstance& in_ci, HeaderSearchDirs& in_hsd, bool in_print_msgs) + : ci(in_ci) + , hsd(in_hsd) + , print_msgs(in_print_msgs) +{ +} void FindTrickICG::FileChanged(clang::SourceLocation Loc, FileChangeReason Reason, clang::SrcMgr::CharacteristicKind FileType, @@ -66,12 +70,8 @@ void FindTrickICG::FileSkipped(const clang::FileEntryRef & SkippedFile, const cl } } - -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) -void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue) -#else -void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) -#endif +void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, + clang::PPCallbacks::ConditionValueKind ConditionValue) { if ( ConditionRange.isValid() ) { // Get the full text of the if statement into a string @@ -100,21 +100,14 @@ void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRan } } -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) -void FindTrickICG::ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue) -#else -void FindTrickICG::ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) -#endif +void FindTrickICG::Elif(clang::SourceLocation Loc, clang::SourceRange ConditionRange, + clang::PPCallbacks::ConditionValueKind ConditionValue, clang::SourceLocation IfLoc) { // Do the same processing for an #elif statement as an #if statement. If(Loc,ConditionRange,ConditionValue) ; } -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 7)) -void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) -#else -void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) -#endif +void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token& MacroNameTok, const clang::MacroDefinition& MD) { // Get the token name that is being tested. std::string name = MacroNameTok.getIdentifierInfo()->getName().str() ; @@ -137,11 +130,7 @@ void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNam } -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 7)) -void FindTrickICG::Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) -#else -void FindTrickICG::Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) -#endif +void FindTrickICG::Ifndef(clang::SourceLocation Loc, const clang::Token& MacroNameTok, const clang::MacroDefinition& MD) { // Get the token name that is being tested. std::string name = MacroNameTok.getIdentifierInfo()->getName().str() ; diff --git a/trick_source/codegen/Interface_Code_Gen/FindTrickICG.hh b/trick_source/codegen/Interface_Code_Gen/FindTrickICG.hh index 02160d605..66a6f6e7c 100644 --- a/trick_source/codegen/Interface_Code_Gen/FindTrickICG.hh +++ b/trick_source/codegen/Interface_Code_Gen/FindTrickICG.hh @@ -11,41 +11,31 @@ We also print a warning to the screen where the TRICK_ICG was found. */ -class FindTrickICG : public clang::PPCallbacks { - public: - FindTrickICG(clang::CompilerInstance & in_ci , HeaderSearchDirs & in_hsd , bool in_print_msgs ) ; +class FindTrickICG final : public clang::PPCallbacks +{ + public: + FindTrickICG(clang::CompilerInstance& in_ci, HeaderSearchDirs& in_hsd, bool in_print_msgs); - // called when the file changes for a variety of reasons. - virtual void FileChanged(clang::SourceLocation Loc, FileChangeReason Reason, - clang::SrcMgr::CharacteristicKind FileType, - clang::FileID PrevFID = clang::FileID()) ; + // called when the file changes for a variety of reasons. + void FileChanged(clang::SourceLocation Loc, FileChangeReason Reason, clang::SrcMgr::CharacteristicKind FileType, + clang::FileID PrevFID = clang::FileID()) override; #if (LIBCLANG_MAJOR < 10) // TODO delete when RHEL 7 no longer supported - virtual void FileSkipped(const clang::FileEntry &SkippedFile, - const clang::Token &FilenameTok, - clang::SrcMgr::CharacteristicKind FileType) ; + void FileSkipped(const clang::FileEntry& SkippedFile, const clang::Token& FilenameTok, + clang::SrcMgr::CharacteristicKind FileType) override; #else - // called when a header file is skipped because of a header guard optimization. - virtual void FileSkipped(const clang::FileEntryRef & SkippedFile, - const clang::Token & FilenameTok, - clang::SrcMgr::CharacteristicKind FileType) ; + // called when a header file is skipped because of a header guard optimization. + void FileSkipped(const clang::FileEntryRef& SkippedFile, const clang::Token& FilenameTok, + clang::SrcMgr::CharacteristicKind FileType) override; #endif // callbacks called when the preprocessor directives of types are processed. -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) - virtual void If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue) ; - virtual void ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue) ; -#else - virtual void If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) ; - virtual void ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) ; -#endif -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 7)) - virtual void Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) ; - virtual void Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) ; -#else - virtual void Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) ; - virtual void Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) ; -#endif + void If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, + clang::PPCallbacks::ConditionValueKind ConditionValue) override; + void Elif(clang::SourceLocation Loc, clang::SourceRange ConditionRange, + clang::PPCallbacks::ConditionValueKind ConditionValue, clang::SourceLocation IfLoc) override; + void Ifdef(clang::SourceLocation Loc, const clang::Token& MacroNameTok, const clang::MacroDefinition& MD) override; + void Ifndef(clang::SourceLocation Loc, const clang::Token& MacroNameTok, const clang::MacroDefinition& MD) override; // print a warning about using TRICK_ICG. void print_header() ; @@ -61,8 +51,8 @@ class FindTrickICG : public clang::PPCallbacks { bool print_msgs ; // Have we printed the big warning about TRICK_ICG? - bool header_printed ; + bool header_printed = false; // Using a vector as a stack to hold the stack of included headers we have entered. std::vector included_files ; -} ; +}; diff --git a/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.cpp b/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.cpp index 979fe668e..edc6a9b3d 100644 --- a/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.cpp +++ b/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.cpp @@ -233,11 +233,7 @@ bool HeaderSearchDirs::isPathInUserDir (const std::string& in_dir ) { for ( sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; ++sdi ) #endif { -#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported - std::string curr_dir = (*sdi).getName() ; -#else - std::string curr_dir = (*sdi).getName().str() ; -#endif + std::string curr_dir = (*sdi).getName().str(); if ( ! in_dir.compare(0, curr_dir.size(), curr_dir)) { return false ; } @@ -265,11 +261,7 @@ bool HeaderSearchDirs::isPathInUserOrTrickDir (const std::string& in_dir ) { for ( sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; ++sdi ) #endif { -#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported - std::string curr_dir = (*sdi).getName() ; -#else - std::string curr_dir = (*sdi).getName().str() ; -#endif + std::string curr_dir = (*sdi).getName().str(); if ( ! in_dir.compare(0, curr_dir.size(), curr_dir)) { return false ; } diff --git a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp index 1cc2d657a..5f7beeb25 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp +++ b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp @@ -267,7 +267,7 @@ void PrintAttributes::printEnum(EnumValues* ev) { outfile.close() ; printSieEnum(&enumValues) ; } - + if (!isHeaderExcluded(fileName, false)) { printer->printEnumMap(enum_map_outfile, ev); } @@ -402,9 +402,7 @@ std::set PrintAttributes::getEmptyFiles() { std::set emptyFiles; for (auto fi = ci.getSourceManager().fileinfo_begin() ; fi != ci.getSourceManager().fileinfo_end() ; ++fi ) { const clang::FileEntry * fe = (*fi).first ; -#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported - std::string header_file_name = fe->getName() ; -#elif (LIBCLANG_MAJOR >= 4 && LIBCLANG_MAJOR < 18) +#if (LIBCLANG_MAJOR < 18) std::string header_file_name = fe->getName().str() ; #else const clang::FileEntryRef fer = fi->first ; @@ -446,19 +444,14 @@ void PrintAttributes::printIOMakefile() { makefile_io_src.open("build/Makefile_io_src") ; makefile_io_src - << "TRICK_IO_CXXFLAGS += -Wno-invalid-offsetof -Wno-old-style-cast -Wno-write-strings -Wno-unused-variable" << std::endl - << std::endl - << "ifeq ($(IS_CC_CLANG), 0)" << std::endl - << " TRICK_IO_CXXFLAGS += -Wno-unused-local-typedefs -Wno-unused-but-set-variable" << std::endl - << " ifeq ($(shell test $(GCC_MAJOR) -lt 6; echo $$?), 0)" << std::endl - << " TRICK_IO_CXXFLAGS += -std=c++11" << std::endl - << " endif" << std::endl - << "endif" << std::endl - << "ifeq ($(IS_CC_CLANG), 1)" << std::endl - << " TRICK_IO_CXXFLAGS += -std=c++14" << std::endl - << "endif" << std::endl + << "TRICK_IO_CXXFLAGS += -Wno-invalid-offsetof -Wno-old-style-cast -Wno-write-strings -Wno-unused-variable" << std::endl - << "IO_OBJECTS =" ; + << '\n' + << "ifeq ($(IS_CC_CLANG), 0)" << '\n' + << " TRICK_IO_CXXFLAGS += -Wno-unused-local-typedefs -Wno-unused-but-set-variable" << '\n' + << "endif" << '\n' + << '\n' + << "IO_OBJECTS ="; std::map< std::string , std::string >::iterator mit ; for ( mit = all_io_files.begin() ; mit != all_io_files.end() ; ++mit ) { diff --git a/trick_source/codegen/Interface_Code_Gen/Utilities.cpp b/trick_source/codegen/Interface_Code_Gen/Utilities.cpp index 03caec9f8..25a927921 100644 --- a/trick_source/codegen/Interface_Code_Gen/Utilities.cpp +++ b/trick_source/codegen/Interface_Code_Gen/Utilities.cpp @@ -114,10 +114,8 @@ char * getResolvedPath(clang::CompilerInstance & ci , clang::SourceLocation sl) if ( ! fid.isInvalid() ) { const clang::FileEntry * fe = ci.getSourceManager().getFileEntryForID(fid) ; if ( fe != NULL ) { -#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported - resolved_path = almostRealPath( fe->getName() ) ; -#elif (LIBCLANG_MAJOR >= 4 && LIBCLANG_MAJOR < 18) - resolved_path = almostRealPath( fe->getName().str() ) ; +#if (LIBCLANG_MAJOR < 18) + resolved_path = almostRealPath(fe->getName().str()); #else const clang::CustomizableOptional cfer = ci.getSourceManager().getFileEntryRefForID(fid) ; if (cfer.has_value()) { diff --git a/trick_source/codegen/Interface_Code_Gen/main.cpp b/trick_source/codegen/Interface_Code_Gen/main.cpp index 22e07a3eb..5b0ee96f9 100644 --- a/trick_source/codegen/Interface_Code_Gen/main.cpp +++ b/trick_source/codegen/Interface_Code_Gen/main.cpp @@ -187,10 +187,7 @@ int main(int argc, char * argv[]) { std::cerr << "No header file specified" << std::endl; return 1; } - clang::CompilerInstance ci ; -#if (LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR < 9) - clang::CompilerInvocation::setLangDefaults(ci.getLangOpts() , clang::IK_CXX) ; -#endif + clang::CompilerInstance ci; #if (LIBCLANG_MAJOR >= 22) ci.createDiagnostics(); @@ -228,7 +225,6 @@ int main(int argc, char * argv[]) { ppo.UsePredefines = true; // Set the default target architecture -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) clang::TargetOptions to; if ( m32 ) { to.Triple = llvm::Triple(llvm::sys::getDefaultTargetTriple()).get32BitArchVariant().str(); @@ -243,37 +239,22 @@ int main(int argc, char * argv[]) { #endif ci.setTarget(pti); ci.createPreprocessor(clang::TU_Complete); -#else - clang::TargetOptions * to = new clang::TargetOptions() ; - if ( m32 ) { - to->Triple = llvm::Triple(llvm::sys::getDefaultTargetTriple()).get32BitArchVariant().str(); - } else { - to->Triple = llvm::sys::getDefaultTargetTriple(); - } - clang::TargetInfo *pti = clang::TargetInfo::CreateTargetInfo(ci.getDiagnostics(), to); - ci.setTarget(pti); - ci.createPreprocessor(); -#endif // Set all of the defaults to c++ -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 9)) llvm::Triple trip (to.Triple) ; #if (LIBCLANG_MAJOR >= 15) clang::LangOptions::setLangDefaults(ci.getLangOpts(), clang::Language::CXX, trip, ppo.Includes); #elif (LIBCLANG_MAJOR >= 12) clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::Language::CXX, trip, ppo.Includes) ; #elif (LIBCLANG_MAJOR >= 10) - clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::Language::CXX, trip, ppo) ; -#elif (LIBCLANG_MAJOR >= 5) - clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::InputKind::CXX, trip, ppo) ; + clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::Language::CXX, trip, ppo); #else - clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::IK_CXX, trip, ppo) ; + clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::InputKind::CXX, trip, ppo); #endif // setting the language defaults clears some of the language opts, set them again. set_lang_opts(ci); -#endif clang::Preprocessor& pp = ci.getPreprocessor(); #if (LIBCLANG_MAJOR >= 10) && (LIBCLANG_MAJOR < 18) @@ -293,19 +274,10 @@ int main(int argc, char * argv[]) { const auto BOU_FALSE_VAL = llvm::cl::BOU_FALSE; #endif -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 6)) auto ftg = std::make_unique(ci, hsd, print_trick_icg != BOU_FALSE_VAL); - pp.addPPCallbacks(std::move(ftg)) ; -#else - FindTrickICG* ftg = new FindTrickICG(ci, hsd, print_trick_icg != BOU_FALSE_VAL); - pp.addPPCallbacks(ftg) ; -#endif + pp.addPPCallbacks(std::move(ftg)); -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 8)) pp.getBuiltinInfo().initializeBuiltins(pp.getIdentifierTable(), pp.getLangOpts()); -#else - pp.getBuiltinInfo().InitializeBuiltins(pp.getIdentifierTable(), pp.getLangOpts()); -#endif // Add all of the #define from the command line to the default predefines hsd.addDefines(defines); @@ -323,11 +295,7 @@ int main(int argc, char * argv[]) { // Tell the compiler to use our ICGASTconsumer ICGASTConsumer* astConsumer = new ICGASTConsumer(ci, hsd, cs, printAttributes); -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 6)) ci.setASTConsumer(std::move(std::unique_ptr(astConsumer))); -#else - ci.setASTConsumer(astConsumer); -#endif ci.createASTContext(); ci.createSema(clang::TU_Complete, NULL); @@ -354,12 +322,12 @@ int main(int argc, char * argv[]) { const clang::FileEntry* fileEntry = ci.getFileManager().getFile(inputFilePath); #endif free(inputFilePath); -#if ((LIBCLANG_MAJOR > 3 && LIBCLANG_MAJOR < 18)) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) - ci.getSourceManager().setMainFileID(ci.getSourceManager().createFileID(fileEntry, clang::SourceLocation(), clang::SrcMgr::C_User)); -#elif (LIBCLANG_MAJOR >= 18) - ci.getSourceManager().setMainFileID(ci.getSourceManager().createFileID(fileEntryRef, clang::SourceLocation(), clang::SrcMgr::C_User)); +#if (LIBCLANG_MAJOR < 18) + ci.getSourceManager().setMainFileID( + ci.getSourceManager().createFileID(fileEntry, clang::SourceLocation(), clang::SrcMgr::C_User)); #else - ci.getSourceManager().createMainFileID(fileEntry); + ci.getSourceManager().setMainFileID( + ci.getSourceManager().createFileID(fileEntryRef, clang::SourceLocation(), clang::SrcMgr::C_User)); #endif ICGDiagnosticConsumer *icgDiagConsumer = new ICGDiagnosticConsumer(llvm::errs(), &ci.getDiagnosticOpts(), ci, hsd); ci.getDiagnostics().setClient(icgDiagConsumer); diff --git a/trick_source/codegen/Interface_Code_Gen/makefile b/trick_source/codegen/Interface_Code_Gen/makefile index eac5ef3fc..a1d9a403a 100644 --- a/trick_source/codegen/Interface_Code_Gen/makefile +++ b/trick_source/codegen/Interface_Code_Gen/makefile @@ -2,26 +2,14 @@ TRICK_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../../..) # The config_${HOST_TYPE}.mk file provides LLVM_HOME include ${TRICK_HOME}/share/trick/makefiles/Makefile.common -CXXFLAGS := -g -I$(shell $(LLVM_HOME)/bin/llvm-config --includedir) -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti $(UDUNITS_INCLUDES) +CXXFLAGS := -g -std=c++17 -I$(shell $(LLVM_HOME)/bin/llvm-config --includedir) -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti $(UDUNITS_INCLUDES) CLANG_MAJOR := $(shell $(LLVM_HOME)/bin/llvm-config --version | cut -f1 -d.) CLANG_MINOR := $(shell $(LLVM_HOME)/bin/llvm-config --version | cut -f2 -d.) CLANG_PATCHLEVEL := $(shell $(LLVM_HOME)/bin/llvm-config --version | cut -f3 -d.) -# check to see if version is greater than 3.5 -CLANG_MINOR_GTEQ5 := $(shell [ $(CLANG_MAJOR) -gt 3 -o \( $(CLANG_MAJOR) -eq 3 -a $(CLANG_MINOR) -ge 5 \) ] && echo 1) -CLANG_MAJOR_GTEQ10 := $(shell [ $(CLANG_MAJOR) -ge 10 ] && echo 1) -# By default, Clang 16 or later builds C++ code according to the C++17 standard. +# Clang 16 and later provide libclang-cpp. CLANG_MAJOR_GTEQ16 := $(shell [ $(CLANG_MAJOR) -ge 16 ] && echo 1) -ifeq ($(CLANG_MAJOR_GTEQ16),1) -CXXFLAGS += -std=c++17 -else -ifeq ($(CLANG_MAJOR_GTEQ10),1) -CXXFLAGS += -std=c++14 -else -CXXFLAGS += -std=c++11 -endif -endif LLVMLDFLAGS := $(shell $(LLVM_HOME)/bin/llvm-config --ldflags) $(UDUNITS_LDFLAGS) @@ -45,11 +33,9 @@ endif ifeq ($(TRICK_HOST_TYPE),Linux) CLANGLIBS += $(shell $(LLVM_HOME)/bin/llvm-config --libs) CXXFLAGS += -DTRICK_GCC_VERSION=\"$(TRICK_GCC_VERSION)\" -ifeq ($(CLANG_MINOR_GTEQ5),1) # Fedora 21 adds -ledit as a system lib, but it isn't installed, or required. CLANGLIBS += $(filter-out -ledit,$(shell $(LLVM_HOME)/bin/llvm-config --system-libs)) endif -endif ifeq ($(TRICK_HOST_TYPE),Darwin) CLANGLIBS += $(shell $(LLVM_HOME)/bin/llvm-config --libs) diff --git a/trick_source/sim_services/DataRecord/DataRecordGroup.cpp b/trick_source/sim_services/DataRecord/DataRecordGroup.cpp index 453bd3ad2..5b80c8dff 100644 --- a/trick_source/sim_services/DataRecord/DataRecordGroup.cpp +++ b/trick_source/sim_services/DataRecord/DataRecordGroup.cpp @@ -1,18 +1,5 @@ - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __GNUC__ -#include -#endif - #include "trick/DataRecordGroup.hh" + #include "trick/ReferenceUtils.hh" #include "trick/command_line_protos.h" #include "trick/exec_proto.h" @@ -21,6 +8,16 @@ #include "trick/message_type.h" #include "trick/reference.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + /** @details -# The recording group is enabled diff --git a/trick_source/sim_services/Executive/ExecutiveException.cpp b/trick_source/sim_services/Executive/ExecutiveException.cpp index 0db9d6292..4b0a86a71 100644 --- a/trick_source/sim_services/Executive/ExecutiveException.cpp +++ b/trick_source/sim_services/Executive/ExecutiveException.cpp @@ -15,10 +15,6 @@ Trick::ExecutiveException::ExecutiveException(int in_ret , std::string in_file , } -Trick::ExecutiveException::~ExecutiveException() throw () { -} - -const char* Trick::ExecutiveException::what() const throw() { - return message.c_str() ; -} +Trick::ExecutiveException::~ExecutiveException() { } +const char* Trick::ExecutiveException::what() const noexcept { return message.c_str(); } diff --git a/trick_source/sim_services/MemoryManager/MemoryManager_add_attr_info.cpp b/trick_source/sim_services/MemoryManager/MemoryManager_add_attr_info.cpp index 14692ca71..5e0514e48 100644 --- a/trick_source/sim_services/MemoryManager/MemoryManager_add_attr_info.cpp +++ b/trick_source/sim_services/MemoryManager/MemoryManager_add_attr_info.cpp @@ -1,14 +1,12 @@ -#include -#include -#include -#include - -#ifdef __GNUC__ -#include -#endif +#include "trick/MemoryManager.hh" #include "trick/SimObject.hh" -#include "trick/MemoryManager.hh" + +#include +#include +#include +#include +#include /** * diff --git a/trick_source/sim_services/MonteCarlo/MonteVarRandom.cpp b/trick_source/sim_services/MonteCarlo/MonteVarRandom.cpp index 3c36f07af..dd32eb540 100644 --- a/trick_source/sim_services/MonteCarlo/MonteVarRandom.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteVarRandom.cpp @@ -29,7 +29,6 @@ Trick::MonteVarRandom::MonteVarRandom(std::string in_name, Distribution in_distr randist.type = (TRICK_GSL_TYPE) distribution; randist.sigma_range = 1; -#if (defined(_HAVE_TR1_RANDOM) || defined(_HAVE_STL_RANDOM)) unsigned long seed = randist.seed; double unused = 0.0; StlRandomGenerator::StlDistribution stlDist = @@ -59,7 +58,6 @@ Trick::MonteVarRandom::MonteVarRandom(std::string in_name, Distribution in_distr break; } } -#endif } Trick::MonteVarRandom::~MonteVarRandom() diff --git a/trick_source/sim_services/MonteCarlo/StlRandomGenerator.cpp b/trick_source/sim_services/MonteCarlo/StlRandomGenerator.cpp index 6cc51d0de..36add09ac 100644 --- a/trick_source/sim_services/MonteCarlo/StlRandomGenerator.cpp +++ b/trick_source/sim_services/MonteCarlo/StlRandomGenerator.cpp @@ -28,92 +28,26 @@ StlRandomGeneratorFactory::newGenerator( StlRandomGenerator::StlDistribution in_dist_type, StlRandomGenerator::StlEngine in_engine_type) { - -#if (defined(_HAVE_TR1_RANDOM) || defined(_HAVE_STL_RANDOM)) - -#ifdef _HAVE_STL_RANDOM -#define UNIFORM_INT_DIST std::uniform_int_distribution -#define UNIFORM_REAL_DIST std::uniform_real_distribution -#define TRICK_DEFAULT_ENGINE_CLASS std::mt19937 -#else -#define UNIFORM_INT_DIST std::uniform_int -#define UNIFORM_REAL_DIST std::uniform_real -#define TRICK_DEFAULT_ENGINE_CLASS std::ranlux_base_01 // because mt19937 doesnt return within canonical range for GCC 4.4.7 -#endif - switch (in_engine_type * 1000 + in_dist_type) { // ------------- TRICK_DEFAULT_ENGINE -------------------------------------- case StlRandomGenerator::TRICK_DEFAULT_ENGINE*1000 + StlRandomGenerator::GAUSSIAN: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< TRICK_DEFAULT_ENGINE_CLASS, std::normal_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; case StlRandomGenerator::TRICK_DEFAULT_ENGINE*1000 + StlRandomGenerator::FLAT: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< TRICK_DEFAULT_ENGINE_CLASS, UNIFORM_REAL_DIST > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; case StlRandomGenerator::TRICK_DEFAULT_ENGINE*1000 + StlRandomGenerator::POISSON: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< TRICK_DEFAULT_ENGINE_CLASS, std::poisson_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; - -#ifdef _HAVE_TR1_RANDOM - // ------------- RANLUX_BASE_01_ENGINE --------------------------------------------- - - case StlRandomGenerator::RANLUX_BASE_01_ENGINE*1000 + StlRandomGenerator::GAUSSIAN: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux_base_01, std::normal_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); - break; - case StlRandomGenerator::RANLUX_BASE_01_ENGINE*1000 + StlRandomGenerator::FLAT: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux_base_01, UNIFORM_REAL_DIST > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); - break; - case StlRandomGenerator::RANLUX_BASE_01_ENGINE*1000 + StlRandomGenerator::POISSON: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux_base_01, std::poisson_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); - break; - - // ------------- RANLUX_64_BASE_01_ENGINE --------------------------------------------- - - case StlRandomGenerator::RANLUX_64_BASE_01_ENGINE*1000 + StlRandomGenerator::GAUSSIAN: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux64_base_01, std::normal_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); - break; - case StlRandomGenerator::RANLUX_64_BASE_01_ENGINE*1000 + StlRandomGenerator::FLAT: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux64_base_01, UNIFORM_REAL_DIST > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); - break; - case StlRandomGenerator::RANLUX_64_BASE_01_ENGINE*1000 + StlRandomGenerator::POISSON: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux64_base_01, std::poisson_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); - break; - -#else - -// std::minstd_rand and mt19937 are not provided for TR1, because GCC 4.4.7 (at least) -// they return outside the canonical range 0 <= x < 1. -// This causes an infinite loop in std::normal_distribution - // ------------- MINSTD_RAND_ENGINE --------------------------------------------- case StlRandomGenerator::MINSTD_RAND_ENGINE*1000 + StlRandomGenerator::GAUSSIAN: @@ -123,16 +57,14 @@ StlRandomGeneratorFactory::newGenerator( ); break; case StlRandomGenerator::MINSTD_RAND_ENGINE*1000 + StlRandomGenerator::FLAT: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::minstd_rand, UNIFORM_REAL_DIST > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; case StlRandomGenerator::MINSTD_RAND_ENGINE*1000 + StlRandomGenerator::POISSON: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::minstd_rand, std::poisson_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>(in_param_a, in_param_b, in_seed, + in_dist_type, in_engine_type)); break; // ------------- MT19937_ENGINE --------------------------------------------- @@ -144,19 +76,15 @@ StlRandomGeneratorFactory::newGenerator( ); break; case StlRandomGenerator::MT19937_ENGINE*1000 + StlRandomGenerator::FLAT: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::mt19937, UNIFORM_REAL_DIST > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; case StlRandomGenerator::MT19937_ENGINE*1000 + StlRandomGenerator::POISSON: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::mt19937, std::poisson_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast(new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; -// these engines are all C++11 only // ------------- MT19937_64_ENGINE --------------------------------------------- case StlRandomGenerator::MT19937_64_ENGINE*1000 + StlRandomGenerator::GAUSSIAN: @@ -166,16 +94,14 @@ StlRandomGeneratorFactory::newGenerator( ); break; case StlRandomGenerator::MT19937_64_ENGINE*1000 + StlRandomGenerator::FLAT: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::mt19937_64, UNIFORM_REAL_DIST > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; case StlRandomGenerator::MT19937_64_ENGINE*1000 + StlRandomGenerator::POISSON: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::mt19937_64, std::poisson_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>(in_param_a, in_param_b, in_seed, + in_dist_type, in_engine_type)); break; // ------------- RANLUX_24_BASE_ENGINE --------------------------------------------- @@ -187,16 +113,14 @@ StlRandomGeneratorFactory::newGenerator( ); break; case StlRandomGenerator::RANLUX_24_BASE_ENGINE*1000 + StlRandomGenerator::FLAT: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux24_base, UNIFORM_REAL_DIST > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; case StlRandomGenerator::RANLUX_24_BASE_ENGINE*1000 + StlRandomGenerator::POISSON: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux24_base, std::poisson_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; // ------------- RANLUX_44_BASE_ENGINE --------------------------------------------- @@ -208,16 +132,14 @@ StlRandomGeneratorFactory::newGenerator( ); break; case StlRandomGenerator::RANLUX_44_BASE_ENGINE*1000 + StlRandomGenerator::FLAT: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux48_base, UNIFORM_REAL_DIST > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; case StlRandomGenerator::RANLUX_44_BASE_ENGINE*1000 + StlRandomGenerator::POISSON: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux48_base, std::poisson_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; // ------------- RANLUX_24_ENGINE --------------------------------------------- @@ -229,16 +151,14 @@ StlRandomGeneratorFactory::newGenerator( ); break; case StlRandomGenerator::RANLUX_24_ENGINE*1000 + StlRandomGenerator::FLAT: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux24, UNIFORM_REAL_DIST > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; case StlRandomGenerator::RANLUX_24_ENGINE*1000 + StlRandomGenerator::POISSON: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux24, std::poisson_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>(in_param_a, in_param_b, in_seed, + in_dist_type, in_engine_type)); break; // ------------- RANLUX_44_ENGINE --------------------------------------------- @@ -250,16 +170,14 @@ StlRandomGeneratorFactory::newGenerator( ); break; case StlRandomGenerator::RANLUX_44_ENGINE*1000 + StlRandomGenerator::FLAT: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux48, UNIFORM_REAL_DIST > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; case StlRandomGenerator::RANLUX_44_ENGINE*1000 + StlRandomGenerator::POISSON: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::ranlux48, std::poisson_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>(in_param_a, in_param_b, in_seed, + in_dist_type, in_engine_type)); break; // ------------- KNUTH_B_ENGINE --------------------------------------------- @@ -271,26 +189,16 @@ StlRandomGeneratorFactory::newGenerator( ); break; case StlRandomGenerator::KNUTH_B_ENGINE*1000 + StlRandomGenerator::FLAT: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::knuth_b, UNIFORM_REAL_DIST > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast( + new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; case StlRandomGenerator::KNUTH_B_ENGINE*1000 + StlRandomGenerator::POISSON: - return static_cast< StlRandomGenerator* > ( - new StlRandomGeneratorSub< std::knuth_b, std::poisson_distribution > - (in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type) - ); + return static_cast(new StlRandomGeneratorSub>( + in_param_a, in_param_b, in_seed, in_dist_type, in_engine_type)); break; -#endif default: throw std::invalid_argument(std::string("error: StlRandomGeneratorFactory::newGenerator called for unimplemented std::random (engine,distribution) combination.")); } - - -#else - // without either _HAVE_TR1_RANDOM or _HAVE_STL_RANDOM, return null pointer. - return 0; // ???? what was I thinking here static_cast< StlRandomGenerator* >( 0 ); -#endif } diff --git a/trick_source/sim_services/MonteCarlo/test/MonteCarlo_test.cpp b/trick_source/sim_services/MonteCarlo/test/MonteCarlo_test.cpp index 3a38fee13..fa5f699ad 100644 --- a/trick_source/sim_services/MonteCarlo/test/MonteCarlo_test.cpp +++ b/trick_source/sim_services/MonteCarlo/test/MonteCarlo_test.cpp @@ -638,8 +638,6 @@ TEST_F(MonteCarloTest, MonteVarRandom_StlGaussian_nonGslSigmaRangeDefaulted_maxD #endif // not _HAVE_GSL -#if (defined(_HAVE_TR1_RANDOM) || defined(_HAVE_STL_RANDOM)) - TEST_F(MonteCarloTest, MonteVarRandom_StlGaussian_distributionMatchesSpec) { //req.add_requirement("3932595803"); std::string str ; @@ -880,7 +878,4 @@ TEST_F(MonteCarloTest, MonteVarRandom_StlGaussian_setSeed_TakesEffect) { EXPECT_NEAR(first_value, second_value, 0.000001) ; } - -#endif // _HAVE_TR1_RANDOM or _HAVE_STL_RANDOM - } diff --git a/trick_source/sim_services/ThreadBase/ThreadBase.cpp b/trick_source/sim_services/ThreadBase/ThreadBase.cpp index 52fca5605..ea7e1700c 100644 --- a/trick_source/sim_services/ThreadBase/ThreadBase.cpp +++ b/trick_source/sim_services/ThreadBase/ThreadBase.cpp @@ -294,14 +294,10 @@ int Trick::ThreadBase::create_thread() { created = true; #if __linux__ -#ifdef __GNUC__ -#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 2 if ( ! name.empty() ) { std::string short_str = name.substr(0,15) ; pthread_setname_np(pthread_id, short_str.c_str()) ; } -#endif -#endif #endif return(0) ; } diff --git a/trick_source/sim_services/VariableServer/VariableServerSessionThread_loop.cpp b/trick_source/sim_services/VariableServer/VariableServerSessionThread_loop.cpp index 93064e56f..27eec934a 100644 --- a/trick_source/sim_services/VariableServer/VariableServerSessionThread_loop.cpp +++ b/trick_source/sim_services/VariableServer/VariableServerSessionThread_loop.cpp @@ -130,27 +130,19 @@ void * Trick::VariableServerSessionThread::thread_body() { exec_signal_terminate(); #ifdef __linux__ -#ifdef __GNUC__ -#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 2 - // for post gcc 4.1.2 or whatever glibc version is used in RHEL6 and above. } catch (abi::__forced_unwind&) { //pthread_exit and pthread_cancel will cause an abi::__forced_unwind to be thrown. Rethrow it. throw; -#endif -#endif #endif } catch (...) { #ifdef __linux__ -#ifdef __GNUC__ -#if (__GNUC__ == 4 && __GNUC_MINOR__ == 1) || __GNUC__ == 12 - // for gcc 4.1.2 or whatever glib version in RHEL 5 that does not work with the abi::__forced_unwind - // Also seems to have a problem with gcc 12 +#if __GNUC__ == 12 + // gcc 12 seems to have a problem with the abi::__forced_unwind catch above. throw; #else message_publish(MSG_ERROR, "\nVARIABLE SERVER caught unknown exception\n" ) ; exec_signal_terminate(); #endif -#endif #endif } diff --git a/trick_source/sim_services/VariableServer/var_server_ext.cpp b/trick_source/sim_services/VariableServer/var_server_ext.cpp index f05890a91..4bfc90c91 100644 --- a/trick_source/sim_services/VariableServer/var_server_ext.cpp +++ b/trick_source/sim_services/VariableServer/var_server_ext.cpp @@ -304,12 +304,8 @@ int var_set_client_tag( std::string text ) { vst->set_client_tag(text); #if __linux__ -#ifdef __GNUC__ -#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 2 std::string short_str = std::string("VS_") + text.substr(0,12) ; - pthread_setname_np(pthread_self(), short_str.c_str()) ; -#endif -#endif + pthread_setname_np(pthread_self(), short_str.c_str()); #endif } return(0) ;