$OpenBSD: patch-hotspot_src_os_bsd_vm_hpi_bsd_hpp,v 1.4 2009/06/10 19:01:09 kurt Exp $
--- hotspot/src/os/bsd/vm/hpi_bsd.hpp.orig	Tue Jun  2 13:44:43 2009
+++ hotspot/src/os/bsd/vm/hpi_bsd.hpp	Wed Jun  3 16:06:36 2009
@@ -36,7 +36,7 @@
 // HPI_FileInterface
 
 inline int hpi::close(int fd) {
-  return ::close(fd);
+  RESTARTABLE_RETURN_INT(::close(fd)); 
 }
 
 inline size_t hpi::read(int fd, void *buf, unsigned int nBytes) {
@@ -55,7 +55,7 @@ inline size_t hpi::write(int fd, const void *buf, unsi
 // HPI_SocketInterface
 
 inline int hpi::socket_close(int fd) {
-  return ::close(fd);
+  RESTARTABLE_RETURN_INT(::close(fd));
 }
 
 inline int hpi::socket(int domain, int type, int protocol) {
@@ -120,9 +120,9 @@ inline int hpi::accept(int fd, struct sockaddr *him, i
   // fetch it's value, this cast is safe for now. The java.net group
   // may need and want to change this interface someday if socklen_t goes
   // to 64 bits on some platform that we support.
-  // Bsd doc says this can't return EINTR, unlike accept() on Solaris
+  // At least OpenBSD and FreeBSD can return EINTR from accept.
 
-  return ::accept(fd, him, (socklen_t *)len);
+  RESTARTABLE_RETURN_INT(::accept(fd, him, (socklen_t *)len));
 }
 
 inline int hpi::recvfrom(int fd, char *buf, int nBytes, int flags,
@@ -136,12 +136,16 @@ inline int hpi::sendto(int fd, char *buf, int len, int
 }
 
 inline int hpi::socket_available(int fd, jint *pbytes) {
-  // Bsd doc says EINTR not returned, unlike Solaris
-  int ret = ::ioctl(fd, FIONREAD, pbytes);
+  int ret;
 
+  if (fd < 0)
+    return OS_OK;
+
+  RESTARTABLE(::ioctl(fd, FIONREAD, pbytes), ret);
+
   //%% note ioctl can return 0 when successful, JVM_SocketAvailable
   // is expected to return 0 on failure and 1 on success to the jdk.
-  return (ret < 0) ? 0 : 1;
+  return (ret == OS_ERR) ? 0 : 1;
 }
 
 
