File tree 5 files changed +65
-3
lines changed 5 files changed +65
-3
lines changed Original file line number Diff line number Diff line change
1
+ //go:build !avr
2
+
3
+ package reflect
4
+
5
+ // intw is an integer type, used in places where an int is typically required,
6
+ // except architectures where the size of an int != word size.
7
+ // See https://github.com/tinygo-org/tinygo/issues/1284.
8
+ type intw = int
Original file line number Diff line number Diff line change
1
+ //go:build avr
2
+
3
+ package reflect
4
+
5
+ // intw is an integer type, used in places where an int is typically required,
6
+ // except architectures where the size of an int != word size.
7
+ // See https://github.com/tinygo-org/tinygo/issues/1284.
8
+ type intw = uintptr
Original file line number Diff line number Diff line change
1
+ //go:build avr
2
+
3
+ package reflect_test
4
+
5
+ import (
6
+ "reflect"
7
+ "testing"
8
+ )
9
+
10
+ // TestSliceHeaderIntegerSize verifies that SliceHeader.Len and Cap are type uintptr on AVR platforms.
11
+ // See https://github.com/tinygo-org/tinygo/issues/1284.
12
+ func TestSliceHeaderIntegerSize (t * testing.T ) {
13
+ var h reflect.SliceHeader
14
+ h .Len = uintptr (0 )
15
+ h .Cap = uintptr (0 )
16
+ }
17
+
18
+ // TestStringHeaderIntegerSize verifies that StringHeader.Len and Cap are type uintptr on AVR platforms.
19
+ // See https://github.com/tinygo-org/tinygo/issues/1284.
20
+ func TestStringHeaderIntegerSize (t * testing.T ) {
21
+ var h reflect.StringHeader
22
+ h .Len = uintptr (0 )
23
+ }
Original file line number Diff line number Diff line change
1
+ //go:build !avr
2
+
3
+ package reflect_test
4
+
5
+ import (
6
+ "reflect"
7
+ "testing"
8
+ )
9
+
10
+ // TestSliceHeaderIntegerSize verifies that SliceHeader.Len and Cap are type int on non-AVR platforms.
11
+ // See https://github.com/tinygo-org/tinygo/issues/1284.
12
+ func TestSliceHeaderIntegerSize (t * testing.T ) {
13
+ var h reflect.SliceHeader
14
+ h .Len = int (0 )
15
+ h .Cap = int (0 )
16
+ }
17
+
18
+ // TestStringHeaderIntegerSize verifies that StringHeader.Len and Cap are type int on non-AVR platforms.
19
+ // See https://github.com/tinygo-org/tinygo/issues/1284.
20
+ func TestStringHeaderIntegerSize (t * testing.T ) {
21
+ var h reflect.StringHeader
22
+ h .Len = int (0 )
23
+ }
Original file line number Diff line number Diff line change @@ -1578,8 +1578,8 @@ type funcHeader struct {
1578
1578
1579
1579
type SliceHeader struct {
1580
1580
Data uintptr
1581
- Len uintptr
1582
- Cap uintptr
1581
+ Len intw
1582
+ Cap intw
1583
1583
}
1584
1584
1585
1585
// Slice header that matches the underlying structure. Used for when we switch
@@ -1592,7 +1592,7 @@ type sliceHeader struct {
1592
1592
1593
1593
type StringHeader struct {
1594
1594
Data uintptr
1595
- Len uintptr
1595
+ Len intw
1596
1596
}
1597
1597
1598
1598
// Like sliceHeader, this type is used internally to make sure pointer and
You can’t perform that action at this time.
0 commit comments