Add special errno handling to libcxx

This commit is contained in:
Justine Tunney 2024-07-25 01:05:39 -07:00
parent 0f486a13c8
commit 2c4b88753b
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
10 changed files with 235 additions and 7 deletions

View file

@ -98,9 +98,16 @@ inline errc __win_err_to_errc(int err) {
#endif // _LIBCPP_WIN32API
errc __cosmo_err_to_errc(int);
int __cosmo_errc_to_err(errc);
inline error_code capture_errno() {
_LIBCPP_ASSERT_INTERNAL(errno != 0, "Expected errno to be non-zero");
#ifdef __COSMOPOLITAN__
return error_code((int)__cosmo_err_to_errc(errno), generic_category());
#else
return error_code(errno, generic_category());
#endif
}
#if defined(_LIBCPP_WIN32API)