diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-09-23 11:02:04 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-09-23 11:04:14 -0700 |
| commit | dbdeff659fb30fd845490cf215b5733e1e064d46 (patch) | |
| tree | 69d321dad8396d8f2ca5d61255253d30e50249b7 /src/rt/rust_debug.h | |
| parent | f8007b5535938be4f8b774177bc96dda2e9f5a71 (diff) | |
| download | rust-dbdeff659fb30fd845490cf215b5733e1e064d46.tar.gz rust-dbdeff659fb30fd845490cf215b5733e1e064d46.zip | |
rt: Factor out the logic that handles the various magic debug environment variables
Diffstat (limited to 'src/rt/rust_debug.h')
| -rw-r--r-- | src/rt/rust_debug.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/rt/rust_debug.h b/src/rt/rust_debug.h new file mode 100644 index 00000000000..f7c444324f7 --- /dev/null +++ b/src/rt/rust_debug.h @@ -0,0 +1,33 @@ +// Routines useful when debugging the Rust runtime. + +#ifndef RUST_DEBUG_H +#define RUST_DEBUG_H + +#include <cstdlib> + +namespace debug { + +class flag { +private: + const char *name; + bool valid; + bool value; + +public: + flag(const char *in_name) : name(in_name), valid(false) {} + + bool operator*() { + // FIXME: We ought to lock this. + if (!valid) { + char *ev = getenv(name); + value = ev && ev[0] != '\0' && ev[0] != '0'; + valid = true; + } + return value; + } +}; + +} // end namespace debug + +#endif + |
