File tree Expand file tree Collapse file tree 2 files changed +7
-55
lines changed
branches/incoming/src/libcore Expand file tree Collapse file tree 2 files changed +7
-55
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9
- refs/heads/incoming: ce773352d06f490fb1bfb5057035e93effcf5781
9
+ refs/heads/incoming: 24c89693f0556ba4b455df358a9136f7873776bf
10
10
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
11
11
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
12
12
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change 1
1
use libc:: { c_char, c_void, intptr_t, uintptr_t} ;
2
2
use ptr:: { mut_null, null, to_unsafe_ptr} ;
3
3
use repr:: BoxRepr ;
4
- use rt:: rt_free;
5
4
use sys:: TypeDesc ;
6
5
use unsafe:: transmute;
7
6
@@ -67,7 +66,12 @@ struct Task {
67
66
* This runs at task death to free all boxes.
68
67
*/
69
68
70
- unsafe fn do_annihilate ( ) {
69
+ /// Destroys all managed memory (i.e. @ boxes) held by the current task.
70
+ #[ cfg( notest) ]
71
+ #[ lang="annihilate" ]
72
+ pub unsafe fn annihilate ( ) {
73
+ use rt:: rt_free;
74
+
71
75
let task: * Task = transmute ( rustrt:: rust_get_task ( ) ) ;
72
76
73
77
// Pass 1: Make all boxes immortal.
@@ -105,61 +109,9 @@ unsafe fn do_annihilate() {
105
109
}
106
110
}
107
111
108
- /// Destroys all managed memory (i.e. @ boxes) held by the current task.
109
- #[ cfg( notest) ]
110
- #[ lang="annihilate" ]
111
- pub unsafe fn annihilate ( ) {
112
- do_annihilate ( ) ;
113
- }
114
-
115
- #[ cfg( test) ]
116
- pub unsafe fn annihilate ( ) {
117
- do_annihilate ( ) ;
118
- }
119
-
120
112
/// Bindings to the runtime
121
113
extern mod rustrt {
122
114
#[ rust_stack]
123
115
/*priv*/ fn rust_get_task ( ) -> * c_void ;
124
116
}
125
117
126
- /*
127
- * Tests
128
- */
129
-
130
- #[ cfg( test) ]
131
- mod tests {
132
- struct Knot {
133
- mut a: Option < @Knot >
134
- }
135
-
136
- struct Blah {
137
- x : int ,
138
- drop { io : : println ( "Blah!" ) ; }
139
- }
140
-
141
- #[ test]
142
- fn test_box_annihilation ( ) {
143
- let knot = @Knot { a : None } ;
144
- knot. a = Some ( knot) ;
145
-
146
- let x = @~"foo";
147
-
148
- let blah = @Blah { x : 3 } ;
149
-
150
- let f_ref = @mut None ;
151
- let f = || { util:: ignore ( f_ref) ; } ;
152
- * f_ref = Some ( f) ;
153
-
154
- unsafe { annihilate ( ) ; }
155
-
156
- unsafe {
157
- unsafe :: forget ( knot) ;
158
- unsafe :: forget ( x) ;
159
- unsafe :: forget ( blah) ;
160
- unsafe :: forget ( f_ref) ;
161
- unsafe :: forget ( f) ;
162
- }
163
- }
164
- }
165
-
You can’t perform that action at this time.
0 commit comments