Mercurial > hg > truffle
diff src/os/bsd/vm/os_bsd.inline.hpp @ 4717:11c26bfcf8c7
7091417: recvfrom's 6th input should be of type socklen_t
Summary: Revamp class os's socket method formal args to match socket.h, insert casts in appropriate places, and copyin-copyout int*'s that s/b socklen_t*'s in jvm.cpp.
Reviewed-by: coleenp, dholmes
Contributed-by: erik.gahlin@oracle.com, rickard.backman@oracle.com, nils.loodin@oracle.com, markus.gronlund@oracle.com
author | phh |
---|---|
date | Wed, 21 Dec 2011 15:48:16 -0500 |
parents | f08d439fab8c |
children | d2a62e0f25eb |
line wrap: on
line diff
--- a/src/os/bsd/vm/os_bsd.inline.hpp Mon Dec 19 21:38:51 2011 -0800 +++ b/src/os/bsd/vm/os_bsd.inline.hpp Wed Dec 21 15:48:16 2011 -0500 @@ -198,15 +198,15 @@ return ::socket(domain, type, protocol); } -inline int os::recv(int fd, char *buf, int nBytes, int flags) { - RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags)); +inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) { + RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags)); } -inline int os::send(int fd, char *buf, int nBytes, int flags) { - RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags)); +inline int os::send(int fd, char* buf, size_t nBytes, uint flags) { + RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags)); } -inline int os::raw_send(int fd, char *buf, int nBytes, int flags) { +inline int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) { return os::send(fd, buf, nBytes, flags); } @@ -246,57 +246,52 @@ return ::listen(fd, count); } -inline int os::connect(int fd, struct sockaddr *him, int len) { +inline int os::connect(int fd, struct sockaddr* him, socklen_t len) { RESTARTABLE_RETURN_INT(::connect(fd, him, len)); } -inline int os::accept(int fd, struct sockaddr *him, int *len) { - // This cast is from int to unsigned int on bsd. Since we - // only pass the parameter "len" around the vm and don't try to - // 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. - +inline int os::accept(int fd, struct sockaddr* him, socklen_t* len) { // At least OpenBSD and FreeBSD can return EINTR from accept. - RESTARTABLE_RETURN_INT(::accept(fd, him, (socklen_t *)len)); + RESTARTABLE_RETURN_INT(::accept(fd, him, len)); } -inline int os::recvfrom(int fd, char *buf, int nBytes, int flags, - sockaddr *from, int *fromlen) { - RESTARTABLE_RETURN_INT(::recvfrom(fd, buf, nBytes, (unsigned int) flags, from, (socklen_t *)fromlen)); +inline int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags, + sockaddr* from, socklen_t* fromlen) { + RESTARTABLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes, flags, from, fromlen)); } -inline int os::sendto(int fd, char *buf, int len, int flags, - struct sockaddr *to, int tolen) { - RESTARTABLE_RETURN_INT(::sendto(fd, buf, len, (unsigned int) flags, to, tolen)); +inline int os::sendto(int fd, char* buf, size_t len, uint flags, + struct sockaddr *to, socklen_t tolen) { + RESTARTABLE_RETURN_INT((int)::sendto(fd, buf, len, flags, to, tolen)); } -inline int os::socket_shutdown(int fd, int howto){ +inline int os::socket_shutdown(int fd, int howto) { return ::shutdown(fd, howto); } -inline int os::bind(int fd, struct sockaddr *him, int len){ +inline int os::bind(int fd, struct sockaddr* him, socklen_t len) { return ::bind(fd, him, len); } -inline int os::get_sock_name(int fd, struct sockaddr *him, int *len){ - return ::getsockname(fd, him, (socklen_t *)len); +inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) { + return ::getsockname(fd, him, len); } -inline int os::get_host_name(char* name, int namelen){ +inline int os::get_host_name(char* name, int namelen) { return ::gethostname(name, namelen); } -inline struct hostent* os::get_host_by_name(char* name) { +inline struct hostent* os::get_host_by_name(char* name) { return ::gethostbyname(name); } + inline int os::get_sock_opt(int fd, int level, int optname, - char *optval, int* optlen){ - return ::getsockopt(fd, level, optname, optval, (socklen_t *)optlen); + char *optval, socklen_t* optlen) { + return ::getsockopt(fd, level, optname, optval, optlen); } inline int os::set_sock_opt(int fd, int level, int optname, - const char *optval, int optlen){ + const char* optval, socklen_t optlen) { return ::setsockopt(fd, level, optname, optval, optlen); } #endif // OS_BSD_VM_OS_BSD_INLINE_HPP