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 <asarai@suse.de>
This commit is contained in:
parent
21364997bb
commit
1e617aaab4
1 changed files with 19 additions and 19 deletions
|
@ -5,31 +5,31 @@ package archutils
|
||||||
// #include <sys/epoll.h>
|
// #include <sys/epoll.h>
|
||||||
/*
|
/*
|
||||||
int EpollCreate1(int flag) {
|
int EpollCreate1(int flag) {
|
||||||
return epoll_create1(flag);
|
return epoll_create1(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
int EpollCtl(int efd, int op, int sfd, int Events, int Fd) {
|
int EpollCtl(int efd, int op,int sfd, int events, int fd) {
|
||||||
struct epoll_event event;
|
struct epoll_event event;
|
||||||
event.events = Events;
|
event.events = events;
|
||||||
event.data.fd = Fd;
|
event.data.fd = fd;
|
||||||
|
|
||||||
return epoll_ctl(efd, op, sfd, &event);
|
return epoll_ctl(efd, op, sfd, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct Event{
|
struct event_t {
|
||||||
uint32_t events;
|
uint32_t events;
|
||||||
int fd;
|
int fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct epoll_event events[128];
|
struct epoll_event events[128];
|
||||||
int run_epoll_wait(int fd, struct Event *event) {
|
int run_epoll_wait(int fd, struct event_t *event) {
|
||||||
int n, i;
|
int n, i;
|
||||||
n = epoll_wait(fd, events, 128, -1);
|
n = epoll_wait(fd, events, 128, -1);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
event[i].events = events[i].events;
|
event[i].events = events[i].events;
|
||||||
event[i].fd = events[i].data.fd;
|
event[i].fd = events[i].data.fd;
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
import "C"
|
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) {
|
func EpollWait(epfd int, events []syscall.EpollEvent, msec int) (int, error) {
|
||||||
var c_events [128]C.struct_Event
|
var c_events [128]C.struct_event_t
|
||||||
n := int(C.run_epoll_wait(C.int(epfd), (*C.struct_Event)(unsafe.Pointer(&c_events))))
|
n := int(C.run_epoll_wait(C.int(epfd), (*C.struct_event_t)(unsafe.Pointer(&c_events))))
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
return int(n), fmt.Errorf("Failed to wait epoll")
|
return int(n), fmt.Errorf("Failed to wait epoll")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue