Fields

hardware None
os None

Parameters

Fields

NameValue

Parameters

NameValue
git_commit commit 2b26ee6e790574e05c3c9a562bc37897daf0f384
Author: James Y Knight <jyknight@google.com>
Date: Wed Jan 8 17:34:48 2025 -0500

[libcxx] Handle windows system error code mapping in std::error_code. (#93101)

The `std::error_code`/`std::error_category` functionality is designed to
support multiple error domains. On Unix, both system calls and libc
functions return the same error codes, and thus, libc++ today treats
`generic_category()` and `system_category()` as being equivalent.

However, on Windows, libc functions return `errno.h` error codes in the
`errno` global, but system calls return the very different `winerror.h`
error codes via `GetLastError()`.

As such, there is a need to map the winerror.h error codes into generic
errno codes. In libc++, however, the system_error facility does not
implement this mapping; instead the mapping is hidden inside libc++,
used directly by the std::filesystem implementation.

That has a few problems:

1. For std::filesystem APIs, the concrete windows error number is lost,
before users can see it. The intent of the distinction between
std::error_code and std::error_condition is that the error_code return
has the original (potentially more detailed) error code.

2. User-written code which calls Windows system APIs requires this same
mapping, so it also can also return error_code objects that other
(cross-platform) code can understand.

After this commit, an `error_code` with `generic_category()` is used to
report an error from `errno`, and, on Windows only, an `error_code` with
`system_category()` is used to report an error from `GetLastError()`. On
Unix, system_category remains identity-mapped to generic_category, but
is never used by libc++ itself.

The windows error code mapping is moved into system_error, so that
conversion of an `error_code` to `error_condition` correctly translates
the `system_category()` code into a `generic_category()` code, when
appropriate.

This allows code like:
`error_code(GetLastError(), system_category()) == errc::invalid_argument`
to work as expected -- as it does with MSVC STL.

(Continued from old phabricator review [D151493](https://reviews.llvm.org/D151493))
Filter

ldionne-old-macbook-results test results

Run Order Start Time Duration
Current 523180 2025-12-16T16:40:01 0:00:00
Previous 523220 2025-12-16T16:40:01 0:00:00
Baseline 485288 2025-12-16T16:40:01 0:00:00


Tests Summary

Status Group # # (B)
Performance Regressions 3 0
Performance Improvements 6 0
Added Tests 0 18
Unchanged Tests 81 72
Total Tests 90

Performance Regressions - execution_time Δ Previous Current σ Δ (B) σ (B)
735_gem5_r 3.00% 13.480 13.883 - 0.00% -
710_omnetpp_r 2.56% 8.569 8.789 - 0.00% -
767_nest_r 1.17% 14.106 14.271 - 0.00% -

Performance Improvements - execution_time Δ Previous Current σ Δ (B) σ (B)
729_abc_r -1.60% 18.988 18.683 - 0.00% -
727_cppcheck_r -1.40% 24.675 24.330 - 0.00% -
753_ns3_r -1.31% 10.420 10.283 - 0.00% -
737_gmsh_r -1.30% 13.274 13.102 - 0.00% -
734_vpr_r -1.30% 15.697 15.494 - 0.00% -
748_flightdm_r -1.18% 8.986 8.880 - 0.00% -

Added Tests - execution_time
706_stockfish_r
707_ntest_r
709_cactus_r
710_omnetpp_r
721_gcc_r
723_llvm_r
727_cppcheck_r
729_abc_r
731_astcenc_r
734_vpr_r
735_gem5_r
736_ocio_r
737_gmsh_r
748_flightdm_r
750_sealcrypto_r
753_ns3_r
766_femflow_r
767_nest_r


Report Time: 0.14s
Name Current %
706_stockfish_r 22.026 -
707_ntest_r 17.913 -
709_cactus_r 19.777 -
710_omnetpp_r 8.789 2.56%
721_gcc_r 13.011 -
723_llvm_r 11.531 -
727_cppcheck_r 24.330 -1.40%
729_abc_r 18.683 -1.60%
731_astcenc_r 10.073 -
734_vpr_r 15.494 -1.30%
735_gem5_r 13.883 3.00%
736_ocio_r 16.162 -
737_gmsh_r 13.102 -1.30%
748_flightdm_r 8.880 -1.18%
750_sealcrypto_r 18.375 -
753_ns3_r 10.283 -1.31%
766_femflow_r 12.799 -
767_nest_r 14.271 1.17%
Geometric Mean 14.340 -