Skip to content

Commit 8151b28

Browse files
Update for fastrand
1 parent 5437642 commit 8151b28

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

compiler/natives/src/net/fastrand.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ import (
77
_ "unsafe" // For go:linkname
88
)
99

10-
//go:linkname fastrand runtime.fastrand
11-
func fastrand() uint32
10+
//go:linkname fastrandu runtime.fastrandu
11+
func fastrandu() uint

compiler/natives/src/runtime/fastrand.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ func fastrand() uint32 {
1313
// similar distribution.
1414
return uint32(js.Global.Get("Math").Call("random").Float() * (1<<32 - 1))
1515
}
16+
17+
func fastrandn(n uint32) uint32 {
18+
return fastrand() % n
19+
}
20+
21+
func fastrand64() uint64 {
22+
return uint64(fastrand())<<32 | uint64(fastrand())
23+
}
24+
25+
func fastrandu() uint {
26+
return uint(fastrand())
27+
}

0 commit comments

Comments
 (0)