From 21e0511c607734773af842b7059adaaeabf4bdad Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 31 Aug 2017 09:35:41 -0500 Subject: [PATCH] Update tapset/python2.stp for RHEL6-era systems. * tapset/python2.stp (Py2Long_AsLongLongAndOverflow_Small): Don't bother trying to see if the Py2LongObject is defined, go ahead and use it. The check to see if it is defined seems to fail. (Py2Long_AsLongLongAndOverflow_Big): Ditto. --- tapset/python2.stp | 183 +++++++++++++++++++++------------------------ 1 file changed, 84 insertions(+), 99 deletions(-) diff --git a/tapset/python2.stp b/tapset/python2.stp index d466ac29b..70ebce139 100644 --- a/tapset/python2.stp +++ b/tapset/python2.stp @@ -279,131 +279,116 @@ private function Py2Int_AsLong:long(op:long) private function Py2Long_AsLongLongAndOverflow_Small:long(v:long) { - if (@defined(@Py2LongObject(0))) { - res = -1 - i = @Py2_SIZE(v) - if (i == -1) { - /* We're using 'x & 0xffff' instead of '(short)x' */ - res = -(@Py2LongObject(v)->ob_digit[0] & 0xffff) + res = -1 + i = @Py2_SIZE(v) + if (i == -1) { + /* We're using 'x & 0xffff' instead of '(short)x' */ + res = -(@Py2LongObject(v)->ob_digit[0] & 0xffff) + } + else if (i == 0) { + res = 0 + } + else if (i == 1) { + res = @Py2LongObject(v)->ob_digit[0] + } + else { + sign = 1 + x = 0 + if (i < 0) { + sign = -1 + i = -(i) + } + while (--i >= 0) { + prev = x + x = ((x << %{ Py2Long_SHIFT_SMALL %}) + | @Py2LongObject(v)->ob_digit[i]) + if ((x >> %{ Py2Long_SHIFT_SMALL %}) != prev) { + error("Python int too large") + return res + } } - else if (i == 0) { - res = 0 + /* Haven't lost any bits, but casting to long requires extra + * care (see comment above). + */ + if (x <= %{ __LONG_LONG_MAX__ %}) { + res = x * sign } - else if (i == 1) { - res = @Py2LongObject(v)->ob_digit[0] + else if (sign < 0 && x == %{ PY2_ABS_LLONG_MIN %}) { + res = %{ PY2_LLONG_MIN %} } else { - sign = 1 - x = 0 - if (i < 0) { - sign = -1 - i = -(i) - } - while (--i >= 0) { - prev = x - x = ((x << %{ Py2Long_SHIFT_SMALL %}) - | @Py2LongObject(v)->ob_digit[i]) - if ((x >> %{ Py2Long_SHIFT_SMALL %}) != prev) { - error("Python int too large") - return res - } - } - /* Haven't lost any bits, but casting to long requires extra - * care (see comment above). - */ - if (x <= %{ __LONG_LONG_MAX__ %}) { - res = x * sign - } - else if (sign < 0 && x == %{ PY2_ABS_LLONG_MIN %}) { - res = %{ PY2_LLONG_MIN %} - } - else { - error("Python int too large") - /* res is already set to -1 */ - } + error("Python int too large") + /* res is already set to -1 */ } - return res - } - else { - error("Py2Long_AsLongLongAndOverflow_Small isn't implemented") } + return res } private function Py2Long_AsLongLongAndOverflow_Big:long(v:long) { - if (@defined(@Py2LongObject(0))) { - res = -1 - i = @Py2_SIZE(v) - if (i == -1) { - /* We're using 'x & 0xffffffff' instead of '(int32_t)x' */ - res = -(@Py2LongObject(v)->ob_digit[0] & 0xffffffff) + res = -1 + i = @Py2_SIZE(v) + if (i == -1) { + /* We're using 'x & 0xffffffff' instead of '(int32_t)x' */ + res = -(@Py2LongObject(v)->ob_digit[0] & 0xffffffff) + } + else if (i == 0) { + res = 0 + } + else if (i == 1) { + res = @Py2LongObject(v)->ob_digit[0] + } + else { + sign = 1 + x = 0 + if (i < 0) { + sign = -1 + i = -(i) } - else if (i == 0) { - res = 0 + while (--i >= 0) { + prev = x + x = ((x << %{ Py2Long_SHIFT_BIG %}) + | @Py2LongObject(v)->ob_digit[i]) + if ((x >> %{ Py2Long_SHIFT_BIG %}) != prev) { + error("Python int too large") + return res + } + } + /* Haven't lost any bits, but casting to long requires extra + * care (see comment above). + */ + if (x <= %{ __LONG_LONG_MAX__ %}) { + res = x * sign } - else if (i == 1) { - res = @Py2LongObject(v)->ob_digit[0] + else if (sign < 0 && x == %{ PY2_ABS_LLONG_MIN %}) { + res = %{ PY2_LLONG_MIN %} } else { - sign = 1 - x = 0 - if (i < 0) { - sign = -1 - i = -(i) - } - while (--i >= 0) { - prev = x - x = ((x << %{ Py2Long_SHIFT_BIG %}) - | @Py2LongObject(v)->ob_digit[i]) - if ((x >> %{ Py2Long_SHIFT_BIG %}) != prev) { - error("Python int too large") - return res - } - } - /* Haven't lost any bits, but casting to long requires extra - * care (see comment above). - */ - if (x <= %{ __LONG_LONG_MAX__ %}) { - res = x * sign - } - else if (sign < 0 && x == %{ PY2_ABS_LLONG_MIN %}) { - res = %{ PY2_LLONG_MIN %} - } - else { - error("Python int too large") - /* res is already set to -1 */ - } + error("Python int too large") + /* res is already set to -1 */ } - return res - } - else { - error("Py2Long_AsLongLongAndOverflow_Big isn't implemented") } + return res } private function Py2Long_AsLongLong:long(v:long) { - if (@defined(@Py2LongObject(0))) { - if (! @Py2Long_Check(v)) { - error(sprintf("Py2Long_AsLong called on %s object at %p", - python2_get_typename(v), @__pointer(v))) - return -1 - } + if (! @Py2Long_Check(v)) { + error(sprintf("Py2Long_AsLong called on %s object at %p", + python2_get_typename(v), @__pointer(v))) + return -1 + } %( CONFIG_64BIT == "y" %? %( CONFIG_COMPAT == "y" %? - if (@__compat_task) { - return Py2Long_AsLongLongAndOverflow_Small(v) - } + if (@__compat_task) { + return Py2Long_AsLongLongAndOverflow_Small(v) + } %) - return Py2Long_AsLongLongAndOverflow_Big(v) + return Py2Long_AsLongLongAndOverflow_Big(v) %: - return Py2Long_AsLongLongAndOverflow_Small(v) + return Py2Long_AsLongLongAndOverflow_Small(v) %) - } - else { - error("Py2Long_AsLongLong isn't implemented") - } } # -- 2.43.5