# Author: Florin Papa diff -r e48ec5f5b82b Modules/mathmodule.c --- a/Modules/mathmodule.c Mon Sep 28 15:04:11 2015 +0200 +++ b/Modules/mathmodule.c Tue Sep 29 16:31:43 2015 +0300 @@ -863,7 +863,7 @@ OverflowError. */ -static PyObject * +__attribute__((bnd_legacy)) static PyObject * math_1(PyObject *arg, double (*func) (double), int can_overflow) { return math_1_to_whatever(arg, func, PyFloat_FromDouble, can_overflow); @@ -875,7 +875,7 @@ return math_1_to_whatever(arg, func, PyLong_FromDouble, can_overflow); } -static PyObject * +__attribute__((bnd_legacy)) static PyObject * math_2(PyObject *args, double (*func) (double, double), char *funcname) { PyObject *ox, *oy; diff -r e48ec5f5b82b configure --- a/configure Mon Sep 28 15:04:11 2015 +0200 +++ b/configure Tue Sep 29 16:31:43 2015 +0300 @@ -806,6 +806,7 @@ enable_shared enable_profiling with_pydebug +with_mpx with_hash_algorithm with_address_sanitizer with_libs @@ -1485,6 +1486,8 @@ compiler --with-suffix=.exe set executable suffix --with-pydebug build with Py_DEBUG defined + --with-mpx Enable Intel MPX (Memory Protection Extensions) + feature. Disabled by default. --with-hash-algorithm=[fnv|siphash24] select hash algorithm --with-address-sanitizer @@ -6437,6 +6440,47 @@ fi +# Check for --with-mpx +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-mpx" >&5 +$as_echo_n "checking for --with-mpx... " >&6; } + +# Check whether --with-mpx was given. +if test "${with_mpx+set}" = set; then : + withval=$with_mpx; +if test "$withval" != no +then + mpx_compatible=false + if [ "$CC" = "gcc" ] + then + CC_MAJOR_VERSION=$(gcc -dumpversion | cut -f1 -d.) + CC_MINOR_VERSION=$(gcc -dumpversion | cut -f2 -d.) + if [ "$CC_MAJOR_VERSION" -ge "5" ] + then + mpx_compatible=true + if [ "$CC_MAJOR_VERSION" -eq "5" ] && [ "$CC_MINOR_VERSION" -lt "1" ] + then + mpx_compatible=false + fi + fi + fi + + if [ "$mpx_compatible" = "false" ] + then + as_fn_error $? "MPX feature can only be used with gcc 5.1 and higher" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; + CC="$CC -fcheck-pointer-bounds -mmpx" + fi +else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + # Enable PGO flags. # Extract the first word of "llvm-profdata", so it can be a program name with args. set dummy llvm-profdata; ac_word=$2 diff -r e48ec5f5b82b configure.ac --- a/configure.ac Mon Sep 28 15:04:11 2015 +0200 +++ b/configure.ac Tue Sep 29 16:31:43 2015 +0300 @@ -1218,6 +1218,40 @@ fi], [AC_MSG_RESULT(no)]) +# Check for --with-mpx +AC_MSG_CHECKING(for --with-mpx) +AC_ARG_WITH(mpx, + AS_HELP_STRING([--with-mpx], [Enable Intel MPX (Memory Protection Extensions) + feature. Disabled by default.]), +[ +if test "$withval" != no +then + mpx_compatible=false + if [[ "$CC" = "gcc" ]] + then + CC_MAJOR_VERSION=$(gcc -dumpversion | cut -f1 -d.) + CC_MINOR_VERSION=$(gcc -dumpversion | cut -f2 -d.) + if [[ "$CC_MAJOR_VERSION" -ge "5" ]] + then + mpx_compatible=true + if [[ "$CC_MAJOR_VERSION" -eq "5" ]] && [[ "$CC_MINOR_VERSION" -lt "1" ]] + then + mpx_compatible=false + fi + fi + fi + + if [[ "$mpx_compatible" = "false" ]] + then + AC_MSG_ERROR([MPX feature can only be used with gcc 5.1 and higher]) + else + AC_MSG_RESULT(yes); + CC="$CC -fcheck-pointer-bounds -mmpx" + fi +else AC_MSG_RESULT(no) +fi], +[AC_MSG_RESULT(no)]) + # Enable PGO flags. AC_SUBST(PGO_PROF_GEN_FLAG) AC_SUBST(PGO_PROF_USE_FLAG)