Fix std::filesystem

This change makes a second pass, at fixing the errno issue with libcxx's
filesystem code. Previously, 89.01% of LLVM's test suite was passing and
now 98.59% of their tests pass. Best of all, it's now possible for Clang
to be built as a working APE binary that can to compile the Cosmopolitan
repository. Please note it has only been vetted so far for some objects,
and more work would obviously need to be done in cosmo, to fix warnings.
This commit is contained in:
Justine Tunney 2024-07-28 17:25:20 -07:00
parent 0d7c272d3f
commit 77d3a07ff2
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
14 changed files with 408 additions and 69 deletions

View file

@ -141,6 +141,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// This leads to the odd pushing and popping of the deprecated
// diagnostic.
_LIBCPP_DECLARE_STRONG_ENUM(errc){
success = 0,
address_family_not_supported = 65536, // = EAFNOSUPPORT,
address_in_use, // = EADDRINUSE,
address_not_available, // = EADDRNOTAVAIL,
@ -221,6 +222,9 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){
wrong_protocol_type};
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
errc __err_to_errc(int) noexcept;
int __errc_to_err(errc) noexcept;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___ERRC

View file

@ -46,8 +46,9 @@ class _LIBCPP_EXPORTED_FROM_ABI error_code {
public:
_LIBCPP_HIDE_FROM_ABI error_code() _NOEXCEPT : __val_(0), __cat_(&system_category()) {}
_LIBCPP_HIDE_FROM_ABI error_code(int __val, const error_category& __cat) _NOEXCEPT : __val_(__val), __cat_(&__cat) {}
_LIBCPP_HIDE_FROM_ABI error_code(errc __val) _NOEXCEPT : __val_(__errc_to_err(__val)), __cat_(&system_category()) {}
_LIBCPP_HIDE_FROM_ABI error_code(int __val, const error_category& __cat) _NOEXCEPT : __val_(__errc_to_err((errc)__val)), __cat_(&__cat) {}
_LIBCPP_HIDE_FROM_ABI error_code(errc __val, const error_category& __cat) _NOEXCEPT : __val_(__errc_to_err(__val)), __cat_(&__cat) {}
template <class _Ep, __enable_if_t<is_error_code_enum<_Ep>::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI error_code(_Ep __e) _NOEXCEPT {
@ -72,7 +73,7 @@ public:
__cat_ = &system_category();
}
_LIBCPP_HIDE_FROM_ABI int value() const _NOEXCEPT { return __val_; }
_LIBCPP_HIDE_FROM_ABI int value() const _NOEXCEPT { return __errc_to_err((errc)__val_); }
_LIBCPP_HIDE_FROM_ABI const error_category& category() const _NOEXCEPT { return *__cat_; }
@ -86,13 +87,17 @@ public:
};
inline _LIBCPP_HIDE_FROM_ABI error_code make_error_code(errc __e) _NOEXCEPT {
return error_code(static_cast<int>(__e), generic_category());
return error_code(__e, generic_category());
}
inline _LIBCPP_HIDE_FROM_ABI bool operator==(const error_code& __x, const error_code& __y) _NOEXCEPT {
return __x.category() == __y.category() && __x.value() == __y.value();
}
inline _LIBCPP_HIDE_FROM_ABI bool operator==(const error_code& __x, errc __y) _NOEXCEPT {
return __x == error_code(__y, __x.category());
}
inline _LIBCPP_HIDE_FROM_ABI bool operator==(const error_code& __x, const error_condition& __y) _NOEXCEPT {
return __x.category().equivalent(__x.value(), __y) || __y.category().equivalent(__x, __y.value());
}

View file

@ -54,8 +54,12 @@ class _LIBCPP_EXPORTED_FROM_ABI error_condition {
public:
_LIBCPP_HIDE_FROM_ABI error_condition() _NOEXCEPT : __val_(0), __cat_(&generic_category()) {}
_LIBCPP_HIDE_FROM_ABI error_condition(errc __val, const error_category& __cat) _NOEXCEPT
: __val_(__errc_to_err(__val)),
__cat_(&__cat) {}
_LIBCPP_HIDE_FROM_ABI error_condition(int __val, const error_category& __cat) _NOEXCEPT
: __val_(__val),
: __val_(__errc_to_err((errc)__val)),
__cat_(&__cat) {}
template <class _Ep, __enable_if_t<is_error_condition_enum<_Ep>::value, int> = 0>
@ -81,7 +85,7 @@ public:
__cat_ = &generic_category();
}
_LIBCPP_HIDE_FROM_ABI int value() const _NOEXCEPT { return __val_; }
_LIBCPP_HIDE_FROM_ABI int value() const _NOEXCEPT { return __errc_to_err((errc)__val_); }
_LIBCPP_HIDE_FROM_ABI const error_category& category() const _NOEXCEPT { return *__cat_; }
string message() const;
@ -90,7 +94,7 @@ public:
};
inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(errc __e) _NOEXCEPT {
return error_condition(static_cast<int>(__e), generic_category());
return error_condition(__e, generic_category());
}
inline _LIBCPP_HIDE_FROM_ABI bool operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT {

View file

@ -11,6 +11,7 @@
#define _LIBCPP___SYSTEM_ERROR_SYSTEM_ERROR_H
#include <__config>
#include <__system_error/errc.h>
#include <__system_error/error_category.h>
#include <__system_error/error_code.h>
#include <__verbose_abort>