xref: /haiku/src/system/libroot/posix/glibc/libio/__fsetlocking.c (revision 87e239b9dc52a9627ba19bf5b8a8bc41627ea04c)
1*87e239b9SJérôme Duval /* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
2*87e239b9SJérôme Duval    This file is part of the GNU C Library.
3*87e239b9SJérôme Duval 
4*87e239b9SJérôme Duval    The GNU C Library is free software; you can redistribute it and/or
5*87e239b9SJérôme Duval    modify it under the terms of the GNU Lesser General Public
6*87e239b9SJérôme Duval    License as published by the Free Software Foundation; either
7*87e239b9SJérôme Duval    version 2.1 of the License, or (at your option) any later version.
8*87e239b9SJérôme Duval 
9*87e239b9SJérôme Duval    The GNU C Library is distributed in the hope that it will be useful,
10*87e239b9SJérôme Duval    but WITHOUT ANY WARRANTY; without even the implied warranty of
11*87e239b9SJérôme Duval    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12*87e239b9SJérôme Duval    Lesser General Public License for more details.
13*87e239b9SJérôme Duval 
14*87e239b9SJérôme Duval    You should have received a copy of the GNU Lesser General Public
15*87e239b9SJérôme Duval    License along with the GNU C Library; if not, write to the Free
16*87e239b9SJérôme Duval    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17*87e239b9SJérôme Duval    02111-1307 USA.  */
18*87e239b9SJérôme Duval 
19*87e239b9SJérôme Duval #include <stdio_ext.h>
20*87e239b9SJérôme Duval 
21*87e239b9SJérôme Duval #undef __fsetlocking
22*87e239b9SJérôme Duval 
23*87e239b9SJérôme Duval int
__fsetlocking(FILE * fp,int type)24*87e239b9SJérôme Duval __fsetlocking (FILE *fp, int type)
25*87e239b9SJérôme Duval {
26*87e239b9SJérôme Duval   int result = ((fp->_flags & _IO_USER_LOCK)
27*87e239b9SJérôme Duval 		? FSETLOCKING_BYCALLER : FSETLOCKING_INTERNAL);
28*87e239b9SJérôme Duval 
29*87e239b9SJérôme Duval   if (type != FSETLOCKING_QUERY)
30*87e239b9SJérôme Duval     {
31*87e239b9SJérôme Duval       fp->_flags &= ~_IO_USER_LOCK;
32*87e239b9SJérôme Duval       if (type == FSETLOCKING_BYCALLER)
33*87e239b9SJérôme Duval 	 fp->_flags |= _IO_USER_LOCK;
34*87e239b9SJérôme Duval     }
35*87e239b9SJérôme Duval 
36*87e239b9SJérôme Duval   return result;
37*87e239b9SJérôme Duval }
38*87e239b9SJérôme Duval INTDEF(__fsetlocking)
39