Skip to content

Commit

Permalink
re-link to runtime.cheaprandn in go1.23
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Jul 5, 2024
1 parent 61a8387 commit 109cd7a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions fastcaller_go1.23.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//go:build go1.23

// MIT license, copy and modify from https://github.com/tlog-dev/loc

//nolint:unused
package log

Expand All @@ -11,15 +13,9 @@ import (

// Fastrandn returns a pseudorandom uint32 in [0,n).
//
//go:nosplit
func Fastrandn(n uint32) uint32 {
// See https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
return uint32((uint64(cheaprand()) * uint64(n)) >> 32)
}

//go:noescape
//go:linkname cheaprand runtime.cheaprand
func cheaprand() uint32
//go:linkname Fastrandn runtime.cheaprandn
func Fastrandn(n uint32) uint32

func pcFileLine(pc uintptr) (file string, line int) {
f := findfunc(pc)
Expand Down

0 comments on commit 109cd7a

Please sign in to comment.