bursavich.dev/fastrand@v0.2.1/fastrand_unsafe.go (about)

     1  // SPDX-License-Identifier: MIT
     2  //
     3  // Copyright 2023 Andrew Bursavich. All rights reserved.
     4  // Use of this source code is governed by The MIT License
     5  // which can be found in the LICENSE file.
     6  
     7  //go:build !safe
     8  
     9  package fastrand
    10  
    11  import (
    12  	"unsafe"
    13  )
    14  
    15  //go:linkname u32 runtime.fastrand
    16  func u32() uint32
    17  
    18  //go:linkname u64 runtime.fastrand64
    19  func u64() uint64
    20  
    21  func putU64(p []byte, v uint64) {
    22  	*(*uint64)(unsafe.Pointer(&p[0])) = v
    23  }