196 |
196 |
197 inline int os::socket(int domain, int type, int protocol) { |
197 inline int os::socket(int domain, int type, int protocol) { |
198 return ::socket(domain, type, protocol); |
198 return ::socket(domain, type, protocol); |
199 } |
199 } |
200 |
200 |
201 inline int os::recv(int fd, char *buf, int nBytes, int flags) { |
201 inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) { |
202 RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags)); |
202 RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags)); |
203 } |
203 } |
204 |
204 |
205 inline int os::send(int fd, char *buf, int nBytes, int flags) { |
205 inline int os::send(int fd, char* buf, size_t nBytes, uint flags) { |
206 RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags)); |
206 RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags)); |
207 } |
207 } |
208 |
208 |
209 inline int os::raw_send(int fd, char *buf, int nBytes, int flags) { |
209 inline int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) { |
210 return os::send(fd, buf, nBytes, flags); |
210 return os::send(fd, buf, nBytes, flags); |
211 } |
211 } |
212 |
212 |
213 inline int os::timeout(int fd, long timeout) { |
213 inline int os::timeout(int fd, long timeout) { |
214 julong prevtime,newtime; |
214 julong prevtime,newtime; |
244 |
244 |
245 inline int os::listen(int fd, int count) { |
245 inline int os::listen(int fd, int count) { |
246 return ::listen(fd, count); |
246 return ::listen(fd, count); |
247 } |
247 } |
248 |
248 |
249 inline int os::connect(int fd, struct sockaddr *him, int len) { |
249 inline int os::connect(int fd, struct sockaddr* him, socklen_t len) { |
250 RESTARTABLE_RETURN_INT(::connect(fd, him, len)); |
250 RESTARTABLE_RETURN_INT(::connect(fd, him, len)); |
251 } |
251 } |
252 |
252 |
253 inline int os::accept(int fd, struct sockaddr *him, int *len) { |
253 inline int os::accept(int fd, struct sockaddr* him, socklen_t* len) { |
254 // This cast is from int to unsigned int on bsd. Since we |
|
255 // only pass the parameter "len" around the vm and don't try to |
|
256 // fetch it's value, this cast is safe for now. The java.net group |
|
257 // may need and want to change this interface someday if socklen_t goes |
|
258 // to 64 bits on some platform that we support. |
|
259 |
|
260 // At least OpenBSD and FreeBSD can return EINTR from accept. |
254 // At least OpenBSD and FreeBSD can return EINTR from accept. |
261 RESTARTABLE_RETURN_INT(::accept(fd, him, (socklen_t *)len)); |
255 RESTARTABLE_RETURN_INT(::accept(fd, him, len)); |
262 } |
256 } |
263 |
257 |
264 inline int os::recvfrom(int fd, char *buf, int nBytes, int flags, |
258 inline int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags, |
265 sockaddr *from, int *fromlen) { |
259 sockaddr* from, socklen_t* fromlen) { |
266 RESTARTABLE_RETURN_INT(::recvfrom(fd, buf, nBytes, (unsigned int) flags, from, (socklen_t *)fromlen)); |
260 RESTARTABLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes, flags, from, fromlen)); |
267 } |
261 } |
268 |
262 |
269 inline int os::sendto(int fd, char *buf, int len, int flags, |
263 inline int os::sendto(int fd, char* buf, size_t len, uint flags, |
270 struct sockaddr *to, int tolen) { |
264 struct sockaddr *to, socklen_t tolen) { |
271 RESTARTABLE_RETURN_INT(::sendto(fd, buf, len, (unsigned int) flags, to, tolen)); |
265 RESTARTABLE_RETURN_INT((int)::sendto(fd, buf, len, flags, to, tolen)); |
272 } |
266 } |
273 |
267 |
274 inline int os::socket_shutdown(int fd, int howto){ |
268 inline int os::socket_shutdown(int fd, int howto) { |
275 return ::shutdown(fd, howto); |
269 return ::shutdown(fd, howto); |
276 } |
270 } |
277 |
271 |
278 inline int os::bind(int fd, struct sockaddr *him, int len){ |
272 inline int os::bind(int fd, struct sockaddr* him, socklen_t len) { |
279 return ::bind(fd, him, len); |
273 return ::bind(fd, him, len); |
280 } |
274 } |
281 |
275 |
282 inline int os::get_sock_name(int fd, struct sockaddr *him, int *len){ |
276 inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) { |
283 return ::getsockname(fd, him, (socklen_t *)len); |
277 return ::getsockname(fd, him, len); |
284 } |
278 } |
285 |
279 |
286 inline int os::get_host_name(char* name, int namelen){ |
280 inline int os::get_host_name(char* name, int namelen) { |
287 return ::gethostname(name, namelen); |
281 return ::gethostname(name, namelen); |
288 } |
282 } |
289 |
283 |
290 inline struct hostent* os::get_host_by_name(char* name) { |
284 inline struct hostent* os::get_host_by_name(char* name) { |
291 return ::gethostbyname(name); |
285 return ::gethostbyname(name); |
292 } |
286 } |
|
287 |
293 inline int os::get_sock_opt(int fd, int level, int optname, |
288 inline int os::get_sock_opt(int fd, int level, int optname, |
294 char *optval, int* optlen){ |
289 char *optval, socklen_t* optlen) { |
295 return ::getsockopt(fd, level, optname, optval, (socklen_t *)optlen); |
290 return ::getsockopt(fd, level, optname, optval, optlen); |
296 } |
291 } |
297 |
292 |
298 inline int os::set_sock_opt(int fd, int level, int optname, |
293 inline int os::set_sock_opt(int fd, int level, int optname, |
299 const char *optval, int optlen){ |
294 const char* optval, socklen_t optlen) { |
300 return ::setsockopt(fd, level, optname, optval, optlen); |
295 return ::setsockopt(fd, level, optname, optval, optlen); |
301 } |
296 } |
302 #endif // OS_BSD_VM_OS_BSD_INLINE_HPP |
297 #endif // OS_BSD_VM_OS_BSD_INLINE_HPP |