thr_writev.c revision 174112
113546Sjulian/* 235509Sjb * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> 313546Sjulian * All rights reserved. 413546Sjulian * 513546Sjulian * Redistribution and use in source and binary forms, with or without 613546Sjulian * modification, are permitted provided that the following conditions 713546Sjulian * are met: 813546Sjulian * 1. Redistributions of source code must retain the above copyright 913546Sjulian * notice, this list of conditions and the following disclaimer. 1013546Sjulian * 2. Redistributions in binary form must reproduce the above copyright 1113546Sjulian * notice, this list of conditions and the following disclaimer in the 1213546Sjulian * documentation and/or other materials provided with the distribution. 13165967Simp * 3. Neither the name of the author nor the names of any co-contributors 1413546Sjulian * may be used to endorse or promote products derived from this software 1513546Sjulian * without specific prior written permission. 1613546Sjulian * 1713546Sjulian * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 1813546Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1913546Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2049439Sdeischen * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2113546Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2213546Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2313546Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2413546Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2513546Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2613546Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2713546Sjulian * SUCH DAMAGE. 2813546Sjulian * 2950476Speter * $FreeBSD: head/lib/libkse/thread/thr_writev.c 174112 2007-11-30 17:20:29Z deischen $ 3024518Sjb * 3113546Sjulian */ 3213546Sjulian#include <sys/types.h> 3313546Sjulian#include <sys/fcntl.h> 3413546Sjulian#include <sys/uio.h> 3513546Sjulian#include <errno.h> 3636830Sjb#include <stdlib.h> 3736830Sjb#include <string.h> 3813546Sjulian#include <unistd.h> 3913546Sjulian#include <pthread.h> 40103388Smini#include "thr_private.h" 4113546Sjulian 42156611SdeischenLT10_COMPAT_PRIVATE(__writev); 43156611SdeischenLT10_COMPAT_DEFAULT(writev); 44156611Sdeischen 45174112Sdeischenssize_t __writev(int fd, const struct iovec *iov, int iovcnt); 46174112Sdeischen 4795948Sarchie__weak_reference(__writev, writev); 4871581Sdeischen 4913546Sjulianssize_t 5095948Sarchie__writev(int fd, const struct iovec *iov, int iovcnt) 5195948Sarchie{ 52113658Sdeischen struct pthread *curthread = _get_curthread(); 5395948Sarchie ssize_t ret; 5495948Sarchie 55123312Sdavidxu _thr_cancel_enter(curthread); 56103419Smini ret = __sys_writev(fd, iov, iovcnt); 57123312Sdavidxu _thr_cancel_leave(curthread, 1); 5895948Sarchie 5995948Sarchie return ret; 6095948Sarchie} 61