tiny-curl: base and FreeRTOS support

This commit is contained in:
Daniel Stenberg 2021-04-12 08:52:24 +02:00
parent 6f19f68e93
commit 462d10f44c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
17 changed files with 1368 additions and 54 deletions

View file

@ -30,7 +30,8 @@ EXTRA_DIST = Makefile.m32 config-win32.h config-win32ce.h \
config-os400.h setup-os400.h \
config-tpf.h mk-ca-bundle.pl mk-ca-bundle.vbs $(CMAKE_DIST) \
firefox-db2pem.sh config-vxworks.h Makefile.vxworks checksrc.pl \
setup-win32.h .checksrc
setup-win32.h .checksrc \
config-freertos.h
lib_LTLIBRARIES = libcurl.la

398
lib/config-freertos.h Normal file
View file

@ -0,0 +1,398 @@
#ifndef CURL_CONFIG_FREERTOS_H
#define CURL_CONFIG_FREERTOS_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
***************************************************************************/
/* to disable cookies support */
#define CURL_DISABLE_COOKIES 1
/* disable HTTP authentication */
#define CURL_DISABLE_HTTP_AUTH 1
/* disable DoH */
#define CURL_DISABLE_DOH 1
/* disable mime API */
#define CURL_DISABLE_MIME 1
/* disable date parsing */
#define CURL_DISABLE_PARSEDATE 1
/* disable netrc parsing */
#define CURL_DISABLE_NETRC 1
/* disable DNS shuffling */
#define CURL_DISABLE_SHUFFLE_DNS 1
/* disable progress-meter */
#define CURL_DISABLE_PROGRESS_METER 1
/* to disable cryptographic authentication */
#define CURL_DISABLE_CRYPTO_AUTH 1
/* to disable DICT */
#define CURL_DISABLE_DICT 1
/* to disable FILE */
#define CURL_DISABLE_FILE 1
/* to disable FTP */
#define CURL_DISABLE_FTP 1
/* to disable Gopher */
#define CURL_DISABLE_GOPHER 1
/* to disable IMAP */
#define CURL_DISABLE_IMAP 1
/* to disable LDAP */
#define CURL_DISABLE_LDAP 1
/* to disable LDAPS */
#define CURL_DISABLE_LDAPS 1
/* to disable POP3 */
#define CURL_DISABLE_POP3 1
/* to disable proxies */
#define CURL_DISABLE_PROXY 1
/* to disable RTSP */
#define CURL_DISABLE_RTSP 1
/* to disable SMB/CIFS */
#define CURL_DISABLE_SMB 1
/* to disable SMTP */
#define CURL_DISABLE_SMTP 1
/* to disable TELNET */
#define CURL_DISABLE_TELNET 1
/* to disable TFTP */
#define CURL_DISABLE_TFTP 1
/* to disable verbose strings */
#define CURL_DISABLE_VERBOSE_STRINGS 1
/* Definition to make a library symbol externally visible. */
#define CURL_EXTERN_SYMBOL __attribute__ ((__visibility__ ("default")))
/* IP address type in sockaddr */
#define CURL_SA_FAMILY_T uint8_t
/* lack of non-blocking support */
#define USE_BLOCKING_SOCKETS 1
/* Define to the type of arg 2 for gethostname. */
#define GETHOSTNAME_TYPE_ARG2 size_t
/* Specifies the number of arguments to getservbyport_r */
#define GETSERVBYPORT_R_ARGS 6
/* Specifies the size of the buffer to pass to getservbyport_r */
#define GETSERVBYPORT_R_BUFSIZE 4096
/* Define to 1 if you have the <alloca.h> header file. */
#define HAVE_ALLOCA_H 1
/* Define to 1 if you have the <arpa/inet.h> header file. */
/* Define to 1 if you have the <arpa/tftp.h> header file. */
/* Define to 1 if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define to 1 if you have the basename function. */
#define HAVE_BASENAME 1
/* Define to 1 if bool is an available type. */
#define HAVE_BOOL_T 1
/* Define to 1 if you have the connect function. */
#define HAVE_CONNECT 1
/* Define to 1 if you have the <cyassl/error-ssl.h> header file. */
#define HAVE_CYASSL_ERROR_SSL_H 1
/* Define to 1 if you have the <cyassl/options.h> header file. */
#define HAVE_CYASSL_OPTIONS_H 1
/* Define to 1 if you have the declaration of `getpwuid_r', and to 0 if you
don't. */
#define HAVE_DECL_GETPWUID_R 1
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the gethostbyname function. */
#define HAVE_GETHOSTBYNAME 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <linux/tcp.h> header file. */
/* if your compiler supports LL */
#define HAVE_LL 1
/* Define to 1 if the compiler supports the 'long long' data type. */
#define HAVE_LONGLONG 1
/* Define to 1 if you have the malloc.h header file. */
#define HAVE_MALLOC_H 1
/* Define to 1 if you have the memory.h header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the <netdb.h> header file. */
/* Define to 1 if you have the <netinet/in.h> header file. */
/* Define to 1 if you have the <netinet/tcp.h> header file. */
/* Define to 1 if you have the <net/if.h> header file. */
/* Define to 1 if you have the recv function. */
#define HAVE_RECV 1
/* Define to 1 if you have the select function. */
#define HAVE_SELECT 1
/* Define to 1 if you have the send function. */
#define HAVE_SEND 1
/* Define to 1 if you have the <setjmp.h> header file. */
#define HAVE_SETJMP_H 1
/* Define to 1 if you have the setsockopt function. */
#define HAVE_SETSOCKOPT 1
/* Define to 1 if you have the socket function. */
#define HAVE_SOCKET 1
/* Define to 1 if you have the <stdbool.h> header file. */
#define HAVE_STDBOOL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the strcasecmp function. */
#define HAVE_STRCASECMP 1
/* Define to 1 if you have the strdup function. */
#define HAVE_STRDUP 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the strncasecmp function. */
#define HAVE_STRNCASECMP 1
/* Define to 1 if you have the <stropts.h> header file. */
/* Define to 1 if you have the strstr function. */
#define HAVE_STRSTR 1
/* Define to 1 if you have the strtok_r function. */
#define HAVE_STRTOK_R 1
/* Define to 1 if you have the strtoll function. */
#define HAVE_STRTOLL 1
/* if struct sockaddr_storage is defined */
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
/* Define to 1 if you have the timeval struct. */
#define HAVE_STRUCT_TIMEVAL 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/uio.h> header file. */
#define HAVE_SYS_UIO_H 1
/* Define to 1 if you have the <sys/un.h> header file. */
/* Define to 1 if you have the <sys/wait.h> header file. */
#define HAVE_SYS_WAIT_H 1
/* Define to 1 if you have the <sys/xattr.h> header file. */
#define HAVE_SYS_XATTR_H 1
/* Define to 1 if you have the <termios.h> header file. */
#define HAVE_TERMIOS_H 1
/* Define to 1 if you have the <termio.h> header file. */
#define HAVE_TERMIO_H 1
/* Define to 1 if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* Define to 1 if you have the `utime' function. */
#define HAVE_UTIME 1
/* Define to 1 if you have the `utimes' function. */
#define HAVE_UTIMES 1
/* Define to 1 if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1
/* Define to 1 if compiler supports C99 variadic macro style. */
#define HAVE_VARIADIC_MACROS_C99 1
/* Define to 1 if compiler supports old gcc variadic macro style. */
#define HAVE_VARIADIC_MACROS_GCC 1
/* Define to 1 if you have the `wolfSSL_CTX_UseSupportedCurve' function. */
#define HAVE_WOLFSSL_CTX_USESUPPORTEDCURVE 1
/* Define to 1 if you have the `wolfSSL_get_peer_certificate' function. */
#define HAVE_WOLFSSL_GET_PEER_CERTIFICATE 1
/* Define to 1 if you have the writev function. */
#define HAVE_WRITEV 1
/* cpu-machine-OS */
#define OS "x86_64-freertos"
/* Define to the type of arg 1 for recv. */
#define RECV_TYPE_ARG1 Socket_t
/* Define to the type of arg 2 for recv. */
#define RECV_TYPE_ARG2 void *
/* Define to the type of arg 3 for recv. */
#define RECV_TYPE_ARG3 size_t
/* Define to the type of arg 4 for recv. */
#define RECV_TYPE_ARG4 long
/* Define to the function return type for recv. */
#define RECV_TYPE_RETV long
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
/* Define to the type qualifier of arg 5 for select. */
#define SELECT_QUAL_ARG5
/* Define to the type of arg 1 for select. */
#define SELECT_TYPE_ARG1 int
/* Define to the type of args 2, 3 and 4 for select. */
#define SELECT_TYPE_ARG234 fd_set *
/* Define to the type of arg 5 for select. */
#define SELECT_TYPE_ARG5 struct timeval *
/* Define to the function return type for select. */
#define SELECT_TYPE_RETV int
/* Define to the type qualifier of arg 2 for send. */
#define SEND_QUAL_ARG2 const
/* Define to the type of arg 1 for send. */
#define SEND_TYPE_ARG1 int
/* Define to the type of arg 2 for send. */
#define SEND_TYPE_ARG2 void *
/* Define to the type of arg 3 for send. */
#define SEND_TYPE_ARG3 size_t
/* Define to the type of arg 4 for send. */
#define SEND_TYPE_ARG4 int
/* Define to the function return type for send. */
#define SEND_TYPE_RETV ssize_t
#define ssize_t int
/* The number of bytes in type curl_off_t */
#define SIZEOF_CURL_OFF_T 8
/* The number of bytes in type int */
#define SIZEOF_INT 4
/* The number of bytes in type long */
#define SIZEOF_LONG 4
/* The number of bytes in type long long */
#define SIZEOF_LONG_LONG 8
/* The number of bytes in type off_t */
#define SIZEOF_OFF_T 8
/* The number of bytes in type short */
#define SIZEOF_SHORT 2
/* The number of bytes in type size_t */
#define SIZEOF_SIZE_T 8
/* The number of bytes in type time_t */
#define SIZEOF_TIME_T 8
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* if CyaSSL/WolfSSL is enabled */
#define USE_CYASSL 1
/* Version number of package */
#define VERSION "-"
/* Define to 1 if OS is AIX. */
#ifndef _ALL_SOURCE
/* # undef _ALL_SOURCE */
#endif
/* Work-around to allow building the Windows FreeRTOS simulator */
#define ALLOW_MSVC6_WITHOUT_PSDK 1
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
#endif /* CURL_CONFIG_FREERTOS_H */

