-
Notifications
You must be signed in to change notification settings - Fork 913
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reflect: use int in StringHeader and SliceHeader on non-AVR platforms (…
- Loading branch information
Showing
5 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//go:build !avr | ||
|
||
package reflect | ||
|
||
// intw is an integer type, used in places where an int is typically required, | ||
// except architectures where the size of an int != word size. | ||
// See https://github.com/tinygo-org/tinygo/issues/1284. | ||
type intw = int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//go:build avr | ||
|
||
package reflect | ||
|
||
// intw is an integer type, used in places where an int is typically required, | ||
// except architectures where the size of an int != word size. | ||
// See https://github.com/tinygo-org/tinygo/issues/1284. | ||
type intw = uintptr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//go:build !avr | ||
|
||
package reflect_test | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
"unsafe" | ||
) | ||
|
||
// Verify that SliceHeader is the same size as a slice. | ||
var _ [unsafe.Sizeof([]byte{})]byte = [unsafe.Sizeof(reflect.SliceHeader{})]byte{} | ||
|
||
// TestSliceHeaderIntegerSize verifies that SliceHeader.Len and Cap are type int on non-AVR platforms. | ||
// See https://github.com/tinygo-org/tinygo/issues/1284. | ||
func TestSliceHeaderIntegerSize(t *testing.T) { | ||
var h reflect.SliceHeader | ||
h.Len = int(0) | ||
h.Cap = int(0) | ||
} | ||
|
||
// Verify that StringHeader is the same size as a string. | ||
var _ [unsafe.Sizeof("hello")]byte = [unsafe.Sizeof(reflect.StringHeader{})]byte{} | ||
|
||
// TestStringHeaderIntegerSize verifies that StringHeader.Len and Cap are type int on non-AVR platforms. | ||
// See https://github.com/tinygo-org/tinygo/issues/1284. | ||
func TestStringHeaderIntegerSize(t *testing.T) { | ||
var h reflect.StringHeader | ||
h.Len = int(0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters