from rpython.rlib.rarithmetic import r_longlong, is_emulated_long from rpython.rlib.rfloat import isinf, isnan from rpython.rtyper.lltypesystem import rffi, llgroup from rpython.rtyper.lltypesystem.llmemory import (Address, AddressOffset, ItemOffset, ArrayItemsOffset, FieldOffset, CompositeOffset, ArrayLengthOffset, GCHeaderOffset, GCREF, AddressAsInt) from rpython.rtyper.lltypesystem.lltype import (Signed, SignedLongLong, Unsigned, UnsignedLongLong, Float, SingleFloat, LongFloat, Char, UniChar, Bool, Void, FixedSizeArray, Ptr, cast_opaque_ptr, typeOf) from rpython.rtyper.lltypesystem.llarena import RoundedUpForAllocation from rpython.rtyper.tool.rffi_platform import memory_alignment from rpython.translator.c.support import cdecl, barebonearray SUPPORT_INT128 = hasattr(rffi, '__INT128_T') MEMORY_ALIGNMENT = memory_alignment() # ____________________________________________________________ # # Primitives # win64: we need different constants, since we emulate 64 bit long. # this function simply replaces 'L' by 'LL' in a format string if is_emulated_long: def lll(fmt): return fmt.replace('L', 'LL') else: def lll(fmt): return fmt def name_signed(value, db):
from rpython.rlib.rarithmetic import r_longlong, is_emulated_long from rpython.rlib.rfloat import isinf, isnan from rpython.rtyper.lltypesystem import rffi, llgroup from rpython.rtyper.lltypesystem.llmemory import ( Address, AddressOffset, ItemOffset, ArrayItemsOffset, FieldOffset, CompositeOffset, ArrayLengthOffset, GCHeaderOffset, GCREF, AddressAsInt) from rpython.rtyper.lltypesystem.lltype import ( Signed, SignedLongLong, Unsigned, UnsignedLongLong, Float, SingleFloat, LongFloat, Char, UniChar, Bool, Void, FixedSizeArray, Ptr, cast_opaque_ptr, typeOf, _uninitialized) from rpython.rtyper.lltypesystem.llarena import RoundedUpForAllocation from rpython.rtyper.tool.rffi_platform import memory_alignment from rpython.translator.c.support import cdecl, barebonearray SUPPORT_INT128 = hasattr(rffi, '__INT128_T') MEMORY_ALIGNMENT = memory_alignment() # ____________________________________________________________ # # Primitives # win64: we need different constants, since we emulate 64 bit long. # this function simply replaces 'L' by 'LL' in a format string if is_emulated_long: def lll(fmt): return fmt.replace('L', 'LL') else: def lll(fmt): return fmt
def test_memory_alignment(): a = rffi_platform.memory_alignment() print a assert a % struct.calcsize("P") == 0
def test_object_alignment(self): res = self.run('object_alignment') from rpython.rtyper.tool import rffi_platform expected_alignment = rffi_platform.memory_alignment() assert (res & (expected_alignment - 1)) == 0