diff --git a/src/kernel/libroot/posix/glibc/libio/Jamfile b/src/kernel/libroot/posix/glibc/libio/Jamfile index 893b067aa0..8c137a7a9d 100644 --- a/src/kernel/libroot/posix/glibc/libio/Jamfile +++ b/src/kernel/libroot/posix/glibc/libio/Jamfile @@ -25,7 +25,7 @@ KernelMergeObject posix_gnu_libio.o : <$(SOURCE_GRIST)>flockfile.c <$(SOURCE_GRIST)>fputc.c <$(SOURCE_GRIST)>fputc_u.c -# <$(SOURCE_GRIST)>freopen.c + <$(SOURCE_GRIST)>freopen.c <$(SOURCE_GRIST)>fseek.c <$(SOURCE_GRIST)>fseeko.c <$(SOURCE_GRIST)>ftello.c diff --git a/src/kernel/libroot/posix/glibc/libio/freopen.c b/src/kernel/libroot/posix/glibc/libio/freopen.c index bf2d7688c3..0b4e889cd0 100644 --- a/src/kernel/libroot/posix/glibc/libio/freopen.c +++ b/src/kernel/libroot/posix/glibc/libio/freopen.c @@ -27,9 +27,41 @@ #include "libioP.h" #include "stdio.h" -#include #include + +FILE* +freopen (filename, mode, fp) + const char* filename; + const char* mode; + FILE* fp; +{ + FILE *result; + CHECK_FILE (fp, NULL); + if (!(fp->_flags & _IO_IS_FILEBUF)) + return NULL; + _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); + _IO_flockfile (fp); +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + if (&_IO_stdin_used == NULL) + /* If the shared C library is used by the application binary which + was linked against the older version of libio, we just use the + older one even for internal use to avoid trouble since a pointer + to the old libio may be passed into shared C library and wind + up here. */ + result = _IO_old_freopen (filename, mode, fp); + else +#endif + result = _IO_freopen (filename, mode, fp); + if (result != NULL) + /* unbound stream orientation */ + result->_mode = 0; + _IO_funlockfile (fp); + _IO_cleanup_region_end (0); + return result; +} + +#if 0 #include FILE* @@ -87,3 +119,4 @@ freopen (filename, mode, fp) _IO_cleanup_region_end (0); return result; } +#endif