Skip to content

Commit f3a6ea2

Browse files
committed
lang: um, actually set locking bits! this code got lost.
1 parent e7d9693 commit f3a6ea2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/libcore/unstable/lang.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint {
235235
fail_borrowed(a, file, line);
236236
}
237237

238+
(*a).header.ref_count = ref_count | FROZEN_BIT;
239+
238240
ref_count
239241
}
240242

@@ -251,6 +253,9 @@ pub unsafe fn borrow_as_mut(a: *u8, file: *c_char, line: size_t) -> uint {
251253
if (ref_count & (MUT_BIT|FROZEN_BIT)) != 0 {
252254
fail_borrowed(a, file, line);
253255
}
256+
257+
(*a).header.ref_count = ref_count | MUT_BIT | FROZEN_BIT;
258+
254259
ref_count
255260
}
256261

@@ -349,7 +354,12 @@ pub unsafe fn check_not_borrowed(a: *u8,
349354
file: *c_char,
350355
line: size_t) {
351356
let a: *mut BoxRepr = transmute(a);
352-
if ((*a).header.ref_count & FROZEN_BIT) != 0 {
357+
let ref_count = (*a).header.ref_count;
358+
debug_ptr("check_not_borrowed (ptr) : ", a);
359+
debug_ptr(" (line): ", line as *());
360+
debug_ptr(" (rc) : ", ref_count as *());
361+
362+
if (ref_count & FROZEN_BIT) != 0 {
353363
fail_borrowed(a, file, line);
354364
}
355365
}

0 commit comments

Comments
 (0)