diff options
Diffstat (limited to 'src/lib/sys.rs')
| -rw-r--r-- | src/lib/sys.rs | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/lib/sys.rs b/src/lib/sys.rs index 5c1a6044082..874694d37c5 100644 --- a/src/lib/sys.rs +++ b/src/lib/sys.rs @@ -1,7 +1,8 @@ +/* +Module: sys -//export rustrt; -//export size_of; - +Misc low level stuff +*/ tag type_desc { type_desc(@type_desc); } @@ -22,30 +23,63 @@ native "rust-intrinsic" mod rusti { fn get_type_desc<T>() -> *type_desc; } +/* +Function: get_type_desc + +Returns a pointer to a type descriptor. Useful for calling certain +function in the Rust runtime or otherwise performing dark magick. +*/ fn get_type_desc<T>() -> *type_desc { ret rusti::get_type_desc::<T>(); } +/* +Function: last_os_error + +Get a string representing the platform-dependent last error +*/ fn last_os_error() -> str { ret rustrt::last_os_error(); } +/* +Function: size_of + +Returns the size of a type +*/ fn size_of<T>() -> uint { ret rustrt::size_of(get_type_desc::<T>()); } +/* +Function: align_of + +Returns the alignment of a type +*/ fn align_of<T>() -> uint { ret rustrt::align_of(get_type_desc::<T>()); } +/* +Function: refcount + +Returns the refcount of a shared box +*/ fn refcount<T>(t: @T) -> uint { ret rustrt::refcount::<T>(t); } +/* +Function: do_gc + +Force a garbage collection +*/ fn do_gc() -> () { ret rustrt::do_gc(); } +// FIXME: There's a wrapper for this in the task module and this really +// just belongs there fn unsupervise() -> () { ret rustrt::unsupervise(); } |
