fix: add runtime.rand and runtime.memhash for hash/maphash support
- Register hash/maphash in hasAltPkg map in runtime/build.go - Add rand() function that bridges to fastrand64() in runtime overlay - Add memhash() function that bridges to internal memhash() in runtime overlay - Fixes issue where hash/maphash package failed with undefined symbols Fixes #1338 Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com> Co-authored-by: xgopilot <noreply@goplus.org>
This commit is contained in:
@@ -24,6 +24,7 @@ var hasAltPkg = map[string]none{
|
||||
"crypto/subtle": {},
|
||||
"go/parser": {},
|
||||
"hash/crc32": {},
|
||||
"hash/maphash": {},
|
||||
"internal/abi": {},
|
||||
"internal/bytealg": {},
|
||||
"internal/chacha8rand": {},
|
||||
|
||||
@@ -56,4 +56,18 @@ func write(fd uintptr, p unsafe.Pointer, n int32) int32 {
|
||||
return int32(c_write(c.Int(fd), p, c.SizeT(n)))
|
||||
}
|
||||
|
||||
//go:linkname llgo_fastrand64 github.com/goplus/llgo/runtime/internal/runtime.fastrand64
|
||||
func llgo_fastrand64() uint64
|
||||
|
||||
//go:linkname llgo_memhash github.com/goplus/llgo/runtime/internal/runtime.memhash
|
||||
func llgo_memhash(p unsafe.Pointer, seed, s uintptr) uintptr
|
||||
|
||||
func rand() uint64 {
|
||||
return llgo_fastrand64()
|
||||
}
|
||||
|
||||
func memhash(p unsafe.Pointer, seed, s uintptr) uintptr {
|
||||
return llgo_memhash(p, seed, s)
|
||||
}
|
||||
|
||||
const heapArenaBytes = 1024 * 1024
|
||||
|
||||
Reference in New Issue
Block a user