Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
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))
Exemplo n.º 4
0
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))
Exemplo n.º 5
0
 def _delete(self):
     "NOT_RPYTHON"
     if self._allocated:
         for data, size in self._allocated:
             rmmap.free(data, size)
     self._allocated = None
Exemplo n.º 6
0
 def __del__(self):
     size = self._size
     assert size >= 0
     free(self._data, size)
Exemplo n.º 7
0
 def entry_point(argv):
     one = alloc(1024)
     free(one, 1024)
     return 0
Exemplo n.º 8
0
 def entry_point(argv):
     one = alloc(1024)
     free(one, 1024)
     return 0
Exemplo n.º 9
0
 def _delete(self):
     "NOT_RPYTHON"
     if self._allocated:
         for data, size in self._allocated:
             rmmap.free(data, size)
     self._allocated = None
Exemplo n.º 10
0
 def __del__(self):
     size = self._size
     assert size >= 0
     free(self._data, size)