1 /* Implement fopen_unlocked and related functions.
2 Copyright (C) 2005 Free Software Foundation, Inc.
3 Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
5 This file is part of the libiberty library.
6 Libiberty is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 Libiberty is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with libiberty; see the file COPYING.LIB. If
18 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
23 @deftypefn Extension FILE * fopen_unlocked (const char *@var{path}, const char * @var{mode})
25 Opens and returns a @code{FILE} pointer via @code{fopen}. If the
26 operating system supports it, ensure that the stream is setup to avoid
27 any multi-threaded locking. Otherwise return the @code{FILE} pointer
32 @deftypefn Extension FILE * fdopen_unlocked (int @var{fildes}, const char * @var{mode})
34 Opens and returns a @code{FILE} pointer via @code{fdopen}. If the
35 operating system supports it, ensure that the stream is setup to avoid
36 any multi-threaded locking. Otherwise return the @code{FILE} pointer
41 @deftypefn Extension FILE * freopen_unlocked (const char * @var{path}, const char * @var{mode}, FILE * @var{stream})
43 Opens and returns a @code{FILE} pointer via @code{freopen}. If the
44 operating system supports it, ensure that the stream is setup to avoid
45 any multi-threaded locking. Otherwise return the @code{FILE} pointer
56 #ifdef HAVE_STDIO_EXT_H
57 #include <stdio_ext.h>
60 #include "libiberty.h"
63 fopen_unlocked (const char *path
, const char *mode
)
65 FILE *const fp
= fopen (path
, mode
);
66 #if defined(HAVE___FSETLOCKING) && defined(FSETLOCKING_BYCALLER)
68 __fsetlocking (fp
, FSETLOCKING_BYCALLER
);
74 fdopen_unlocked (int fildes
, const char *mode
)
76 FILE *const fp
= fdopen (fildes
, mode
);
77 #if defined(HAVE___FSETLOCKING) && defined(FSETLOCKING_BYCALLER)
79 __fsetlocking (fp
, FSETLOCKING_BYCALLER
);
85 freopen_unlocked (const char *path
, const char *mode
, FILE *stream
)
87 FILE *const fp
= freopen (path
, mode
, stream
);
88 #if defined(HAVE___FSETLOCKING) && defined(FSETLOCKING_BYCALLER)
90 __fsetlocking (fp
, FSETLOCKING_BYCALLER
);
This page took 0.052538 seconds and 5 git commands to generate.