hotspot/src/os/linux/vm/hpi_linux.hpp

Print this page
rev 611 : Merge


  56 
  57 
  58 // HPI_SocketInterface
  59 
  60 inline int hpi::socket_close(int fd) {
  61   return ::close(fd);
  62 }
  63 
  64 inline int hpi::socket(int domain, int type, int protocol) {
  65   return ::socket(domain, type, protocol);
  66 }
  67 
  68 inline int hpi::recv(int fd, char *buf, int nBytes, int flags) {
  69   RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags));
  70 }
  71 
  72 inline int hpi::send(int fd, char *buf, int nBytes, int flags) {
  73   RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags));
  74 }
  75 




  76 inline int hpi::timeout(int fd, long timeout) {
  77   julong prevtime,newtime;
  78   struct timeval t;
  79 
  80   gettimeofday(&t, NULL);
  81   prevtime = ((julong)t.tv_sec * 1000)  +  t.tv_usec / 1000;
  82 
  83   for(;;) {
  84     struct pollfd pfd;
  85 
  86     pfd.fd = fd;
  87     pfd.events = POLLIN | POLLERR;
  88   
  89     int res = ::poll(&pfd, 1, timeout);
  90 
  91     if (res == OS_ERR && errno == EINTR) {
  92 
  93       // On Linux any value < 0 means "forever"
  94 
  95       if(timeout >= 0) {




  56 
  57 
  58 // HPI_SocketInterface
  59 
  60 inline int hpi::socket_close(int fd) {
  61   return ::close(fd);
  62 }
  63 
  64 inline int hpi::socket(int domain, int type, int protocol) {
  65   return ::socket(domain, type, protocol);
  66 }
  67 
  68 inline int hpi::recv(int fd, char *buf, int nBytes, int flags) {
  69   RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags));
  70 }
  71 
  72 inline int hpi::send(int fd, char *buf, int nBytes, int flags) {
  73   RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags));
  74 }
  75 
  76 inline int hpi::raw_send(int fd, char *buf, int nBytes, int flags) {
  77   return send(fd, buf, nBytes, flags);
  78 }
  79 
  80 inline int hpi::timeout(int fd, long timeout) {
  81   julong prevtime,newtime;
  82   struct timeval t;
  83 
  84   gettimeofday(&t, NULL);
  85   prevtime = ((julong)t.tv_sec * 1000)  +  t.tv_usec / 1000;
  86 
  87   for(;;) {
  88     struct pollfd pfd;
  89 
  90     pfd.fd = fd;
  91     pfd.events = POLLIN | POLLERR;
  92   
  93     int res = ::poll(&pfd, 1, timeout);
  94 
  95     if (res == OS_ERR && errno == EINTR) {
  96 
  97       // On Linux any value < 0 means "forever"
  98 
  99       if(timeout >= 0) {