thr_tcdrain.c revision 174112
1284345Ssjg/*
2301464Sbdrewery * Copyright (C) 2000 Jason Evans <jasone@freebsd.org>.
3284345Ssjg * All rights reserved.
4284345Ssjg *
5284345Ssjg * Redistribution and use in source and binary forms, with or without
6284345Ssjg * modification, are permitted provided that the following conditions
7284345Ssjg * are met:
8284345Ssjg * 1. Redistributions of source code must retain the above copyright
9284345Ssjg *    notice(s), this list of conditions and the following disclaimer as
10284345Ssjg *    the first lines of this file unmodified other than the possible
11284345Ssjg *    addition of one or more copyright notices.
12284345Ssjg * 2. Redistributions in binary form must reproduce the above copyright
13284345Ssjg *    notice(s), this list of conditions and the following disclaimer in
14284345Ssjg *    the documentation and/or other materials provided with the
15284345Ssjg *    distribution.
16284345Ssjg *
17284345Ssjg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
18284345Ssjg * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19284345Ssjg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20284345Ssjg * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
21284345Ssjg * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22284345Ssjg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23284345Ssjg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24284345Ssjg * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25284345Ssjg * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26284345Ssjg * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27288964Ssjg * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28288964Ssjg *
29284345Ssjg * $FreeBSD: head/lib/libkse/thread/thr_tcdrain.c 174112 2007-11-30 17:20:29Z deischen $
30296637Ssjg */
31284345Ssjg
32284345Ssjg#include "namespace.h"
33284345Ssjg#include <termios.h>
34284345Ssjg#include <pthread.h>
35284345Ssjg#include "un-namespace.h"
36284345Ssjg#include "thr_private.h"
37284345Ssjg
38284345Ssjgint	_tcdrain(int fd);
39284345Ssjgextern int __tcdrain(int);
40284345Ssjg
41284345SsjgLT10_COMPAT_PRIVATE(_tcdrain);
42284345SsjgLT10_COMPAT_DEFAULT(tcdrain);
43284345Ssjg
44284345Ssjg__weak_reference(_tcdrain, tcdrain);
45284345Ssjg
46284345Ssjgint
47284345Ssjg_tcdrain(int fd)
48284345Ssjg{
49284345Ssjg	struct pthread *curthread = _get_curthread();
50284345Ssjg	int	ret;
51284345Ssjg
52284345Ssjg	_thr_cancel_enter(curthread);
53284345Ssjg	ret = __tcdrain(fd);
54284345Ssjg	_thr_cancel_leave(curthread, 1);
55284345Ssjg
56284345Ssjg	return (ret);
57284345Ssjg}
58284345Ssjg