View file

@ -109,8 +109,8 @@ tcpkeepalive(struct Curl_easy *data,
int optval = data->set.tcp_keepalive?1:0;
/* only set IDLE and INTVL if setting KEEPALIVE is successful */
if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE,
(void *)&optval, sizeof(optval)) < 0) {
if(curl_setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE,
(void *)&optval, sizeof(optval)) < 0) {
infof(data, "Failed to set SO_KEEPALIVE on fd %d", sockfd);
}
else {
@ -133,16 +133,16 @@ tcpkeepalive(struct Curl_easy *data,
#ifdef TCP_KEEPIDLE
optval = curlx_sltosi(data->set.tcp_keepidle);
KEEPALIVE_FACTOR(optval);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE,
(void *)&optval, sizeof(optval)) < 0) {
if(curl_setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE,
(void *)&optval, sizeof(optval)) < 0) {
infof(data, "Failed to set TCP_KEEPIDLE on fd %d", sockfd);
}
#endif
#ifdef TCP_KEEPINTVL
optval = curlx_sltosi(data->set.tcp_keepintvl);
KEEPALIVE_FACTOR(optval);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL,
(void *)&optval, sizeof(optval)) < 0) {
if(curl_setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL,
(void *)&optval, sizeof(optval)) < 0) {
infof(data, "Failed to set TCP_KEEPINTVL on fd %d", sockfd);
}
#endif
@ -240,7 +240,8 @@ static CURLcode bindlocal(struct Curl_easy *data,
{
struct connectdata *conn = data->conn;
struct Curl_sockaddr_storage sa;
struct sockaddr *sock = (struct sockaddr *)&sa; /* bind to this address */
struct curl_struct_sockaddr *sock =
(struct curl_struct_sockaddr *)&sa; /* bind to this address */
curl_socklen_t sizeof_sa = 0; /* size of the data sock points to */
struct sockaddr_in *si4 = (struct sockaddr_in *)&sa;
#ifdef ENABLE_IPV6
@ -302,8 +303,8 @@ static CURLcode bindlocal(struct Curl_easy *data,
* converted to an IP address and would fail Curl_if2ip. Simply try
* to use it straight away.
*/
if(setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
dev, (curl_socklen_t)strlen(dev) + 1) == 0) {
if(curl_setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
dev, (curl_socklen_t)strlen(dev) + 1) == 0) {
/* This is typically "errno 1, error: Operation not permitted" if
* you're not running as root or another suitable privileged
* user.
@ -446,8 +447,9 @@ static CURLcode bindlocal(struct Curl_easy *data,
(void)setsockopt(sockfd, SOL_IP, IP_BIND_ADDRESS_NO_PORT, &on, sizeof(on));
#endif
for(;;) {
if(bind(sockfd, sock, sizeof_sa) >= 0) {
if(curl_bind(sockfd, sock, sizeof_sa) >= 0) {
/* we succeeded to bind */
#ifdef HAVE_GETSOCKNAME
struct Curl_sockaddr_storage add;
curl_socklen_t size = sizeof(add);
memset(&add, 0, sizeof(struct Curl_sockaddr_storage));
@ -462,7 +464,7 @@ static CURLcode bindlocal(struct Curl_easy *data,
conn->bits.bound = TRUE;
return CURLE_OK;
}
#endif
if(--portnum > 0) {
infof(data, "Bind to local port %hu failed, trying next", port);
port++; /* try next port */
@ -487,6 +489,7 @@ static CURLcode bindlocal(struct Curl_easy *data,
return CURLE_INTERFACE_FAILED;
}
#ifdef HAVE_GETSOCKOPT
/*
* verifyconnect() returns TRUE if the connect really has happened.
*/
@ -553,6 +556,10 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
#endif
return rc;
}
#else
#define verifyconnect(x,y) TRUE
#endif
/* update tempaddr[tempindex] (to the next entry), makes sure to stick
to the correct family */
@ -1069,8 +1076,8 @@ static void tcpnodelay(struct Curl_easy *data, curl_socket_t sockfd)
(void) data;
#endif
if(setsockopt(sockfd, level, TCP_NODELAY, (void *)&onoff,
sizeof(onoff)) < 0)
if(curl_setsockopt(sockfd, level, TCP_NODELAY, (void *)&onoff,
sizeof(onoff)) < 0)
infof(data, "Could not set TCP_NODELAY: %s",
Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
#else
@ -1271,18 +1278,18 @@ static CURLcode singleipconnect(struct Curl_easy *data,
NULL, 0, NULL, NULL);
}
else {
rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
rc = curl_connect(sockfd, &addr.sa_addr, addr.addrlen);
}
# else
rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
rc = curl_connect(sockfd, &addr.sa_addr, addr.addrlen);
# endif /* HAVE_BUILTIN_AVAILABLE */
#elif defined(TCP_FASTOPEN_CONNECT) /* Linux >= 4.11 */
#elif defined(HAVE_TCP_FASTOPEN_CONNECT) /* Linux >= 4.11 */
if(setsockopt(sockfd, IPPROTO_TCP, TCP_FASTOPEN_CONNECT,
(void *)&optval, sizeof(optval)) < 0)
infof(data, "Failed to enable TCP Fast Open on fd %d", sockfd);
rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
#elif defined(MSG_FASTOPEN) /* old Linux */
#elif defined(HAVE_MSG_FASTOPEN) /* old Linux */
if(conn->given->flags & PROTOPT_SSL)
rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
else
@ -1290,7 +1297,7 @@ static CURLcode singleipconnect(struct Curl_easy *data,
#endif
}
else {
rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
rc = curl_connect(sockfd, &addr.sa_addr, addr.addrlen);
}
if(-1 == rc)
@ -1499,8 +1506,8 @@ bool Curl_connalive(struct connectdata *conn)
else {
/* use the socket */
char buf;
if(recv((RECV_TYPE_ARG1)conn->sock[FIRSTSOCKET], (RECV_TYPE_ARG2)&buf,
(RECV_TYPE_ARG3)1, (RECV_TYPE_ARG4)MSG_PEEK) == 0) {
if(curl_recv((RECV_TYPE_ARG1)conn->sock[FIRSTSOCKET], (RECV_TYPE_ARG2)&buf,
(RECV_TYPE_ARG3)1, (RECV_TYPE_ARG4)MSG_PEEK) == 0) {
return false; /* FIN received */
}
}
@ -1598,7 +1605,7 @@ CURLcode Curl_socket(struct Curl_easy *data,
}
else
/* opensocket callback not set, so simply create the socket now */
*sockfd = socket(addr->family, addr->socktype, addr->protocol);
*sockfd = curl_socket(addr->family, addr->socktype, addr->protocol);
if(*sockfd == CURL_SOCKET_BAD)
/* no socket, no connection */

View file

@ -100,7 +100,7 @@ struct Curl_sockaddr_ex {
int protocol;
unsigned int addrlen;
union {
struct sockaddr addr;
struct curl_struct_sockaddr addr;
struct Curl_sockaddr_storage buff;
} _sa_ex_u;
};

View file

@ -77,10 +77,14 @@
#else /* HAVE_CONFIG_H */
#ifdef FreeRTOS
#include "config-freertos.h"
#endif
#ifdef _WIN32_WCE
# include "config-win32ce.h"
#else
# ifdef WIN32
# if defined(WIN32) && !defined(FreeRTOS)
# include "config-win32.h"
# endif
#endif
@ -619,6 +623,23 @@
# endif
#endif
/*
* Intentionally fail to build when using msvc 6.0 without PSDK installed.
* The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK
* in lib/config-win32.h although absolutely discouraged and unsupported.
*/
#if 0
# if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_))
# if !defined(ALLOW_MSVC6_WITHOUT_PSDK)
# error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. \
"Windows Server 2003 PSDK"
# else
# define CURL_DISABLE_LDAP 1
# endif
# endif
#endif
#ifdef NETWARE
int netware_init(void);
#ifndef __NOVELL_LIBC__

View file

@ -124,7 +124,8 @@ struct timeval {
#define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \
(RECV_TYPE_ARG2)(y), \
(RECV_TYPE_ARG3)(z))
#elif defined(FreeRTOS)
#define sread(a,b,c) FreeRTOS_recv(a,b,c,0)
#elif defined(HAVE_RECV)
/*
* The definitions for the return type and arguments types
@ -187,6 +188,9 @@ struct timeval {
/* */
Error Missing_definition_of_return_and_arguments_types_of_send
/* */
#elif defined(FreeRTOS)
/* The flags argument (4) marked as 'Not currently used' */
#define swrite(a,b,c) FreeRTOS_send(a,b,c,0)
#else
#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
(SEND_QUAL_ARG2 SEND_TYPE_ARG2)(y), \
@ -254,6 +258,8 @@ struct timeval {
# define sclose(x) close_s((x))
#elif defined(USE_LWIPSOCK)
# define sclose(x) lwip_close((x))
#elif defined(FreeRTOS)
# define sclose(x) FreeRTOS_closesocket((x))
#else
# define sclose(x) close((x))
#endif

View file

@ -311,7 +311,7 @@ static size_t hash_fd(void *key, size_t key_length, size_t slots_num)
curl_socket_t fd = *((curl_socket_t *) key);
(void) key_length;
return (fd % slots_num);
return ((long)fd % slots_num); /* weirdo FreeRTOS hack */
}
/*
@ -1022,8 +1022,8 @@ static int multi_getsock(struct Curl_easy *data,
}
CURLMcode curl_multi_fdset(struct Curl_multi *multi,
fd_set *read_fd_set, fd_set *write_fd_set,
fd_set *exc_fd_set, int *max_fd)
curl_fd_set *read_fd_set, curl_fd_set *write_fd_set,
curl_fd_set *exc_fd_set, int *max_fd)
{
/* Scan through all the easy handles to get the file descriptors set.
Some easy handles may not have connected to the remote host yet,
@ -1056,21 +1056,23 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi,
if(!FDSET_SOCK(sockbunch[i]))
/* pretend it doesn't exist */
continue;
FD_SET(sockbunch[i], read_fd_set);
CURL_FD_SET(sockbunch[i], read_fd_set, eSELECT_READ);
s = sockbunch[i];
}
if((bitmap & GETSOCK_WRITESOCK(i)) && VALID_SOCK(sockbunch[i])) {
if(!FDSET_SOCK(sockbunch[i]))
/* pretend it doesn't exist */
continue;
FD_SET(sockbunch[i], write_fd_set);
CURL_FD_SET(sockbunch[i], write_fd_set, eSELECT_WRITE);
s = sockbunch[i];
}
if(s == CURL_SOCKET_BAD)
/* this socket is unused, break out of loop */
break;
#ifndef FreeRTOS
if((int)s > this_max_fd)
this_max_fd = (int)s;
#endif
}
data = data->next; /* check next handle */
@ -1099,8 +1101,8 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
unsigned int curlfds;
long timeout_internal;
int retcode = 0;
struct pollfd a_few_on_stack[NUM_POLLS_ON_STACK];
struct pollfd *ufds = &a_few_on_stack[0];
struct curl_pollfd a_few_on_stack[NUM_POLLS_ON_STACK];
struct curl_pollfd *ufds = &a_few_on_stack[0];
bool ufds_malloc = FALSE;
#ifdef USE_WINSOCK
WSANETWORKEVENTS wsa_events;

View file

@ -143,9 +143,9 @@ int Curl_wait_ms(timediff_t timeout_ms)
* N = number of signalled file descriptors
*/
static int our_select(curl_socket_t maxfd, /* highest socket number */
fd_set *fds_read, /* sockets ready for reading */
fd_set *fds_write, /* sockets ready for writing */
fd_set *fds_err, /* sockets with errors */
curl_fd_set *fds_read, /* sockets ready for reading */
curl_fd_set *fds_write, /* sockets ready for writing */
curl_fd_set *fds_err, /* sockets with errors */
timediff_t timeout_ms) /* milliseconds to wait */
{
struct timeval pending_tv;
@ -216,6 +216,13 @@ static int our_select(curl_socket_t maxfd, /* highest socket number */
fds_read && fds_read->fd_count ? fds_read : NULL,
fds_write && fds_write->fd_count ? fds_write : NULL,
fds_err && fds_err->fd_count ? fds_err : NULL, ptimeout);
#elif defined(FreeRTOS)
{
/* convert the timeout to FreeRTOS ticks */
TickType_t ticks = ptimeout ? ptimeout->tv_sec * configTICK_RATE_HZ : +
(ptimeout->tv_usec * configTICK_RATE_HZ) / 1000000;
return FreeRTOS_select(fds_read, ticks);
}
#else
return select((int)maxfd + 1, fds_read, fds_write, fds_err, ptimeout);
#endif
@ -331,9 +338,9 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
#ifdef HAVE_POLL_FINE
int pending_ms;
#else
fd_set fds_read;
fd_set fds_write;
fd_set fds_err;
curl_fd_set fds_read;
curl_fd_set fds_write;
curl_fd_set fds_err;
curl_socket_t maxfd;
#endif
bool fds_none = TRUE;

View file

@ -94,7 +94,7 @@ int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes,
With Winsock the valid range is [0..INVALID_SOCKET-1] according to
https://docs.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2
*/
#if defined(TPF)
#if defined(USE_WINSOCK) || defined(TPF) || defined(FreeRTOS)
#define VALID_SOCK(x) 1
#define VERIFY_SOCK(x) Curl_nop_stmt
#define FDSET_SOCK(x) 1

View file

@ -25,6 +25,7 @@
/* This file is for lib internal stuff */
#include "curl_setup.h"
#include <curl/curl.h>
#define PORT_FTP 21
#define PORT_FTPS 990