Commit 32e82bd8 by Kaveh R. Ghazi Committed by Kaveh Ghazi

libiberty.h (unlock_std_streams): New.

include:
	* libiberty.h (unlock_std_streams): New.

libiberty:
	* fopen_unlocked.c (unlock_std_streams): New.

	* functions.texi: Regenerate.

From-SVN: r98746
parent c2cab3e9
2005-04-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* libiberty.h (unlock_std_streams): New.
2005-04-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2005-04-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* hashtab.h, libiberty.h, objalloc.h, splay-tree.h, ternary.h: * hashtab.h, libiberty.h, objalloc.h, splay-tree.h, ternary.h:
......
...@@ -54,6 +54,12 @@ extern "C" { ...@@ -54,6 +54,12 @@ extern "C" {
extern void unlock_stream (FILE *); extern void unlock_stream (FILE *);
/* If the OS supports it, ensure that the standard I/O streams, stdin,
stdout and stderr are setup to avoid any multi-threaded locking.
Otherwise do nothing. */
extern void unlock_std_streams (void);
/* Open and return a FILE pointer. If the OS supports it, ensure that /* Open and return a FILE pointer. If the OS supports it, ensure that
the stream is setup to avoid any multi-threaded locking. Otherwise the stream is setup to avoid any multi-threaded locking. Otherwise
return the FILE pointer unchanged. */ return the FILE pointer unchanged. */
......
2005-04-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* fopen_unlocked.c (unlock_std_streams): New.
* functions.texi: Regenerate.
2005-04-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2005-04-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* fopen_unlocked.c (unlock_stream): New. * fopen_unlocked.c (unlock_stream): New.
......
...@@ -28,6 +28,14 @@ pointer unchanged. If the @var{stream} is @code{NULL} do nothing. ...@@ -28,6 +28,14 @@ pointer unchanged. If the @var{stream} is @code{NULL} do nothing.
@end deftypefn @end deftypefn
@deftypefn Extension void unlock_std_streams (void)
If the OS supports it, ensure that the standard I/O streams,
@code{stdin}, @code{stdout} and @code{stderr} are setup to avoid any
multi-threaded locking. Otherwise do nothing.
@end deftypefn
@deftypefn Extension FILE * fopen_unlocked (const char *@var{path}, const char * @var{mode}) @deftypefn Extension FILE * fopen_unlocked (const char *@var{path}, const char * @var{mode})
Opens and returns a @code{FILE} pointer via @code{fopen}. If the Opens and returns a @code{FILE} pointer via @code{fopen}. If the
...@@ -80,11 +88,19 @@ unlock_1 (FILE *const fp ATTRIBUTE_UNUSED) ...@@ -80,11 +88,19 @@ unlock_1 (FILE *const fp ATTRIBUTE_UNUSED)
} }
void void
unlock_stream(FILE *fp) unlock_stream (FILE *fp)
{ {
unlock_1 (fp); unlock_1 (fp);
} }
void
unlock_std_streams (void)
{
unlock_1 (stdin);
unlock_1 (stdout);
unlock_1 (stderr);
}
FILE * FILE *
fopen_unlocked (const char *path, const char *mode) fopen_unlocked (const char *path, const char *mode)
{ {
......
...@@ -176,7 +176,7 @@ the possibility of a GCC built-in function. ...@@ -176,7 +176,7 @@ the possibility of a GCC built-in function.
@end deftypefn @end deftypefn
@c asprintf.c:29 @c asprintf.c:32
@deftypefn Extension int asprintf (char **@var{resptr}, const char *@var{format}, ...) @deftypefn Extension int asprintf (char **@var{resptr}, const char *@var{format}, ...)
Like @code{sprintf}, but instead of passing a pointer to a buffer, you Like @code{sprintf}, but instead of passing a pointer to a buffer, you
...@@ -237,7 +237,7 @@ is respectively less than, matching, or greater than the array member. ...@@ -237,7 +237,7 @@ is respectively less than, matching, or greater than the array member.
@end deftypefn @end deftypefn
@c argv.c:121 @c argv.c:124
@deftypefn Extension char** buildargv (char *@var{sp}) @deftypefn Extension char** buildargv (char *@var{sp})
Given a pointer to a string, parse the string extracting fields Given a pointer to a string, parse the string extracting fields
...@@ -318,7 +318,7 @@ pointer encountered. Pointers to empty strings are ignored. ...@@ -318,7 +318,7 @@ pointer encountered. Pointers to empty strings are ignored.
@end deftypefn @end deftypefn
@c argv.c:49 @c argv.c:52
@deftypefn Extension char** dupargv (char **@var{vector}) @deftypefn Extension char** dupargv (char **@var{vector})
Duplicate an argument vector. Simply scans through @var{vector}, Duplicate an argument vector. Simply scans through @var{vector},
...@@ -362,7 +362,7 @@ and inode numbers. ...@@ -362,7 +362,7 @@ and inode numbers.
@end deftypefn @end deftypefn
@c fopen_unlocked.c:40 @c fopen_unlocked.c:48
@deftypefn Extension FILE * fdopen_unlocked (int @var{fildes}, const char * @var{mode}) @deftypefn Extension FILE * fdopen_unlocked (int @var{fildes}, const char * @var{mode})
Opens and returns a @code{FILE} pointer via @code{fdopen}. If the Opens and returns a @code{FILE} pointer via @code{fdopen}. If the
...@@ -431,7 +431,7 @@ Ignores case when performing the comparison. ...@@ -431,7 +431,7 @@ Ignores case when performing the comparison.
@end deftypefn @end deftypefn
@c fopen_unlocked.c:31 @c fopen_unlocked.c:39
@deftypefn Extension FILE * fopen_unlocked (const char *@var{path}, const char * @var{mode}) @deftypefn Extension FILE * fopen_unlocked (const char *@var{path}, const char * @var{mode})
Opens and returns a @code{FILE} pointer via @code{fopen}. If the Opens and returns a @code{FILE} pointer via @code{fopen}. If the
...@@ -441,7 +441,7 @@ unchanged. ...@@ -441,7 +441,7 @@ unchanged.
@end deftypefn @end deftypefn
@c argv.c:94 @c argv.c:97
@deftypefn Extension void freeargv (char **@var{vector}) @deftypefn Extension void freeargv (char **@var{vector})
Free an argument vector that was built using @code{buildargv}. Simply Free an argument vector that was built using @code{buildargv}. Simply
...@@ -451,7 +451,7 @@ itself. ...@@ -451,7 +451,7 @@ itself.
@end deftypefn @end deftypefn
@c fopen_unlocked.c:49 @c fopen_unlocked.c:57
@deftypefn Extension FILE * freopen_unlocked (const char * @var{path}, const char * @var{mode}, FILE * @var{stream}) @deftypefn Extension FILE * freopen_unlocked (const char * @var{path}, const char * @var{mode}, FILE * @var{stream})
Opens and returns a @code{FILE} pointer via @code{freopen}. If the Opens and returns a @code{FILE} pointer via @code{freopen}. If the
...@@ -510,7 +510,7 @@ that @var{tz} be NULL. Returns 0 on success, -1 on failure. ...@@ -510,7 +510,7 @@ that @var{tz} be NULL. Returns 0 on success, -1 on failure.
@end deftypefn @end deftypefn
@c hex.c:30 @c hex.c:33
@deftypefn Extension void hex_init (void) @deftypefn Extension void hex_init (void)
Initializes the array mapping the current character set to Initializes the array mapping the current character set to
...@@ -520,7 +520,7 @@ default ASCII-based table will normally be used on ASCII systems. ...@@ -520,7 +520,7 @@ default ASCII-based table will normally be used on ASCII systems.
@end deftypefn @end deftypefn
@c hex.c:39 @c hex.c:42
@deftypefn Extension int hex_p (int @var{c}) @deftypefn Extension int hex_p (int @var{c})
Evaluates to non-zero if the given character is a valid hex character, Evaluates to non-zero if the given character is a valid hex character,
...@@ -529,7 +529,7 @@ or zero if it is not. Note that the value you pass will be cast to ...@@ -529,7 +529,7 @@ or zero if it is not. Note that the value you pass will be cast to
@end deftypefn @end deftypefn
@c hex.c:47 @c hex.c:50
@deftypefn Extension {unsigned int} hex_value (int @var{c}) @deftypefn Extension {unsigned int} hex_value (int @var{c})
Returns the numeric equivalent of the given character when interpreted Returns the numeric equivalent of the given character when interpreted
...@@ -1201,6 +1201,15 @@ was made to unlink the file because it is special. ...@@ -1201,6 +1201,15 @@ was made to unlink the file because it is special.
@end deftypefn @end deftypefn
@c fopen_unlocked.c:31
@deftypefn Extension void unlock_std_streams (void)
If the OS supports it, ensure that the standard I/O streams,
@code{stdin}, @code{stdout} and @code{stderr} are setup to avoid any
multi-threaded locking. Otherwise do nothing.
@end deftypefn
@c fopen_unlocked.c:23 @c fopen_unlocked.c:23
@deftypefn Extension void unlock_stream (FILE * @var{stream}) @deftypefn Extension void unlock_stream (FILE * @var{stream})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment