diff options
author | Andrey Khalyavin <halyavin@gmail.com> | 2022-05-26 20:37:34 +0300 |
---|---|---|
committer | Andrey Khalyavin <halyavin@gmail.com> | 2022-05-26 20:37:34 +0300 |
commit | a983ee268a191f2757454e98e94d36615ee1339b (patch) | |
tree | 055e74fe7ae499ccc794ebd2b7bdef9004414850 /contrib/libs/cxxsupp/libcxx/src | |
parent | a5bc0482bae2efd3f9a770e96967a317b5c26632 (diff) | |
download | ydb-a983ee268a191f2757454e98e94d36615ee1339b.tar.gz |
Update libc++ to revision ab0554b2 (31 Jan 2022).
Notable changes:
* allow using thread safety annotation in MinGW mode
* implement compare_{strong,weak,partial}_fallback
* omit atomic_{,un}signed_lock_free on platforms that doesn't support lock free atomics
* set enable_borrowed_range template variable for ref_view and empty_view
* fix bug in reverse_iterator::operator=
* move some function from directory_iterator.cpp to a header so that they can be reused
* fix bug in ranges::advance when try to advance by 0
* fix missing constraint which affects common_iterator for output iterators
* correctly handle move-only iterators in move_iterator
* make base() method in counted_iterator and transform_view::iterator noexcept
* remove C++03 workarounds in reference_wrapper, since clang supports necessary features in C++03 mode
* simplify convertible_to concept implementation
* fix issue with __convertible_to_non_slicing rejecting correct case
* remove excessive wrapping in std::ref and std::cref
* fix std::seed_seq constructors
* remove std::basic_string base class when using ABI v2
* std::basic_string::reserve now never shrinks in all C++ modes
ref:b62ec6bac0283b075dd2348bad7e8a271155b378
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src')
3 files changed, 83 insertions, 90 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp index de7ded45140..fa793f68295 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp @@ -9,97 +9,12 @@ #include "__config" #include "filesystem" #include "stack" -#if defined(_LIBCPP_WIN32API) -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#include <windows.h> -#else -#include <dirent.h> -#endif #include <errno.h> #include "filesystem_common.h" _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM -namespace detail { -namespace { - -#if !defined(_LIBCPP_WIN32API) - -#if defined(DT_BLK) -template <class DirEntT, class = decltype(DirEntT::d_type)> -static file_type get_file_type(DirEntT* ent, int) { - switch (ent->d_type) { - case DT_BLK: - return file_type::block; - case DT_CHR: - return file_type::character; - case DT_DIR: - return file_type::directory; - case DT_FIFO: - return file_type::fifo; - case DT_LNK: - return file_type::symlink; - case DT_REG: - return file_type::regular; - case DT_SOCK: - return file_type::socket; - // Unlike in lstat, hitting "unknown" here simply means that the underlying - // filesystem doesn't support d_type. Report is as 'none' so we correctly - // set the cache to empty. - case DT_UNKNOWN: - break; - } - return file_type::none; -} -#endif // defined(DT_BLK) - -template <class DirEntT> -static file_type get_file_type(DirEntT*, long) { - return file_type::none; -} - -static pair<string_view, file_type> posix_readdir(DIR* dir_stream, - error_code& ec) { - struct dirent* dir_entry_ptr = nullptr; - errno = 0; // zero errno in order to detect errors - ec.clear(); - if ((dir_entry_ptr = ::readdir(dir_stream)) == nullptr) { - if (errno) - ec = capture_errno(); - return {}; - } else { - return {dir_entry_ptr->d_name, get_file_type(dir_entry_ptr, 0)}; - } -} -#else -// defined(_LIBCPP_WIN32API) - -static file_type get_file_type(const WIN32_FIND_DATAW& data) { - if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && - data.dwReserved0 == IO_REPARSE_TAG_SYMLINK) - return file_type::symlink; - if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - return file_type::directory; - return file_type::regular; -} -static uintmax_t get_file_size(const WIN32_FIND_DATAW& data) { - return (static_cast<uint64_t>(data.nFileSizeHigh) << 32) + data.nFileSizeLow; -} -static file_time_type get_write_time(const WIN32_FIND_DATAW& data) { - ULARGE_INTEGER tmp; - const FILETIME& time = data.ftLastWriteTime; - tmp.u.LowPart = time.dwLowDateTime; - tmp.u.HighPart = time.dwHighDateTime; - return file_time_type(file_time_type::duration(tmp.QuadPart)); -} - -#endif - -} // namespace -} // namespace detail - using detail::ErrorHandler; #if defined(_LIBCPP_WIN32API) @@ -197,9 +112,9 @@ public: : __stream_(nullptr), __root_(root) { if ((__stream_ = ::opendir(root.c_str())) == nullptr) { ec = detail::capture_errno(); - const bool allow_eacess = + const bool allow_eacces = bool(opts & directory_options::skip_permission_denied); - if (allow_eacess && ec.value() == EACCES) + if (allow_eacces && ec.value() == EACCES) ec.clear(); return; } diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h index a3642df4486..b693476518f 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_common.h @@ -20,12 +20,19 @@ #include "ratio" #include "system_error" +#if defined(_LIBCPP_WIN32API) +# define WIN32_LEAN_AND_MEAN +# define NOMINMAX +# include <windows.h> +#endif + #if !defined(_LIBCPP_WIN32API) -# include <unistd.h> +# include <dirent.h> // for DIR & friends +# include <fcntl.h> /* values for fchmodat */ # include <sys/stat.h> # include <sys/statvfs.h> # include <sys/time.h> // for ::utimes as used in __last_write_time -# include <fcntl.h> /* values for fchmodat */ +# include <unistd.h> #endif #include "../include/apple_availability.h" @@ -537,7 +544,76 @@ bool set_file_times(const path& p, std::array<TimeSpec, 2> const& TS, return posix_utimensat(p, TS, ec); #endif } -#endif /* !_LIBCPP_WIN32API */ + +#if defined(DT_BLK) +template <class DirEntT, class = decltype(DirEntT::d_type)> +static file_type get_file_type(DirEntT* ent, int) { + switch (ent->d_type) { + case DT_BLK: + return file_type::block; + case DT_CHR: + return file_type::character; + case DT_DIR: + return file_type::directory; + case DT_FIFO: + return file_type::fifo; + case DT_LNK: + return file_type::symlink; + case DT_REG: + return file_type::regular; + case DT_SOCK: + return file_type::socket; + // Unlike in lstat, hitting "unknown" here simply means that the underlying + // filesystem doesn't support d_type. Report is as 'none' so we correctly + // set the cache to empty. + case DT_UNKNOWN: + break; + } + return file_type::none; +} +#endif // defined(DT_BLK) + +template <class DirEntT> +static file_type get_file_type(DirEntT*, long) { + return file_type::none; +} + +static pair<string_view, file_type> posix_readdir(DIR* dir_stream, + error_code& ec) { + struct dirent* dir_entry_ptr = nullptr; + errno = 0; // zero errno in order to detect errors + ec.clear(); + if ((dir_entry_ptr = ::readdir(dir_stream)) == nullptr) { + if (errno) + ec = capture_errno(); + return {}; + } else { + return {dir_entry_ptr->d_name, get_file_type(dir_entry_ptr, 0)}; + } +} + +#else // _LIBCPP_WIN32API + +static file_type get_file_type(const WIN32_FIND_DATAW& data) { + if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && + data.dwReserved0 == IO_REPARSE_TAG_SYMLINK) + return file_type::symlink; + if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + return file_type::directory; + return file_type::regular; +} +static uintmax_t get_file_size(const WIN32_FIND_DATAW& data) { + return (static_cast<uint64_t>(data.nFileSizeHigh) << 32) + data.nFileSizeLow; +} +static file_time_type get_write_time(const WIN32_FIND_DATAW& data) { + ULARGE_INTEGER tmp; + const FILETIME& time = data.ftLastWriteTime; + tmp.u.LowPart = time.dwLowDateTime; + tmp.u.HighPart = time.dwHighDateTime; + return file_time_type(file_time_type::duration(tmp.QuadPart)); +} + +#endif // !_LIBCPP_WIN32API } // namespace } // end namespace detail diff --git a/contrib/libs/cxxsupp/libcxx/src/string.cpp b/contrib/libs/cxxsupp/libcxx/src/string.cpp index 608dcb2c586..3c63f408240 100644 --- a/contrib/libs/cxxsupp/libcxx/src/string.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/string.cpp @@ -21,6 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_ABI_NO_BASIC_STRING_BASE_CLASS void __basic_string_common<true>::__throw_length_error() const { _VSTD::__throw_length_error("basic_string"); } @@ -28,6 +29,7 @@ void __basic_string_common<true>::__throw_length_error() const { void __basic_string_common<true>::__throw_out_of_range() const { _VSTD::__throw_out_of_range("basic_string"); } +#endif #define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__; #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |