From 86c4c4f00cc2ab6445ccb333c5b585bfe4a1002f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 30 Aug 2014 14:54:09 -0400 Subject: cmd/cc: generate error if #pragma pack off does anything We can't translate misaligned things to Go, so start rejecting them in C. The only one in any build appears to be EpollEvent on linux/amd64. Fix that. LGTM=r R=golang-codereviews, r, dvyukov CC=golang-codereviews, iant https://golang.org/cl/137020043 --- src/pkg/runtime/defs_linux_amd64.h | 2 +- src/pkg/runtime/netpoll_epoll.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pkg/runtime') diff --git a/src/pkg/runtime/defs_linux_amd64.h b/src/pkg/runtime/defs_linux_amd64.h index 73fd9947a7..14616dffed 100644 --- a/src/pkg/runtime/defs_linux_amd64.h +++ b/src/pkg/runtime/defs_linux_amd64.h @@ -122,7 +122,7 @@ struct Itimerval { }; struct EpollEvent { uint32 events; - uint64 data; + byte data[8]; // unaligned uintptr }; diff --git a/src/pkg/runtime/netpoll_epoll.c b/src/pkg/runtime/netpoll_epoll.c index a0ae7df310..2cf9b3760d 100644 --- a/src/pkg/runtime/netpoll_epoll.c +++ b/src/pkg/runtime/netpoll_epoll.c @@ -37,7 +37,7 @@ runtime·netpollopen(uintptr fd, PollDesc *pd) int32 res; ev.events = EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET; - ev.data = (uint64)pd; + *(uintptr*)ev.data = (uintptr)pd; res = runtime·epollctl(epfd, EPOLL_CTL_ADD, (int32)fd, &ev); return -res; } -- cgit v1.3-5-g9baa