Skip to content

Commit

Permalink
use cheaprandn as Fastrandn for go1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Mar 10, 2024
1 parent e88be0d commit 10697b8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
6 changes: 0 additions & 6 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -2135,9 +2135,3 @@ func absClock(abs uint64) (hour, min, sec int)
//go:noescape
//go:linkname callers runtime.callers
func callers(skip int, pcbuf []uintptr) int

// Fastrandn returns a pseudorandom uint32 in [0,n).
//
//go:noescape
//go:linkname Fastrandn runtime.fastrandn
func Fastrandn(x uint32) uint32
14 changes: 14 additions & 0 deletions logger_go1.18.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//go:build go1.18 && !go1.22
// +build go1.18,!go1.22

package log

import (
_ "unsafe"
)

// Fastrandn returns a pseudorandom uint32 in [0,n).
//
//go:noescape
//go:linkname Fastrandn runtime.fastrandn
func Fastrandn(x uint32) uint32
14 changes: 14 additions & 0 deletions logger_go1.22.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//go:build go1.22
// +build go1.22

package log

import (
_ "unsafe"
)

// Fastrandn returns a pseudorandom uint32 in [0,n).
//
//go:noescape
//go:linkname Fastrandn runtime.cheaprandn
func Fastrandn(x uint32) uint32

0 comments on commit 10697b8

Please sign in to comment.