From f3a6ea26437e240b02d749331b3a2d60aab0588b Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 3 May 2013 15:12:04 -0400 Subject: [PATCH] lang: um, actually set locking bits! this code got lost. --- src/libcore/unstable/lang.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libcore/unstable/lang.rs b/src/libcore/unstable/lang.rs index 27fc3287bdb3..01ab2345918b 100644 --- a/src/libcore/unstable/lang.rs +++ b/src/libcore/unstable/lang.rs @@ -235,6 +235,8 @@ pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint { fail_borrowed(a, file, line); } + (*a).header.ref_count = ref_count | FROZEN_BIT; + ref_count } @@ -251,6 +253,9 @@ pub unsafe fn borrow_as_mut(a: *u8, file: *c_char, line: size_t) -> uint { if (ref_count & (MUT_BIT|FROZEN_BIT)) != 0 { fail_borrowed(a, file, line); } + + (*a).header.ref_count = ref_count | MUT_BIT | FROZEN_BIT; + ref_count } @@ -349,7 +354,12 @@ pub unsafe fn check_not_borrowed(a: *u8, file: *c_char, line: size_t) { let a: *mut BoxRepr = transmute(a); - if ((*a).header.ref_count & FROZEN_BIT) != 0 { + let ref_count = (*a).header.ref_count; + debug_ptr("check_not_borrowed (ptr) : ", a); + debug_ptr(" (line): ", line as *()); + debug_ptr(" (rc) : ", ref_count as *()); + + if (ref_count & FROZEN_BIT) != 0 { fail_borrowed(a, file, line); } }