PR#4097: suite

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7697 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 2006-10-18 08:26:54 +00:00
parent 35d863e204
commit 4af5727d18
7 changed files with 42 additions and 41 deletions

View File

@ -29,7 +29,7 @@ CAMLprim value unix_accept(sock)
int oldvalue, oldvaluelen, newvalue, retcode;
union sock_addr_union addr;
socklen_param_type addr_len;
DWORD errcode = 0;
DWORD err = 0;
oldvaluelen = sizeof(oldvalue);
retcode = getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
@ -43,7 +43,7 @@ CAMLprim value unix_accept(sock)
addr_len = sizeof(sock_addr);
enter_blocking_section();
snew = accept(sconn, &addr.s_gen, &addr_len);
if (snew == INVALID_SOCKET) errcode = WSAGetLastError ();
if (snew == INVALID_SOCKET) err = WSAGetLastError ();
leave_blocking_section();
if (retcode == 0) {
/* Restore initial mode */
@ -51,7 +51,7 @@ CAMLprim value unix_accept(sock)
(char *) &oldvalue, oldvaluelen);
}
if (snew == INVALID_SOCKET) {
win32_maperr(errcode);
win32_maperr(err);
uerror("accept", Nothing);
}
Begin_roots2 (fd, adr)

View File

@ -24,15 +24,15 @@ CAMLprim value unix_connect(socket, address)
SOCKET s = Socket_val(socket);
union sock_addr_union addr;
socklen_param_type addr_len;
DWORD errcode = 0;
DWORD err = 0;
get_sockaddr(address, &addr, &addr_len);
enter_blocking_section();
if (connect(s, &addr.s_gen, addr_len) == -1)
errcode = WSAGetLastError();
err = WSAGetLastError();
leave_blocking_section();
if (errcode) {
win32_maperr(errcode);
if (err) {
win32_maperr(err);
uerror("connect", Nothing);
}
return Val_unit;

View File

@ -24,7 +24,7 @@ CAMLprim value unix_read(value fd, value buf, value ofs, value vlen)
intnat len;
DWORD numbytes, numread;
char iobuf[UNIX_BUFFER_SIZE];
DOWRD errcode = 0;
DWORD err = 0;
Begin_root (buf);
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);
enter_blocking_section();
ret = recv(s, iobuf, numbytes, 0);
if (ret == SOCKET_ERROR) errcode = WSAGetLastError();
if (ret == SOCKET_ERROR) err = WSAGetLastError();
leave_blocking_section();
numread = ret;
} else {
HANDLE h = Handle_val(fd);
enter_blocking_section();
if (! ReadFile(h, iobuf, numbytes, &numread, NULL))
errcode = GetLastError();
err = GetLastError();
leave_blocking_section();
}
if (errcode) {
win32_maperr(errcode);
if (err) {
win32_maperr(err);
uerror("read", Nothing);
}
memmove (&Byte(buf, Long_val(ofs)), iobuf, numread);

View File

@ -54,7 +54,7 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds, value
int retcode;
value res;
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 (read_list, write_list, except_list)
@ -81,10 +81,10 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds, value
}
enter_blocking_section();
if (select(FD_SETSIZE, &read, &write, &except, tvp) == -1)
errcode = WSAGetLastError();
err = WSAGetLastError();
leave_blocking_section();
if (errcode) {
win32_maperr(errcode);
if (err) {
win32_maperr(err);
uerror("select", Nothing);
}
read_list = fdset_to_fdlist(readfds, &read);

View File

@ -31,17 +31,17 @@ CAMLprim value unix_recv(value sock, value buff, value ofs, value len, value fla
int ret;
intnat numbytes;
char iobuf[UNIX_BUFFER_SIZE];
DWORD errcode = 0;
DWORD err = 0;
Begin_root (buff);
numbytes = Long_val(len);
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
enter_blocking_section();
ret = recv(s, iobuf, (int) numbytes, flg);
if (ret == -1) errcode = WSAGetLastError();
if (ret == -1) err = WSAGetLastError();
leave_blocking_section();
if (ret == -1) {
win32_maperr(errcode);
win32_maperr(err);
uerror("recv", Nothing);
}
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;
union sock_addr_union addr;
socklen_param_type addr_len;
DWORD errcode = 0;
DWORD err = 0;
Begin_roots2 (buff, adr);
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);
enter_blocking_section();
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();
if (ret == -1) {
win32_maperr(errcode);
win32_maperr(err);
uerror("recvfrom", Nothing);
}
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;
intnat numbytes;
char iobuf[UNIX_BUFFER_SIZE];
DWORD errcode = 0;
DWORD err = 0;
numbytes = Long_val(len);
if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE;
memmove (iobuf, &Byte(buff, Long_val(ofs)), numbytes);
enter_blocking_section();
ret = send(s, iobuf, (int) numbytes, flg);
if (ret == -1) errcode = WSAGetLastError();
if (ret == -1) err = WSAGetLastError();
leave_blocking_section();
if (ret == -1) {
win32_maperr(errcode);
win32_maperr(err);
uerror("send", Nothing);
}
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];
union sock_addr_union addr;
socklen_param_type addr_len;
DWORD errcode = 0;
DWORD err = 0;
get_sockaddr(dest, &addr, &addr_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);
enter_blocking_section();
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();
if (ret == -1) {
win32_maperr(errcode);
win32_maperr(err);
uerror("sendto", Nothing);
}
return Val_int(ret);

