thr_tcdrain.c revision 113658
110491SRishi.Srivatsavai@Sun.COM/* 210491SRishi.Srivatsavai@Sun.COM * Copyright (C) 2000 Jason Evans <jasone@freebsd.org>. 310491SRishi.Srivatsavai@Sun.COM * All rights reserved. 410491SRishi.Srivatsavai@Sun.COM * 510491SRishi.Srivatsavai@Sun.COM * Redistribution and use in source and binary forms, with or without 610491SRishi.Srivatsavai@Sun.COM * modification, are permitted provided that the following conditions 710491SRishi.Srivatsavai@Sun.COM * are met: 810491SRishi.Srivatsavai@Sun.COM * 1. Redistributions of source code must retain the above copyright 910491SRishi.Srivatsavai@Sun.COM * notice(s), this list of conditions and the following disclaimer as 1010491SRishi.Srivatsavai@Sun.COM * the first lines of this file unmodified other than the possible 1110491SRishi.Srivatsavai@Sun.COM * addition of one or more copyright notices. 1210491SRishi.Srivatsavai@Sun.COM * 2. Redistributions in binary form must reproduce the above copyright 1310491SRishi.Srivatsavai@Sun.COM * notice(s), this list of conditions and the following disclaimer in 1410491SRishi.Srivatsavai@Sun.COM * the documentation and/or other materials provided with the 1510491SRishi.Srivatsavai@Sun.COM * distribution. 1610491SRishi.Srivatsavai@Sun.COM * 1710491SRishi.Srivatsavai@Sun.COM * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 1810491SRishi.Srivatsavai@Sun.COM * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1910491SRishi.Srivatsavai@Sun.COM * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2010491SRishi.Srivatsavai@Sun.COM * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE 2110491SRishi.Srivatsavai@Sun.COM * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2210491SRishi.Srivatsavai@Sun.COM * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2310491SRishi.Srivatsavai@Sun.COM * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 2410491SRishi.Srivatsavai@Sun.COM * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2510491SRishi.Srivatsavai@Sun.COM * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 2610491SRishi.Srivatsavai@Sun.COM * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 2710491SRishi.Srivatsavai@Sun.COM * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2810491SRishi.Srivatsavai@Sun.COM * 2910491SRishi.Srivatsavai@Sun.COM * $FreeBSD: head/lib/libkse/thread/thr_tcdrain.c 113658 2003-04-18 05:04:16Z deischen $ 3010491SRishi.Srivatsavai@Sun.COM */ 3110491SRishi.Srivatsavai@Sun.COM 3210491SRishi.Srivatsavai@Sun.COM#include <termios.h> 3310491SRishi.Srivatsavai@Sun.COM#include <pthread.h> 3410491SRishi.Srivatsavai@Sun.COM#include "thr_private.h" 3510491SRishi.Srivatsavai@Sun.COM 3610491SRishi.Srivatsavai@Sun.COM__weak_reference(_tcdrain, tcdrain); 3710491SRishi.Srivatsavai@Sun.COM 3810491SRishi.Srivatsavai@Sun.COMint 3910491SRishi.Srivatsavai@Sun.COM_tcdrain(int fd) 4010491SRishi.Srivatsavai@Sun.COM{ 4110491SRishi.Srivatsavai@Sun.COM struct pthread *curthread = _get_curthread(); 4210491SRishi.Srivatsavai@Sun.COM int ret; 4310491SRishi.Srivatsavai@Sun.COM 4410491SRishi.Srivatsavai@Sun.COM _thr_enter_cancellation_point(curthread); 4510491SRishi.Srivatsavai@Sun.COM ret = __tcdrain(fd); 4610491SRishi.Srivatsavai@Sun.COM _thr_leave_cancellation_point(curthread); 4710491SRishi.Srivatsavai@Sun.COM 4810491SRishi.Srivatsavai@Sun.COM return (ret); 4910491SRishi.Srivatsavai@Sun.COM} 5010491SRishi.Srivatsavai@Sun.COM