Rename net/fd_rtems.go to net/fd_select.go.
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 28 Mar 2011 18:30:21 +0000 (18:30 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 28 Mar 2011 18:30:21 +0000 (18:30 +0000)
From-SVN: r171621

libgo/Makefile.am
libgo/Makefile.in
libgo/go/net/fd_rtems.go [deleted file]
libgo/go/net/fd_select.go [new file with mode: 0644]

index 24587ca34acd17daefccb484a40de6bf255578cf..6eb752c7e040d273ff93a19f0ab2c553241aa491 100644 (file)
@@ -642,7 +642,7 @@ go_mime_files = \
        go/mime/type.go
 
 if LIBGO_IS_RTEMS
-go_net_fd_os_file = go/net/fd_rtems.go
+go_net_fd_os_file = go/net/fd_select.go
 go_net_newpollserver_file = go/net/newpollserver_rtems.go
 else # !LIBGO_IS_RTEMS
 if LIBGO_IS_LINUX
@@ -651,7 +651,7 @@ go_net_newpollserver_file = go/net/newpollserver.go
 else # !LIBGO_IS_LINUX && !LIBGO_IS_RTEMS
 # By default use select with pipes.  Most systems should have
 # something better.
-go_net_fd_os_file = go/net/fd_rtems.go
+go_net_fd_os_file = go/net/fd_select.go
 go_net_newpollserver_file = go/net/newpollserver.go
 endif # !LIBGO_IS_LINUX
 endif # !LIBGO_IS_RTEMS
index e61f1e749652b1af7aec12b0e0f4c46ec3318c32..3af5ffcde16d57feea0b21f216df7f7e9c6c33d9 100644 (file)
@@ -1032,9 +1032,9 @@ go_mime_files = \
 
 # By default use select with pipes.  Most systems should have
 # something better.
-@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_RTEMS_FALSE@go_net_fd_os_file = go/net/fd_rtems.go
+@LIBGO_IS_LINUX_FALSE@@LIBGO_IS_RTEMS_FALSE@go_net_fd_os_file = go/net/fd_select.go
 @LIBGO_IS_LINUX_TRUE@@LIBGO_IS_RTEMS_FALSE@go_net_fd_os_file = go/net/fd_linux.go
-@LIBGO_IS_RTEMS_TRUE@go_net_fd_os_file = go/net/fd_rtems.go
+@LIBGO_IS_RTEMS_TRUE@go_net_fd_os_file = go/net/fd_select.go
 @LIBGO_IS_LINUX_FALSE@@LIBGO_IS_RTEMS_FALSE@go_net_newpollserver_file = go/net/newpollserver.go
 @LIBGO_IS_LINUX_TRUE@@LIBGO_IS_RTEMS_FALSE@go_net_newpollserver_file = go/net/newpollserver.go
 @LIBGO_IS_RTEMS_TRUE@go_net_newpollserver_file = go/net/newpollserver_rtems.go
diff --git a/libgo/go/net/fd_rtems.go b/libgo/go/net/fd_rtems.go
deleted file mode 100644 (file)
index 61759ca..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2010 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.
-
-// Waiting for FDs via select(2).
-
-package net
-
-import (
-       "os"
-       "syscall"
-)
-
-type pollster struct {
-       readFds, writeFds, repeatFds *syscall.FdSet_t
-       maxFd int
-       readyReadFds, readyWriteFds *syscall.FdSet_t
-       nReady int
-       lastFd int
-}
-
-func newpollster() (p *pollster, err os.Error) {
-       p = new(pollster)
-       p.readFds = new(syscall.FdSet_t)
-       p.writeFds = new(syscall.FdSet_t)
-       p.repeatFds = new(syscall.FdSet_t)
-       p.readyReadFds = new(syscall.FdSet_t)
-       p.readyWriteFds = new(syscall.FdSet_t)
-       p.maxFd = -1
-       p.nReady = 0
-       p.lastFd = 0
-       return p, nil
-}
-
-func (p *pollster) AddFD(fd int, mode int, repeat bool) os.Error {
-       if mode == 'r' {
-               syscall.FDSet(fd, p.readFds)
-       } else {
-               syscall.FDSet(fd, p.writeFds)
-       }
-
-       if repeat {
-               syscall.FDSet(fd, p.repeatFds)
-       }
-
-       if fd > p.maxFd {
-               p.maxFd = fd
-       }
-
-       return nil
-}
-
-func (p *pollster) DelFD(fd int, mode int) {
-       if mode == 'r' {
-               if !syscall.FDIsSet(fd, p.readFds) {
-                       print("Select unexpected fd=", fd, " for read\n")
-                       return
-               }
-               syscall.FDClr(fd, p.readFds)
-       } else {
-               if !syscall.FDIsSet(fd, p.writeFds) {
-                       print("Select unexpected fd=", fd, " for write\n")
-                       return
-               }
-               syscall.FDClr(fd, p.writeFds)
-       }
-
-       // Doesn't matter if not already present.
-       syscall.FDClr(fd, p.repeatFds)
-
-       // We don't worry about maxFd here.
-}
-
-func (p *pollster) WaitFD(nsec int64) (fd int, mode int, err os.Error) {
-       if p.nReady == 0 {
-               var timeout *syscall.Timeval
-               var tv syscall.Timeval
-               timeout = nil
-               if nsec > 0 {
-                       tv = syscall.NsecToTimeval(nsec)
-                       timeout = &tv
-               }
-
-               var n, e int
-               var tmpReadFds, tmpWriteFds syscall.FdSet_t
-               for {
-                       // Temporary syscall.FdSet_ts into which the values are copied
-                       // because select mutates the values.
-                       tmpReadFds = *p.readFds
-                       tmpWriteFds = *p.writeFds
-
-                       n, e = syscall.Select(p.maxFd + 1, &tmpReadFds, &tmpWriteFds, nil, timeout)
-                       if e != syscall.EINTR {
-                               break
-                       }
-               }
-               if e != 0 {
-                       return -1, 0, os.NewSyscallError("select", e)
-               }
-               if n == 0 {
-                       return -1, 0, nil
-               }
-
-               p.nReady = n
-               *p.readyReadFds = tmpReadFds
-               *p.readyWriteFds = tmpWriteFds
-               p.lastFd = 0
-       }
-
-       flag := false
-       for i := p.lastFd; i < p.maxFd + 1; i++ {
-               if syscall.FDIsSet(i, p.readyReadFds) {
-                       flag = true
-                       mode = 'r'
-                       syscall.FDClr(i, p.readyReadFds)
-               } else if syscall.FDIsSet(i, p.readyWriteFds) {
-                       flag = true
-                       mode = 'w'
-                       syscall.FDClr(i, p.readyWriteFds)
-               }
-               if flag {
-                       if !syscall.FDIsSet(i, p.repeatFds) {
-                               p.DelFD(i, mode)
-                       }
-                       p.nReady--
-                       p.lastFd = i
-                       return i, mode, nil
-               }
-       }
-
-       // Will not reach here.  Just to shut up the compiler.
-       return -1, 0, nil
-}
-
-func (p *pollster) Close() os.Error {
-       return nil
-}
diff --git a/libgo/go/net/fd_select.go b/libgo/go/net/fd_select.go
new file mode 100644 (file)
index 0000000..61759ca
--- /dev/null
@@ -0,0 +1,137 @@
+// Copyright 2010 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.
+
+// Waiting for FDs via select(2).
+
+package net
+
+import (
+       "os"
+       "syscall"
+)
+
+type pollster struct {
+       readFds, writeFds, repeatFds *syscall.FdSet_t
+       maxFd int
+       readyReadFds, readyWriteFds *syscall.FdSet_t
+       nReady int
+       lastFd int
+}
+
+func newpollster() (p *pollster, err os.Error) {
+       p = new(pollster)
+       p.readFds = new(syscall.FdSet_t)
+       p.writeFds = new(syscall.FdSet_t)
+       p.repeatFds = new(syscall.FdSet_t)
+       p.readyReadFds = new(syscall.FdSet_t)
+       p.readyWriteFds = new(syscall.FdSet_t)
+       p.maxFd = -1
+       p.nReady = 0
+       p.lastFd = 0
+       return p, nil
+}
+
+func (p *pollster) AddFD(fd int, mode int, repeat bool) os.Error {
+       if mode == 'r' {
+               syscall.FDSet(fd, p.readFds)
+       } else {
+               syscall.FDSet(fd, p.writeFds)
+       }
+
+       if repeat {
+               syscall.FDSet(fd, p.repeatFds)
+       }
+
+       if fd > p.maxFd {
+               p.maxFd = fd
+       }
+
+       return nil
+}
+
+func (p *pollster) DelFD(fd int, mode int) {
+       if mode == 'r' {
+               if !syscall.FDIsSet(fd, p.readFds) {
+                       print("Select unexpected fd=", fd, " for read\n")
+                       return
+               }
+               syscall.FDClr(fd, p.readFds)
+       } else {
+               if !syscall.FDIsSet(fd, p.writeFds) {
+                       print("Select unexpected fd=", fd, " for write\n")
+                       return
+               }
+               syscall.FDClr(fd, p.writeFds)
+       }
+
+       // Doesn't matter if not already present.
+       syscall.FDClr(fd, p.repeatFds)
+
+       // We don't worry about maxFd here.
+}
+
+func (p *pollster) WaitFD(nsec int64) (fd int, mode int, err os.Error) {
+       if p.nReady == 0 {
+               var timeout *syscall.Timeval
+               var tv syscall.Timeval
+               timeout = nil
+               if nsec > 0 {
+                       tv = syscall.NsecToTimeval(nsec)
+                       timeout = &tv
+               }
+
+               var n, e int
+               var tmpReadFds, tmpWriteFds syscall.FdSet_t
+               for {
+                       // Temporary syscall.FdSet_ts into which the values are copied
+                       // because select mutates the values.
+                       tmpReadFds = *p.readFds
+                       tmpWriteFds = *p.writeFds
+
+                       n, e = syscall.Select(p.maxFd + 1, &tmpReadFds, &tmpWriteFds, nil, timeout)
+                       if e != syscall.EINTR {
+                               break
+                       }
+               }
+               if e != 0 {
+                       return -1, 0, os.NewSyscallError("select", e)
+               }
+               if n == 0 {
+                       return -1, 0, nil
+               }
+
+               p.nReady = n
+               *p.readyReadFds = tmpReadFds
+               *p.readyWriteFds = tmpWriteFds
+               p.lastFd = 0
+       }
+
+       flag := false
+       for i := p.lastFd; i < p.maxFd + 1; i++ {
+               if syscall.FDIsSet(i, p.readyReadFds) {
+                       flag = true
+                       mode = 'r'
+                       syscall.FDClr(i, p.readyReadFds)
+               } else if syscall.FDIsSet(i, p.readyWriteFds) {
+                       flag = true
+                       mode = 'w'
+                       syscall.FDClr(i, p.readyWriteFds)
+               }
+               if flag {
+                       if !syscall.FDIsSet(i, p.repeatFds) {
+                               p.DelFD(i, mode)
+                       }
+                       p.nReady--
+                       p.lastFd = i
+                       return i, mode, nil
+               }
+       }
+
+       // Will not reach here.  Just to shut up the compiler.
+       return -1, 0, nil
+}
+
+func (p *pollster) Close() os.Error {
+       return nil
+}