Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r57174:096738ec54d5 Date: 2012-09-06 13:30 +0200 http://bitbucket.org/pypy/pypy/changeset/096738ec54d5/
Log: Add a test for int128 in the C backend. diff --git a/pypy/rlib/rbigint.py b/pypy/rlib/rbigint.py --- a/pypy/rlib/rbigint.py +++ b/pypy/rlib/rbigint.py @@ -7,12 +7,10 @@ from pypy.rlib import jit from pypy.rpython.lltypesystem import lltype, rffi from pypy.rpython import extregistry -from pypy.rpython.tool import rffi_platform -from pypy.translator.tool.cbuild import ExternalCompilationInfo import math, sys -SUPPORT_INT128 = rffi_platform.has('__int128_t', '') +SUPPORT_INT128 = hasattr(rffi, '__INT128_T') # note about digit sizes: # In division, the native integer type must be able to hold diff --git a/pypy/translator/c/primitive.py b/pypy/translator/c/primitive.py --- a/pypy/translator/c/primitive.py +++ b/pypy/translator/c/primitive.py @@ -12,8 +12,7 @@ from pypy.rpython.lltypesystem.llarena import RoundedUpForAllocation from pypy.translator.c.support import cdecl, barebonearray -from pypy.rpython.tool import rffi_platform -SUPPORT_INT128 = rffi_platform.has('__int128_t', '') +SUPPORT_INT128 = hasattr(rffi, '__INT128_T') # ____________________________________________________________ # diff --git a/pypy/translator/c/test/test_typed.py b/pypy/translator/c/test/test_typed.py --- a/pypy/translator/c/test/test_typed.py +++ b/pypy/translator/c/test/test_typed.py @@ -896,6 +896,21 @@ res = f(-2000000000) assert res == -200000000000000 + def test_int128(self): + from pypy.rpython.lltypesystem import rffi + if not hasattr(rffi, '__INT128_T'): + py.test.skip("no '__int128_t'") + def func(n): + x = rffi.cast(getattr(rffi, '__INT128_T'), n) + x *= x + x *= x + x *= x + x *= x + return intmask(x >> 96) + f = self.getcompiled(func, [int]) + res = f(217) + assert res == 305123851 + def test_bool_2(self): from pypy.rpython.lltypesystem import lltype, rffi def func(n): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit