mirror of
https://github.com/curl/curl.git
synced 2026-07-24 10:57:16 +03:00
build: avoid overriding system symbols for socket functions
Before this patch `accept4()`, `socket()`, `socketpair()`, `send()` and `recv()` system symbols were remapped via macros, using the same name, to local curl debug wrappers. This patch replaces these overrides by introducing curl-namespaced macros that map either to the system symbols or to their curl debug wrappers in `CURLDEBUG` (TrackMemory) builds. This follows a patch that implemented the same for `accept()`. The old method required tricks to make these redefines work in unity builds, and avoid them interfering with system headers. These tricks did not work for system symbols implemented as macros. The new method allows to setup these mappings once, without interfering with system headers, upstream macros, or unity builds. It makes builds more robust. Also: - checksrc: ban all mapped functions. - docs/examples: tidy up checksrc rules. Follow-up to9863599d69#18502 Follow-up to3bb5e58c10#17827 Closes #18503
This commit is contained in:
parent
2fe95cb0e3
commit
bf7375ecc5
24 changed files with 74 additions and 57 deletions
|
|
@ -92,7 +92,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
|
|||
execute */
|
||||
if(per->uploadfile && !strcmp(per->uploadfile, ".") && per->infd > 0) {
|
||||
#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP) && !defined(UNDER_CE)
|
||||
rc = recv(per->infd, buffer, curlx_uztosi(sz * nmemb), 0);
|
||||
rc = CURL_RECV(per->infd, buffer, curlx_uztosi(sz * nmemb), 0);
|
||||
if(rc < 0) {
|
||||
if(SOCKERRNO == SOCKEWOULDBLOCK) {
|
||||
CURL_SETERRNO(0);
|
||||
|
|
|
|||
|
|
@ -54,5 +54,5 @@ curl_socket_t tool_socket_open_mptcp_cb(void *clientp,
|
|||
return CURL_SOCKET_BAD;
|
||||
#endif
|
||||
|
||||
return socket(addr->family, addr->socktype, protocol);
|
||||
return CURL_SOCKET(addr->family, addr->socktype, protocol);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -785,7 +785,7 @@ static DWORD WINAPI win_stdin_thread_func(void *thread_data)
|
|||
break;
|
||||
if(n == 0)
|
||||
break;
|
||||
nwritten = send(socket_w, buffer, n, 0);
|
||||
nwritten = CURL_SEND(socket_w, buffer, n, 0);
|
||||
if(nwritten == SOCKET_ERROR)
|
||||
break;
|
||||
if((DWORD)nwritten != n)
|
||||
|
|
@ -889,7 +889,7 @@ curl_socket_t win32_stdin_read_thread(void)
|
|||
}
|
||||
|
||||
/* Connect to the thread and rearrange our own STDIN handles */
|
||||
socket_r = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
socket_r = CURL_SOCKET(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if(socket_r == CURL_SOCKET_BAD) {
|
||||
errorf("socket error: %08lx", GetLastError());
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue