Commit 31f8310c authored by Keith Randall's avatar Keith Randall

reflect: fix func layout test for nacl build

This test code is ugly.  There must be a better way.
But for now, fix the build.

Change-Id: I33064145ea37f11abf040ec97caa87669be1a9fa
Reviewed-on: https://go-review.googlesource.com/2114Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 9371babd
...@@ -4085,8 +4085,10 @@ var funcLayoutTests []funcLayoutTest ...@@ -4085,8 +4085,10 @@ var funcLayoutTests []funcLayoutTest
func init() { func init() {
var argAlign = PtrSize var argAlign = PtrSize
var naclExtra []byte
if runtime.GOARCH == "amd64p32" { if runtime.GOARCH == "amd64p32" {
argAlign = 2 * PtrSize argAlign = 2 * PtrSize
naclExtra = append(naclExtra, BitsScalar)
} }
roundup := func(x uintptr, a uintptr) uintptr { roundup := func(x uintptr, a uintptr) uintptr {
return (x + a - 1) / a * a return (x + a - 1) / a * a
...@@ -4106,7 +4108,7 @@ func init() { ...@@ -4106,7 +4108,7 @@ func init() {
var r, s []byte var r, s []byte
if PtrSize == 4 { if PtrSize == 4 {
r = []byte{BitsScalar, BitsScalar, BitsScalar, BitsPointer} r = []byte{BitsScalar, BitsScalar, BitsScalar, BitsPointer}
s = []byte{BitsScalar, BitsScalar, BitsScalar, BitsPointer, BitsScalar} s = append([]byte{BitsScalar, BitsScalar, BitsScalar, BitsPointer, BitsScalar}, naclExtra...)
} else { } else {
r = []byte{BitsScalar, BitsScalar, BitsPointer} r = []byte{BitsScalar, BitsScalar, BitsPointer}
s = []byte{BitsScalar, BitsScalar, BitsPointer, BitsScalar} s = []byte{BitsScalar, BitsScalar, BitsPointer, BitsScalar}
...@@ -4156,24 +4158,24 @@ func init() { ...@@ -4156,24 +4158,24 @@ func init() {
3 * PtrSize, 3 * PtrSize,
roundup(3*PtrSize, argAlign), roundup(3*PtrSize, argAlign),
[]byte{BitsPointer, BitsScalar, BitsPointer}, []byte{BitsPointer, BitsScalar, BitsPointer},
[]byte{BitsPointer, BitsScalar, BitsPointer}, append([]byte{BitsPointer, BitsScalar, BitsPointer}, naclExtra...),
}) })
funcLayoutTests = append(funcLayoutTests, funcLayoutTests = append(funcLayoutTests,
funcLayoutTest{ funcLayoutTest{
nil, nil,
ValueOf(func(a uintptr){}).Type(), ValueOf(func(a uintptr) {}).Type(),
PtrSize, roundup(PtrSize, argAlign),
PtrSize,
PtrSize, PtrSize,
roundup(PtrSize, argAlign),
[]byte{}, []byte{},
[]byte{BitsScalar}, append([]byte{BitsScalar}, naclExtra...),
}) })
funcLayoutTests = append(funcLayoutTests, funcLayoutTests = append(funcLayoutTests,
funcLayoutTest{ funcLayoutTest{
nil, nil,
ValueOf(func() uintptr{return 0}).Type(), ValueOf(func() uintptr { return 0 }).Type(),
PtrSize, PtrSize,
0, 0,
0, 0,
...@@ -4184,10 +4186,10 @@ func init() { ...@@ -4184,10 +4186,10 @@ func init() {
funcLayoutTests = append(funcLayoutTests, funcLayoutTests = append(funcLayoutTests,
funcLayoutTest{ funcLayoutTest{
ValueOf(uintptr(0)).Type(), ValueOf(uintptr(0)).Type(),
ValueOf(func(a uintptr){}).Type(), ValueOf(func(a uintptr) {}).Type(),
2*PtrSize, 2 * PtrSize,
2*PtrSize, 2 * PtrSize,
2*PtrSize, 2 * PtrSize,
[]byte{BitsPointer}, []byte{BitsPointer},
[]byte{BitsPointer, BitsScalar}, []byte{BitsPointer, BitsScalar},
// Note: this one is tricky, as the receiver is not a pointer. But we // Note: this one is tricky, as the receiver is not a pointer. But we
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment