diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libgo/syscalls/socket_epoll.go | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libgo/syscalls/socket_epoll.go')
-rw-r--r-- | libgo/syscalls/socket_epoll.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libgo/syscalls/socket_epoll.go b/libgo/syscalls/socket_epoll.go new file mode 100644 index 000000000..0013f3349 --- /dev/null +++ b/libgo/syscalls/socket_epoll.go @@ -0,0 +1,50 @@ +// socket_epoll.go -- GNU/Linux epoll handling. + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Support for GNU/Linux epoll. +// Only for implementing net package. +// DO NOT USE DIRECTLY. + +package syscall + +// We don't take this type directly from the header file because it +// uses a union. FIXME. + +type EpollEvent struct { + Events uint32; + Fd int32; + Pad int32; +}; + +func libc_epoll_create(size int) int __asm__ ("epoll_create"); +func libc_epoll_ctl(epfd, op, fd int, event *EpollEvent) int __asm__ ("epoll_ctl"); +func libc_epoll_wait(epfd int, events *EpollEvent, maxevents int, + timeout int) int __asm__ ("epoll_wait"); + + +func EpollCreate(size int) (fd int, errno int) { + fd = libc_epoll_create(int(size)); + if fd < 0 { errno = GetErrno() } + return; +} + +func EpollCtl(epfd, op, fd int, ev *EpollEvent) (errno int) { + r := libc_epoll_ctl(epfd, op, fd, ev); + if r < 0 { errno = GetErrno() } + return; +} + +func EpollWait(epfd int, ev []EpollEvent, msec int) (n int, errno int) { + var events *EpollEvent; + var maxevents int; + if len(ev) > 0 { + maxevents = len(ev); + events = &ev[0] + } + n = libc_epoll_wait(epfd, events, maxevents, msec); + if n < 0 { errno = GetErrno() } + return; +} |