runtime: stubs init hashkey
This commit is contained in:
@@ -8,12 +8,16 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/c/sync/atomic"
|
"github.com/goplus/llgo/c/sync/atomic"
|
||||||
|
"github.com/goplus/llgo/c/time"
|
||||||
"github.com/goplus/llgo/internal/runtime/math"
|
"github.com/goplus/llgo/internal/runtime/math"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:linkname fastrand C.rand
|
//go:linkname fastrand C.rand
|
||||||
func fastrand() uint32
|
func fastrand() uint32
|
||||||
|
|
||||||
|
//go:linkname srand C.srand
|
||||||
|
func srand(uint32)
|
||||||
|
|
||||||
func fastrand64() uint64 {
|
func fastrand64() uint64 {
|
||||||
n := uint64(fastrand())
|
n := uint64(fastrand())
|
||||||
n += 0xa0761d6478bd642f
|
n += 0xa0761d6478bd642f
|
||||||
@@ -21,6 +25,14 @@ func fastrand64() uint64 {
|
|||||||
return hi ^ lo
|
return hi ^ lo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
srand(uint32(time.Time(nil)))
|
||||||
|
hashkey[0] = uintptr(fastrand()) | 1
|
||||||
|
hashkey[1] = uintptr(fastrand()) | 1
|
||||||
|
hashkey[2] = uintptr(fastrand()) | 1
|
||||||
|
hashkey[3] = uintptr(fastrand()) | 1
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO(xsw):
|
/* TODO(xsw):
|
||||||
func fastrand() uint32 {
|
func fastrand() uint32 {
|
||||||
mp := getg().m
|
mp := getg().m
|
||||||
|
|||||||
Reference in New Issue
Block a user