diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-09-15 13:43:43 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-09-15 21:57:41 +0100 |
commit | c4baeaecbbf7d0626d44ac0b69b3c8456dddb01a (patch) | |
tree | 1b921a92b810e0e0ddf455ab9456d9726347db3d /libstdc++-v3/configure | |
parent | a923c52920d2f5c6cbd486f465dc4aec2d1f9544 (diff) | |
download | gcc-c4baeaecbbf7d0626d44ac0b69b3c8456dddb01a.zip gcc-c4baeaecbbf7d0626d44ac0b69b3c8456dddb01a.tar.gz gcc-c4baeaecbbf7d0626d44ac0b69b3c8456dddb01a.tar.bz2 |
libstdc++: Implement C++26 native handles for file streams (P1759R6)
The new __basic_file::native_handle() function can be added for C++11
and above, because the names "native_handle" and "native_handle_type"
are already reserved since C++11. Exporting those symbols from the
shared library does no harm, even if the feature gets dropped before the
C++23 standard is final.
The new member functions of std::fstream etc. are only declared for
C++26 and so are not instantiated in src/c++11/fstream-inst.cc. Declare
them with the always_inline attribute so that no symbol definitions are
needed in the library (we can change this later when C++26 support is
less experimental).
libstdc++-v3/ChangeLog:
* acinclude.m4 (GLIBCXX_CHECK_FILEBUF_NATIVE_HANDLES): New
macro.
* config.h.in: Regenerate.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.32): Export new
basic_filebuf members.
* config/io/basic_file_stdio.cc (__basic_file::native_handle):
Define new function.
* config/io/basic_file_stdio.h (__basic_file::native_handle):
Declare new function.
* configure: Regenerate.
* configure.ac: Use GLIBCXX_CHECK_FILEBUF_NATIVE_HANDLES.
* include/bits/version.def (fstream_native_handles): New macro.
* include/bits/version.h: Regenerate.
* include/std/fstream (basic_filebuf::native_handle)
(basic_fstream::native_handle, basic_ifstream::native_handle)
(basic_ofstream::native_handle): New functions.
* src/c++11/Makefile.am: Move compilation of basic_file.cc,
locale_init.cc and localename.cc to here.
* src/c++11/Makefile.in: Regenerate.
* src/c++98/locale_init.cc: Moved to...
* src/c++11/locale_init.cc: ...here.
* src/c++98/localename.cc: Moved to...
* src/c++11/localename.cc: ...here.
* src/c++98/Makefile.am: Remove basic_file.cc, locale_init.cc
and localename.cc from here.
* src/c++98/Makefile.in: Regenerate.
* testsuite/27_io/basic_filebuf/native_handle/version.cc: New test.
* testsuite/27_io/basic_fstream/native_handle/char/1.cc: New test.
* testsuite/27_io/basic_fstream/native_handle/wchar_t/1.cc: New test.
* testsuite/27_io/basic_ifstream/native_handle/char/1.cc: New test.
* testsuite/27_io/basic_ifstream/native_handle/wchar_t/1.cc: New test.
* testsuite/27_io/basic_ofstream/native_handle/char/1.cc: New test.
* testsuite/27_io/basic_ofstream/native_handle/wchar_t/1.cc: New test.
Diffstat (limited to 'libstdc++-v3/configure')
-rwxr-xr-x | libstdc++-v3/configure | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 9ac6771..13fc03b 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -73906,6 +73906,63 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +# For __basic_file::native_handle() + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether _get_osfhandle is defined in <io.h>" >&5 +$as_echo_n "checking whether _get_osfhandle is defined in <io.h>... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #if defined(_WIN32) && !defined(__CYGWIN__) + # include <stdint.h> + # include <io.h> + #endif + +int +main () +{ + + FILE* file = 0; + int fd = fileno(file); + intptr_t crt_handle = _get_osfhandle(fd); + void* win32_handle = reinterpret_cast<void*>(crt_handle); + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_get_osfhandle=yes +else + ac_get_osfhandle=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test "$ac_objext" = yes; then + +cat >>confdefs.h <<_ACEOF +#define _GLIBCXX_USE__GET_OSFHANDLE 1 +_ACEOF + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_get_osfhandle" >&5 +$as_echo "$ac_get_osfhandle" >&6; } + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + # Define documentation rules conditionally. # See if makeinfo has been installed and is modern enough |