提交 964c0070 编写于 作者: P phh

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
上级 e3a20f79
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// All local includes have been commented out. // All local includes have been commented out.
*/ */
#ifndef JVM_MD_H #ifndef JVM_MD_H
#define JVM_MD_H #define JVM_MD_H
...@@ -59,6 +58,7 @@ ...@@ -59,6 +58,7 @@
#include <dirent.h> /* For DIR */ #include <dirent.h> /* For DIR */
#include <sys/param.h> /* For MAXPATHLEN */ #include <sys/param.h> /* For MAXPATHLEN */
#include <sys/socket.h> /* For socklen_t */
#include <unistd.h> /* For F_OK, R_OK, W_OK */ #include <unistd.h> /* For F_OK, R_OK, W_OK */
#define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"} #define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"}
...@@ -128,8 +128,4 @@ ...@@ -128,8 +128,4 @@
#endif #endif
#endif /* JVM_MD_H */ #endif /* JVM_MD_H */
// Reconciliation History
// jvm_solaris.h 1.6 99/06/22 16:38:47
// End
#endif // OS_BSD_VM_JVM_BSD_H #endif // OS_BSD_VM_JVM_BSD_H
...@@ -198,15 +198,15 @@ inline int os::socket(int domain, int type, int protocol) { ...@@ -198,15 +198,15 @@ inline int os::socket(int domain, int type, int protocol) {
return ::socket(domain, type, protocol); return ::socket(domain, type, protocol);
} }
inline int os::recv(int fd, char *buf, int nBytes, int flags) { inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags)); RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags));
} }
inline int os::send(int fd, char *buf, int nBytes, int flags) { inline int os::send(int fd, char* buf, size_t nBytes, uint flags) {
RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) 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); return os::send(fd, buf, nBytes, flags);
} }
...@@ -246,57 +246,52 @@ inline int os::listen(int fd, int count) { ...@@ -246,57 +246,52 @@ inline int os::listen(int fd, int count) {
return ::listen(fd, count); 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)); RESTARTABLE_RETURN_INT(::connect(fd, him, len));
} }
inline int os::accept(int fd, struct sockaddr *him, int *len) { inline int os::accept(int fd, struct sockaddr* him, socklen_t* 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.
// At least OpenBSD and FreeBSD can return EINTR from accept. // 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, inline int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags,
sockaddr *from, int *fromlen) { sockaddr* from, socklen_t* fromlen) {
RESTARTABLE_RETURN_INT(::recvfrom(fd, buf, nBytes, (unsigned int) flags, 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, inline int os::sendto(int fd, char* buf, size_t len, uint flags,
struct sockaddr *to, int tolen) { struct sockaddr *to, socklen_t tolen) {
RESTARTABLE_RETURN_INT(::sendto(fd, buf, len, (unsigned int) flags, to, 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); 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); return ::bind(fd, him, len);
} }
inline int os::get_sock_name(int fd, struct sockaddr *him, int *len){ inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) {
return ::getsockname(fd, 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); 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); return ::gethostbyname(name);
} }
inline int os::get_sock_opt(int fd, int level, int optname, inline int os::get_sock_opt(int fd, int level, int optname,
char *optval, int* optlen){ char *optval, socklen_t* optlen) {
return ::getsockopt(fd, level, optname, optval, (socklen_t *)optlen); return ::getsockopt(fd, level, optname, optval, optlen);
} }
inline int os::set_sock_opt(int fd, int level, int optname, 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); return ::setsockopt(fd, level, optname, optval, optlen);
} }
#endif // OS_BSD_VM_OS_BSD_INLINE_HPP #endif // OS_BSD_VM_OS_BSD_INLINE_HPP
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// All local includes have been commented out. // All local includes have been commented out.
*/ */
#ifndef JVM_MD_H #ifndef JVM_MD_H
#define JVM_MD_H #define JVM_MD_H
...@@ -44,6 +43,7 @@ ...@@ -44,6 +43,7 @@
#include <dirent.h> /* For DIR */ #include <dirent.h> /* For DIR */
#include <sys/param.h> /* For MAXPATHLEN */ #include <sys/param.h> /* For MAXPATHLEN */
#include <sys/socket.h> /* For socklen_t */
#include <unistd.h> /* For F_OK, R_OK, W_OK */ #include <unistd.h> /* For F_OK, R_OK, W_OK */
#define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"} #define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"}
...@@ -95,8 +95,4 @@ ...@@ -95,8 +95,4 @@
#endif /* JVM_MD_H */ #endif /* JVM_MD_H */
// Reconciliation History
// jvm_solaris.h 1.6 99/06/22 16:38:47
// End
#endif // OS_LINUX_VM_JVM_LINUX_H #endif // OS_LINUX_VM_JVM_LINUX_H
...@@ -202,15 +202,15 @@ inline int os::socket(int domain, int type, int protocol) { ...@@ -202,15 +202,15 @@ inline int os::socket(int domain, int type, int protocol) {
return ::socket(domain, type, protocol); return ::socket(domain, type, protocol);
} }
inline int os::recv(int fd, char *buf, int nBytes, int flags) { inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags)); RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags));
} }
inline int os::send(int fd, char *buf, int nBytes, int flags) { inline int os::send(int fd, char* buf, size_t nBytes, uint flags) {
RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) 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); return os::send(fd, buf, nBytes, flags);
} }
...@@ -250,57 +250,53 @@ inline int os::listen(int fd, int count) { ...@@ -250,57 +250,53 @@ inline int os::listen(int fd, int count) {
return ::listen(fd, count); 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)); RESTARTABLE_RETURN_INT(::connect(fd, him, len));
} }
inline int os::accept(int fd, struct sockaddr *him, int *len) { inline int os::accept(int fd, struct sockaddr* him, socklen_t* len) {
// This cast is from int to unsigned int on linux. Since we // Linux doc says this can't return EINTR, unlike accept() on Solaris.
// only pass the parameter "len" around the vm and don't try to // But see attachListener_linux.cpp, LinuxAttachListener::dequeue().
// fetch it's value, this cast is safe for now. The java.net group return (int)::accept(fd, him, len);
// may need and want to change this interface someday if socklen_t goes
// to 64 bits on some platform that we support.
// Linux doc says this can't return EINTR, unlike accept() on Solaris
return ::accept(fd, him, (socklen_t *)len);
} }
inline int os::recvfrom(int fd, char *buf, int nBytes, int flags, inline int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags,
sockaddr *from, int *fromlen) { sockaddr* from, socklen_t* fromlen) {
RESTARTABLE_RETURN_INT(::recvfrom(fd, buf, nBytes, (unsigned int) flags, 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, inline int os::sendto(int fd, char* buf, size_t len, uint flags,
struct sockaddr *to, int tolen) { struct sockaddr* to, socklen_t tolen) {
RESTARTABLE_RETURN_INT(::sendto(fd, buf, len, (unsigned int) flags, to, 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); 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); return ::bind(fd, him, len);
} }
inline int os::get_sock_name(int fd, struct sockaddr *him, int *len){ inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) {
return ::getsockname(fd, 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); 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); return ::gethostbyname(name);
} }
inline int os::get_sock_opt(int fd, int level, int optname, inline int os::get_sock_opt(int fd, int level, int optname,
char *optval, int* optlen){ char* optval, socklen_t* optlen) {
return ::getsockopt(fd, level, optname, optval, (socklen_t *)optlen); return ::getsockopt(fd, level, optname, optval, optlen);
} }
inline int os::set_sock_opt(int fd, int level, int optname, 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); return ::setsockopt(fd, level, optname, optval, optlen);
} }
#endif // OS_LINUX_VM_OS_LINUX_INLINE_HPP #endif // OS_LINUX_VM_OS_LINUX_INLINE_HPP
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// All local includes have been commented out. // All local includes have been commented out.
*/ */
#ifndef JVM_MD_H #ifndef JVM_MD_H
#define JVM_MD_H #define JVM_MD_H
...@@ -44,6 +43,7 @@ ...@@ -44,6 +43,7 @@
#include <dirent.h> /* For DIR */ #include <dirent.h> /* For DIR */
#include <sys/param.h> /* For MAXPATHLEN */ #include <sys/param.h> /* For MAXPATHLEN */
#include <sys/socket.h> /* For socklen_t */
#include <unistd.h> /* For F_OK, R_OK, W_OK */ #include <unistd.h> /* For F_OK, R_OK, W_OK */
#include <sys/int_types.h> /* for intptr_t types (64 Bit cleanliness) */ #include <sys/int_types.h> /* for intptr_t types (64 Bit cleanliness) */
...@@ -82,7 +82,6 @@ ...@@ -82,7 +82,6 @@
#define JVM_O_EXCL O_EXCL #define JVM_O_EXCL O_EXCL
#define JVM_O_CREAT O_CREAT #define JVM_O_CREAT O_CREAT
/* Signal definitions */ /* Signal definitions */
#define BREAK_SIGNAL SIGQUIT /* Thread dumping support. */ #define BREAK_SIGNAL SIGQUIT /* Thread dumping support. */
......
...@@ -6363,17 +6363,16 @@ int os::socket_close(int fd) { ...@@ -6363,17 +6363,16 @@ int os::socket_close(int fd) {
RESTARTABLE_RETURN_INT(::close(fd)); RESTARTABLE_RETURN_INT(::close(fd));
} }
int os::recv(int fd, char *buf, int nBytes, int flags) { int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
INTERRUPTIBLE_RETURN_INT(::recv(fd, buf, nBytes, flags), os::Solaris::clear_interrupted); INTERRUPTIBLE_RETURN_INT((int)::recv(fd, buf, nBytes, flags), os::Solaris::clear_interrupted);
} }
int os::send(int fd, char* buf, size_t nBytes, uint flags) {
int os::send(int fd, char *buf, int nBytes, int flags) { INTERRUPTIBLE_RETURN_INT((int)::send(fd, buf, nBytes, flags), os::Solaris::clear_interrupted);
INTERRUPTIBLE_RETURN_INT(::send(fd, buf, nBytes, flags), os::Solaris::clear_interrupted);
} }
int os::raw_send(int fd, char *buf, int nBytes, int flags) { int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) {
RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags)); RESTARTABLE_RETURN_INT((int)::send(fd, buf, nBytes, flags));
} }
// As both poll and select can be interrupted by signals, we have to be // As both poll and select can be interrupted by signals, we have to be
...@@ -6408,9 +6407,9 @@ int os::timeout(int fd, long timeout) { ...@@ -6408,9 +6407,9 @@ int os::timeout(int fd, long timeout) {
} }
} }
int os::connect(int fd, struct sockaddr *him, int len) { int os::connect(int fd, struct sockaddr *him, socklen_t len) {
int _result; int _result;
INTERRUPTIBLE_NORESTART(::connect(fd, him, len), _result, INTERRUPTIBLE_NORESTART(::connect(fd, him, len), _result,\
os::Solaris::clear_interrupted); os::Solaris::clear_interrupted);
// Depending on when thread interruption is reset, _result could be // Depending on when thread interruption is reset, _result could be
...@@ -6419,7 +6418,7 @@ int os::connect(int fd, struct sockaddr *him, int len) { ...@@ -6419,7 +6418,7 @@ int os::connect(int fd, struct sockaddr *him, int len) {
if (((_result == OS_INTRPT) || (_result == OS_ERR)) if (((_result == OS_INTRPT) || (_result == OS_ERR))
&& (errno == EINTR)) { && (errno == EINTR)) {
/* restarting a connect() changes its errno semantics */ /* restarting a connect() changes its errno semantics */
INTERRUPTIBLE(::connect(fd, him, len), _result, INTERRUPTIBLE(::connect(fd, him, len), _result,\
os::Solaris::clear_interrupted); os::Solaris::clear_interrupted);
/* undo these changes */ /* undo these changes */
if (_result == OS_ERR) { if (_result == OS_ERR) {
...@@ -6434,43 +6433,38 @@ int os::connect(int fd, struct sockaddr *him, int len) { ...@@ -6434,43 +6433,38 @@ int os::connect(int fd, struct sockaddr *him, int len) {
return _result; return _result;
} }
int os::accept(int fd, struct sockaddr *him, int *len) { int os::accept(int fd, struct sockaddr* him, socklen_t* len) {
if (fd < 0) if (fd < 0) {
return OS_ERR; return OS_ERR;
INTERRUPTIBLE_RETURN_INT((int)::accept(fd, him,\
(socklen_t*) len), os::Solaris::clear_interrupted);
} }
INTERRUPTIBLE_RETURN_INT((int)::accept(fd, him, len),\
os::Solaris::clear_interrupted);
}
int os::recvfrom(int fd, char *buf, int nBytes, int flags, int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags,
sockaddr *from, int *fromlen) { sockaddr* from, socklen_t* fromlen) {
//%%note jvm_r11 INTERRUPTIBLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes, flags, from, fromlen),\
INTERRUPTIBLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes,\ os::Solaris::clear_interrupted);
flags, from, fromlen), os::Solaris::clear_interrupted);
} }
int os::sendto(int fd, char *buf, int len, int flags, int os::sendto(int fd, char* buf, size_t len, uint flags,
struct sockaddr *to, int tolen) { struct sockaddr* to, socklen_t tolen) {
//%%note jvm_r11 INTERRUPTIBLE_RETURN_INT((int)::sendto(fd, buf, len, flags, to, tolen),\
INTERRUPTIBLE_RETURN_INT((int)::sendto(fd, buf, len, flags,\ os::Solaris::clear_interrupted);
to, tolen), os::Solaris::clear_interrupted);
} }
int os::socket_available(int fd, jint *pbytes) { int os::socket_available(int fd, jint *pbytes) {
if (fd < 0) if (fd < 0) {
return OS_OK; return OS_OK;
}
int ret; int ret;
RESTARTABLE(::ioctl(fd, FIONREAD, pbytes), ret); RESTARTABLE(::ioctl(fd, FIONREAD, pbytes), ret);
// note: ioctl can return 0 when successful, JVM_SocketAvailable
//%% note ioctl can return 0 when successful, JVM_SocketAvailable
// is expected to return 0 on failure and 1 on success to the jdk. // is expected to return 0 on failure and 1 on success to the jdk.
return (ret == OS_ERR) ? 0 : 1; return (ret == OS_ERR) ? 0 : 1;
} }
int os::bind(int fd, struct sockaddr* him, socklen_t len) {
int os::bind(int fd, struct sockaddr *him, int len) {
INTERRUPTIBLE_RETURN_INT_NORESTART(::bind(fd, him, len),\ INTERRUPTIBLE_RETURN_INT_NORESTART(::bind(fd, him, len),\
os::Solaris::clear_interrupted); os::Solaris::clear_interrupted);
} }
...@@ -243,8 +243,8 @@ inline int os::socket_shutdown(int fd, int howto){ ...@@ -243,8 +243,8 @@ inline int os::socket_shutdown(int fd, int howto){
return ::shutdown(fd, howto); return ::shutdown(fd, howto);
} }
inline int os::get_sock_name(int fd, struct sockaddr *him, int *len){ inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len){
return ::getsockname(fd, 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){
...@@ -254,13 +254,14 @@ inline int os::get_host_name(char* name, int namelen){ ...@@ -254,13 +254,14 @@ inline int os::get_host_name(char* name, int namelen){
inline struct hostent* os::get_host_by_name(char* name) { inline struct hostent* os::get_host_by_name(char* name) {
return ::gethostbyname(name); return ::gethostbyname(name);
} }
inline int os::get_sock_opt(int fd, int level, int optname, inline int os::get_sock_opt(int fd, int level, int optname,
char *optval, int* optlen){ char* optval, socklen_t* optlen) {
return ::getsockopt(fd, level, optname, optval, (socklen_t*) optlen); return ::getsockopt(fd, level, optname, optval, optlen);
} }
inline int os::set_sock_opt(int fd, int level, int optname, 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); return ::setsockopt(fd, level, optname, optval, optlen);
} }
#endif // OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP #endif // OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
* *
*/ */
#ifndef OS_WINDOWS_VM_JVM_WINDOWS_H
#define OS_WINDOWS_VM_JVM_WINDOWS_H
#ifndef _JAVASOFT_JVM_MD_H_ #ifndef _JAVASOFT_JVM_MD_H_
#define _JAVASOFT_JVM_MD_H_ #define _JAVASOFT_JVM_MD_H_
...@@ -54,10 +57,10 @@ typedef struct _MODULEINFO { ...@@ -54,10 +57,10 @@ typedef struct _MODULEINFO {
#include <Psapi.h> #include <Psapi.h>
#endif #endif
#include <Tlhelp32.h> #include <Tlhelp32.h>
typedef unsigned int socklen_t;
// #include "jni.h" // #include "jni.h"
#define JNI_ONLOAD_SYMBOLS {"_JNI_OnLoad@8", "JNI_OnLoad"} #define JNI_ONLOAD_SYMBOLS {"_JNI_OnLoad@8", "JNI_OnLoad"}
...@@ -129,3 +132,5 @@ JVM_GetThreadInterruptEvent(); ...@@ -129,3 +132,5 @@ JVM_GetThreadInterruptEvent();
#define SHUTDOWN2_SIGNAL SIGTERM #define SHUTDOWN2_SIGNAL SIGTERM
#endif /* !_JAVASOFT_JVM_MD_H_ */ #endif /* !_JAVASOFT_JVM_MD_H_ */
#endif // OS_WINDOWS_VM_JVM_WINDOWS_H
...@@ -4882,39 +4882,39 @@ int os::listen(int fd, int count) { ...@@ -4882,39 +4882,39 @@ int os::listen(int fd, int count) {
return 0; return 0;
} }
int os::connect(int fd, struct sockaddr *him, int len) { int os::connect(int fd, struct sockaddr* him, socklen_t len) {
ShouldNotReachHere(); ShouldNotReachHere();
return 0; return 0;
} }
int os::accept(int fd, struct sockaddr *him, int *len) { int os::accept(int fd, struct sockaddr* him, socklen_t* len) {
ShouldNotReachHere(); ShouldNotReachHere();
return 0; return 0;
} }
int os::sendto(int fd, char *buf, int len, int flags, int os::sendto(int fd, char* buf, size_t len, uint flags,
struct sockaddr *to, int tolen) { struct sockaddr* to, socklen_t tolen) {
ShouldNotReachHere(); ShouldNotReachHere();
return 0; return 0;
} }
int os::recvfrom(int fd, char *buf, int nBytes, int flags, int os::recvfrom(int fd, char *buf, size_t nBytes, uint flags,
sockaddr *from, int *fromlen) { sockaddr* from, socklen_t* fromlen) {
ShouldNotReachHere(); ShouldNotReachHere();
return 0; return 0;
} }
int os::recv(int fd, char *buf, int nBytes, int flags) { int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
ShouldNotReachHere(); ShouldNotReachHere();
return 0; return 0;
} }
int os::send(int fd, char *buf, int nBytes, int flags) { int os::send(int fd, char* buf, size_t nBytes, uint flags) {
ShouldNotReachHere(); ShouldNotReachHere();
return 0; return 0;
} }
int os::raw_send(int fd, char *buf, int nBytes, int flags) { int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) {
ShouldNotReachHere(); ShouldNotReachHere();
return 0; return 0;
} }
...@@ -4934,24 +4934,24 @@ int os::socket_shutdown(int fd, int howto) { ...@@ -4934,24 +4934,24 @@ int os::socket_shutdown(int fd, int howto) {
return 0; return 0;
} }
int os::bind(int fd, struct sockaddr *him, int len) { int os::bind(int fd, struct sockaddr* him, socklen_t len) {
ShouldNotReachHere(); ShouldNotReachHere();
return 0; return 0;
} }
int os::get_sock_name(int fd, struct sockaddr *him, int *len) { int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) {
ShouldNotReachHere(); ShouldNotReachHere();
return 0; return 0;
} }
int os::get_sock_opt(int fd, int level, int optname, int os::get_sock_opt(int fd, int level, int optname,
char *optval, int* optlen) { char* optval, socklen_t* optlen) {
ShouldNotReachHere(); ShouldNotReachHere();
return 0; return 0;
} }
int os::set_sock_opt(int fd, int level, int optname, int os::set_sock_opt(int fd, int level, int optname,
const char *optval, int optlen) { const char* optval, socklen_t optlen) {
ShouldNotReachHere(); ShouldNotReachHere();
return 0; return 0;
} }
......
...@@ -3515,14 +3515,14 @@ JVM_END ...@@ -3515,14 +3515,14 @@ JVM_END
JVM_LEAF(jint, JVM_Recv(jint fd, char *buf, jint nBytes, jint flags)) JVM_LEAF(jint, JVM_Recv(jint fd, char *buf, jint nBytes, jint flags))
JVMWrapper2("JVM_Recv (0x%x)", fd); JVMWrapper2("JVM_Recv (0x%x)", fd);
//%note jvm_r6 //%note jvm_r6
return os::recv(fd, buf, nBytes, flags); return os::recv(fd, buf, (size_t)nBytes, (uint)flags);
JVM_END JVM_END
JVM_LEAF(jint, JVM_Send(jint fd, char *buf, jint nBytes, jint flags)) JVM_LEAF(jint, JVM_Send(jint fd, char *buf, jint nBytes, jint flags))
JVMWrapper2("JVM_Send (0x%x)", fd); JVMWrapper2("JVM_Send (0x%x)", fd);
//%note jvm_r6 //%note jvm_r6
return os::send(fd, buf, nBytes, flags); return os::send(fd, buf, (size_t)nBytes, (uint)flags);
JVM_END JVM_END
...@@ -3543,42 +3543,51 @@ JVM_END ...@@ -3543,42 +3543,51 @@ JVM_END
JVM_LEAF(jint, JVM_Connect(jint fd, struct sockaddr *him, jint len)) JVM_LEAF(jint, JVM_Connect(jint fd, struct sockaddr *him, jint len))
JVMWrapper2("JVM_Connect (0x%x)", fd); JVMWrapper2("JVM_Connect (0x%x)", fd);
//%note jvm_r6 //%note jvm_r6
return os::connect(fd, him, len); return os::connect(fd, him, (socklen_t)len);
JVM_END JVM_END
JVM_LEAF(jint, JVM_Bind(jint fd, struct sockaddr *him, jint len)) JVM_LEAF(jint, JVM_Bind(jint fd, struct sockaddr *him, jint len))
JVMWrapper2("JVM_Bind (0x%x)", fd); JVMWrapper2("JVM_Bind (0x%x)", fd);
//%note jvm_r6 //%note jvm_r6
return os::bind(fd, him, len); return os::bind(fd, him, (socklen_t)len);
JVM_END JVM_END
JVM_LEAF(jint, JVM_Accept(jint fd, struct sockaddr *him, jint *len)) JVM_LEAF(jint, JVM_Accept(jint fd, struct sockaddr *him, jint *len))
JVMWrapper2("JVM_Accept (0x%x)", fd); JVMWrapper2("JVM_Accept (0x%x)", fd);
//%note jvm_r6 //%note jvm_r6
return os::accept(fd, him, (int *)len); socklen_t socklen = (socklen_t)(*len);
jint result = os::accept(fd, him, &socklen);
*len = (jint)socklen;
return result;
JVM_END JVM_END
JVM_LEAF(jint, JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen)) JVM_LEAF(jint, JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen))
JVMWrapper2("JVM_RecvFrom (0x%x)", fd); JVMWrapper2("JVM_RecvFrom (0x%x)", fd);
//%note jvm_r6 //%note jvm_r6
return os::recvfrom(fd, buf, nBytes, flags, from, fromlen); socklen_t socklen = (socklen_t)(*fromlen);
jint result = os::recvfrom(fd, buf, (size_t)nBytes, (uint)flags, from, &socklen);
*fromlen = (int)socklen;
return result;
JVM_END JVM_END
JVM_LEAF(jint, JVM_GetSockName(jint fd, struct sockaddr *him, int *len)) JVM_LEAF(jint, JVM_GetSockName(jint fd, struct sockaddr *him, int *len))
JVMWrapper2("JVM_GetSockName (0x%x)", fd); JVMWrapper2("JVM_GetSockName (0x%x)", fd);
//%note jvm_r6 //%note jvm_r6
return os::get_sock_name(fd, him, len); socklen_t socklen = (socklen_t)(*len);
jint result = os::get_sock_name(fd, him, &socklen);
*len = (int)socklen;
return result;
JVM_END JVM_END
JVM_LEAF(jint, JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen)) JVM_LEAF(jint, JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen))
JVMWrapper2("JVM_SendTo (0x%x)", fd); JVMWrapper2("JVM_SendTo (0x%x)", fd);
//%note jvm_r6 //%note jvm_r6
return os::sendto(fd, buf, len, flags, to, tolen); return os::sendto(fd, buf, (size_t)len, (uint)flags, to, (socklen_t)tolen);
JVM_END JVM_END
...@@ -3592,21 +3601,26 @@ JVM_END ...@@ -3592,21 +3601,26 @@ JVM_END
JVM_LEAF(jint, JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen)) JVM_LEAF(jint, JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen))
JVMWrapper2("JVM_GetSockOpt (0x%x)", fd); JVMWrapper2("JVM_GetSockOpt (0x%x)", fd);
//%note jvm_r6 //%note jvm_r6
return os::get_sock_opt(fd, level, optname, optval, optlen); socklen_t socklen = (socklen_t)(*optlen);
jint result = os::get_sock_opt(fd, level, optname, optval, &socklen);
*optlen = (int)socklen;
return result;
JVM_END JVM_END
JVM_LEAF(jint, JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen)) JVM_LEAF(jint, JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen))
JVMWrapper2("JVM_GetSockOpt (0x%x)", fd); JVMWrapper2("JVM_GetSockOpt (0x%x)", fd);
//%note jvm_r6 //%note jvm_r6
return os::set_sock_opt(fd, level, optname, optval, optlen); return os::set_sock_opt(fd, level, optname, optval, (socklen_t)optlen);
JVM_END JVM_END
JVM_LEAF(int, JVM_GetHostName(char* name, int namelen)) JVM_LEAF(int, JVM_GetHostName(char* name, int namelen))
JVMWrapper("JVM_GetHostName"); JVMWrapper("JVM_GetHostName");
return os::get_host_name(name, namelen); return os::get_host_name(name, namelen);
JVM_END JVM_END
// Library support /////////////////////////////////////////////////////////////////////////// // Library support ///////////////////////////////////////////////////////////////////////////
JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name)) JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name))
...@@ -3647,6 +3661,7 @@ JVM_LEAF(void*, JVM_FindLibraryEntry(void* handle, const char* name)) ...@@ -3647,6 +3661,7 @@ JVM_LEAF(void*, JVM_FindLibraryEntry(void* handle, const char* name))
return os::dll_lookup(handle, name); return os::dll_lookup(handle, name);
JVM_END JVM_END
// Floating point support //////////////////////////////////////////////////////////////////// // Floating point support ////////////////////////////////////////////////////////////////////
JVM_LEAF(jboolean, JVM_IsNaN(jdouble a)) JVM_LEAF(jboolean, JVM_IsNaN(jdouble a))
...@@ -3655,7 +3670,6 @@ JVM_LEAF(jboolean, JVM_IsNaN(jdouble a)) ...@@ -3655,7 +3670,6 @@ JVM_LEAF(jboolean, JVM_IsNaN(jdouble a))
JVM_END JVM_END
// JNI version /////////////////////////////////////////////////////////////////////////////// // JNI version ///////////////////////////////////////////////////////////////////////////////
JVM_LEAF(jboolean, JVM_IsSupportedJNIVersion(jint version)) JVM_LEAF(jboolean, JVM_IsSupportedJNIVersion(jint version))
......
...@@ -584,25 +584,25 @@ class os: AllStatic { ...@@ -584,25 +584,25 @@ class os: AllStatic {
static int socket(int domain, int type, int protocol); static int socket(int domain, int type, int protocol);
static int socket_close(int fd); static int socket_close(int fd);
static int socket_shutdown(int fd, int howto); static int socket_shutdown(int fd, int howto);
static int recv(int fd, char *buf, int nBytes, int flags); static int recv(int fd, char* buf, size_t nBytes, uint flags);
static int send(int fd, char *buf, int nBytes, int flags); static int send(int fd, char* buf, size_t nBytes, uint flags);
static int raw_send(int fd, char *buf, int nBytes, int flags); static int raw_send(int fd, char* buf, size_t nBytes, uint flags);
static int timeout(int fd, long timeout); static int timeout(int fd, long timeout);
static int listen(int fd, int count); static int listen(int fd, int count);
static int connect(int fd, struct sockaddr *him, int len); static int connect(int fd, struct sockaddr* him, socklen_t len);
static int bind(int fd, struct sockaddr *him, int len); static int bind(int fd, struct sockaddr* him, socklen_t len);
static int accept(int fd, struct sockaddr *him, int *len); static int accept(int fd, struct sockaddr* him, socklen_t* len);
static int recvfrom(int fd, char *buf, int nbytes, int flags, static int recvfrom(int fd, char* buf, size_t nbytes, uint flags,
struct sockaddr *from, int *fromlen); struct sockaddr* from, socklen_t* fromlen);
static int get_sock_name(int fd, struct sockaddr *him, int *len); static int get_sock_name(int fd, struct sockaddr* him, socklen_t* len);
static int sendto(int fd, char *buf, int len, int flags, static int sendto(int fd, char* buf, size_t len, uint flags,
struct sockaddr *to, int tolen); struct sockaddr* to, socklen_t tolen);
static int socket_available(int fd, jint *pbytes); static int socket_available(int fd, jint* pbytes);
static int get_sock_opt(int fd, int level, int optname, static int get_sock_opt(int fd, int level, int optname,
char *optval, int* optlen); char* optval, socklen_t* optlen);
static int set_sock_opt(int fd, int level, int optname, static int set_sock_opt(int fd, int level, int optname,
const char *optval, int optlen); const char* optval, socklen_t optlen);
static int get_host_name(char* name, int namelen); static int get_host_name(char* name, int namelen);
static struct hostent* get_host_by_name(char* name); static struct hostent* get_host_by_name(char* name);
...@@ -715,7 +715,6 @@ class os: AllStatic { ...@@ -715,7 +715,6 @@ class os: AllStatic {
# include "os_bsd_zero.hpp" # include "os_bsd_zero.hpp"
#endif #endif
// debugging support (mostly used by debug.cpp but also fatal error handler) // debugging support (mostly used by debug.cpp but also fatal error handler)
static bool find(address pc, outputStream* st = tty); // OS specific function to make sense out of an address static bool find(address pc, outputStream* st = tty); // OS specific function to make sense out of an address
......
...@@ -1021,7 +1021,7 @@ int networkStream::read(char *buf, size_t len) { ...@@ -1021,7 +1021,7 @@ int networkStream::read(char *buf, size_t len) {
void networkStream::flush() { void networkStream::flush() {
if (size() != 0) { if (size() != 0) {
int result = os::raw_send(_socket, (char *)base(), (int)size(), 0); int result = os::raw_send(_socket, (char *)base(), size(), 0);
assert(result != -1, "connection error"); assert(result != -1, "connection error");
assert(result == (int)size(), "didn't send enough data"); assert(result == (int)size(), "didn't send enough data");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册