File tree Expand file tree Collapse file tree 3 files changed +39
-15
lines changed Expand file tree Collapse file tree 3 files changed +39
-15
lines changed Original file line number Diff line number Diff line change 1
1
// Rust cycle collector. Temporary, but will probably stick around for some
2
2
// time until LLVM's GC infrastructure is more mature.
3
3
4
+ #include " rust_debug.h"
4
5
#include " rust_gc.h"
5
6
#include " rust_internal.h"
6
7
#include " rust_shape.h"
@@ -434,14 +435,8 @@ do_cc(rust_task *task) {
434
435
435
436
void
436
437
maybe_cc (rust_task *task) {
437
- // FIXME: We ought to lock this.
438
- static int zeal = -1 ;
439
- if (zeal == -1 ) {
440
- char *ev = getenv (" RUST_CC_ZEAL" );
441
- zeal = ev && ev[0 ] != ' \0 ' && ev[0 ] != ' 0' ;
442
- }
443
-
444
- if (zeal)
438
+ static debug::flag zeal (" RUST_CC_ZEAL" );
439
+ if (*zeal)
445
440
do_cc (task);
446
441
}
447
442
Original file line number Diff line number Diff line change
1
+ // Routines useful when debugging the Rust runtime.
2
+
3
+ #ifndef RUST_DEBUG_H
4
+ #define RUST_DEBUG_H
5
+
6
+ #include < cstdlib>
7
+
8
+ namespace debug {
9
+
10
+ class flag {
11
+ private:
12
+ const char *name;
13
+ bool valid;
14
+ bool value;
15
+
16
+ public:
17
+ flag (const char *in_name) : name(in_name), valid(false ) {}
18
+
19
+ bool operator *() {
20
+ // FIXME: We ought to lock this.
21
+ if (!valid) {
22
+ char *ev = getenv (name);
23
+ value = ev && ev[0 ] != ' \0 ' && ev[0 ] != ' 0' ;
24
+ valid = true ;
25
+ }
26
+ return value;
27
+ }
28
+ };
29
+
30
+ } // end namespace debug
31
+
32
+ #endif
33
+
Original file line number Diff line number Diff line change 7
7
#include < stdint.h>
8
8
9
9
#include " rust_abi.h"
10
+ #include " rust_debug.h"
10
11
#include " rust_gc.h"
11
12
#include " rust_internal.h"
12
13
#include " rust_shape.h"
@@ -180,14 +181,9 @@ maybe_gc(rust_task *task) {
180
181
if (*safe_point_data == NULL )
181
182
return ;
182
183
183
- // FIXME: We ought to lock this.
184
- static int zeal = -1 ;
185
- if (zeal == -1 ) {
186
- char *ev = getenv (" RUST_GC_ZEAL" );
187
- zeal = ev && ev[0 ] != ' \0 ' && ev[0 ] != ' 0' ;
188
- }
184
+ static debug::flag zeal (" RUST_GC_ZEAL" );
189
185
190
- if (zeal) {
186
+ if (* zeal) {
191
187
gc gc (task);
192
188
gc.run ();
193
189
}
You can’t perform that action at this time.
0 commit comments