def test_threadlocalref_get(self): tlfield = rthread.ThreadLocalField(lltype.Signed, 'foobar_test_') def f(): tlfield.setraw(0x544c) return tlfield.getraw() res = self.interp_operations(f, []) assert res == 0x544c
def test_threadlocalref_get_char(self): tlfield = rthread.ThreadLocalField(lltype.Char, 'foobar_test_char_') def f(): tlfield.setraw('\x92') return ord(tlfield.getraw()) res = self.interp_operations(f, []) assert res == 0x92
def _freeze_(self): return True # --- copy a few declarations from src/vmprof_stack.h --- VMPROF_CODE_TAG = 1 VMPROFSTACK = lltype.ForwardReference() PVMPROFSTACK = lltype.Ptr(VMPROFSTACK) VMPROFSTACK.become( rffi.CStruct("vmprof_stack_s", ('next', PVMPROFSTACK), ('value', lltype.Signed), ('kind', lltype.Signed))) # ---------- vmprof_tl_stack = rthread.ThreadLocalField(PVMPROFSTACK, "vmprof_tl_stack") do_use_eci = rffi.llexternal_use_eci( ExternalCompilationInfo(includes=['vmprof_stack.h'], include_dirs=[SRC])) def enter_code(unique_id): do_use_eci() s = lltype.malloc(VMPROFSTACK, flavor='raw') s.c_next = vmprof_tl_stack.get_or_make_raw() s.c_value = unique_id s.c_kind = VMPROF_CODE_TAG vmprof_tl_stack.setraw(s) return s def leave_code(s):