thr_read.c revision 156611
1193323Sed/* 2193323Sed * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> 3193323Sed * All rights reserved. 4193323Sed * 5193323Sed * Redistribution and use in source and binary forms, with or without 6193323Sed * modification, are permitted provided that the following conditions 7193323Sed * are met: 8193323Sed * 1. Redistributions of source code must retain the above copyright 9193323Sed * notice, this list of conditions and the following disclaimer. 10193323Sed * 2. Redistributions in binary form must reproduce the above copyright 11193323Sed * notice, this list of conditions and the following disclaimer in the 12193323Sed * documentation and/or other materials provided with the distribution. 13193323Sed * 3. All advertising materials mentioning features or use of this software 14193323Sed * must display the following acknowledgement: 15193323Sed * This product includes software developed by John Birrell. 16193323Sed * 4. Neither the name of the author nor the names of any co-contributors 17193323Sed * may be used to endorse or promote products derived from this software 18193323Sed * without specific prior written permission. 19193323Sed * 20193323Sed * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 21193323Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22193323Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23193323Sed * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24193323Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25193323Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26193323Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27193323Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28193323Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29249423Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30249423Sdim * SUCH DAMAGE. 31249423Sdim * 32193323Sed * $FreeBSD: head/lib/libkse/thread/thr_read.c 156611 2006-03-13 00:59:51Z deischen $ 33193323Sed * 34193323Sed */ 35249423Sdim#include <sys/types.h> 36249423Sdim#include <sys/fcntl.h> 37249423Sdim#include <sys/uio.h> 38249423Sdim#include <errno.h> 39249423Sdim#include <unistd.h> 40249423Sdim#include <pthread.h> 41249423Sdim#include "thr_private.h" 42249423Sdim 43193323SedLT10_COMPAT_PRIVATE(__read); 44224145SdimLT10_COMPAT_DEFAULT(read); 45193323Sed 46198090Srdivacky__weak_reference(__read, read); 47249423Sdim 48249423Sdimssize_t 49193323Sed__read(int fd, void *buf, size_t nbytes) 50226633Sdim{ 51193323Sed struct pthread *curthread = _get_curthread(); 52193323Sed ssize_t ret; 53224145Sdim 54224145Sdim _thr_cancel_enter(curthread); 55224145Sdim ret = __sys_read(fd, buf, nbytes); 56224145Sdim _thr_cancel_leave(curthread, 1); 57224145Sdim 58193323Sed return ret; 59234353Sdim} 60234353Sdim