@@ -273,7 +273,7 @@ func (r *Rand) Read(p []byte) (n int, err error) {
273
273
switch src := r .src .(type ) {
274
274
case * lockedSource :
275
275
return src .read (p , & r .readVal , & r .readPos )
276
- case * fastSource :
276
+ case * runtimeSource :
277
277
return src .read (p , & r .readVal , & r .readPos )
278
278
}
279
279
return read (p , r .src , & r .readVal , & r .readPos )
@@ -328,8 +328,8 @@ func globalRand() *Rand {
328
328
r .Seed (1 )
329
329
} else {
330
330
r = & Rand {
331
- src : & fastSource {},
332
- s64 : & fastSource {},
331
+ src : & runtimeSource {},
332
+ s64 : & runtimeSource {},
333
333
}
334
334
}
335
335
@@ -346,29 +346,29 @@ func globalRand() *Rand {
346
346
return r
347
347
}
348
348
349
- //go:linkname fastrand64
350
- func fastrand64 () uint64
349
+ //go:linkname runtime_rand runtime.rand
350
+ func runtime_rand () uint64
351
351
352
- // fastSource is an implementation of Source64 that uses the runtime
352
+ // runtimeSource is an implementation of Source64 that uses the runtime
353
353
// fastrand functions.
354
- type fastSource struct {
354
+ type runtimeSource struct {
355
355
// The mutex is used to avoid race conditions in Read.
356
356
mu sync.Mutex
357
357
}
358
358
359
- func (* fastSource ) Int63 () int64 {
360
- return int64 (fastrand64 () & rngMask )
359
+ func (* runtimeSource ) Int63 () int64 {
360
+ return int64 (runtime_rand () & rngMask )
361
361
}
362
362
363
- func (* fastSource ) Seed (int64 ) {
364
- panic ("internal error: call to fastSource .Seed" )
363
+ func (* runtimeSource ) Seed (int64 ) {
364
+ panic ("internal error: call to runtimeSource .Seed" )
365
365
}
366
366
367
- func (* fastSource ) Uint64 () uint64 {
368
- return fastrand64 ()
367
+ func (* runtimeSource ) Uint64 () uint64 {
368
+ return runtime_rand ()
369
369
}
370
370
371
- func (fs * fastSource ) read (p []byte , readVal * int64 , readPos * int8 ) (n int , err error ) {
371
+ func (fs * runtimeSource ) read (p []byte , readVal * int64 , readPos * int8 ) (n int , err error ) {
372
372
fs .mu .Lock ()
373
373
n , err = read (p , fs , readVal , readPos )
374
374
fs .mu .Unlock ()
@@ -405,7 +405,7 @@ func Seed(seed int64) {
405
405
// Otherwise either
406
406
// 1) orig == nil, which is the normal case when Seed is the first
407
407
// top-level function to be called, or
408
- // 2) orig is already a fastSource , in which case we need to change
408
+ // 2) orig is already a runtimeSource , in which case we need to change
409
409
// to a lockedSource.
410
410
// Either way we do the same thing.
411
411
0 commit comments