diff options
Diffstat (limited to 'lib/libc_r/uthread/uthread_write.c')
-rw-r--r-- | lib/libc_r/uthread/uthread_write.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/libc_r/uthread/uthread_write.c b/lib/libc_r/uthread/uthread_write.c index f25c606..6408a64 100644 --- a/lib/libc_r/uthread/uthread_write.c +++ b/lib/libc_r/uthread/uthread_write.c @@ -42,7 +42,7 @@ #include "pthread_private.h" ssize_t -_libc_write(int fd, const void *buf, size_t nbytes) +_write(int fd, const void *buf, size_t nbytes) { int blocking; int type; @@ -50,12 +50,9 @@ _libc_write(int fd, const void *buf, size_t nbytes) ssize_t num = 0; ssize_t ret; - _thread_enter_cancellation_point(); /* POSIX says to do just this: */ - if (nbytes == 0) { - _thread_leave_cancellation_point(); + if (nbytes == 0) return (0); - } /* Lock the file descriptor for write: */ if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { @@ -67,7 +64,6 @@ _libc_write(int fd, const void *buf, size_t nbytes) /* File is not open for write: */ errno = EBADF; _FD_UNLOCK(fd, FD_WRITE); - _thread_leave_cancellation_point(); return (-1); } @@ -133,9 +129,18 @@ _libc_write(int fd, const void *buf, size_t nbytes) } _FD_UNLOCK(fd, FD_RDWR); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_write, write); +ssize_t +write(int fd, const void *buf, size_t nbytes) +{ + ssize_t ret; + + _thread_enter_cancellation_point(); + ret = _write(fd, buf, nbytes); + _thread_leave_cancellation_point(); + + return ret; +} #endif |