From 1e617aaab4942faf8a354c7239f061300637e5b8 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Wed, 13 Apr 2016 16:08:28 +1000 Subject: [PATCH 1/2] archutils: epoll_aarch64: fix C formatting Use proper C formatting to make the cgo code much easier to read. Also remove the pointless typedef. Signed-off-by: Aleksa Sarai --- archutils/epoll_aarch64.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/archutils/epoll_aarch64.go b/archutils/epoll_aarch64.go index 3984ac4..73cd8ed 100644 --- a/archutils/epoll_aarch64.go +++ b/archutils/epoll_aarch64.go @@ -5,31 +5,31 @@ package archutils // #include /* int EpollCreate1(int flag) { - return epoll_create1(flag); + return epoll_create1(flag); } -int EpollCtl(int efd, int op, int sfd, int Events, int Fd) { - struct epoll_event event; - event.events = Events; - event.data.fd = Fd; +int EpollCtl(int efd, int op,int sfd, int events, int fd) { + struct epoll_event event; + event.events = events; + event.data.fd = fd; - return epoll_ctl(efd, op, sfd, &event); + return epoll_ctl(efd, op, sfd, &event); } -typedef struct Event{ - uint32_t events; - int fd; +struct event_t { + uint32_t events; + int fd; }; struct epoll_event events[128]; -int run_epoll_wait(int fd, struct Event *event) { - int n, i; - n = epoll_wait(fd, events, 128, -1); - for (i = 0; i < n; i++) { - event[i].events = events[i].events; - event[i].fd = events[i].data.fd; - } - return n; +int run_epoll_wait(int fd, struct event_t *event) { + int n, i; + n = epoll_wait(fd, events, 128, -1); + for (i = 0; i < n; i++) { + event[i].events = events[i].events; + event[i].fd = events[i].data.fd; + } + return n; } */ import "C" @@ -57,8 +57,8 @@ func EpollCtl(epfd int, op int, fd int, event *syscall.EpollEvent) error { } func EpollWait(epfd int, events []syscall.EpollEvent, msec int) (int, error) { - var c_events [128]C.struct_Event - n := int(C.run_epoll_wait(C.int(epfd), (*C.struct_Event)(unsafe.Pointer(&c_events)))) + var c_events [128]C.struct_event_t + n := int(C.run_epoll_wait(C.int(epfd), (*C.struct_event_t)(unsafe.Pointer(&c_events)))) if n < 0 { return int(n), fmt.Errorf("Failed to wait epoll") } From 7c572f16734b69134b17c5f6c563d6d6a595e606 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Wed, 13 Apr 2016 19:29:20 +1000 Subject: [PATCH 2/2] archutils: fix build on aarch64 Due to an invalid architecture name (arm64), containerd could not build on aarch64 machines. Fix this by using the correct name of the architecture for conditional building. Signed-off-by: Aleksa Sarai --- archutils/epoll.go | 3 ++- archutils/epoll_aarch64.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/archutils/epoll.go b/archutils/epoll.go index 6922b52..6bb6047 100644 --- a/archutils/epoll.go +++ b/archutils/epoll.go @@ -1,4 +1,5 @@ -//+build !arm64,linux +// +build linux,!aarch64 + package archutils import ( diff --git a/archutils/epoll_aarch64.go b/archutils/epoll_aarch64.go index 73cd8ed..3d63147 100644 --- a/archutils/epoll_aarch64.go +++ b/archutils/epoll_aarch64.go @@ -1,4 +1,4 @@ -// +build arm64,linux +// +build linux,aarch64 package archutils