# Author: Florin Papa diff -r ea91991c7db5 Modules/mathmodule.c --- a/Modules/mathmodule.c Mon Sep 28 15:37:57 2015 +0300 +++ b/Modules/mathmodule.c Thu Oct 01 14:14:16 2015 +0300 @@ -679,7 +679,7 @@ care about right now. */ -static PyObject * +__attribute__((bnd_legacy)) static PyObject * math_1(PyObject *arg, double (*func) (double), int can_overflow) { double x, r; @@ -755,7 +755,7 @@ OverflowError. */ -static PyObject * +__attribute__((bnd_legacy)) static PyObject * math_2(PyObject *args, double (*func) (double, double), char *funcname) { PyObject *ox, *oy; @@ -1272,7 +1272,7 @@ However, intermediate overflow is possible for a long if the number of bits in that long is larger than PY_SSIZE_T_MAX. */ -static PyObject* +__attribute__((bnd_legacy)) static PyObject* loghelper(PyObject* arg, double (*func)(double), char *funcname) { /* If it is long, do it ourselves. */ @@ -1310,7 +1310,7 @@ return math_1(arg, func, 0); } -static PyObject * +__attribute__((bnd_legacy)) static PyObject * math_log(PyObject *self, PyObject *args) { PyObject *arg; @@ -1342,7 +1342,7 @@ Return the logarithm of x to the given base.\n\ If the base not specified, returns the natural logarithm (base e) of x."); -static PyObject * +__attribute__((bnd_legacy)) static PyObject * math_log10(PyObject *self, PyObject *arg) { return loghelper(arg, m_log10, "log10"); diff -r ea91991c7db5 configure --- a/configure Mon Sep 28 15:37:57 2015 +0300 +++ b/configure Thu Oct 01 14:14:16 2015 +0300 @@ -794,6 +794,7 @@ enable_shared enable_profiling with_pydebug +with_mpx enable_toolbox_glue with_libs with_system_expat @@ -1474,6 +1475,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-libs='lib1 ...' link against additional libs --with-system-expat build pyexpat module using an installed expat library @@ -5935,6 +5938,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 + + # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be # merged with this chunk of code? diff -r ea91991c7db5 configure.ac --- a/configure.ac Mon Sep 28 15:37:57 2015 +0300 +++ b/configure.ac Thu Oct 01 14:14:16 2015 +0300 @@ -1034,6 +1034,41 @@ 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)]) + # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be # merged with this chunk of code?