Skip to content

Commit

Permalink
Add system time to guest environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
lthibault committed Nov 14, 2024
1 parent a46d363 commit 17eb004
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions proc/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package proc
import (
"bytes"
"context"
"crypto/rand"
"errors"
"io"
"log/slog"
"path"
"runtime"
"strings"

"capnproto.org/go/capnp/v3"
Expand Down Expand Up @@ -35,7 +37,12 @@ func (cfg Config) Bind(ctx context.Context, p *P) (err error) {
WithStdin(&p.mailbox).
WithStdout(cfg.Stdout).
WithStderr(cfg.Stderr).
WithEnv("WW_PROTO", proto)
WithEnv("WW_PROTO", proto).
WithRandSource(rand.Reader).
WithOsyield(runtime.Gosched).
WithSysNanosleep().
WithSysNanotime().
WithSysWalltime()

p.Mod, err = cfg.Runtime.InstantiateModule(ctx, cfg.Module,
cfg.WithEnv(mc))
Expand Down Expand Up @@ -122,11 +129,3 @@ func (p *P) ToWasmStack(stack capnp.UInt64List) []uint64 {

return p.stack
}

// rd io.LimitedReader
// func (p *P) ReadFrom(r io.Reader) (int64, error) {
// p.buf.Reset()
// p.rd.R = r
// p.rd.N = 1<<32 - 1 // max uint32
// return io.Copy(&p.buf, r)
// }

0 comments on commit 17eb004

Please sign in to comment.