Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r46977:f42981403e3e Date: 2011-09-01 11:39 +0200 http://bitbucket.org/pypy/pypy/changeset/f42981403e3e/
Log: Translation fix for jit/backend/x86: give these global constants the type 'int', and only cast them as needed to USHORT. Avoids surprizes. diff --git a/pypy/rlib/clibffi.py b/pypy/rlib/clibffi.py --- a/pypy/rlib/clibffi.py +++ b/pypy/rlib/clibffi.py @@ -286,10 +286,10 @@ FFI_OK = cConfig.FFI_OK FFI_BAD_TYPEDEF = cConfig.FFI_BAD_TYPEDEF -FFI_DEFAULT_ABI = rffi.cast(rffi.USHORT, cConfig.FFI_DEFAULT_ABI) +FFI_DEFAULT_ABI = cConfig.FFI_DEFAULT_ABI if _WIN32: - FFI_STDCALL = rffi.cast(rffi.USHORT, cConfig.FFI_STDCALL) -FFI_TYPE_STRUCT = rffi.cast(rffi.USHORT, cConfig.FFI_TYPE_STRUCT) + FFI_STDCALL = cConfig.FFI_STDCALL +FFI_TYPE_STRUCT = cConfig.FFI_TYPE_STRUCT FFI_CIFP = rffi.COpaquePtr('ffi_cif', compilation_info=eci) FFI_CLOSUREP = lltype.Ptr(cConfig.ffi_closure) @@ -319,7 +319,7 @@ which the 'ffistruct' member is a regular FFI_TYPE. """ tpe = lltype.malloc(FFI_STRUCT_P.TO, len(field_types)+1, flavor='raw') - tpe.ffistruct.c_type = FFI_TYPE_STRUCT + tpe.ffistruct.c_type = rffi.cast(rffi.USHORT, FFI_TYPE_STRUCT) tpe.ffistruct.c_size = rffi.cast(rffi.SIZE_T, size) tpe.ffistruct.c_alignment = rffi.cast(rffi.USHORT, aligment) tpe.ffistruct.c_elements = rffi.cast(FFI_TYPE_PP, @@ -438,13 +438,14 @@ if _MSVC: # This little trick works correctly with MSVC. # It returns small structures in registers - if r_uint(restype.c_type) == FFI_TYPE_STRUCT: + if intmask(restype.c_type) == FFI_TYPE_STRUCT: if restype.c_size <= 4: restype = ffi_type_sint32 elif restype.c_size <= 8: restype = ffi_type_sint64 - res = c_ffi_prep_cif(self.ll_cif, get_call_conv(flags, False), + res = c_ffi_prep_cif(self.ll_cif, + rffi.cast(rffi.USHORT, get_call_conv(flags,False)), rffi.cast(rffi.UINT, argnum), restype, self.ll_argtypes) if not res == FFI_OK: diff --git a/pypy/rlib/libffi.py b/pypy/rlib/libffi.py --- a/pypy/rlib/libffi.py +++ b/pypy/rlib/libffi.py @@ -75,7 +75,7 @@ @staticmethod @jit.elidable def is_struct(ffi_type): - return intmask(ffi_type.c_type) == intmask(FFI_TYPE_STRUCT) + return intmask(ffi_type.c_type) == FFI_TYPE_STRUCT types._import() _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit