PR libstdc++/86756 Move rest of std::filesystem to libstdc++.so

Move std::filesystem directory iterators and operations from
libstdc++fs.a to main libstdc++ library. These components have many
dependencies on OS support, which is not available on all targets. Some
additional autoconf checks and conditional compilation is needed to
ensure the files will build for all targets. Previously this code was
not compiled without --enable-libstdcxx-filesystem-ts but the C++17
components should be available for all hosted builds.

The tests for these components no longer need to link to libstdc++fs.a,
but are not expected to pass on all targets. To avoid numerous failures
on targets which are not expected to pass the tests (due to missing OS
functionality) leave the dg-require-filesystem-ts directives in place
for now. This will ensure the tests only run for builds where the
filesystem-ts library is built, which presumably means some level of OS
support is present.

	PR libstdc++/86756
	* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for utime and
	lstat and define _GLIBCXX_USE_UTIME and _GLIBCXX_USE_LSTAT.
	* config.h.in: Regenerate.
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Export symbols for
	remaining std::filesystem types and functions.
	* configure: Regenerate.
	* src/c++17/Makefile.am: Add C++17 filesystem sources.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++17/cow-fs_dir.cc: Move src/filesystem/cow-std-dir.cc to
	here, and change name of included file.
	* src/c++17/cow-fs_ops.cc: Move src/filesystem/cow-std-ops.cc to
	here, and change name of included file.
	* src/c++17/fs_dir.cc: Move src/filesystem/std-dir.cc to here. Change
	path to dir-common.h.
	* src/c++17/fs_ops.cc: Move src/filesystem/std-ops.cc to here. Change
	path to ops-common.h. Disable -Wunused-parameter warnings.
	(internal_file_clock): Define unconditionally.
	[!_GLIBCXX_HAVE_SYS_STAT_H] (internal_file_clock::from_stat): Do not
	define.
	(do_copy_file, do_space): Move definitions to ops.common.h.
	(copy, file_size, hard_link_count, last_write_time, space): Only
	perform operation when _GLIBCXX_HAVE_SYS_STAT_H is defined, otherwise
	report an error.
	(last_write_time, read_symlink): Remove unused attributes from
	parameters.
	* src/filesystem/Makefile.am: Remove C++17 filesystem sources.
	* src/filesystem/Makefile.in: Regenerate.
	* src/filesystem/cow-std-dir.cc: Move to src/c++17/cow-fs_dir.cc.
	* src/filesystem/cow-std-ops.cc: Move to src/c++17/cow-fs_ops.cc.
	* src/filesystem/std-dir.cc: Move to src/c++17/fs_dir.cc.
	* src/filesystem/std-ops.cc: Move to src/c++17/fs_ops.cc.
	* src/filesystem/dir-common.h [!_GLIBCXX_HAVE_DIRENT_H]: Define
	dummy types and functions instead of using #error.
	* src/filesystem/dir.cc [!_GLIBCXX_HAVE_DIRENT_H]: Use #error.
	* src/filesystem/ops-common.h [!_GLIBCXX_USE_LSTAT] (lstat): Define
	in terms of stat.
	[!_GLIBCXX_HAVE_UNISTD_H]: Define dummy types and functions.
	(do_copy_file, do_space): Move definitions here from std-ops.cc.
	* src/filesystem/ops.cc: Adjust calls to do_copy_file and do_space
	to account for new namespace.
	* testsuite/27_io/filesystem/directory_entry/86597.cc: Remove
	-lstdc++fs from dg-options.
	* testsuite/27_io/filesystem/directory_entry/lwg3171.cc: Likewise.
	* testsuite/27_io/filesystem/file_status/1.cc: Likewise.
	* testsuite/27_io/filesystem/filesystem_error/cons.cc: Likewise.
	* testsuite/27_io/filesystem/filesystem_error/copy.cc: Likewise.
	* testsuite/27_io/filesystem/iterators/directory_iterator.cc:
	Likewise.
	* testsuite/27_io/filesystem/iterators/pop.cc: Likewise.
	* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/absolute.cc: Likewise.
	* testsuite/27_io/filesystem/operations/canonical.cc: Likewise.
	* testsuite/27_io/filesystem/operations/copy.cc: Likewise.
	* testsuite/27_io/filesystem/operations/copy_file.cc: Likewise.
	* testsuite/27_io/filesystem/operations/create_directories.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/create_directory.cc: Likewise.
	* testsuite/27_io/filesystem/operations/create_symlink.cc: Likewise.
	* testsuite/27_io/filesystem/operations/current_path.cc: Likewise.
	* testsuite/27_io/filesystem/operations/equivalent.cc: Likewise.
	* testsuite/27_io/filesystem/operations/exists.cc: Likewise.
	* testsuite/27_io/filesystem/operations/file_size.cc: Likewise.
	* testsuite/27_io/filesystem/operations/is_empty.cc: Likewise.
	* testsuite/27_io/filesystem/operations/last_write_time.cc: Likewise.
	* testsuite/27_io/filesystem/operations/permissions.cc: Likewise.
	* testsuite/27_io/filesystem/operations/proximate.cc: Likewise.
	* testsuite/27_io/filesystem/operations/read_symlink.cc: Likewise.
	* testsuite/27_io/filesystem/operations/relative.cc: Likewise.
	* testsuite/27_io/filesystem/operations/remove.cc: Likewise.
	* testsuite/27_io/filesystem/operations/remove_all.cc: Likewise.
	* testsuite/27_io/filesystem/operations/space.cc: Likewise.
	* testsuite/27_io/filesystem/operations/status.cc: Likewise.
	* testsuite/27_io/filesystem/operations/symlink_status.cc: Likewise.
	* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/weakly_canonical.cc: Likewise.

From-SVN: r267616
This commit is contained in:
Jonathan Wakely 2019-01-06 22:34:37 +00:00 committed by Jonathan Wakely
parent 2b5225352e
commit de4db54fd9
49 changed files with 692 additions and 329 deletions

View file

