diff options
Diffstat (limited to 'libio/oldstdfiles.c')
-rw-r--r-- | libio/oldstdfiles.c | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/libio/oldstdfiles.c b/libio/oldstdfiles.c index 3017109..64c792f 100644 --- a/libio/oldstdfiles.c +++ b/libio/oldstdfiles.c @@ -36,22 +36,52 @@ #define DEF_STDFILE(INAME, NAME, FD, CHAIN, FLAGS) \ static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \ struct _IO_FILE_plus INAME \ - = {FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_old_file_jumps}; \ - symbol_version (INAME, NAME,) + = {FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_old_file_jumps}; #else #define DEF_STDFILE(INAME, NAME, FD, CHAIN, FLAGS) \ struct _IO_FILE_plus INAME \ - = {FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_old_file_jumps}; \ - symbol_version (INAME, NAME,) + = {FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_old_file_jumps}; #endif -DEF_STDFILE(_IO_old_stdin_, _IO_stdin_, 0, 0, _IO_NO_WRITES); -DEF_STDFILE(_IO_old_stdout_, _IO_stdout_, 1, &_IO_stdin_.plus.file, +DEF_STDFILE(_IO_stdin_, _IO_stdin_, 0, 0, _IO_NO_WRITES); +DEF_STDFILE(_IO_stdout_, _IO_stdout_, 1, &_IO_stdin_.file, _IO_NO_READS); -DEF_STDFILE(_IO_old_stderr_, _IO_stderr_, 2, &_IO_stdout_.plus.file, +DEF_STDFILE(_IO_stderr_, _IO_stderr_, 2, &_IO_stdout_.file, _IO_NO_READS+_IO_UNBUFFERED); -#if 0 -_IO_FILE *_IO_old_list_all = &_IO_stderr_.plus.file; -symbol_version (_IO_old_list_all, _IO_list_all,); +#if defined __GNUC__ && __GNUC__ >= 2 + +#include <stdio.h> + +extern void * _IO_stdin_used; +weak_extern (_IO_stdin_used); + +#undef stdin +#undef stdout +#undef stderr + +extern FILE *stdin; +extern FILE *stdout; +extern FILE *stderr; + +extern FILE *_IO_list_all; + +static void _IO_check_libio __P ((void)) __attribute__ ((constructor)); + +/* This function determines which shared C library the application + was linked against. We then set up the stdin/stdout/stderr and + _IO_list_all accordingly. */ + +static void +_IO_check_libio () +{ + if (&_IO_stdin_used == NULL) + { + /* We are using the old one. */ + stdin = &_IO_stdin_.file; + stdout = &_IO_stdout_.file; + stderr = _IO_list_all = &_IO_stderr_.file; + } +} + #endif |