avr: use i16 for lengths

This commit is contained in:
Ayke van Laethem
2018-09-20 20:52:59 +02:00
parent 45348bfc3e
commit dbb5ae5a23
4 changed files with 52 additions and 13 deletions
+11
View File
@@ -0,0 +1,11 @@
// +build avr
package runtime
const GOARCH = "avr"
// The length type used inside strings and slices.
type lenType uint16
// The bitness of the CPU (e.g. 8, 32, 64).
const TargetBits = 8
+1 -1
View File
@@ -1,4 +1,4 @@
// +build wasm
// +build wasm,!avr
package runtime
+4 -4
View File
@@ -16,15 +16,15 @@ func runtimePanic(msg string) {
}
// Check for bounds in *ssa.Index, *ssa.IndexAddr and *ssa.Lookup.
func lookupBoundsCheck(length, index int) {
if index < 0 || index >= length {
func lookupBoundsCheck(length lenType, index int) {
if index < 0 || index >= int(length) {
runtimePanic("index out of range")
}
}
// Check for bounds in *ssa.Slice.
func sliceBoundsCheck(length, low, high uint) {
if !(0 <= low && low <= high && high <= length) {
func sliceBoundsCheck(length lenType, low, high uint) {
if !(0 <= low && low <= high && high <= uint(length)) {
runtimePanic("slice out of range")
}
}