View File

@ -43,16 +43,16 @@ CAMLprim value win_waitpid(value vflags, value vpid_req)
int flags;
DWORD status, retcode;
HANDLE pid_req = (HANDLE) Long_val(vpid_req);
DWORD errcode = 0;
DWORD err = 0;
flags = convert_flag_list(vflags, wait_flag_table);
if ((flags & CAML_WNOHANG) == 0) {
enter_blocking_section();
retcode = WaitForSingleObject(pid_req, INFINITE);
if (retcode == WAIT_FAILED) errcode = GetLastError();
if (retcode == WAIT_FAILED) err = GetLastError();
leave_blocking_section();
if (errcode) {
win32_maperr(errcode);
if (err) {
win32_maperr(err);
uerror("waitpid", Nothing);
}
}

View File

@ -25,7 +25,7 @@ CAMLprim value unix_write(value fd, value buf, value vofs, value vlen)
intnat ofs, len, written;
DWORD numbytes, numwritten;
char iobuf[UNIX_BUFFER_SIZE];
DWORD errcode = 0;
DWORD err = 0;
Begin_root (buf);
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);
enter_blocking_section();
ret = send(s, iobuf, numbytes, 0);
if (ret == SOCKET_ERROR) errcode = WSAGetLastError();
if (ret == SOCKET_ERROR) err = WSAGetLastError();
leave_blocking_section();
numwritten = ret;
} else {
HANDLE h = Handle_val(fd);
enter_blocking_section();
if (! WriteFile(h, iobuf, numbytes, &numwritten, NULL))
errcode = GetLastError();
err = GetLastError();
leave_blocking_section();
}
if (errcode) {
win32_maperr(errcode);
if (err) {
win32_maperr(err);
uerror("write", Nothing);
}
written += numwritten;
@ -66,6 +66,7 @@ CAMLprim value unix_single_write(value fd, value buf, value vofs, value vlen)
intnat ofs, len, written;
DWORD numbytes, numwritten;
char iobuf[UNIX_BUFFER_SIZE];
DWORD err;
Begin_root (buf);
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);
enter_blocking_section();
ret = send(s, iobuf, numbytes, 0);
if (ret == SOCKET_ERROR) errcode = WSAGetLastError();
if (ret == SOCKET_ERROR) err = WSAGetLastError();
leave_blocking_section();
numwritten = ret;
} else {
HANDLE h = Handle_val(fd);
enter_blocking_section();
if (! WriteFile(h, iobuf, numbytes, &numwritten, NULL))
errcode = GetLastError();
err = GetLastError();
leave_blocking_section();
}
if (errcode) {
win32_maperr(errcode);
if (err) {
win32_maperr(err);
uerror("single_write", Nothing);
}
written = numwritten;