コード例 #1
0
 def _more(self):
     chunk = rffi.cast(CLOSURES, alloc(CHUNK))
     count = CHUNK//rffi.sizeof(FFI_CLOSUREP.TO)
     for i in range(count):
         rffi.cast(rffi.VOIDPP, chunk)[0] = self.free_list
         self.free_list = rffi.cast(rffi.VOIDP, chunk)
         chunk = rffi.ptradd(chunk, 1)
コード例 #2
0
 def _more(self):
     chunk = rffi.cast(CLOSURES, alloc(CHUNK))
     count = CHUNK//rffi.sizeof(FFI_CLOSUREP.TO)
     for i in range(count):
         rffi.cast(rffi.VOIDPP, chunk)[0] = self.free_list
         self.free_list = rffi.cast(rffi.VOIDP, chunk)
         chunk = rffi.ptradd(chunk, 1)
コード例 #3
0
ファイル: test_rmmap.py プロジェクト: gorakhargosh/pypy
def test_alloc_free():
    map_size = 65536
    data = alloc(map_size)
    for i in range(0, map_size, 171):
        data[i] = chr(i & 0xff)
    for i in range(0, map_size, 171):
        assert data[i] == chr(i & 0xff)
    free(data, map_size)
コード例 #4
0
def test_alloc_free():
    map_size = 65536
    data = alloc(map_size)
    for i in range(0, map_size, 171):
        data[i] = chr(i & 0xff)
    for i in range(0, map_size, 171):
        assert data[i] == chr(i & 0xff)
    free(data, map_size)
コード例 #5
0
ファイル: detect_sse2.py プロジェクト: Debug-Orz/Sypy
def detect_sse2():
    data = alloc(4096)
    pos = 0
    for c in ("\xB8\x01\x00\x00\x00"     # MOV EAX, 1
              "\x53"                     # PUSH EBX
              "\x0F\xA2"                 # CPUID
              "\x5B"                     # POP EBX
              "\x92"                     # XCHG EAX, EDX
              "\xC3"):                   # RET
        data[pos] = c
        pos += 1
    fnptr = rffi.cast(lltype.Ptr(lltype.FuncType([], lltype.Signed)), data)
    code = fnptr()
    free(data, 4096)
    return bool(code & (1<<25)) and bool(code & (1<<26))
コード例 #6
0
ファイル: detect_sse2.py プロジェクト: xx312022850/pypy
def detect_sse2():
    data = alloc(4096)
    pos = 0
    for c in ("\xB8\x01\x00\x00\x00"  # MOV EAX, 1
              "\x53"  # PUSH EBX
              "\x0F\xA2"  # CPUID
              "\x5B"  # POP EBX
              "\x92"  # XCHG EAX, EDX
              "\xC3"):  # RET
        data[pos] = c
        pos += 1
    fnptr = rffi.cast(lltype.Ptr(lltype.FuncType([], lltype.Signed)), data)
    code = fnptr()
    free(data, 4096)
    return bool(code & (1 << 25)) and bool(code & (1 << 26))
コード例 #7
0
ファイル: asmmemmgr.py プロジェクト: purepython/pypy
 def _allocate_large_block(self, minsize):
     # Compute 'size' from 'minsize': it must be rounded up to
     # 'large_alloc_size'.  Additionally, we use the following line
     # to limit how many mmap() requests the OS will see in total:
     minsize = max(minsize, intmask(self.total_memory_allocated >> 4))
     size = minsize + self.large_alloc_size - 1
     size = (size // self.large_alloc_size) * self.large_alloc_size
     data = rmmap.alloc(size)
     if not we_are_translated():
         if self._allocated is None:
             self._allocated = []
         self._allocated.append((data, size))
         if sys.maxint > 2147483647:
             # Hack to make sure that mcs are not within 32-bits of one
             # another for testing purposes
             rmmap.hint.pos += 0x80000000 - size
     self.total_memory_allocated += r_uint(size)
     data = rffi.cast(lltype.Signed, data)
     return self._add_free_block(data, data + size)
コード例 #8
0
ファイル: asmmemmgr.py プロジェクト: Debug-Orz/Sypy
 def _allocate_large_block(self, minsize):
     # Compute 'size' from 'minsize': it must be rounded up to
     # 'large_alloc_size'.  Additionally, we use the following line
     # to limit how many mmap() requests the OS will see in total:
     minsize = max(minsize, intmask(self.total_memory_allocated >> 4))
     size = minsize + self.large_alloc_size - 1
     size = (size // self.large_alloc_size) * self.large_alloc_size
     data = rmmap.alloc(size)
     if not we_are_translated():
         if self._allocated is None:
             self._allocated = []
         self._allocated.append((data, size))
         if sys.maxint > 2147483647:
             # Hack to make sure that mcs are not within 32-bits of one
             # another for testing purposes
             rmmap.hint.pos += 0x80000000 - size
     self.total_memory_allocated += r_uint(size)
     data = rffi.cast(lltype.Signed, data)
     return self._add_free_block(data, data + size)
コード例 #9
0
ファイル: codebuf.py プロジェクト: enyst/plexnet
 def __init__(self, map_size):
     data = alloc(map_size)
     self._init(data, map_size)
コード例 #10
0
 def entry_point(argv):
     one = alloc(1024)
     free(one, 1024)
     return 0
コード例 #11
0
ファイル: test_sandbox.py プロジェクト: nipengadmaster/pypy
 def entry_point(argv):
     one = alloc(1024)
     free(one, 1024)
     return 0
コード例 #12
0
ファイル: codebuf.py プロジェクト: neurobcn/plexnet
 def __init__(self, map_size):
     data = alloc(map_size)
     self._init(data, map_size)