PR#4097: suite
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7697 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
35d863e204
commit
4af5727d18
|
@ -29,7 +29,7 @@ CAMLprim value unix_accept(sock)
|
||||||
int oldvalue, oldvaluelen, newvalue, retcode;
|
int oldvalue, oldvaluelen, newvalue, retcode;
|
||||||
union sock_addr_union addr;
|
union sock_addr_union addr;
|
||||||
socklen_param_type addr_len;
|
socklen_param_type addr_len;
|
||||||
DWORD errcode = 0;
|
DWORD err = 0;
|
||||||
|
|
||||||
oldvaluelen = sizeof(oldvalue);
|
oldvaluelen = sizeof(oldvalue);
|
||||||
retcode = getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
|
retcode = getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
|
||||||
|
@ -43,7 +43,7 @@ CAMLprim value unix_accept(sock)
|
||||||
addr_len = sizeof(sock_addr);
|
addr_len = sizeof(sock_addr);
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
snew = accept(sconn, &addr.s_gen, &addr_len);
|
snew = accept(sconn, &addr.s_gen, &addr_len);
|
||||||
if (snew == INVALID_SOCKET) errcode = WSAGetLastError ();
|
if (snew == INVALID_SOCKET) err = WSAGetLastError ();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
if (retcode == 0) {
|
if (retcode == 0) {
|
||||||
/* Restore initial mode */
|
/* Restore initial mode */
|
||||||
|
@ -51,7 +51,7 @@ CAMLprim value unix_accept(sock)
|
||||||
(char *) &oldvalue, oldvaluelen);
|
(char *) &oldvalue, oldvaluelen);
|
||||||
}
|
}
|
||||||
if (snew == INVALID_SOCKET) {
|
if (snew == INVALID_SOCKET) {
|
||||||
win32_maperr(errcode);
|
win32_maperr(err);
|
||||||
uerror("accept", Nothing);
|
uerror("accept", Nothing);
|
||||||
}
|
}
|
||||||
Begin_roots2 (fd, adr)
|
Begin_roots2 (fd, adr)
|
||||||
|
|
|
@ -24,15 +24,15 @@ CAMLprim value unix_connect(socket, address)
|
||||||
SOCKET s = Socket_val(socket);
|
SOCKET s = Socket_val(socket);
|
||||||
union sock_addr_union addr;
|
union sock_addr_union addr;
|
||||||
socklen_param_type addr_len;
|
socklen_param_type addr_len;
|
||||||
DWORD errcode = 0;
|
DWORD err = 0;
|
||||||
|
|
||||||
get_sockaddr(address, &addr, &addr_len);
|
get_sockaddr(address, &addr, &addr_len);
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
if (connect(s, &addr.s_gen, addr_len) == -1)
|
if (connect(s, &addr.s_gen, addr_len) == -1)
|
||||||
errcode = WSAGetLastError();
|
err = WSAGetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
if (errcode) {
|
if (err) {
|
||||||
win32_maperr(errcode);
|
win32_maperr(err);
|
||||||
uerror("connect", Nothing);
|
uerror("connect", Nothing);
|
||||||
}
|
}
|
||||||
return Val_unit;
|
return Val_unit;
|
||||||
|
|
|
@ -24,7 +24,7 @@ CAMLprim value unix_read(value fd, value buf, value ofs, value vlen)
|
||||||
intnat len;
|
intnat len;
|
||||||
DWORD numbytes, numread;
|
DWORD numbytes, numread;
|
||||||
char iobuf[UNIX_BUFFER_SIZE];
|
char iobuf[UNIX_BUFFER_SIZE];
|
||||||
DOWRD errcode = 0;
|
DWORD err = 0;
|
||||||
|
|
||||||
Begin_root (buf);
|
Begin_root (buf);
|
||||||
len = Long_val(vlen);
|
len = Long_val(vlen);
|
||||||
|
@ -34,18 +34,18 @@ CAMLprim value unix_read(value fd, value buf, value ofs, value vlen)
|
||||||
SOCKET s = Socket_val(fd);
|
SOCKET s = Socket_val(fd);
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
ret = recv(s, iobuf, numbytes, 0);
|
ret = recv(s, iobuf, numbytes, 0);
|
||||||
if (ret == SOCKET_ERROR) errcode = WSAGetLastError();
|
if (ret == SOCKET_ERROR) err = WSAGetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
numread = ret;
|
numread = ret;
|
||||||
} else {
|
} else {
|
||||||
HANDLE h = Handle_val(fd);
|
HANDLE h = Handle_val(fd);
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
if (! ReadFile(h, iobuf, numbytes, &numread, NULL))
|
if (! ReadFile(h, iobuf, numbytes, &numread, NULL))
|
||||||
errcode = GetLastError();
|
err = GetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
}
|
}
|
||||||
if (errcode) {
|
if (err) {
|
||||||
win32_maperr(errcode);
|
win32_maperr(err);
|
||||||
uerror("read", Nothing);
|
uerror("read", Nothing);
|
||||||
}
|
}
|
||||||
memmove (&Byte(buf, Long_val(ofs)), iobuf, numread);
|
memmove (&Byte(buf, Long_val(ofs)), iobuf, numread);
|
||||||
|
|
|
@ -54,7 +54,7 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds, value
|
||||||
int retcode;
|
int retcode;
|
||||||
value res;
|
value res;
|
||||||
value read_list = Val_unit, write_list = Val_unit, except_list = Val_unit;
|
value read_list = Val_unit, write_list = Val_unit, except_list = Val_unit;
|
||||||
DWORD errcode = 0;
|
DWORD err = 0;
|
||||||
|
|
||||||
Begin_roots3 (readfds, writefds, exceptfds)
|
Begin_roots3 (readfds, writefds, exceptfds)
|
||||||
Begin_roots3 (read_list, write_list, except_list)
|
Begin_roots3 (read_list, write_list, except_list)
|
||||||
|
@ -81,10 +81,10 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds, value
|
||||||
}
|
}
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
if (select(FD_SETSIZE, &read, &write, &except, tvp) == -1)
|
if (select(FD_SETSIZE, &read, &write, &except, tvp) == -1)
|
||||||
errcode = WSAGetLastError();
|
err = WSAGetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
if (errcode) {
|
if (err) {
|
||||||
win32_maperr(errcode);
|
win32_maperr(err);
|
||||||
uerror("select", Nothing);
|
uerror("select", Nothing);
|
||||||
}
|
}
|
||||||
read_list = fdset_to_fdlist(readfds, &read);
|
read_list = fdset_to_fdlist(readfds, &read);
|
||||||
|
|
|
@ -31,17 +31,17 @@ CAMLprim value unix_recv(value sock, value buff, value ofs, value len, value fla
|
||||||
int ret;
|
int ret;
|
||||||
intnat numbytes;
|
intnat numbytes;
|
||||||
char iobuf[UNIX_BUFFER_SIZE];
|
char iobuf[UNIX_BUFFER_SIZE];
|
||||||
DWORD errcode = 0;
|
DWORD err = 0;
|
||||||
|
|
||||||
Begin_root (buff);
|
Begin_root (buff);
|
||||||
numbytes = Long_val(len);
|
numbytes = Long_val(len);
|
||||||
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
|
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
ret = recv(s, iobuf, (int) numbytes, flg);
|
ret = recv(s, iobuf, (int) numbytes, flg);
|
||||||
if (ret == -1) errcode = WSAGetLastError();
|
if (ret == -1) err = WSAGetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
win32_maperr(errcode);
|
win32_maperr(err);
|
||||||
uerror("recv", Nothing);
|
uerror("recv", Nothing);
|
||||||
}
|
}
|
||||||
memmove (&Byte(buff, Long_val(ofs)), iobuf, ret);
|
memmove (&Byte(buff, Long_val(ofs)), iobuf, ret);
|
||||||
|
@ -60,7 +60,7 @@ CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len, value
|
||||||
value adr = Val_unit;
|
value adr = Val_unit;
|
||||||
union sock_addr_union addr;
|
union sock_addr_union addr;
|
||||||
socklen_param_type addr_len;
|
socklen_param_type addr_len;
|
||||||
DWORD errcode = 0;
|
DWORD err = 0;
|
||||||
|
|
||||||
Begin_roots2 (buff, adr);
|
Begin_roots2 (buff, adr);
|
||||||
numbytes = Long_val(len);
|
numbytes = Long_val(len);
|
||||||
|
@ -68,10 +68,10 @@ CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len, value
|
||||||
addr_len = sizeof(sock_addr);
|
addr_len = sizeof(sock_addr);
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
ret = recvfrom(s, iobuf, (int) numbytes, flg, &addr.s_gen, &addr_len);
|
ret = recvfrom(s, iobuf, (int) numbytes, flg, &addr.s_gen, &addr_len);
|
||||||
if (ret == -1) errcode = WSAGetLastError();
|
if (ret == -1) err = WSAGetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
win32_maperr(errcode);
|
win32_maperr(err);
|
||||||
uerror("recvfrom", Nothing);
|
uerror("recvfrom", Nothing);
|
||||||
}
|
}
|
||||||
memmove (&Byte(buff, Long_val(ofs)), iobuf, ret);
|
memmove (&Byte(buff, Long_val(ofs)), iobuf, ret);
|
||||||
|
@ -90,17 +90,17 @@ CAMLprim value unix_send(value sock, value buff, value ofs, value len, value fla
|
||||||
int ret;
|
int ret;
|
||||||
intnat numbytes;
|
intnat numbytes;
|
||||||
char iobuf[UNIX_BUFFER_SIZE];
|
char iobuf[UNIX_BUFFER_SIZE];
|
||||||
DWORD errcode = 0;
|
DWORD err = 0;
|
||||||
|
|
||||||
numbytes = Long_val(len);
|
numbytes = Long_val(len);
|
||||||
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
|
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
|
||||||
memmove (iobuf, &Byte(buff, Long_val(ofs)), numbytes);
|
memmove (iobuf, &Byte(buff, Long_val(ofs)), numbytes);
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
ret = send(s, iobuf, (int) numbytes, flg);
|
ret = send(s, iobuf, (int) numbytes, flg);
|
||||||
if (ret == -1) errcode = WSAGetLastError();
|
if (ret == -1) err = WSAGetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
win32_maperr(errcode);
|
win32_maperr(err);
|
||||||
uerror("send", Nothing);
|
uerror("send", Nothing);
|
||||||
}
|
}
|
||||||
return Val_int(ret);
|
return Val_int(ret);
|
||||||
|
@ -115,7 +115,7 @@ value unix_sendto_native(value sock, value buff, value ofs, value len, value fla
|
||||||
char iobuf[UNIX_BUFFER_SIZE];
|
char iobuf[UNIX_BUFFER_SIZE];
|
||||||
union sock_addr_union addr;
|
union sock_addr_union addr;
|
||||||
socklen_param_type addr_len;
|
socklen_param_type addr_len;
|
||||||
DWORD errcode = 0;
|
DWORD err = 0;
|
||||||
|
|
||||||
get_sockaddr(dest, &addr, &addr_len);
|
get_sockaddr(dest, &addr, &addr_len);
|
||||||
numbytes = Long_val(len);
|
numbytes = Long_val(len);
|
||||||
|
@ -123,10 +123,10 @@ value unix_sendto_native(value sock, value buff, value ofs, value len, value fla
|
||||||
memmove (iobuf, &Byte(buff, Long_val(ofs)), numbytes);
|
memmove (iobuf, &Byte(buff, Long_val(ofs)), numbytes);
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
ret = sendto(s, iobuf, (int) numbytes, flg, &addr.s_gen, addr_len);
|
ret = sendto(s, iobuf, (int) numbytes, flg, &addr.s_gen, addr_len);
|
||||||
if (ret == -1) errcode = WSAGetLastError();
|
if (ret == -1) err = WSAGetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
win32_maperr(errcode);
|
win32_maperr(err);
|
||||||
uerror("sendto", Nothing);
|
uerror("sendto", Nothing);
|
||||||
}
|
}
|
||||||
return Val_int(ret);
|
return Val_int(ret);
|
||||||
|
|
|
@ -43,16 +43,16 @@ CAMLprim value win_waitpid(value vflags, value vpid_req)
|
||||||
int flags;
|
int flags;
|
||||||
DWORD status, retcode;
|
DWORD status, retcode;
|
||||||
HANDLE pid_req = (HANDLE) Long_val(vpid_req);
|
HANDLE pid_req = (HANDLE) Long_val(vpid_req);
|
||||||
DWORD errcode = 0;
|
DWORD err = 0;
|
||||||
|
|
||||||
flags = convert_flag_list(vflags, wait_flag_table);
|
flags = convert_flag_list(vflags, wait_flag_table);
|
||||||
if ((flags & CAML_WNOHANG) == 0) {
|
if ((flags & CAML_WNOHANG) == 0) {
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
retcode = WaitForSingleObject(pid_req, INFINITE);
|
retcode = WaitForSingleObject(pid_req, INFINITE);
|
||||||
if (retcode == WAIT_FAILED) errcode = GetLastError();
|
if (retcode == WAIT_FAILED) err = GetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
if (errcode) {
|
if (err) {
|
||||||
win32_maperr(errcode);
|
win32_maperr(err);
|
||||||
uerror("waitpid", Nothing);
|
uerror("waitpid", Nothing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ CAMLprim value unix_write(value fd, value buf, value vofs, value vlen)
|
||||||
intnat ofs, len, written;
|
intnat ofs, len, written;
|
||||||
DWORD numbytes, numwritten;
|
DWORD numbytes, numwritten;
|
||||||
char iobuf[UNIX_BUFFER_SIZE];
|
char iobuf[UNIX_BUFFER_SIZE];
|
||||||
DWORD errcode = 0;
|
DWORD err = 0;
|
||||||
|
|
||||||
Begin_root (buf);
|
Begin_root (buf);
|
||||||
ofs = Long_val(vofs);
|
ofs = Long_val(vofs);
|
||||||
|
@ -39,18 +39,18 @@ CAMLprim value unix_write(value fd, value buf, value vofs, value vlen)
|
||||||
SOCKET s = Socket_val(fd);
|
SOCKET s = Socket_val(fd);
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
ret = send(s, iobuf, numbytes, 0);
|
ret = send(s, iobuf, numbytes, 0);
|
||||||
if (ret == SOCKET_ERROR) errcode = WSAGetLastError();
|
if (ret == SOCKET_ERROR) err = WSAGetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
numwritten = ret;
|
numwritten = ret;
|
||||||
} else {
|
} else {
|
||||||
HANDLE h = Handle_val(fd);
|
HANDLE h = Handle_val(fd);
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
if (! WriteFile(h, iobuf, numbytes, &numwritten, NULL))
|
if (! WriteFile(h, iobuf, numbytes, &numwritten, NULL))
|
||||||
errcode = GetLastError();
|
err = GetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
}
|
}
|
||||||
if (errcode) {
|
if (err) {
|
||||||
win32_maperr(errcode);
|
win32_maperr(err);
|
||||||
uerror("write", Nothing);
|
uerror("write", Nothing);
|
||||||
}
|
}
|
||||||
written += numwritten;
|
written += numwritten;
|
||||||
|
@ -66,6 +66,7 @@ CAMLprim value unix_single_write(value fd, value buf, value vofs, value vlen)
|
||||||
intnat ofs, len, written;
|
intnat ofs, len, written;
|
||||||
DWORD numbytes, numwritten;
|
DWORD numbytes, numwritten;
|
||||||
char iobuf[UNIX_BUFFER_SIZE];
|
char iobuf[UNIX_BUFFER_SIZE];
|
||||||
|
DWORD err;
|
||||||
|
|
||||||
Begin_root (buf);
|
Begin_root (buf);
|
||||||
ofs = Long_val(vofs);
|
ofs = Long_val(vofs);
|
||||||
|
@ -79,18 +80,18 @@ CAMLprim value unix_single_write(value fd, value buf, value vofs, value vlen)
|
||||||
SOCKET s = Socket_val(fd);
|
SOCKET s = Socket_val(fd);
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
ret = send(s, iobuf, numbytes, 0);
|
ret = send(s, iobuf, numbytes, 0);
|
||||||
if (ret == SOCKET_ERROR) errcode = WSAGetLastError();
|
if (ret == SOCKET_ERROR) err = WSAGetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
numwritten = ret;
|
numwritten = ret;
|
||||||
} else {
|
} else {
|
||||||
HANDLE h = Handle_val(fd);
|
HANDLE h = Handle_val(fd);
|
||||||
enter_blocking_section();
|
enter_blocking_section();
|
||||||
if (! WriteFile(h, iobuf, numbytes, &numwritten, NULL))
|
if (! WriteFile(h, iobuf, numbytes, &numwritten, NULL))
|
||||||
errcode = GetLastError();
|
err = GetLastError();
|
||||||
leave_blocking_section();
|
leave_blocking_section();
|
||||||
}
|
}
|
||||||
if (errcode) {
|
if (err) {
|
||||||
win32_maperr(errcode);
|
win32_maperr(err);
|
||||||
uerror("single_write", Nothing);
|
uerror("single_write", Nothing);
|
||||||
}
|
}
|
||||||
written = numwritten;
|
written = numwritten;
|
||||||
|
|
Loading…
Reference in New Issue