]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: round channel size in allocation instead of using system-specific pad field
authorRuss Cox <rsc@golang.org>
Mon, 25 Aug 2014 17:31:55 +0000 (13:31 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 25 Aug 2014 17:31:55 +0000 (13:31 -0400)
Followup to CL 128700043.

LGTM=bradfitz, dvyukov
R=dvyukov, bradfitz
CC=golang-codereviews
https://golang.org/cl/133850043

src/pkg/runtime/chan.go
src/pkg/runtime/chan.h

index d3fcc6d13f3bf184412c340948abe1f098a6fd81..7a44afacecbb5eb5fc9bd2a44e988f3ed7a02e71 100644 (file)
@@ -11,11 +11,11 @@ import "unsafe"
 
 const (
        maxAlign  = 8
-       hchanSize = unsafe.Sizeof(hchan{})
+       hchanSize = unsafe.Sizeof(hchan{}) + uintptr(-int(unsafe.Sizeof(hchan{}))&(maxAlign-1))
        debugChan = false
 )
 
-// TODO: make hchan.buf an unsafe.Pointer, not a *uint8
+// TODO(khr): make hchan.buf an unsafe.Pointer, not a *uint8
 
 func makechan(t *chantype, size int64) *hchan {
        elem := t.elem
index 30825eafad681e5c183549a3e9eb41fa5c42c82c..52eb20099dcb69b86c06a77dba94a4ab4a8a3b6f 100644 (file)
@@ -21,9 +21,6 @@ struct        Hchan
        byte*   buf;
        uint16  elemsize;
        uint32  closed;
-#ifndef GOARCH_amd64
-       uint32  pad;                    // ensures proper alignment of the buffer that follows Hchan in memory
-#endif
        Type*   elemtype;               // element type
        uintgo  sendx;                  // send index
        uintgo  recvx;                  // receive index