From: Russ Cox Date: Mon, 25 Aug 2014 17:31:55 +0000 (-0400) Subject: runtime: round channel size in allocation instead of using system-specific pad field X-Git-Tag: go1.4beta1~710 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1d2955a2afac04f5d392ecb1ad8b489f28976bf4;p=gostls13.git runtime: round channel size in allocation instead of using system-specific pad field Followup to CL 128700043. LGTM=bradfitz, dvyukov R=dvyukov, bradfitz CC=golang-codereviews https://golang.org/cl/133850043 --- diff --git a/src/pkg/runtime/chan.go b/src/pkg/runtime/chan.go index d3fcc6d13f..7a44afacec 100644 --- a/src/pkg/runtime/chan.go +++ b/src/pkg/runtime/chan.go @@ -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 diff --git a/src/pkg/runtime/chan.h b/src/pkg/runtime/chan.h index 30825eafad..52eb20099d 100644 --- a/src/pkg/runtime/chan.h +++ b/src/pkg/runtime/chan.h @@ -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