From ee1de6a067c70fbd8cb73facd64c3b0b275f9f83 Mon Sep 17 00:00:00 2001 From: deischen Date: Wed, 24 Jan 2001 13:03:38 +0000 Subject: Add weak definitions for wrapped system calls. In general: _foo - wrapped system call foo - weak definition to _foo and for cancellation points: _foo - wrapped system call __foo - enter cancellation point, call _foo(), leave cancellation point foo - weak definition to __foo Change use of global _thread_run to call a function to get the currently running thread. Make all pthread_foo functions weak definitions to _pthread_foo, where _pthread_foo is the implementation. This allows an application to provide its own pthread functions. Provide slightly different versions of pthread_mutex_lock and pthread_mutex_init so that we can tell the difference between a libc mutex and an application mutex. Threads holding mutexes internal to libc should never be allowed to exit, call signal handlers, or cancel. Approved by: -arch --- lib/libpthread/thread/thr_writev.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib/libpthread/thread/thr_writev.c') diff --git a/lib/libpthread/thread/thr_writev.c b/lib/libpthread/thread/thr_writev.c index 5f31468..66b451f 100644 --- a/lib/libpthread/thread/thr_writev.c +++ b/lib/libpthread/thread/thr_writev.c @@ -39,13 +39,15 @@ #include #include #include -#ifdef _THREAD_SAFE #include #include "pthread_private.h" +#pragma weak writev=_writev + ssize_t _writev(int fd, const struct iovec * iov, int iovcnt) { + struct pthread *curthread = _get_curthread(); int blocking; int idx = 0; int type; @@ -92,7 +94,7 @@ _writev(int fd, const struct iovec * iov, int iovcnt) */ while (ret == 0) { /* Perform a non-blocking write syscall: */ - n = _thread_sys_writev(fd, &p_iov[idx], iovcnt - idx); + n = __sys_writev(fd, &p_iov[idx], iovcnt - idx); /* Check if one or more bytes were written: */ if (n > 0) { @@ -158,11 +160,11 @@ _writev(int fd, const struct iovec * iov, int iovcnt) */ if (blocking && ((n < 0 && (errno == EWOULDBLOCK || errno == EAGAIN)) || (n >= 0 && idx < iovcnt))) { - _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__); @@ -171,7 +173,7 @@ _writev(int fd, const struct iovec * iov, int iovcnt) * Check if the operation was * interrupted by a signal */ - if (_thread_run->interrupted) { + if (curthread->interrupted) { /* Return an error: */ ret = -1; } @@ -200,6 +202,3 @@ _writev(int fd, const struct iovec * iov, int iovcnt) return (ret); } - -__strong_reference(_writev, writev); -#endif -- cgit v1.1