@ -1,5 +1,85 @@
2019-01-06 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/86756
* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for utime and
lstat and define _GLIBCXX_USE_UTIME and _GLIBCXX_USE_LSTAT.
* config.h.in: Regenerate.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Export symbols for
remaining std::filesystem types and functions.
* configure: Regenerate.
* src/c++17/Makefile.am: Add C++17 filesystem sources.
* src/c++17/Makefile.in: Regenerate.
* src/c++17/cow-fs_dir.cc: Move src/filesystem/cow-std-dir.cc to
here, and change name of included file.
* src/c++17/cow-fs_ops.cc: Move src/filesystem/cow-std-ops.cc to
here, and change name of included file.
* src/c++17/fs_dir.cc: Move src/filesystem/std-dir.cc to here. Change
path to dir-common.h.
* src/c++17/fs_ops.cc: Move src/filesystem/std-ops.cc to here. Change
path to ops-common.h. Disable -Wunused-parameter warnings.
(internal_file_clock): Define unconditionally.
[!_GLIBCXX_HAVE_SYS_STAT_H] (internal_file_clock::from_stat): Do not
define.
(do_copy_file, do_space): Move definitions to ops.common.h.
(copy, file_size, hard_link_count, last_write_time, space): Only
perform operation when _GLIBCXX_HAVE_SYS_STAT_H is defined, otherwise
report an error.
(last_write_time, read_symlink): Remove unused attributes from
parameters.
* src/filesystem/Makefile.am: Remove C++17 filesystem sources.
* src/filesystem/Makefile.in: Regenerate.
* src/filesystem/cow-std-dir.cc: Move to src/c++17/cow-fs_dir.cc.
* src/filesystem/cow-std-ops.cc: Move to src/c++17/cow-fs_ops.cc.
* src/filesystem/std-dir.cc: Move to src/c++17/fs_dir.cc.
* src/filesystem/std-ops.cc: Move to src/c++17/fs_ops.cc.
* src/filesystem/dir-common.h [!_GLIBCXX_HAVE_DIRENT_H]: Define
dummy types and functions instead of using #error.
* src/filesystem/dir.cc [!_GLIBCXX_HAVE_DIRENT_H]: Use #error.
* src/filesystem/ops-common.h [!_GLIBCXX_USE_LSTAT] (lstat): Define
in terms of stat.
[!_GLIBCXX_HAVE_UNISTD_H]: Define dummy types and functions.
(do_copy_file, do_space): Move definitions here from std-ops.cc.
* src/filesystem/ops.cc: Adjust calls to do_copy_file and do_space
to account for new namespace.
* testsuite/27_io/filesystem/directory_entry/86597.cc: Remove
-lstdc++fs from dg-options.
* testsuite/27_io/filesystem/directory_entry/lwg3171.cc: Likewise.
* testsuite/27_io/filesystem/file_status/1.cc: Likewise.
* testsuite/27_io/filesystem/filesystem_error/cons.cc: Likewise.
* testsuite/27_io/filesystem/filesystem_error/copy.cc: Likewise.
* testsuite/27_io/filesystem/iterators/directory_iterator.cc:
Likewise.
* testsuite/27_io/filesystem/iterators/pop.cc: Likewise.
* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc:
Likewise.
* testsuite/27_io/filesystem/operations/absolute.cc: Likewise.
* testsuite/27_io/filesystem/operations/canonical.cc: Likewise.
* testsuite/27_io/filesystem/operations/copy.cc: Likewise.
* testsuite/27_io/filesystem/operations/copy_file.cc: Likewise.
* testsuite/27_io/filesystem/operations/create_directories.cc:
Likewise.
* testsuite/27_io/filesystem/operations/create_directory.cc: Likewise.
* testsuite/27_io/filesystem/operations/create_symlink.cc: Likewise.
* testsuite/27_io/filesystem/operations/current_path.cc: Likewise.
* testsuite/27_io/filesystem/operations/equivalent.cc: Likewise.
* testsuite/27_io/filesystem/operations/exists.cc: Likewise.
* testsuite/27_io/filesystem/operations/file_size.cc: Likewise.
* testsuite/27_io/filesystem/operations/is_empty.cc: Likewise.
* testsuite/27_io/filesystem/operations/last_write_time.cc: Likewise.
* testsuite/27_io/filesystem/operations/permissions.cc: Likewise.
* testsuite/27_io/filesystem/operations/proximate.cc: Likewise.
* testsuite/27_io/filesystem/operations/read_symlink.cc: Likewise.
* testsuite/27_io/filesystem/operations/relative.cc: Likewise.
* testsuite/27_io/filesystem/operations/remove.cc: Likewise.
* testsuite/27_io/filesystem/operations/remove_all.cc: Likewise.
* testsuite/27_io/filesystem/operations/space.cc: Likewise.
* testsuite/27_io/filesystem/operations/status.cc: Likewise.
* testsuite/27_io/filesystem/operations/symlink_status.cc: Likewise.
* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
Likewise.
* testsuite/27_io/filesystem/operations/weakly_canonical.cc: Likewise.
PR libstdc++/86756
* config/abi/pre/gnu.ver (GLIBCXX_3.4): Make various patterns for
typeinfo and vtables less greedy.

View file

@ -4451,6 +4451,40 @@ dnl
AC_DEFINE(_GLIBCXX_USE_UTIMENSAT, 1, [Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and AT_FDCWD in <fcntl.h>.])
fi
AC_MSG_RESULT($glibcxx_cv_utimensat)
dnl
AC_MSG_CHECKING([for utime])
AC_CACHE_VAL(glibcxx_cv_utime, [dnl
GCC_TRY_COMPILE_OR_LINK(
[
#include <utime.h>
],
[
struct utimbuf t = { 1, 1 };
int i = utime("path", &t);
],
[glibcxx_cv_utime=yes],
[glibcxx_cv_utime=no])
])
if test $glibcxx_cv_utime = yes; then
AC_DEFINE(_GLIBCXX_USE_UTIME, 1, [Define if utime is available in <utime.h>.])
fi
AC_MSG_RESULT($glibcxx_cv_utime)
dnl
AC_MSG_CHECKING([for lstat])
AC_CACHE_VAL(glibcxx_cv_lstat, [dnl
GCC_TRY_COMPILE_OR_LINK(
[ #include <sys/stat.h> ],
[
struct stat st;
int i = lstat("path", &st);
],
[glibcxx_cv_lstat=yes],
[glibcxx_cv_lstat=no])
])
if test $glibcxx_cv_lstat = yes; then
AC_DEFINE(_GLIBCXX_USE_LSTAT, 1, [Define if lstat is available in <sys/stat.h>.])
fi
AC_MSG_RESULT($glibcxx_cv_lstat)
dnl
AC_MSG_CHECKING([for struct stat.st_mtim.tv_nsec])
AC_CACHE_VAL(glibcxx_cv_st_mtim, [dnl

View file

@ -970,6 +970,9 @@
/* Define if code specialized for long long should be used. */
#undef _GLIBCXX_USE_LONG_LONG
/* Define if lstat is available in <sys/stat.h>. */
#undef _GLIBCXX_USE_LSTAT
/* Defined if nanosleep is available. */
#undef _GLIBCXX_USE_NANOSLEEP
@ -1010,6 +1013,9 @@
/* Define if obsolescent tmpnam is available in <stdio.h>. */
#undef _GLIBCXX_USE_TMPNAM
/* Define if utime is available in <utime.h>. */
#undef _GLIBCXX_USE_UTIME
/* Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and
AT_FDCWD in <fcntl.h>. */
#undef _GLIBCXX_USE_UTIMENSAT

View file

@ -2167,6 +2167,58 @@ GLIBCXX_3.4.26 {
_ZNSt10filesystem7__cxx114pathpLERKS1_;
_ZT[IV]NSt10filesystem7__cxx1116filesystem_errorE;
_ZNSt10filesystem10equivalent*;
_ZNSt10filesystem10remove_all*;
_ZNSt10filesystem11permissions*;
_ZNSt10filesystem12current_path*;
_ZNSt10filesystem12read_symlink*;
_ZNSt10filesystem14create_symlink*;
_ZNSt10filesystem14symlink_status*;
_ZNSt10filesystem15last_write_time*;
_ZNSt10filesystem16create_directory*;
_ZNSt10filesystem16create_hard_link*;
_ZNSt10filesystem16weakly_canonical*;
_ZNSt10filesystem18create_directories*;
_ZNSt10filesystem19temp_directory_path*;
_ZNSt10filesystem24create_directory_symlink*;
_ZNSt10filesystem4copy*;
_ZNSt10filesystem5space*;
_ZNSt10filesystem6remove*;
_ZNSt10filesystem6status*;
_ZNSt10filesystem8absolute*;
_ZNSt10filesystem8is_empty*;
_ZNSt10filesystem8relative*;
_ZNSt10filesystem9canonical*;
_ZNSt10filesystem9copy_file*;
_ZNSt10filesystem9file_size*;
_ZNSt10filesystem9proximate*;
_ZNKSt10filesystem18directory_iteratordeEv;
_ZNKSt10filesystem28recursive_directory_iterator5depthEv;
_ZNKSt10filesystem28recursive_directory_iteratordeEv;
_ZNSt10filesystem18directory_iteratorC[12]ERKNS_4pathENS_17directory_optionsEPSt10error_code;
_ZNSt10filesystem18directory_iteratorppEv;
_ZNSt10filesystem28recursive_directory_iterator3popERSt10error_code;
_ZNSt10filesystem28recursive_directory_iterator3popEv;
_ZNSt10filesystem28recursive_directory_iterator9incrementERSt10error_code;
_ZNSt10filesystem28recursive_directory_iteratorC[12]ERKNS_4pathENS_17directory_optionsEPSt10error_code;
_ZNSt10filesystem28recursive_directory_iteratorD[12]Ev;
_ZNSt10filesystem28recursive_directory_iteratoraSEOS0_;
_ZNSt10filesystem28recursive_directory_iteratorppEv;
_ZNKSt10filesystem7__cxx1118directory_iteratordeEv;
_ZNKSt10filesystem7__cxx1128recursive_directory_iterator5depthEv;
_ZNKSt10filesystem7__cxx1128recursive_directory_iteratordeEv;
_ZNSt10filesystem7__cxx1118directory_iteratorC[12]ERKNS0_4pathENS_17directory_optionsEPSt10error_code;
_ZNSt10filesystem7__cxx1118directory_iteratorppEv;
_ZNSt10filesystem7__cxx1128recursive_directory_iterator3popERSt10error_code;
_ZNSt10filesystem7__cxx1128recursive_directory_iterator3popEv;
_ZNSt10filesystem7__cxx1128recursive_directory_iterator9incrementERSt10error_code;
_ZNSt10filesystem7__cxx1128recursive_directory_iteratorC[12]ERKNS0_4pathENS_17directory_optionsEPSt10error_code;
_ZNSt10filesystem7__cxx1128recursive_directory_iteratorD[12]Ev;
_ZNSt10filesystem7__cxx1128recursive_directory_iteratoraSEOS1_;
_ZNSt10filesystem7__cxx1128recursive_directory_iteratorppEv;
} GLIBCXX_3.4.25;
# Symbols in the support library (libsupc++) have their own tag.

128
libstdc++-v3/configure vendored
View file

@ -80499,6 +80499,134 @@ $as_echo "#define _GLIBCXX_USE_UTIMENSAT 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_utimensat" >&5
$as_echo "$glibcxx_cv_utimensat" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for utime" >&5
$as_echo_n "checking for utime... " >&6; }
if ${glibcxx_cv_utime+:} 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 <utime.h>
int
main ()
{
struct utimbuf t = { 1, 1 };
int i = utime("path", &t);
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
glibcxx_cv_utime=yes
else
glibcxx_cv_utime=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 <utime.h>
int
main ()
{
struct utimbuf t = { 1, 1 };
int i = utime("path", &t);
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
glibcxx_cv_utime=yes
else
glibcxx_cv_utime=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
fi
if test $glibcxx_cv_utime = yes; then
$as_echo "#define _GLIBCXX_USE_UTIME 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_utime" >&5
$as_echo "$glibcxx_cv_utime" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lstat" >&5
$as_echo_n "checking for lstat... " >&6; }
if ${glibcxx_cv_lstat+:} 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 <sys/stat.h>
int
main ()
{
struct stat st;
int i = lstat("path", &st);
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
glibcxx_cv_lstat=yes
else
glibcxx_cv_lstat=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 <sys/stat.h>
int
main ()
{
struct stat st;
int i = lstat("path", &st);
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
glibcxx_cv_lstat=yes
else
glibcxx_cv_lstat=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
fi
if test $glibcxx_cv_lstat = yes; then
$as_echo "#define _GLIBCXX_USE_LSTAT 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_lstat" >&5
$as_echo "$glibcxx_cv_lstat" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct stat.st_mtim.tv_nsec" >&5
$as_echo_n "checking for struct stat.st_mtim.tv_nsec... " >&6; }
if ${glibcxx_cv_st_mtim+:} false; then :

View file

@ -29,7 +29,10 @@ headers =
if ENABLE_DUAL_ABI
extra_string_inst_sources = cow-string-inst.cc
extra_fs_sources = cow-fs_path.cc
extra_fs_sources = \
cow-fs_dir.cc \
cow-fs_ops.cc \
cow-fs_path.cc
else
extra_string_inst_sources =
extra_fs_sources =
@ -45,6 +48,8 @@ inst_sources =
endif
sources = \
fs_dir.cc \
fs_ops.cc \
fs_path.cc \
memory_resource.cc \
string-inst.cc \

View file

@ -121,9 +121,10 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libc__17convenience_la_LIBADD =
@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-fs_path.lo
am__objects_2 = fs_path.lo memory_resource.lo string-inst.lo \
$(am__objects_1)
@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-fs_dir.lo cow-fs_ops.lo \
@ENABLE_DUAL_ABI_TRUE@ cow-fs_path.lo
am__objects_2 = fs_dir.lo fs_ops.lo fs_path.lo memory_resource.lo \
string-inst.lo $(am__objects_1)
@ENABLE_DUAL_ABI_TRUE@am__objects_3 = cow-string-inst.lo
@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_4 = $(am__objects_3)
am_libc__17convenience_la_OBJECTS = $(am__objects_2) $(am__objects_4)
@ -415,7 +416,11 @@ headers =
@ENABLE_DUAL_ABI_FALSE@extra_string_inst_sources =
@ENABLE_DUAL_ABI_TRUE@extra_string_inst_sources = cow-string-inst.cc
@ENABLE_DUAL_ABI_FALSE@extra_fs_sources =
@ENABLE_DUAL_ABI_TRUE@extra_fs_sources = cow-fs_path.cc
@ENABLE_DUAL_ABI_TRUE@extra_fs_sources = \
@ENABLE_DUAL_ABI_TRUE@ cow-fs_dir.cc \
@ENABLE_DUAL_ABI_TRUE@ cow-fs_ops.cc \
@ENABLE_DUAL_ABI_TRUE@ cow-fs_path.cc
# XTEMPLATE_FLAGS =
@ENABLE_EXTERN_TEMPLATE_FALSE@inst_sources =
@ -424,6 +429,8 @@ headers =
@ENABLE_EXTERN_TEMPLATE_TRUE@ $(extra_string_inst_sources)
sources = \
fs_dir.cc \
fs_ops.cc \
fs_path.cc \
memory_resource.cc \
string-inst.cc \

View file

@ -23,4 +23,4 @@
// <http://www.gnu.org/licenses/>.
#define _GLIBCXX_USE_CXX11_ABI 0
#include "std-dir.cc"
#include "fs_dir.cc"

View file

@ -23,4 +23,4 @@
// <http://www.gnu.org/licenses/>.
#define _GLIBCXX_USE_CXX11_ABI 0
#include "std-ops.cc"
#include "fs_ops.cc"

View file

@ -27,14 +27,13 @@
#endif
#include <filesystem>
#include <experimental/filesystem>
#include <utility>
#include <stack>
#include <string.h>
#include <errno.h>
#define _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM namespace filesystem {
#define _GLIBCXX_END_NAMESPACE_FILESYSTEM }
#include "dir-common.h"
#include "../filesystem/dir-common.h"
namespace fs = std::filesystem;
namespace posix = std::filesystem::__gnu_posix;

View file

@ -29,11 +29,9 @@
#endif
#include <filesystem>
#include <experimental/filesystem>
#include <functional>
#include <ostream>
#include <stack>
#include <ext/stdio_filebuf.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
@ -47,9 +45,6 @@
#ifdef _GLIBCXX_HAVE_SYS_STATVFS_H
# include <sys/statvfs.h> // statvfs
#endif
#ifdef _GLIBCXX_USE_SENDFILE
# include <sys/sendfile.h> // sendfile
#endif
#if !_GLIBCXX_USE_UTIMENSAT && _GLIBCXX_HAVE_UTIME_H
# include <utime.h> // utime
#endif
@ -59,7 +54,9 @@
#define _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM namespace filesystem {
#define _GLIBCXX_END_NAMESPACE_FILESYSTEM }
#include "ops-common.h"
#include "../filesystem/ops-common.h"
#pragma GCC diagnostic ignored "-Wunused-parameter"
namespace fs = std::filesystem;
namespace posix = std::filesystem::__gnu_posix;
@ -274,8 +271,6 @@ namespace std::filesystem
}
}
#ifdef _GLIBCXX_HAVE_SYS_STAT_H
namespace
{
struct internal_file_clock : fs::__file_clock
@ -283,6 +278,7 @@ namespace
using __file_clock::_S_to_sys;
using __file_clock::_S_from_sys;
#ifdef _GLIBCXX_HAVE_SYS_STAT_H
static fs::file_time_type
from_stat(const fs::stat_type& st, std::error_code& ec) noexcept
{
@ -291,209 +287,15 @@ namespace
return fs::file_time_type::min();
return _S_from_sys(sys_time);
}
#endif
};
}
#ifdef NEED_DO_COPY_FILE
bool
fs::do_copy_file(const path::value_type* from, const path::value_type* to,
copy_options_existing_file options,
stat_type* from_st, stat_type* to_st,
std::error_code& ec) noexcept
{
stat_type st1, st2;
fs::file_status t, f;
if (to_st == nullptr)
{
if (posix::stat(to, &st1))
{
const int err = errno;
if (!is_not_found_errno(err))
{
ec.assign(err, std::generic_category());
return false;
}
}
else
to_st = &st1;
}
else if (to_st == from_st)
to_st = nullptr;
if (to_st == nullptr)
t = fs::file_status{fs::file_type::not_found};
else
t = make_file_status(*to_st);
if (from_st == nullptr)
{
if (posix::stat(from, &st2))
{
ec.assign(errno, std::generic_category());
return false;
}
else
from_st = &st2;
}
f = make_file_status(*from_st);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2712. copy_file() has a number of unspecified error conditions
if (!is_regular_file(f))
{
ec = std::make_error_code(std::errc::not_supported);
return false;
}
if (exists(t))
{
if (!is_regular_file(t))
{
ec = std::make_error_code(std::errc::not_supported);
return false;
}
if (to_st->st_dev == from_st->st_dev
&& to_st->st_ino == from_st->st_ino)
{
ec = std::make_error_code(std::errc::file_exists);
return false;
}
if (options.skip)
{
ec.clear();
return false;
}
else if (options.update)
{
const auto from_mtime = internal_file_clock::from_stat(*from_st, ec);
if (ec)
return false;
if ((from_mtime <= internal_file_clock::from_stat(*to_st, ec)) || ec)
return false;
}
else if (!options.overwrite)
{
ec = std::make_error_code(std::errc::file_exists);
return false;
}
else if (!is_regular_file(t))
{
ec = std::make_error_code(std::errc::not_supported);
return false;
}
}
struct CloseFD {
~CloseFD() { if (fd != -1) posix::close(fd); }
bool close() { return posix::close(std::exchange(fd, -1)) == 0; }
int fd;
};
CloseFD in = { posix::open(from, O_RDONLY) };
if (in.fd == -1)
{
ec.assign(errno, std::generic_category());
return false;
}
int oflag = O_WRONLY|O_CREAT;
if (options.overwrite || options.update)
oflag |= O_TRUNC;
else
oflag |= O_EXCL;
CloseFD out = { posix::open(to, oflag, S_IWUSR) };
if (out.fd == -1)
{
if (errno == EEXIST && options.skip)
ec.clear();
else
ec.assign(errno, std::generic_category());
return false;
}
#if defined _GLIBCXX_USE_FCHMOD && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS
if (::fchmod(out.fd, from_st->st_mode))
#elif defined _GLIBCXX_USE_FCHMODAT && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS
if (::fchmodat(AT_FDCWD, to, from_st->st_mode, 0))
#else
if (posix::chmod(to, from_st->st_mode))
#endif
{
ec.assign(errno, std::generic_category());
return false;
}
size_t count = from_st->st_size;
#if defined _GLIBCXX_USE_SENDFILE && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS
off_t offset = 0;
ssize_t n = ::sendfile(out.fd, in.fd, &offset, count);
if (n < 0 && errno != ENOSYS && errno != EINVAL)
{
ec.assign(errno, std::generic_category());
return false;
}
if ((size_t)n == count)
{
if (!out.close() || !in.close())
{
ec.assign(errno, std::generic_category());
return false;
}
ec.clear();
return true;
}
else if (n > 0)
count -= n;
#endif // _GLIBCXX_USE_SENDFILE
using std::ios;
__gnu_cxx::stdio_filebuf<char> sbin(in.fd, ios::in|ios::binary);
__gnu_cxx::stdio_filebuf<char> sbout(out.fd, ios::out|ios::binary);
if (sbin.is_open())
in.fd = -1;
if (sbout.is_open())
out.fd = -1;
#ifdef _GLIBCXX_USE_SENDFILE
if (n != 0)
{
if (n < 0)
n = 0;
const auto p1 = sbin.pubseekoff(n, ios::beg, ios::in);
const auto p2 = sbout.pubseekoff(n, ios::beg, ios::out);
const std::streampos errpos(std::streamoff(-1));
if (p1 == errpos || p2 == errpos)
{
ec = std::make_error_code(std::errc::io_error);
return false;
}
}
#endif
if (count && !(std::ostream(&sbout) << &sbin))
{
ec = std::make_error_code(std::errc::io_error);
return false;
}
if (!sbout.close() || !sbin.close())
{
ec.assign(errno, std::generic_category());
return false;
}
ec.clear();
return true;
}
#endif // NEED_DO_COPY_FILE
#endif // _GLIBCXX_HAVE_SYS_STAT_H
void
fs::copy(const path& from, const path& to, copy_options options,
error_code& ec)
{
#ifdef _GLIBCXX_HAVE_SYS_STAT_H
const bool skip_symlinks = is_set(options, copy_options::skip_symlinks);
const bool create_symlinks = is_set(options, copy_options::create_symlinks);
const bool copy_symlinks = is_set(options, copy_options::copy_symlinks);
@ -591,6 +393,9 @@ fs::copy(const path& from, const path& to, copy_options options,
// 2683. filesystem::copy() says "no effects"
else
ec.clear();
#else
ec = std::make_error_code(std::errc::not_supported);
#endif
}
bool
@ -1068,6 +873,7 @@ namespace
std::uintmax_t
fs::file_size(const path& p, error_code& ec) noexcept
{
#ifdef _GLIBCXX_HAVE_SYS_STAT_H
struct S
{
S(const stat_type& st) : type(make_file_type(st)), size(st.st_size) { }
@ -1085,6 +891,9 @@ fs::file_size(const path& p, error_code& ec) noexcept
else
ec = std::make_error_code(std::errc::not_supported);
}
#else
ec = std::make_error_code(std::errc::not_supported);
#endif
return -1;
}
@ -1101,8 +910,13 @@ fs::hard_link_count(const path& p)
std::uintmax_t
fs::hard_link_count(const path& p, error_code& ec) noexcept
{
#ifdef _GLIBCXX_HAVE_SYS_STAT_H
return do_stat(p, ec, std::mem_fn(&stat_type::st_nlink),
static_cast<uintmax_t>(-1));
#else
ec = std::make_error_code(std::errc::not_supported);
return static_cast<uintmax_t>(-1);
#endif
}
bool
@ -1141,11 +955,16 @@ fs::last_write_time(const path& p)
fs::file_time_type
fs::last_write_time(const path& p, error_code& ec) noexcept
{
#ifdef _GLIBCXX_HAVE_SYS_STAT_H
return do_stat(p, ec,
[&ec](const auto& st) {
return internal_file_clock::from_stat(st, ec);
},
file_time_type::min());
#else
ec = std::make_error_code(std::errc::not_supported);
return file_time_type::min();
#endif
}
void
@ -1158,7 +977,7 @@ fs::last_write_time(const path& p, file_time_type new_time)
}
void
fs::last_write_time(const path& p __attribute__((__unused__)),
fs::last_write_time(const path& p,
file_time_type new_time, error_code& ec) noexcept
{
auto d = internal_file_clock::_S_to_sys(new_time).time_since_epoch();
@ -1179,7 +998,7 @@ fs::last_write_time(const path& p __attribute__((__unused__)),
ec.assign(errno, std::generic_category());
else
ec.clear();
#elif _GLIBCXX_HAVE_UTIME_H
#elif _GLIBCXX_USE_UTIME && _GLIBCXX_HAVE_SYS_STAT_H
posix::utimbuf times;
times.modtime = s.count();
times.actime = do_stat(p, ec, [](const auto& st) { return st.st_atime; },
@ -1279,7 +1098,7 @@ fs::read_symlink(const path& p)
return tgt;
}
fs::path fs::read_symlink(const path& p [[gnu::unused]], error_code& ec)
fs::path fs::read_symlink(const path& p, error_code& ec)
{
path result;
#if defined(_GLIBCXX_HAVE_READLINK) && defined(_GLIBCXX_HAVE_SYS_STAT_H)
@ -1472,51 +1291,6 @@ fs::space(const path& p)
return s;
}
#ifdef NEED_DO_SPACE
void
fs::do_space(const __gnu_posix::char_type* pathname,
uintmax_t& capacity, uintmax_t& free, uintmax_t& available,
std::error_code& ec)
{
#ifdef _GLIBCXX_HAVE_SYS_STATVFS_H
struct ::statvfs f;
if (::statvfs(pathname, &f))
ec.assign(errno, std::generic_category());
else
{
if (f.f_frsize != (unsigned long)-1)
{
const uintmax_t fragment_size = f.f_frsize;
const fsblkcnt_t unknown = -1;
if (f.f_blocks != unknown)
capacity = f.f_blocks * fragment_size;
if (f.f_bfree != unknown)
free = f.f_bfree * fragment_size;
if (f.f_bavail != unknown)
available = f.f_bavail * fragment_size;
}
ec.clear();
}
#elif _GLIBCXX_FILESYSTEM_IS_WINDOWS
ULARGE_INTEGER bytes_avail = {}, bytes_total = {}, bytes_free = {};
if (GetDiskFreeSpaceExW(pathname, &bytes_avail, &bytes_total, &bytes_free))
{
if (bytes_total.QuadPart != 0)
capacity = bytes_total.QuadPart;
if (bytes_free.QuadPart != 0)
free = bytes_free.QuadPart;
if (bytes_avail.QuadPart != 0)
available = bytes_avail.QuadPart;
ec.clear();
}
else
ec.assign((int)GetLastError(), std::system_category());
#else
ec = std::make_error_code(std::errc::not_supported);
#endif
}
#endif // NEED_DO_SPACE
fs::space_info
fs::space(const path& p, error_code& ec) noexcept
{
@ -1525,6 +1299,7 @@ fs::space(const path& p, error_code& ec) noexcept
static_cast<uintmax_t>(-1),
static_cast<uintmax_t>(-1)
};
#ifdef _GLIBCXX_HAVE_SYS_STAT_H
#if _GLIBCXX_FILESYSTEM_IS_WINDOWS
path dir = absolute(p);
dir.remove_filename();
@ -1532,7 +1307,10 @@ fs::space(const path& p, error_code& ec) noexcept
#else
auto str = p.c_str();
#endif
do_space(str, info.capacity, info.free, info.available, ec);
#endif // _GLIBCXX_HAVE_SYS_STAT_H
return info;
}

View file

@ -30,9 +30,7 @@ if ENABLE_DUAL_ABI
cxx11_abi_sources = \
cow-dir.cc \
cow-ops.cc \
cow-path.cc \
cow-std-dir.cc \
cow-std-ops.cc
cow-path.cc
else
cxx11_abi_sources =
endif
@ -41,8 +39,6 @@ sources = \
dir.cc \
ops.cc \
path.cc \
std-dir.cc \
std-ops.cc \
${cxx11_abi_sources}
# vpath % $(top_srcdir)/src/filesystem

View file

@ -150,10 +150,8 @@ am__installdirs = "$(DESTDIR)$(toolexeclibdir)"
LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
libstdc__fs_la_LIBADD =
@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-dir.lo cow-ops.lo \
@ENABLE_DUAL_ABI_TRUE@ cow-path.lo cow-std-dir.lo \
@ENABLE_DUAL_ABI_TRUE@ cow-std-ops.lo
am__objects_2 = dir.lo ops.lo path.lo std-dir.lo std-ops.lo \
$(am__objects_1)
@ENABLE_DUAL_ABI_TRUE@ cow-path.lo
am__objects_2 = dir.lo ops.lo path.lo $(am__objects_1)
am_libstdc__fs_la_OBJECTS = $(am__objects_2)
libstdc__fs_la_OBJECTS = $(am_libstdc__fs_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
@ -442,16 +440,12 @@ headers =
@ENABLE_DUAL_ABI_TRUE@cxx11_abi_sources = \
@ENABLE_DUAL_ABI_TRUE@ cow-dir.cc \
@ENABLE_DUAL_ABI_TRUE@ cow-ops.cc \
@ENABLE_DUAL_ABI_TRUE@ cow-path.cc \
@ENABLE_DUAL_ABI_TRUE@ cow-std-dir.cc \
@ENABLE_DUAL_ABI_TRUE@ cow-std-ops.cc
@ENABLE_DUAL_ABI_TRUE@ cow-path.cc
sources = \
dir.cc \
ops.cc \
path.cc \
std-dir.cc \
std-ops.cc \
${cxx11_abi_sources}

View file

@ -26,6 +26,7 @@
#define _GLIBCXX_DIR_COMMON_H 1
#include <string.h> // strcmp
#include <errno.h>
#if _GLIBCXX_FILESYSTEM_IS_WINDOWS
#include <wchar.h> // wcscmp
#endif
@ -34,8 +35,6 @@
# include <sys/types.h>
# endif
# include <dirent.h>
#else
# error "the <dirent.h> header is needed to build the Filesystem TS"
#endif
namespace std _GLIBCXX_VISIBILITY(default)
@ -53,13 +52,20 @@ using dirent = _wdirent;
inline DIR* opendir(const wchar_t* path) { return ::_wopendir(path); }
inline dirent* readdir(DIR* dir) { return ::_wreaddir(dir); }
inline int closedir(DIR* dir) { return ::_wclosedir(dir); }
#else
#elif defined _GLIBCXX_HAVE_DIRENT_H
using char_type = char;
using DIR = ::DIR;
typedef struct ::dirent dirent;
using ::opendir;
using ::readdir;
using ::closedir;
#else
using char_type = char;
struct dirent { const char* d_name; };
struct DIR { };
inline DIR* opendir(const char*) { return nullptr; }
inline dirent* readdir(DIR*) { return nullptr; }
inline int closedir(DIR*) { return -1; }
#endif
} // namespace __gnu_posix

View file

@ -27,6 +27,11 @@
#endif
#include <experimental/filesystem>
#ifndef _GLIBCXX_HAVE_DIRENT_H
# error "the <dirent.h> header is needed to build the Filesystem TS"
#endif
#include <utility>
#include <stack>
#include <string.h>

View file

@ -42,6 +42,14 @@
# include <wchar.h>
#endif
#ifdef NEED_DO_COPY_FILE
# include <filesystem>
# include <ext/stdio_filebuf.h>
# ifdef _GLIBCXX_USE_SENDFILE
# include <sys/sendfile.h> // sendfile
# endif
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@ -108,26 +116,42 @@ namespace __gnu_posix
return ret;
}
using char_type = wchar_t;
#else // _GLIBCXX_FILESYSTEM_IS_WINDOWS
#elif defined _GLIBCXX_HAVE_UNISTD_H
using ::open;
using ::close;
#ifdef _GLIBCXX_HAVE_SYS_STAT_H
# ifdef _GLIBCXX_HAVE_SYS_STAT_H
typedef struct ::stat stat_type;
using ::stat;
# ifdef _GLIBCXX_USE_LSTAT
using ::lstat;
#endif
# else
inline int lstat(const char* path, stat_type* buffer)
{ return stat(path, buffer); }
# endif
# endif
using ::mode_t;
using ::chmod;
using ::mkdir;
using ::getcwd;
using ::chdir;
#if !_GLIBCXX_USE_UTIMENSAT && _GLIBCXX_HAVE_UTIME_H
# if !_GLIBCXX_USE_UTIMENSAT && _GLIBCXX_USE_UTIME
using ::utimbuf;
using ::utime;
#endif
# endif
using ::rename;
using ::truncate;
using char_type = char;
#else // ! _GLIBCXX_FILESYSTEM_IS_WINDOWS && ! _GLIBCXX_HAVE_UNISTD_H
inline int open(const char*, int, ...) { errno = ENOTSUP; return -1; }
inline int close(int) { errno = ENOTSUP; return -1; }
using mode_t = int;
inline int chmod(const char*, mode_t) { errno = ENOTSUP; return -1; }
inline int mkdir(const char*, mode_t) { errno = ENOTSUP; return -1; }
inline char* getcwd(char*, size_t) { errno = ENOTSUP; return nullptr; }
inline int chdir(const char*) { errno = ENOTSUP; return -1; }
inline int rename(const char*, const char*) { errno = ENOTSUP; return -1; }
inline int truncate(const char*, long) { errno = ENOTSUP; return -1; }
using char_type = char;
#endif // _GLIBCXX_FILESYSTEM_IS_WINDOWS
} // namespace __gnu_posix
@ -190,18 +214,6 @@ namespace __gnu_posix
bool skip, update, overwrite;
};
bool
do_copy_file(const __gnu_posix::char_type* from,
const __gnu_posix::char_type* to,
copy_options_existing_file options,
stat_type* from_st, stat_type* to_st,
std::error_code& ec) noexcept;
void
do_space(const __gnu_posix::char_type* pathname,
uintmax_t& capacity, uintmax_t& free, uintmax_t& available,
std::error_code&);
#endif // _GLIBCXX_HAVE_SYS_STAT_H
} // namespace filesystem
@ -211,6 +223,19 @@ _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM
#ifdef _GLIBCXX_HAVE_SYS_STAT_H
using std::filesystem::__gnu_posix::stat_type;
using std::filesystem::__gnu_posix::char_type;
bool
do_copy_file(const char_type* from, const char_type* to,
std::filesystem::copy_options_existing_file options,
stat_type* from_st, stat_type* to_st,
std::error_code& ec) noexcept;
void
do_space(const char_type* pathname,
uintmax_t& capacity, uintmax_t& free, uintmax_t& available,
std::error_code&);
inline file_type
make_file_type(const stat_type& st) noexcept
@ -257,6 +282,253 @@ _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM
is_set(opt, copy_options::overwrite_existing)
};
}
#ifdef NEED_DO_COPY_FILE
bool
do_copy_file(const char_type* from, const char_type* to,
std::filesystem::copy_options_existing_file options,
stat_type* from_st, stat_type* to_st,
std::error_code& ec) noexcept
{
namespace fs = std::filesystem;
namespace posix = fs::__gnu_posix;
stat_type st1, st2;
file_status t, f;
if (to_st == nullptr)
{
if (posix::stat(to, &st1))
{
const int err = errno;
if (!fs::is_not_found_errno(err))
{
ec.assign(err, std::generic_category());
return false;
}
}
else
to_st = &st1;
}
else if (to_st == from_st)
to_st = nullptr;
if (to_st == nullptr)
t = file_status{file_type::not_found};
else
t = make_file_status(*to_st);
if (from_st == nullptr)
{
if (posix::stat(from, &st2))
{
ec.assign(errno, std::generic_category());
return false;
}
else
from_st = &st2;
}
f = make_file_status(*from_st);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2712. copy_file() has a number of unspecified error conditions
if (!is_regular_file(f))
{
ec = std::make_error_code(std::errc::not_supported);
return false;
}
if (exists(t))
{
if (!is_regular_file(t))
{
ec = std::make_error_code(std::errc::not_supported);
return false;
}
if (to_st->st_dev == from_st->st_dev
&& to_st->st_ino == from_st->st_ino)
{
ec = std::make_error_code(std::errc::file_exists);
return false;
}
if (options.skip)
{
ec.clear();
return false;
}
else if (options.update)
{
const auto from_mtime = fs::file_time(*from_st, ec);
if (ec)
return false;
if ((from_mtime <= fs::file_time(*to_st, ec)) || ec)
return false;
}
else if (!options.overwrite)
{
ec = std::make_error_code(std::errc::file_exists);
return false;
}
else if (!is_regular_file(t))
{
ec = std::make_error_code(std::errc::not_supported);
return false;
}
}
struct CloseFD {
~CloseFD() { if (fd != -1) posix::close(fd); }
bool close() { return posix::close(std::exchange(fd, -1)) == 0; }
int fd;
};
CloseFD in = { posix::open(from, O_RDONLY) };
if (in.fd == -1)
{
ec.assign(errno, std::generic_category());
return false;
}
int oflag = O_WRONLY|O_CREAT;
if (options.overwrite || options.update)
oflag |= O_TRUNC;
else
oflag |= O_EXCL;
CloseFD out = { posix::open(to, oflag, S_IWUSR) };
if (out.fd == -1)
{
if (errno == EEXIST && options.skip)
ec.clear();
else
ec.assign(errno, std::generic_category());
return false;
}
#if defined _GLIBCXX_USE_FCHMOD && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS
if (::fchmod(out.fd, from_st->st_mode))
#elif defined _GLIBCXX_USE_FCHMODAT && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS
if (::fchmodat(AT_FDCWD, to, from_st->st_mode, 0))
#else
if (posix::chmod(to, from_st->st_mode))
#endif
{
ec.assign(errno, std::generic_category());
return false;
}
size_t count = from_st->st_size;
#if defined _GLIBCXX_USE_SENDFILE && ! defined _GLIBCXX_FILESYSTEM_IS_WINDOWS
off_t offset = 0;
ssize_t n = ::sendfile(out.fd, in.fd, &offset, count);
if (n < 0 && errno != ENOSYS && errno != EINVAL)
{
ec.assign(errno, std::generic_category());
return false;
}
if ((size_t)n == count)
{
if (!out.close() || !in.close())
{
ec.assign(errno, std::generic_category());
return false;
}
ec.clear();
return true;
}
else if (n > 0)
count -= n;
#endif // _GLIBCXX_USE_SENDFILE
using std::ios;
__gnu_cxx::stdio_filebuf<char> sbin(in.fd, ios::in|ios::binary);
__gnu_cxx::stdio_filebuf<char> sbout(out.fd, ios::out|ios::binary);
if (sbin.is_open())
in.fd = -1;
if (sbout.is_open())
out.fd = -1;
#ifdef _GLIBCXX_USE_SENDFILE
if (n != 0)
{
if (n < 0)
n = 0;
const auto p1 = sbin.pubseekoff(n, ios::beg, ios::in);
const auto p2 = sbout.pubseekoff(n, ios::beg, ios::out);
const std::streampos errpos(std::streamoff(-1));
if (p1 == errpos || p2 == errpos)
{
ec = std::make_error_code(std::errc::io_error);
return false;
}
}
#endif
if (count && !(std::ostream(&sbout) << &sbin))
{
ec = std::make_error_code(std::errc::io_error);
return false;
}
if (!sbout.close() || !sbin.close())
{
ec.assign(errno, std::generic_category());
return false;
}
ec.clear();
return true;
}
#endif // NEED_DO_COPY_FILE
#ifdef NEED_DO_SPACE
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
void
do_space(const char_type* pathname,
uintmax_t& capacity, uintmax_t& free, uintmax_t& available,
std::error_code& ec)
{
#ifdef _GLIBCXX_HAVE_SYS_STATVFS_H
struct ::statvfs f;
if (::statvfs(pathname, &f))
ec.assign(errno, std::generic_category());
else
{
if (f.f_frsize != (unsigned long)-1)
{
const uintmax_t fragment_size = f.f_frsize;
const fsblkcnt_t unknown = -1;
if (f.f_blocks != unknown)
capacity = f.f_blocks * fragment_size;
if (f.f_bfree != unknown)
free = f.f_bfree * fragment_size;
if (f.f_bavail != unknown)
available = f.f_bavail * fragment_size;
}
ec.clear();
}
#elif _GLIBCXX_FILESYSTEM_IS_WINDOWS
ULARGE_INTEGER bytes_avail = {}, bytes_total = {}, bytes_free = {};
if (GetDiskFreeSpaceExW(pathname, &bytes_avail, &bytes_total, &bytes_free))
{
if (bytes_total.QuadPart != 0)
capacity = bytes_total.QuadPart;
if (bytes_free.QuadPart != 0)
free = bytes_free.QuadPart;
if (bytes_avail.QuadPart != 0)
available = bytes_avail.QuadPart;
ec.clear();
}
else
ec.assign((int)GetLastError(), std::system_category());
#else
ec = std::make_error_code(std::errc::not_supported);
#endif
}
#pragma GCC diagnostic pop
#endif // NEED_DO_SPACE
#endif // _GLIBCXX_HAVE_SYS_STAT_H
_GLIBCXX_END_NAMESPACE_FILESYSTEM

View file

@ -24,6 +24,8 @@
#ifndef _GLIBCXX_USE_CXX11_ABI
# define _GLIBCXX_USE_CXX11_ABI 1
# define NEED_DO_COPY_FILE
# define NEED_DO_SPACE
#endif
#include <experimental/filesystem>
@ -243,7 +245,6 @@ namespace
using std::filesystem::is_not_found_errno;
using std::filesystem::file_time;
using std::filesystem::do_copy_file;
#endif // _GLIBCXX_HAVE_SYS_STAT_H
} // namespace
@ -1175,7 +1176,7 @@ fs::space(const path& p, error_code& ec) noexcept
#else
auto str = p.c_str();
#endif
std::filesystem::do_space(str, info.capacity, info.free, info.available, ec);
fs::do_space(str, info.capacity, info.free, info.available, ec);
return info;
}

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -1,4 +1,4 @@
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -1,4 +1,4 @@
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -1,4 +1,4 @@
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }
// { dg-xfail-if "symlinks not supported" { *-*-mingw* } }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }

View file

@ -15,7 +15,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-std=gnu++17 -lstdc++fs" }
// { dg-options "-std=gnu++17" }
// { dg-do run { target c++17 } }
// { dg-require-filesystem-ts "" }