Skip to content

Commit 41e501a

Browse files
aykevldeadprogram
authored andcommitted
runtime: move timeUnit to a single place
The timeUnit is now the same type everywhere. Move it to a single place and add some documentation to it.
1 parent abc373d commit 41e501a

27 files changed

+13
-58
lines changed

src/runtime/runtime.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ import (
88

99
const Compiler = "tinygo"
1010

11+
// Unit for the 'ticks' and 'sleepTicks' functions.
12+
//
13+
// This is the native time unit for the given system. One timeUnit tick might be
14+
// 1ns or 100ns on a desktop system, or 1/32768s on baremetal systems with a
15+
// low-power RTC. Many other tick durations are possible.
16+
//
17+
// Conversion from time units to nanoseconds and back is done using
18+
// ticksToNanoseconds and nanosecondsToTicks, which need to be implemented for
19+
// each system as needed.
20+
type timeUnit int64
21+
1122
// The compiler will fill this with calls to the initialization function of each
1223
// package.
1324
func initAll()

src/runtime/runtime_arm7tdmi.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"unsafe"
88
)
99

10-
type timeUnit int64
11-
1210
func putchar(c byte) {
1311
// dummy, TODO
1412
}

src/runtime/runtime_atsamd21.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import (
1212
"unsafe"
1313
)
1414

15-
type timeUnit int64
16-
1715
//export Reset_Handler
1816
func main() {
1917
preinit()

src/runtime/runtime_atsamd51.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"runtime/volatile"
1212
)
1313

14-
type timeUnit int64
15-
1614
//export Reset_Handler
1715
func main() {
1816
arm.SCB.CPACR.Set(0) // disable FPU if it is enabled

src/runtime/runtime_avr.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ import (
1212

1313
const BOARD = "arduino"
1414

15-
// timeUnit in nanoseconds
16-
type timeUnit int64
17-
1815
// Watchdog timer periods. These can be off by a large margin (hence the jump
1916
// between 64ms and 125ms which is not an exact double), so don't rely on this
2017
// for accurate time keeping.

src/runtime/runtime_avrtiny.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import (
2222
"runtime/volatile"
2323
)
2424

25-
type timeUnit int64
26-
2725
//export main
2826
func main() {
2927
// Initialize RTC.

src/runtime/runtime_cortexm_qemu.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"unsafe"
1212
)
1313

14-
type timeUnit int64
15-
1614
var timestamp timeUnit
1715

1816
//export Reset_Handler

src/runtime/runtime_esp32xx.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"unsafe"
99
)
1010

11-
type timeUnit int64
12-
1311
// Initialize .bss: zero-initialized global variables.
1412
// The .data section has already been loaded by the ROM bootloader.
1513
func clearbss() {

src/runtime/runtime_esp8266.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"unsafe"
1010
)
1111

12-
type timeUnit int64
13-
1412
var currentTime timeUnit = 0
1513

1614
func putchar(c byte) {

src/runtime/runtime_fe310.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
"runtime/volatile"
1515
)
1616

17-
type timeUnit int64
18-
1917
//export main
2018
func main() {
2119
// Zero the PLIC enable bits on startup: they are not zeroed at reset.

0 commit comments

Comments
 (0)