golang.org/toolchain@v0.0.1-go1.9rc2.windows-amd64/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  const (
     8  	_ARM64_FEATURE_HAS_CRC32 = 0x80
     9  )
    10  
    11  var randomNumber uint32
    12  var supportCRC32 bool
    13  
    14  func archauxv(tag, val uintptr) {
    15  	switch tag {
    16  	case _AT_RANDOM:
    17  		// sysargs filled in startupRandomData, but that
    18  		// pointer may not be word aligned, so we must treat
    19  		// it as a byte array.
    20  		randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
    21  			uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
    22  	case _AT_HWCAP:
    23  		supportCRC32 = val&_ARM64_FEATURE_HAS_CRC32 != 0
    24  	}
    25  }
    26  
    27  //go:nosplit
    28  func cputicks() int64 {
    29  	// Currently cputicks() is used in blocking profiler and to seed fastrand().
    30  	// nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
    31  	// randomNumber provides better seeding of fastrand.
    32  	return nanotime() + int64(randomNumber)
    33  }