Mercurial > repos > rhope
diff kernel.rhope @ 147:f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 22 Nov 2010 01:15:02 -0500 |
parents | 7bbdc034e347 |
children | f582fd6c75ee |
line wrap: on
line diff
--- a/kernel.rhope Sun Nov 21 22:47:14 2010 -0500 +++ b/kernel.rhope Mon Nov 22 01:15:02 2010 -0500 @@ -302,3 +302,46 @@ out <- Pause[Resume[?,Yes]] } +Foreign C:libc +{ + rand[:out(Int32,Naked)] + srand[seed(Int32,Naked)] + time[storage(Int64,Raw Pointer,Mutable):storage] +} + +Globals _rand +{ + seeded <- No +} + +_Seeded?[:yep,nope] uses _rand +{ + Print["Seeded"] + yep,nope <- If[_rand::seeded] {} + { + _rand::seeded <- Yes + } +} + +_srand[val:out] +{ + srand[] + out <- Yes +} + +Random[:out] +{ + Print["Random"] + yep,nope <- _Seeded?[] + Val[yep] + { + _srand[Trunc Int32[time[0i64]]] + { out <- rand[] } + } + Val[nope] + { + out <- rand[] + } +} + +