* reg-stack.c (subst_stack_regs_pat): Handle <UNSPEC_FIST_FLOOR> and
[official-gcc.git] / libiberty / fopen_unlocked.c
blobb193dfd908183a0b41100198364e9c6c3ecbca97
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
28 unchanged.
30 @end deftypefn
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
37 unchanged.
39 @end deftypefn
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
46 unchanged.
48 @end deftypefn
52 #ifdef HAVE_CONFIG_H
53 #include "config.h"
54 #endif
55 #include <stdio.h>
56 #ifdef HAVE_STDIO_EXT_H
57 #include <stdio_ext.h>
58 #endif
60 #include "libiberty.h"
62 FILE *
63 fopen_unlocked (const char *path, const char *mode)
65 FILE *const fp = fopen (path, mode);
66 #if defined(HAVE___FSETLOCKING) && defined(FSETLOCKING_BYCALLER)
67 if (fp)
68 __fsetlocking (fp, FSETLOCKING_BYCALLER);
69 #endif
70 return fp;
73 FILE *
74 fdopen_unlocked (int fildes, const char *mode)
76 FILE *const fp = fdopen (fildes, mode);
77 #if defined(HAVE___FSETLOCKING) && defined(FSETLOCKING_BYCALLER)
78 if (fp)
79 __fsetlocking (fp, FSETLOCKING_BYCALLER);
80 #endif
81 return fp;
84 FILE *
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)
89 if (fp)
90 __fsetlocking (fp, FSETLOCKING_BYCALLER);
91 #endif
92 return fp;