From 8555ce8fe79fbf54924845a608054306733eeeba Mon Sep 17 00:00:00 2001 From: Damien Doligez Date: Mon, 26 May 1997 17:16:31 +0000 Subject: Changement de Push/Pop_roots en Begin/End_roots git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1572 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- otherlibs/unix/write.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'otherlibs/unix/write.c') diff --git a/otherlibs/unix/write.c b/otherlibs/unix/write.c index 5ae80459f6..aae03aaae8 100644 --- a/otherlibs/unix/write.c +++ b/otherlibs/unix/write.c @@ -30,26 +30,25 @@ value unix_write(fd, buf, vofs, vlen) /* ML */ long ofs, len, written; int numbytes, ret; char iobuf[UNIX_BUFFER_SIZE]; - Push_roots(r, 1); - r[0] = buf; - ofs = Long_val(vofs); - len = Long_val(vlen); - written = 0; - while (len > 0) { - numbytes = len > UNIX_BUFFER_SIZE ? UNIX_BUFFER_SIZE : len; - bcopy(&Byte(r[0], ofs), iobuf, numbytes); - enter_blocking_section(); - ret = write(Int_val(fd), iobuf, numbytes); - leave_blocking_section(); - if (ret == -1) { - if ((errno == EAGAIN || errno == EWOULDBLOCK) && written > 0) break; - uerror("write", Nothing); + Begin_root (buf); + ofs = Long_val(vofs); + len = Long_val(vlen); + written = 0; + while (len > 0) { + numbytes = len > UNIX_BUFFER_SIZE ? UNIX_BUFFER_SIZE : len; + bcopy(&Byte(buf, ofs), iobuf, numbytes); + enter_blocking_section(); + ret = write(Int_val(fd), iobuf, numbytes); + leave_blocking_section(); + if (ret == -1) { + if ((errno == EAGAIN || errno == EWOULDBLOCK) && written > 0) break; + uerror("write", Nothing); + } + written += ret; + ofs += ret; + len -= ret; } - written += ret; - ofs += ret; - len -= ret; - } - Pop_roots(); + End_roots(); return Val_long(written); } -- cgit v1.2.1