diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-07-06 17:10:41 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-07-12 21:04:13 +0100 |
commit | 2f6bbc9a7d9a62423c576e13dc46323fe16ba5aa (patch) | |
tree | db52364f1ac7727290c016d724bb0c24b60127f9 /libstdc++-v3/configure | |
parent | 519b29c9e53d110d165059faa8a300c74450235a (diff) | |
download | gcc-2f6bbc9a7d9a62423c576e13dc46323fe16ba5aa.zip gcc-2f6bbc9a7d9a62423c576e13dc46323fe16ba5aa.tar.gz gcc-2f6bbc9a7d9a62423c576e13dc46323fe16ba5aa.tar.bz2 |
libstdc++: Fix --enable-cstdio=stdio_pure [PR110574]
When configured with --enable-cstdio=stdio_pure we need to consistently
use fseek and not mix seeks on the file descriptor with reads and writes
on the FILE stream.
There are also a number of bugs related to error handling and return
values, because fread and fwrite return 0 on error, not -1, and fseek
returns 0 on success, not the file offset.
libstdc++-v3/ChangeLog:
PR libstdc++/110574
* acinclude.m4 (GLIBCXX_CHECK_LFS): Check for fseeko and ftello
and define _GLIBCXX_USE_FSEEKO_FTELLO.
* config.h.in: Regenerate.
* configure: Regenerate.
* config/io/basic_file_stdio.cc (xwrite) [_GLIBCXX_USE_STDIO_PURE]:
Check for fwrite error correctly.
(__basic_file<char>::xsgetn) [_GLIBCXX_USE_STDIO_PURE]: Check for
fread error correctly.
(get_file_offset): New function.
(__basic_file<char>::seekoff) [_GLIBCXX_USE_STDIO_PURE]: Use
fseeko if available. Use get_file_offset instead of return value
of fseek.
(__basic_file<char>::showmanyc): Use get_file_offset.
Diffstat (limited to 'libstdc++-v3/configure')
-rwxr-xr-x | libstdc++-v3/configure | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index c8d5508..36f217c 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -19940,6 +19940,72 @@ $as_echo "$glibcxx_cv_LFS" >&6; } $as_echo "#define _GLIBCXX_USE_LFS 1" >>confdefs.h fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fseeko and ftello" >&5 +$as_echo_n "checking for fseeko and ftello... " >&6; } +if ${glibcxx_cv_posix_lfs+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test x$gcc_no_link = xyes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdio.h> + +int +main () +{ +FILE* fp; + fseeko(fp, 0, SEEK_CUR); + ftello(fp); + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + glibcxx_cv_posix_lfs=yes +else + glibcxx_cv_posix_lfs=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdio.h> + +int +main () +{ +FILE* fp; + fseeko(fp, 0, SEEK_CUR); + ftello(fp); + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + glibcxx_cv_posix_lfs=yes +else + glibcxx_cv_posix_lfs=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_posix_lfs" >&5 +$as_echo "$glibcxx_cv_posix_lfs" >&6; } + if test $glibcxx_cv_posix_lfs = yes; then + +$as_echo "#define _GLIBCXX_USE_FSEEKO_FTELLO 1" >>confdefs.h + + fi + CXXFLAGS="$ac_save_CXXFLAGS" ac_ext=c ac_cpp='$CPP $CPPFLAGS' |