-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: drop linkname to allow exec on go 1.23+
- Loading branch information
Showing
4 changed files
with
36 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//go:build !go1.22 | ||
|
||
package crypto | ||
|
||
import ( | ||
_ "unsafe" // required by go:linkname | ||
) | ||
|
||
// randuint32 returns a lock free uint32 value. | ||
// | ||
// Too much legacy code has go:linkname references | ||
// to runtime.fastrand and friends, so keep these around for now. | ||
// Code should migrate to math/rand/v2.Uint64, | ||
// which is just as fast, but that's only available in Go 1.22+. | ||
// It would be reasonable to remove these in Go 1.24. | ||
// Do not call these from package runtime. | ||
// | ||
//go:linkname randuint32 runtime.fastrand | ||
func randuint32() uint32 | ||
|
||
func RandU32() uint32 { | ||
return randuint32() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//go:build go1.22 | ||
|
||
package crypto | ||
|
||
import ( | ||
"math/rand/v2" | ||
) | ||
|
||
func RandU32() uint32 { | ||
return rand.Uint32() | ||
} |