-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
binmode: convert to macro and use it from tests #15787
Conversation
``` In file included from curltool_unity.c:47: ../../include/../lib/curl_binmode.c:46:33: error: too many arguments to function call, expected 1, have 2 (void)setmode(fileno(stream), O_BINARY); ~~~~~~~ ^~~~~~~~ ../../src/tool_cb_wrt.c:43:18: note: expanded from macro 'O_BINARY' ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:730:7: note: 'setmode' declared here void *setmode(const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(setmode)); ^ 1 error generated. ``` https://github.com/curl/curl/actions/runs/12061996281/job/33634959417#step:11:563
``` In file included from curltool_unity.c:47: ../../include/../lib/curl_binmode.c:46:33: error: too many arguments to function call, expected 1, have 2 (void)setmode(fileno(stream), O_BINARY); ~~~~~~~ ^~~~~~~~ ../../src/tool_operate.c:116:20: note: expanded from macro 'O_BINARY' ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:730:7: note: 'setmode' declared here void *setmode(const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(setmode)); ^ 1 error generated. ``` https://github.com/curl/curl/actions/runs/12062155068/job/33635362901#step:11:563
But is this even used inside the library? |
No, not used from libcurl itself, but from tests/servers, tests/libtest (and src). |
I agree that is indeed practical and probably the easiest way to do it, but I still believe it is the wrong approach. I think code in lib/ should only be for the library's own sake. |
Adding it to curltool and adding curltool as a dependency to everything Maybe converting this to a macro and offering it via the usual macro |
Replace _WIN32 with their own specific guards. They are always set for _WIN32, so the end result doesn't change.
Yes, that also seems like the wrong thing to do.
Less bad, but I am against adding stuff to lib/ that is not necessary for the library itself. Even if that means that the alternative might mean duplicated code or more work. I would prefer to have a dedicated source file in the tool's source code directory or something that the test servers can use in their build as well. |
Converted to a macro and moved to The seems fine given the simplicity of the macro. I like the looks of it, but we can move it back out to a separate (edit: I think the builds will have to be updated to pick up headers |
Yeah, I think that sounds like the cleanest approach.
Yes, I believe we don't include anything from there before. |
OK, pushed! While we're here, the set binmode macro now has the single mention It's doubtful it'd compile curl, regardless of this guard. Do we need it? Footnotes |
Nah. |
And use it from src and tests.
Syncing this functionality between platforms and build targets.
Also: Stop redefining
O_BINARY
in src, and use a local macro withthe same effect.
O_BINARY
is used inCURL_SET_BINMODE()
to decideif this functionality is supported, and redefining it makes this check
pass always in unity builds. The check is required for Apple OS, because
it offers a
setmode()
function, successfully detected by both CMakeand autotools, but that function has a different functionality and
signature than that expected by
CURL_SET_BINMODE()
.Also:
io.h
,fcntl.h
.Ref: #15652