build: detect and use _setmode() with Cygwin/MSYS, also use on Windows - #15169
Closed
vszakats wants to merge 1 commit into
Closed
build: detect and use _setmode() with Cygwin/MSYS, also use on Windows#15169vszakats wants to merge 1 commit into
_setmode() with Cygwin/MSYS, also use on Windows#15169vszakats wants to merge 1 commit into
Conversation
Before this patch `setmode()` was not detected with Cygwin/MSYS, because it's a macro, not a function, and detection is looking for a function. Switching to symbol detection doesn't work because it mis-detects it on BSD systems which feature a function with the same name but different functionality and arguments. Fix it by looking for a `_setmode()` function on Cygwin/MSYS, and use it if available. `_setmode()` is recommended over `setmode()` by Windows documentation so use that on Windows too. It seems to be available on all supported compilers, so omit detection. https://learn.microsoft.com/cpp/c-runtime-library/reference/posix-setmode https://learn.microsoft.com/cpp/c-runtime-library/reference/setmode Officially Windows requires argument `_O_BINARY` with an underscore. `O_BINARY` is also supported but bound to conditions, continue to use it. Cygwin supports uses `O_BINARY` (no underscore).
Contributor
|
Analysis of PR #15169 at 870ee5d9: Test http/test_09_push.py::TestPush::test_09_02_h2_push[0] failed, which has NOT been flaky recently, so there could be a real issue in the PR. Test 1450 failed, which has NOT been flaky recently, so there could be a real issue in the PR. Generated by Testclutch |
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
Before this patch `setmode()` was not detected with Cygwin/MSYS, because it's a macro, not a function, and detection is looking for a function. Switching to symbol detection doesn't work because it mis-detects it on BSD systems which features a function with the same name but different functionality and arguments. Fix it by looking for a `_setmode()` function on Cygwin/MSYS, and use it if available. `_setmode()` is recommended over `setmode()` by Windows documentation so use that on Windows too. It seems to be available on all supported compilers, so omit detection. https://learn.microsoft.com/cpp/c-runtime-library/reference/posix-setmode https://learn.microsoft.com/cpp/c-runtime-library/reference/setmode Officially Windows requires argument `_O_BINARY` with an underscore. `O_BINARY` is also supported but bound to conditions. Continue to use it for simplicity. Cygwin supports `O_BINARY` (no underscore). Closes curl#15169
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Feb 7, 2026
Follow-up to 5e70566 curl#15169
3 tasks
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Feb 8, 2026
Follow-up to 5e70566 curl#15169
vszakats
added a commit
that referenced
this pull request
Feb 8, 2026
- move macro to `curl_setup.h` (from curlx), and rename. It's required by src, test servers, libtests. Also used by unit/tunit, (which is fixable but this patch doesn't touch it.) - special-case it for Windows/Cygwin/MS-DOS. - build: drop `setmode()`/`_setmode()` detection. This also avoids detecting the different `setmode()` on BSDs, and a lot of complexity and overhead. - use `CURL_O_BINARY`. Follow-up to 250d613 #15787 Follow-up to 5e70566 #15169 Closes #20539
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Before this patch
setmode()was not detected with Cygwin/MSYS, becauseit's a macro, not a function, and detection is looking for a function.
Switching to symbol detection doesn't work because it mis-detects it on
BSD systems which features a function with the same name but different
functionality and arguments.
Fix it by looking for a
_setmode()function on Cygwin/MSYS, and use itif available.
_setmode()is recommended oversetmode()by Windows documentation souse that on Windows too. It seems to be available on all supported
compilers, so omit detection.
https://learn.microsoft.com/cpp/c-runtime-library/reference/posix-setmode
https://learn.microsoft.com/cpp/c-runtime-library/reference/setmode
Officially Windows requires argument
_O_BINARYwith an underscore.O_BINARYis also supported but bound to conditions. Continue to use itfor simplicity. Cygwin supports
O_BINARY(no underscore).