Russ Cox | 7d51607 | 2014-12-05 16:17:09 -0500 | [diff] [blame] | 1 | // Copyright 2013 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 | import "unsafe" |
| 8 | |
Ben Shi | 69261ec | 2017-02-27 07:56:57 +0000 | [diff] [blame] | 9 | var hardDiv bool // TODO: set if a hardware divider is available |
| 10 | |
Russ Cox | 7d51607 | 2014-12-05 16:17:09 -0500 | [diff] [blame] | 11 | func lwp_mcontext_init(mc *mcontextt, stk unsafe.Pointer, mp *m, gp *g, fn uintptr) { |
| 12 | // Machine dependent mcontext initialisation for LWP. |
| 13 | mc.__gregs[_REG_R15] = uint32(funcPC(lwp_tramp)) |
| 14 | mc.__gregs[_REG_R13] = uint32(uintptr(stk)) |
| 15 | mc.__gregs[_REG_R0] = uint32(uintptr(unsafe.Pointer(mp))) |
| 16 | mc.__gregs[_REG_R1] = uint32(uintptr(unsafe.Pointer(gp))) |
| 17 | mc.__gregs[_REG_R2] = uint32(fn) |
| 18 | } |
| 19 | |
| 20 | func checkgoarm() { |
Russ Cox | 4a19081 | 2015-08-07 11:48:52 -0400 | [diff] [blame] | 21 | // TODO(minux): FP checks like in os_linux_arm.go. |
| 22 | |
| 23 | // osinit not called yet, so ncpu not set: must use getncpu directly. |
| 24 | if getncpu() > 1 && goarm < 7 { |
| 25 | print("runtime: this system has multiple CPUs and must use\n") |
| 26 | print("atomic synchronization instructions. Recompile using GOARM=7.\n") |
| 27 | exit(1) |
| 28 | } |
Russ Cox | 7d51607 | 2014-12-05 16:17:09 -0500 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | //go:nosplit |
| 32 | func cputicks() int64 { |
Josh Bleecher Snyder | 2b74de3 | 2016-06-28 09:22:46 -0700 | [diff] [blame] | 33 | // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand(). |
Russ Cox | 7d51607 | 2014-12-05 16:17:09 -0500 | [diff] [blame] | 34 | // runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler. |
Josh Bleecher Snyder | 2b74de3 | 2016-06-28 09:22:46 -0700 | [diff] [blame] | 35 | // TODO: need more entropy to better seed fastrand. |
Russ Cox | 7d51607 | 2014-12-05 16:17:09 -0500 | [diff] [blame] | 36 | return nanotime() |
| 37 | } |