github.com/riscv/riscv-go@v0.0.0-20200123204226-124ebd6fcc8e/src/runtime/os_linux_arm64.go (about)

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package runtime
     6  
     7  var randomNumber uint32
     8  
     9  func archauxv(tag, val uintptr) {
    10  	switch tag {
    11  	case _AT_RANDOM:
    12  		// sysargs filled in startupRandomData, but that
    13  		// pointer may not be word aligned, so we must treat
    14  		// it as a byte array.
    15  		randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
    16  			uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
    17  	}
    18  }
    19  
    20  //go:nosplit
    21  func cputicks() int64 {
    22  	// Currently cputicks() is used in blocking profiler and to seed fastrand().
    23  	// nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
    24  	// randomNumber provides better seeding of fastrand.
    25  	return nanotime() + int64(randomNumber)
    26  }