示例#1
0
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):
示例#2
0
文件: primitive.py 项目: sbw111/lab4
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
示例#3
0
def test_memory_alignment():
    a = rffi_platform.memory_alignment()
    print a
    assert a % struct.calcsize("P") == 0
示例#4
0
def test_memory_alignment():
    a = rffi_platform.memory_alignment()
    print a
    assert a % struct.calcsize("P") == 0
示例#5
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