Home | History | Annotate | Download | only in runtime
      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 // +build linux
      6 // +build mips64 mips64le
      7 
      8 package runtime
      9 
     10 var randomNumber uint32
     11 
     12 func archauxv(tag, val uintptr) {
     13 	switch tag {
     14 	case _AT_RANDOM:
     15 		// sysargs filled in startupRandomData, but that
     16 		// pointer may not be word aligned, so we must treat
     17 		// it as a byte array.
     18 		randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
     19 			uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
     20 	}
     21 }
     22 
     23 //go:nosplit
     24 func cputicks() int64 {
     25 	// Currently cputicks() is used in blocking profiler and to seed fastrand().
     26 	// nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
     27 	// randomNumber provides better seeding of fastrand.
     28 	return nanotime() + int64(randomNumber)
     29 }
     30 
     31 const (
     32 	_SS_DISABLE  = 2
     33 	_NSIG        = 129
     34 	_SI_USER     = 0
     35 	_SIG_BLOCK   = 1
     36 	_SIG_UNBLOCK = 2
     37 	_SIG_SETMASK = 3
     38 	_RLIMIT_AS   = 6
     39 )
     40 
     41 type sigset [2]uint64
     42 
     43 type rlimit struct {
     44 	rlim_cur uintptr
     45 	rlim_max uintptr
     46 }
     47 
     48 var sigset_all = sigset{^uint64(0), ^uint64(0)}
     49 
     50 //go:nosplit
     51 //go:nowritebarrierrec
     52 func sigaddset(mask *sigset, i int) {
     53 	(*mask)[(i-1)/64] |= 1 << ((uint32(i) - 1) & 63)
     54 }
     55 
     56 func sigdelset(mask *sigset, i int) {
     57 	(*mask)[(i-1)/64] &^= 1 << ((uint32(i) - 1) & 63)
     58 }
     59 
     60 func sigfillset(mask *[2]uint64) {
     61 	(*mask)[0], (*mask)[1] = ^uint64(0), ^uint64(0)
     62 }
     63