def test_struct_fields_longlong(self): POINT = lltype.Struct('POINT', ('x', rffi.LONGLONG), ('y', rffi.ULONGLONG)) y_ofs = 8 p = lltype.malloc(POINT, flavor='raw') p.x = r_longlong(123) p.y = r_ulonglong(456) addr = rffi.cast(rffi.VOIDP, p) assert struct_getfield_longlong(types.slonglong, addr, 0) == 123 assert struct_getfield_longlong(types.ulonglong, addr, y_ofs) == 456 # v = rffi.cast(lltype.SignedLongLong, r_ulonglong(9223372036854775808)) struct_setfield_longlong(types.slonglong, addr, 0, v) struct_setfield_longlong(types.ulonglong, addr, y_ofs, r_longlong(-1)) assert p.x == -9223372036854775808 assert rffi.cast(lltype.UnsignedLongLong, p.y) == 18446744073709551615 # lltype.free(p, flavor='raw')
def test_struct_fields_longlong(self): POINT = lltype.Struct('POINT', ('x', rffi.LONGLONG), ('y', rffi.ULONGLONG) ) y_ofs = 8 p = lltype.malloc(POINT, flavor='raw') p.x = r_longlong(123) p.y = r_ulonglong(456) addr = rffi.cast(rffi.VOIDP, p) assert struct_getfield_longlong(types.slonglong, addr, 0) == 123 assert struct_getfield_longlong(types.ulonglong, addr, y_ofs) == 456 # v = rffi.cast(lltype.SignedLongLong, r_ulonglong(9223372036854775808)) struct_setfield_longlong(types.slonglong, addr, 0, v) struct_setfield_longlong(types.ulonglong, addr, y_ofs, r_longlong(-1)) assert p.x == -9223372036854775808 assert rffi.cast(lltype.UnsignedLongLong, p.y) == 18446744073709551615 # lltype.free(p, flavor='raw')
def get_ulonglong(self, w_ffitype): longlongval = libffi.struct_getfield_longlong(libffi.types.ulonglong, self.rawmem, self.offset) return r_ulonglong(longlongval)
def get_longlong(self, w_ffitype): return libffi.struct_getfield_longlong(libffi.types.slonglong, self.rawmem, self.offset)