diff options
Diffstat (limited to 'lib/libc_r/uthread/uthread_write.c')
-rw-r--r-- | lib/libc_r/uthread/uthread_write.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/libc_r/uthread/uthread_write.c b/lib/libc_r/uthread/uthread_write.c index 5d9ef35..b841726 100644 --- a/lib/libc_r/uthread/uthread_write.c +++ b/lib/libc_r/uthread/uthread_write.c @@ -37,13 +37,15 @@ #include <sys/uio.h> #include <errno.h> #include <unistd.h> -#ifdef _THREAD_SAFE #include <pthread.h> #include "pthread_private.h" +#pragma weak write=__write + ssize_t _write(int fd, const void *buf, size_t nbytes) { + struct pthread *curthread = _get_curthread(); int blocking; int type; ssize_t n; @@ -76,7 +78,7 @@ _write(int fd, const void *buf, size_t nbytes) */ while (ret == 0) { /* Perform a non-blocking write syscall: */ - n = _thread_sys_write(fd, buf + num, nbytes - num); + n = __sys_write(fd, buf + num, nbytes - num); /* Check if one or more bytes were written: */ if (n > 0) @@ -94,11 +96,11 @@ _write(int fd, const void *buf, size_t nbytes) */ if (blocking && ((n < 0 && (errno == EWOULDBLOCK || errno == EAGAIN)) || (n >= 0 && num < nbytes))) { - _thread_run->data.fd.fd = fd; + curthread->data.fd.fd = fd; _thread_kern_set_timeout(NULL); /* Reset the interrupted operation flag: */ - _thread_run->interrupted = 0; + curthread->interrupted = 0; _thread_kern_sched_state(PS_FDW_WAIT, __FILE__, __LINE__); @@ -107,7 +109,7 @@ _write(int fd, const void *buf, size_t nbytes) * Check if the operation was * interrupted by a signal */ - if (_thread_run->interrupted) { + if (curthread->interrupted) { /* Return an error: */ ret = -1; } @@ -133,7 +135,7 @@ _write(int fd, const void *buf, size_t nbytes) } ssize_t -write(int fd, const void *buf, size_t nbytes) +__write(int fd, const void *buf, size_t nbytes) { ssize_t ret; @@ -143,4 +145,3 @@ write(int fd, const void *buf, size_t nbytes) return ret; } -#endif |