aboutsummaryrefslogtreecommitdiff
path: root/lib/libkse/thread/thr_writev.c
diff options
context:
space:
mode:
authorDaniel Eischen <deischen@FreeBSD.org>2001-01-24 13:03:38 +0000
committerDaniel Eischen <deischen@FreeBSD.org>2001-01-24 13:03:38 +0000
commite5106342c6de9cbe26c4827e4e29bae309cd8cfb (patch)
tree5199387f09deaa21f12482317c165f815c4e8c2b /lib/libkse/thread/thr_writev.c
parentf9447cd11209a5fb5ecef3f4cbe539e990f3b1bd (diff)
downloadsrc-e5106342c6de9cbe26c4827e4e29bae309cd8cfb.tar.gz
src-e5106342c6de9cbe26c4827e4e29bae309cd8cfb.zip
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
Notes
Notes: svn path=/head/; revision=71581
Diffstat (limited to 'lib/libkse/thread/thr_writev.c')
-rw-r--r--lib/libkse/thread/thr_writev.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/libkse/thread/thr_writev.c b/lib/libkse/thread/thr_writev.c
index 5f3146887765..66b451fed2d3 100644
--- a/lib/libkse/thread/thr_writev.c
+++ b/lib/libkse/thread/thr_writev.c
@@ -39,13 +39,15 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#ifdef _THREAD_SAFE
#include <pthread.h>
#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