]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: fix func layout test for nacl build
authorKeith Randall <khr@golang.org>
Tue, 23 Dec 2014 21:45:58 +0000 (13:45 -0800)
committerKeith Randall <khr@golang.org>
Wed, 24 Dec 2014 02:42:47 +0000 (02:42 +0000)
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/2114
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/reflect/all_test.go

index 69be8c6b4039a5e1a4b979369cea6b34b1cf42ef..974b5d2f6c1e1b511da92a2c1e6db2fef9cb5234 100644 (file)
@@ -4085,8 +4085,10 @@ var funcLayoutTests []funcLayoutTest
 
 func init() {
        var argAlign = PtrSize
+       var naclExtra []byte
        if runtime.GOARCH == "amd64p32" {
                argAlign = 2 * PtrSize
+               naclExtra = append(naclExtra, BitsScalar)
        }
        roundup := func(x uintptr, a uintptr) uintptr {
                return (x + a - 1) / a * a
@@ -4106,7 +4108,7 @@ func init() {
        var r, s []byte
        if PtrSize == 4 {
                r = []byte{BitsScalar, BitsScalar, BitsScalar, BitsPointer}
-               s = []byte{BitsScalar, BitsScalar, BitsScalar, BitsPointer, BitsScalar}
+               s = append([]byte{BitsScalar, BitsScalar, BitsScalar, BitsPointer, BitsScalar}, naclExtra...)
        } else {
                r = []byte{BitsScalar, BitsScalar, BitsPointer}
                s = []byte{BitsScalar, BitsScalar, BitsPointer, BitsScalar}
@@ -4156,24 +4158,24 @@ func init() {
                        3 * PtrSize,
                        roundup(3*PtrSize, argAlign),
                        []byte{BitsPointer, BitsScalar, BitsPointer},
-                       []byte{BitsPointer, BitsScalar, BitsPointer},
+                       append([]byte{BitsPointer, BitsScalar, BitsPointer}, naclExtra...),
                })
 
        funcLayoutTests = append(funcLayoutTests,
                funcLayoutTest{
                        nil,
-                       ValueOf(func(a uintptr){}).Type(),
-                       PtrSize,
-                       PtrSize,
+                       ValueOf(func(a uintptr) {}).Type(),
+                       roundup(PtrSize, argAlign),
                        PtrSize,
+                       roundup(PtrSize, argAlign),
                        []byte{},
-                       []byte{BitsScalar},
+                       append([]byte{BitsScalar}, naclExtra...),
                })
 
        funcLayoutTests = append(funcLayoutTests,
                funcLayoutTest{
                        nil,
-                       ValueOf(func() uintptr{return 0}).Type(),
+                       ValueOf(func() uintptr { return 0 }).Type(),
                        PtrSize,
                        0,
                        0,
@@ -4184,10 +4186,10 @@ func init() {
        funcLayoutTests = append(funcLayoutTests,
                funcLayoutTest{
                        ValueOf(uintptr(0)).Type(),
-                       ValueOf(func(a uintptr){}).Type(),
-                       2*PtrSize,
-                       2*PtrSize,
-                       2*PtrSize,
+                       ValueOf(func(a uintptr) {}).Type(),
+                       2 * PtrSize,
+                       2 * PtrSize,
+                       2 * PtrSize,
                        []byte{BitsPointer},
                        []byte{BitsPointer, BitsScalar},
                        // Note: this one is tricky, as the receiver is not a pointer.  But we