2011-06-15 13:19:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-25 23:45:09 -05:00
|
|
|
/**
|
|
|
|
* Bindings the runtime's random number generator (ISAAC).
|
|
|
|
*/
|
|
|
|
native "rust" mod rustrt {
|
2010-09-22 17:44:13 -05:00
|
|
|
type rctx;
|
|
|
|
fn rand_new() -> rctx;
|
2011-07-27 07:19:39 -05:00
|
|
|
fn rand_next(c: rctx) -> u32;
|
|
|
|
fn rand_free(c: rctx);
|
2010-07-25 23:45:09 -05:00
|
|
|
}
|
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
type rng =
|
|
|
|
obj {
|
|
|
|
fn next() -> u32 ;
|
|
|
|
};
|
2010-07-25 23:45:09 -05:00
|
|
|
|
|
|
|
fn mk_rng() -> rng {
|
2011-07-27 07:19:39 -05:00
|
|
|
obj rt_rng(c: rustrt::rctx) {
|
2010-09-22 17:44:13 -05:00
|
|
|
fn next() -> u32 {
|
2011-05-12 10:24:54 -05:00
|
|
|
ret rustrt::rand_next(c);
|
2011-07-27 10:05:34 -05:00
|
|
|
}
|
|
|
|
drop { rustrt::rand_free(c); }
|
2010-07-25 23:45:09 -05:00
|
|
|
}
|
2011-05-12 10:24:54 -05:00
|
|
|
ret rt_rng(rustrt::rand_new());
|
2010-07-25 23:45:09 -05:00
|
|
|
}
|
2010-09-22 17:44:13 -05:00
|
|
|
// Local Variables:
|
|
|
|
// mode: rust;
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
2011-06-15 14:01:19 -05:00
|
|
|
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
2010-09-22 17:44:13 -05:00
|
|
|
// End:
|