diff options
author | Damien Doligez <damien.doligez-inria.fr> | 1997-05-26 17:16:31 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 1997-05-26 17:16:31 +0000 |
commit | 8555ce8fe79fbf54924845a608054306733eeeba (patch) | |
tree | dd5b22190a08dcf3c1d8c16adc89988b60d982f1 /otherlibs/unix/write.c | |
parent | ff13e60cd68933428c60c10680c82c3cd91ea8c2 (diff) | |
download | ocaml-8555ce8fe79fbf54924845a608054306733eeeba.tar.gz |
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
Diffstat (limited to 'otherlibs/unix/write.c')
-rw-r--r-- | otherlibs/unix/write.c | 37 |
1 files changed, 18 insertions, 19 deletions
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); } |