hotspot/src/os/linux/vm/os_linux.inline.hpp
changeset 11256 025cd1741566
parent 8921 14bfe81f2a9d
child 13195 be27e1b6a4b9
equal deleted inserted replaced
11255:7d28e253b4b0 11256:025cd1741566
   200 
   200 
   201 inline int os::socket(int domain, int type, int protocol) {
   201 inline int os::socket(int domain, int type, int protocol) {
   202   return ::socket(domain, type, protocol);
   202   return ::socket(domain, type, protocol);
   203 }
   203 }
   204 
   204 
   205 inline int os::recv(int fd, char *buf, int nBytes, int flags) {
   205 inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
   206   RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags));
   206   RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags));
   207 }
   207 }
   208 
   208 
   209 inline int os::send(int fd, char *buf, int nBytes, int flags) {
   209 inline int os::send(int fd, char* buf, size_t nBytes, uint flags) {
   210   RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags));
   210   RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags));
   211 }
   211 }
   212 
   212 
   213 inline int os::raw_send(int fd, char *buf, int nBytes, int flags) {
   213 inline int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) {
   214   return os::send(fd, buf, nBytes, flags);
   214   return os::send(fd, buf, nBytes, flags);
   215 }
   215 }
   216 
   216 
   217 inline int os::timeout(int fd, long timeout) {
   217 inline int os::timeout(int fd, long timeout) {
   218   julong prevtime,newtime;
   218   julong prevtime,newtime;
   248 
   248 
   249 inline int os::listen(int fd, int count) {
   249 inline int os::listen(int fd, int count) {
   250   return ::listen(fd, count);
   250   return ::listen(fd, count);
   251 }
   251 }
   252 
   252 
   253 inline int os::connect(int fd, struct sockaddr *him, int len) {
   253 inline int os::connect(int fd, struct sockaddr* him, socklen_t len) {
   254   RESTARTABLE_RETURN_INT(::connect(fd, him, len));
   254   RESTARTABLE_RETURN_INT(::connect(fd, him, len));
   255 }
   255 }
   256 
   256 
   257 inline int os::accept(int fd, struct sockaddr *him, int *len) {
   257 inline int os::accept(int fd, struct sockaddr* him, socklen_t* len) {
   258   // This cast is from int to unsigned int on linux.  Since we
   258   // Linux doc says this can't return EINTR, unlike accept() on Solaris.
   259   // only pass the parameter "len" around the vm and don't try to
   259   // But see attachListener_linux.cpp, LinuxAttachListener::dequeue().
   260   // fetch it's value, this cast is safe for now. The java.net group
   260   return (int)::accept(fd, him, len);
   261   // may need and want to change this interface someday if socklen_t goes
   261 }
   262   // to 64 bits on some platform that we support.
   262 
   263   // Linux doc says this can't return EINTR, unlike accept() on Solaris
   263 inline int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags,
   264 
   264                         sockaddr* from, socklen_t* fromlen) {
   265   return ::accept(fd, him, (socklen_t *)len);
   265   RESTARTABLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes, flags, from, fromlen));
   266 }
   266 }
   267 
   267 
   268 inline int os::recvfrom(int fd, char *buf, int nBytes, int flags,
   268 inline int os::sendto(int fd, char* buf, size_t len, uint flags,
   269                          sockaddr *from, int *fromlen) {
   269                       struct sockaddr* to, socklen_t tolen) {
   270   RESTARTABLE_RETURN_INT(::recvfrom(fd, buf, nBytes, (unsigned int) flags, from, (socklen_t *)fromlen));
   270   RESTARTABLE_RETURN_INT((int)::sendto(fd, buf, len, flags, to, tolen));
   271 }
   271 }
   272 
   272 
   273 inline int os::sendto(int fd, char *buf, int len, int flags,
   273 inline int os::socket_shutdown(int fd, int howto) {
   274                         struct sockaddr *to, int tolen) {
       
   275   RESTARTABLE_RETURN_INT(::sendto(fd, buf, len, (unsigned int) flags, to, tolen));
       
   276 }
       
   277 
       
   278 inline int os::socket_shutdown(int fd, int howto){
       
   279   return ::shutdown(fd, howto);
   274   return ::shutdown(fd, howto);
   280 }
   275 }
   281 
   276 
   282 inline int os::bind(int fd, struct sockaddr *him, int len){
   277 inline int os::bind(int fd, struct sockaddr* him, socklen_t len) {
   283   return ::bind(fd, him, len);
   278   return ::bind(fd, him, len);
   284 }
   279 }
   285 
   280 
   286 inline int os::get_sock_name(int fd, struct sockaddr *him, int *len){
   281 inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) {
   287   return ::getsockname(fd, him, (socklen_t *)len);
   282   return ::getsockname(fd, him, len);
   288 }
   283 }
   289 
   284 
   290 inline int os::get_host_name(char* name, int namelen){
   285 inline int os::get_host_name(char* name, int namelen) {
   291   return ::gethostname(name, namelen);
   286   return ::gethostname(name, namelen);
   292 }
   287 }
   293 
   288 
   294 inline struct hostent*  os::get_host_by_name(char* name) {
   289 inline struct hostent* os::get_host_by_name(char* name) {
   295   return ::gethostbyname(name);
   290   return ::gethostbyname(name);
   296 }
   291 }
       
   292 
   297 inline int os::get_sock_opt(int fd, int level, int optname,
   293 inline int os::get_sock_opt(int fd, int level, int optname,
   298                              char *optval, int* optlen){
   294                             char* optval, socklen_t* optlen) {
   299   return ::getsockopt(fd, level, optname, optval, (socklen_t *)optlen);
   295   return ::getsockopt(fd, level, optname, optval, optlen);
   300 }
   296 }
   301 
   297 
   302 inline int os::set_sock_opt(int fd, int level, int optname,
   298 inline int os::set_sock_opt(int fd, int level, int optname,
   303                              const char *optval, int optlen){
   299                             const char* optval, socklen_t optlen) {
   304   return ::setsockopt(fd, level, optname, optval, optlen);
   300   return ::setsockopt(fd, level, optname, optval, optlen);
   305 }
   301 }
   306 #endif // OS_LINUX_VM_OS_LINUX_INLINE_HPP
   302 #endif // OS_LINUX_VM_OS_LINUX_INLINE_HPP