Skip to content

Commit

Permalink
Fix: update calls to runtime.fastrand to use cheaprand for compat…
Browse files Browse the repository at this point in the history
…ibility with Go 1.22 (#14897)
  • Loading branch information
Aoang authored Aug 8, 2024
1 parent eeaa25b commit 6816ea5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
3 changes: 0 additions & 3 deletions pkg/vm/engine/tae/containers/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,3 @@ func newVectorElement(pool *VectorPool, t *types.Type, mp *mpool.MPool) *vectorP
}
return element
}

//go:linkname fastrand runtime.fastrand
func fastrand() uint32
24 changes: 24 additions & 0 deletions pkg/vm/engine/tae/containers/runtime.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2021 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !go1.22

package containers

import (
_ "unsafe"
)

//go:linkname fastrand runtime.fastrand
func fastrand() uint32
24 changes: 24 additions & 0 deletions pkg/vm/engine/tae/containers/runtime_1.22.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2021 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build go1.22

package containers

import (
_ "unsafe"
)

//go:linkname fastrand runtime.cheaprand
func fastrand() uint32

0 comments on commit 6816ea5

Please sign in to comment.