GH-48788: [C++] Fix Windows mmap error code mapping in mman.h #48788
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale for this change
The
__map_mman_error()function incpp/src/arrow/io/mman.hwas not properly mapping Windows error codes to POSIX errno values. The function contained a TODO comment and returned raw Windows error codes (DWORD values like 2, 5, 6, 112) directly instead of converting them to POSIX errno values (like ENOENT, EACCES, EBADF, ENOSPC). This broke errno-based error handling in memory mapping operations on Windows, as code expecting POSIX errno values would receive raw Windows error codes instead.What changes are included in this PR?
__map_mman_error()functionWinErrorToErrno()conventions for consistencydeferrparameter (EPERM default) for unmapped errorsfile_test.cccovering all mapped errors, zero case, and fallback behaviorAre these changes tested?
Yes. Added
TestMmanErrorMapping.MapCommonErrorstest covering all mapped error codes, zero error code case, and fallback behavior. Tests are Windows-gated (#ifdef _WIN32) and will run on Windows CI.Are there any user-facing changes?
No.
GitHub Issue: #48793