mirror of
https://github.com/golang/go
synced 2024-11-26 03:17:57 -07:00
internal/concurrent: remove dependency on math/rand/v2
This change uses linkname for the one random function internal/concurrent needs to avoid taking a dependency on math/rand/v2. This lowers the bar to using this package. Change-Id: I9dba1121b66ba35f56521643937f220936ea5321 Reviewed-on: https://go-review.googlesource.com/c/go/+/594057 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
6c66005285
commit
cea365ddfb
@ -103,7 +103,8 @@ var depsRules = `
|
||||
< internal/godebug
|
||||
< internal/reflectlite
|
||||
< errors
|
||||
< internal/oserror;
|
||||
< internal/oserror
|
||||
< internal/concurrent;
|
||||
|
||||
cmp, runtime, math/bits
|
||||
< iter
|
||||
@ -164,9 +165,6 @@ var depsRules = `
|
||||
MATH
|
||||
< runtime/metrics;
|
||||
|
||||
RUNTIME, math/rand/v2
|
||||
< internal/concurrent;
|
||||
|
||||
MATH, unicode/utf8
|
||||
< strconv;
|
||||
|
||||
|
@ -7,7 +7,6 @@ package concurrent
|
||||
import (
|
||||
"internal/abi"
|
||||
"internal/goarch"
|
||||
"math/rand/v2"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
@ -34,7 +33,7 @@ func NewHashTrieMap[K, V comparable]() *HashTrieMap[K, V] {
|
||||
keyHash: mapType.Hasher,
|
||||
keyEqual: mapType.Key.Equal,
|
||||
valEqual: mapType.Elem.Equal,
|
||||
seed: uintptr(rand.Uint64()),
|
||||
seed: uintptr(runtime_rand()),
|
||||
}
|
||||
return ht
|
||||
}
|
||||
@ -406,3 +405,9 @@ func (n *node[K, V]) indirect() *indirect[K, V] {
|
||||
}
|
||||
return (*indirect[K, V])(unsafe.Pointer(n))
|
||||
}
|
||||
|
||||
// Pull in runtime.rand so that we don't need to take a dependency
|
||||
// on math/rand/v2.
|
||||
//
|
||||
//go:linkname runtime_rand runtime.rand
|
||||
func runtime_rand() uint64
|
||||
|
Loading…
Reference in New Issue
Block a user