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 523174 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 2 0
Performance Improvements 1 0
Added Tests 0 18
Unchanged Tests 87 72
Total Tests 90

Performance Regressions - execution_time Δ Previous Current σ Δ (B) σ (B)
710_omnetpp_r 2.59% 8.567 8.789 - 0.00% -
735_gem5_r 1.82% 13.635 13.883 - 0.00% -

Performance Improvements - execution_time Δ Previous Current σ Δ (B) σ (B)
709_cactus_r -2.01% 20.182 19.777 - 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.19s
Name Current %
706_stockfish_r 22.026 -
707_ntest_r 17.913 -
709_cactus_r 19.777 -2.01%
710_omnetpp_r 8.789 2.59%
721_gcc_r 13.011 -
723_llvm_r 11.531 -
727_cppcheck_r 24.330 -
729_abc_r 18.683 -
731_astcenc_r 10.073 -
734_vpr_r 15.494 -
735_gem5_r 13.883 1.82%
736_ocio_r 16.162 -
737_gmsh_r 13.102 -
748_flightdm_r 8.880 -
750_sealcrypto_r 18.375 -
753_ns3_r 10.283 -
766_femflow_r 12.799 -
767_nest_r 14.271 -
Geometric Mean 14.340 -